Просмотр исходного кода

[backend] Distributions : correction bug point de vente non lié à une distribution

refactoring
Guillaume Bourgeois 5 лет назад
Родитель
Сommit
3c1347e2a2
3 измененных файлов: 16 добавлений и 10 удалений
  1. +2
    -1
      backend/controllers/DistributionController.php
  2. +1
    -0
      backend/controllers/PointSaleController.php
  3. +13
    -9
      common/models/PointSaleDistribution.php

+ 2
- 1
backend/controllers/DistributionController.php Просмотреть файл

@@ -46,6 +46,7 @@ use common\models\Order ;
use common\models\User ;
use common\models\Subscription ;
use common\helpers\Price ;
use common\models\PointSaleDistribution ;
use DateTime;

class DistributionController extends BackendController
@@ -478,10 +479,10 @@ class DistributionController extends BackendController
$dateObject = DateTime::createFromFormat($format, $date);
if($dateObject && $dateObject->format($format) === $date) {
$distribution = Distribution::initDistribution($date) ;
}
if($distribution) {
PointSaleDistribution::setAll($distribution->id, true);
$distribution->active = (int) $active ;
$distribution->save() ;


+ 1
- 0
backend/controllers/PointSaleController.php Просмотреть файл

@@ -49,6 +49,7 @@ use common\models\User;
use common\models\UserPointSale;
use common\models\Order ;
use common\models\Producer ;
use common\models\Distribution ;
use yii\helpers\Html;

/**

+ 13
- 9
common/models/PointSaleDistribution.php Просмотреть файл

@@ -122,15 +122,19 @@ class PointSaleDistribution extends ActiveRecordCommon
* @param boolean $bool_livraison
*/
public static function setAll($idDistribution, $boolDelivery)
{
$countPointSaleDistribution = self::searchCount([
'id_distribution' => $idDistribution
]) ;

if (!$countPointSaleDistribution) {
$arrPointsSale = PointSale::searchAll() ;
foreach ($arrPointsSale as $pointSale) {
{
// liaison PointSale / Distribution
$arrPointsSale = PointSale::find()
->with(['pointSaleDistribution' => function($q) use ($idDistribution) {
$q->where(['id_distribution' => $idDistribution]);
}])
->where([
'id_producer' => Producer::getId(),
])
->all();
foreach ($arrPointsSale as $pointSale) {
if(!$pointSale->pointSaleDistribution) {
$pointSaleDistribution = new PointSaleDistribution();
$pointSaleDistribution->id_distribution = $idDistribution;
$pointSaleDistribution->id_point_sale = $pointSale->id;

Загрузка…
Отмена
Сохранить