|
|
@@ -263,19 +263,39 @@ class Subscription extends ActiveRecordCommon |
|
|
|
]) ; |
|
|
|
|
|
|
|
if ($distribution) { |
|
|
|
$countOrdersProd = Order::searchCount([ |
|
|
|
$arrayOrdersDistribution = Order::searchAll([ |
|
|
|
Order::tableName().'.id_distribution' => $distribution->id |
|
|
|
]) ; |
|
|
|
|
|
|
|
if (!$countOrdersProd || $force) { |
|
|
|
$subscriptions = self::searchByDate($date); |
|
|
|
foreach ($subscriptions as $s) { |
|
|
|
$s->add($date); |
|
|
|
]); |
|
|
|
$arraySubscriptions = self::searchByDate($date); |
|
|
|
foreach ($arraySubscriptions as $subscription) { |
|
|
|
if(!$subscription->hasOrderAlreadyExist($arrayOrdersDistribution)) { |
|
|
|
$subscription->add($date); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Informe s'il existe une commande correspond à l'abonnement courant. |
|
|
|
* |
|
|
|
* @param array $arrayOrders |
|
|
|
* @return boolean |
|
|
|
*/ |
|
|
|
public function hasOrderAlreadyExist($arrayOrders) |
|
|
|
{ |
|
|
|
if(is_array($arrayOrders) && count($arrayOrders) > 0) { |
|
|
|
foreach($arrayOrders as $order) { |
|
|
|
if(($order->id_user == $this->id_user || $order->username == $this->username) && |
|
|
|
$order->id_point_sale == $this->id_point_sale) { |
|
|
|
return true ; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false ; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Retourne les abonnements pour une date donnée. |
|
|
|
* |