Ver código fonte

Merge branch 'dev'

master
Guillaume Bourgeois 5 anos atrás
pai
commit
16138b6cad
2 arquivos alterados com 17 adições e 5 exclusões
  1. +7
    -1
      common/models/User.php
  2. +10
    -4
      producer/controllers/OrderController.php

+ 7
- 1
common/models/User.php Ver arquivo

@@ -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 Ver arquivo

@@ -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 ;

Carregando…
Cancelar
Salvar