Browse Source

[producer] Correction bug accès restreint des points de vente non pris en compte

dev
Guillaume Bourgeois 5 years ago
parent
commit
a33bf04eb2
1 changed files with 14 additions and 4 deletions
  1. +14
    -4
      producer/controllers/OrderController.php

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

use common\models\User ; use common\models\User ;
use common\models\Producer ; use common\models\Producer ;
use common\models\Order ; use common\models\Order ;
use common\models\UserPointSale ;
use DateTime; use DateTime;


class OrderController extends ProducerBaseController class OrderController extends ProducerBaseController
} else { } else {
$errorPointSale = true; $errorPointSale = true;
} }
$userPointSale = UserPointSale::searchOne([
'id_user' => User::getCurrentId(),
'id_point_sale' => $pointSale->id
]) ;
if($pointSale->restricted_access && !$userPointSale) {
$errorPointSale = true;
}
} }


$errors = [] ; $errors = [] ;
// distribution // distribution
$distribution = Distribution::initDistribution($date) ; $distribution = Distribution::initDistribution($date) ;
$json['distribution'] = $distribution ; $json['distribution'] = $distribution ;
$pointsSaleArray = PointSale::find() $pointsSaleArray = PointSale::find()
->joinWith(['pointSaleDistribution' => function($query) use ($distribution) { ->joinWith(['pointSaleDistribution' => function($query) use ($distribution) {
$query->where(['id_distribution' => $distribution->id]); $query->where(['id_distribution' => $distribution->id]);
->with(['userPointSale' => function($query) { ->with(['userPointSale' => function($query) {
$query->onCondition(['id_user' => User::getCurrentId()]) ; $query->onCondition(['id_user' => User::getCurrentId()]) ;
}]) }])
->where([
'id_producer' => $distribution->id_producer,
])
->where(['id_producer' => $distribution->id_producer])
->andWhere('restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0)')
->params([':id_user' => User::getCurrentId()])
->all(); ->all();


$creditFunctioningProducer = Producer::getConfig('credit_functioning') ; $creditFunctioningProducer = Producer::getConfig('credit_functioning') ;

Loading…
Cancel
Save