Browse Source

[producer] Order : correction bug point de vente favoris absent

dev
Guillaume Bourgeois 5 years ago
parent
commit
59b40d4521
2 changed files with 17 additions and 5 deletions
  1. +7
    -1
      common/models/User.php
  2. +10
    -4
      producer/controllers/OrderController.php

+ 7
- 1
common/models/User.php View File

*/ */
public function getFavoritePointSale() public function getFavoritePointSale()
{ {
$arrayUserPointSale = UserPointSale::find()->where(['id_user' => $this->id])->all() ;
$arrayUserPointSale = UserPointSale::find()
->innerJoinWith('pointSale')
->where([
'user_point_sale.id_user' => $this->id,
'point_sale.id_producer' => Producer::getId()
])
->all() ;
if(count($arrayUserPointSale) == 1) { if(count($arrayUserPointSale) == 1) {
$pointSale = PointSale::findOne(['id' => $arrayUserPointSale[0]->id_point_sale]) ; $pointSale = PointSale::findOne(['id' => $arrayUserPointSale[0]->id_point_sale]) ;

+ 10
- 4
producer/controllers/OrderController.php View File

$favoritePointSale = User::getCurrent()->getFavoritePointSale() ; $favoritePointSale = User::getCurrent()->getFavoritePointSale() ;
if($favoritePointSale) { if($favoritePointSale) {
foreach($pointsSaleArray as $key => $pointSale) {
if($pointSale['id'] == $favoritePointSale->id) {
unset($pointsSaleArray[$key]) ;
array_unshift($pointsSaleArray, $pointSale) ;
for( $i = 0; $i < count($pointsSaleArray) ; $i++) {
if($pointsSaleArray[$i]['id'] == $favoritePointSale->id) {
$theFavoritePointSale = $pointsSaleArray[$i] ;
unset($pointsSaleArray[$i]) ;
} }
} }

if(isset($theFavoritePointSale)) {
$pointsSaleArray = array_reverse($pointsSaleArray, false) ;
$pointsSaleArray[] = $theFavoritePointSale ;
$pointsSaleArray = array_reverse($pointsSaleArray, false) ;
}
} }
$json['points_sale'] = $pointsSaleArray ; $json['points_sale'] = $pointsSaleArray ;

Loading…
Cancel
Save