|
|
|
|
|
|
|
|
$subscriptionModule = $this->getSubscriptionModule(); |
|
|
$subscriptionModule = $this->getSubscriptionModule(); |
|
|
$distributionModule = $this-> getDistributionModule(); |
|
|
$distributionModule = $this-> getDistributionModule(); |
|
|
$subscription = $subscriptionModule->findOneSubscriptionById($idSubscription); |
|
|
$subscription = $subscriptionModule->findOneSubscriptionById($idSubscription); |
|
|
$matchedDistributionsArray = $distributionModule->findDistributionsIncomingMatchWithSubscrtiption($subscription, true); |
|
|
|
|
|
|
|
|
if($subscription) { |
|
|
|
|
|
$matchedDistributionsArray = $distributionModule->findDistributionsIncomingMatchWithSubscrtiption($subscription, true); |
|
|
|
|
|
|
|
|
if ($generate) { |
|
|
|
|
|
if ($update) { |
|
|
|
|
|
$subscriptionModule->getOrderManager() |
|
|
|
|
|
->deleteOrdersIncomingDistributionsFromSubscription($subscription); |
|
|
|
|
|
} |
|
|
|
|
|
foreach ($matchedDistributionsArray as $distribution) { |
|
|
|
|
|
$subscriptionModule->createOrderFromSubscription($subscription, $distribution->date); |
|
|
|
|
|
|
|
|
if ($generate) { |
|
|
|
|
|
if ($update) { |
|
|
|
|
|
$subscriptionModule->getOrderManager() |
|
|
|
|
|
->deleteOrdersIncomingDistributionsFromSubscription($subscription); |
|
|
|
|
|
} |
|
|
|
|
|
foreach ($matchedDistributionsArray as $distribution) { |
|
|
|
|
|
$subscriptionModule->createOrderFromSubscription($subscription, $distribution->date); |
|
|
|
|
|
} |
|
|
|
|
|
$this->setFlash('success', 'Commandes ' . ($update ? 're-' : '') . 'générées dans les distributions futures.'); |
|
|
|
|
|
return $this->redirect(['subscription/index']); |
|
|
} |
|
|
} |
|
|
$this->setFlash('success', 'Commandes ' . ($update ? 're-' : '') . 'générées dans les distributions futures.'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->render('update_distributions', [ |
|
|
|
|
|
'matchedDistributionsArray' => $matchedDistributionsArray, |
|
|
|
|
|
'idSubscription' => $idSubscription, |
|
|
|
|
|
'update' => $update |
|
|
|
|
|
]); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$this->setFlash('error', 'Abonnement introuvable'); |
|
|
return $this->redirect(['subscription/index']); |
|
|
return $this->redirect(['subscription/index']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->render('update_distributions', [ |
|
|
|
|
|
'matchedDistributionsArray' => $matchedDistributionsArray, |
|
|
|
|
|
'idSubscription' => $idSubscription, |
|
|
|
|
|
'update' => $update |
|
|
|
|
|
]); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function actionAjaxInfos(int $idSubscription = 0) |
|
|
public function actionAjaxInfos(int $idSubscription = 0) |