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