Bladeren bron

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

refactoring
Guillaume Bourgeois 5 jaren geleden
bovenliggende
commit
59b40d4521
2 gewijzigde bestanden met toevoegingen van 17 en 5 verwijderingen
  1. +7
    -1
      common/models/User.php
  2. +10
    -4
      producer/controllers/OrderController.php

+ 7
- 1
common/models/User.php Bestand weergeven

@@ -590,7 +590,13 @@ class User extends ActiveRecordCommon implements IdentityInterface
*/
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) {
$pointSale = PointSale::findOne(['id' => $arrayUserPointSale[0]->id_point_sale]) ;

+ 10
- 4
producer/controllers/OrderController.php Bestand weergeven

@@ -571,12 +571,18 @@ class OrderController extends ProducerBaseController
$favoritePointSale = User::getCurrent()->getFavoritePointSale() ;
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 ;

Laden…
Annuleren
Opslaan