if ($orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING) > 0) { | if ($orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING) > 0) { | ||||
$creditHistoryManager->createCreditHistory( | $creditHistoryManager->createCreditHistory( | ||||
CreditHistory::TYPE_PAYMENT, | CreditHistory::TYPE_PAYMENT, | ||||
$orderManager->getAmount($order, Order::AMOUNT_REMAINING), | |||||
$orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING), | |||||
$order->distribution->producer, | $order->distribution->producer, | ||||
$order->user, | $order->user, | ||||
$userManager->findOneUserById(User::ID_USER_SYSTEM), | $userManager->findOneUserById(User::ID_USER_SYSTEM), |
$creditHistoryManager = $this->getCreditHistoryManager(); | $creditHistoryManager = $this->getCreditHistoryManager(); | ||||
$userManager = $this->getUserManager(); | $userManager = $this->getUserManager(); | ||||
$subscriptionManager = $this->getSubscriptionManager(); | $subscriptionManager = $this->getSubscriptionManager(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
if ($ordersArray) { | if ($ordersArray) { | ||||
foreach ($ordersArray as &$order) { | foreach ($ordersArray as &$order) { | ||||
$orderManager->initOrder($order); | |||||
$productOrderArray = []; | $productOrderArray = []; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
$productOrderArray[$productOrder->id_product] = [ | $productOrderArray[$productOrder->id_product] = [ |
$userManager = $this->getUserManager(); | $userManager = $this->getUserManager(); | ||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
$userPointSaleManager = $this->getUserPointSaleManager(); | $userPointSaleManager = $this->getUserPointSaleManager(); | ||||
$creditHistoryManager = $this->getCreditHistoryManager(); | |||||
$request = \Yii::$app->request; | $request = \Yii::$app->request; | ||||
$date = $request->post('date'); | $date = $request->post('date'); | ||||
&& $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) { | ||||
$oldIdUser = $order->id_user; | $oldIdUser = $order->id_user; | ||||
$oldUser = $userManager->findOneUserById($oldIdUser); | |||||
if ($idUser) { | if ($idUser) { | ||||
$order->username = ''; | $order->username = ''; | ||||
$order->id_user = $idUser; | $order->id_user = $idUser; | ||||
$order = Order::searchOne(['id' => $order->id]); | $order = Order::searchOne(['id' => $order->id]); | ||||
if ($order && $orderManager->isCreditAutoPayment($order)) { | if ($order && $orderManager->isCreditAutoPayment($order)) { | ||||
// Si changement d'user : on rembourse l'ancien user | // Si changement d'user : on rembourse l'ancien user | ||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||||
$amountPaid = $orderManager->getOrderAmount($order, Order::AMOUNT_PAID); | |||||
if ($oldIdUser != $idUser && $amountPaid > 0) { | if ($oldIdUser != $idUser && $amountPaid > 0) { | ||||
$order->saveCreditHistory( | |||||
$creditHistoryManager->createCreditHistory( | |||||
CreditHistory::TYPE_REFUND, | CreditHistory::TYPE_REFUND, | ||||
$amountPaid, | $amountPaid, | ||||
GlobalParam::getCurrentProducerId(), | |||||
$oldIdUser, | |||||
GlobalParam::getCurrentUserId() | |||||
$this->getProducerCurrent(), | |||||
$oldUser, | |||||
$this->getUserCurrent() | |||||
); | ); | ||||
$order = Order::searchOne(['id' => $order->id]); | $order = Order::searchOne(['id' => $order->id]); | ||||
} | } | ||||
$order->processCredit(); | |||||
$orderManager->processCredit($order); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Retourne l'état du paiement (historique, crédit) d'une commande donnée. | * Retourne l'état du paiement (historique, crédit) d'une commande donnée. | ||||
*/ | */ | ||||
]) | ]) | ||||
->one(); | ->one(); | ||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||||
$amountPaid = $orderManager->getOrderAmount($order, Order::AMOUNT_PAID); | |||||
if (abs($order->amount - $amountPaid) < 0.0001) { | if (abs($order->amount - $amountPaid) < 0.0001) { | ||||
$html .= '<span class="label label-success">Payé</span>'; | $html .= '<span class="label label-success">Payé</span>'; |
termes. | termes. | ||||
*/ | */ | ||||
use common\models\Order ; | |||||
use common\models\Product ; | |||||
use common\helpers\Price; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use common\logic\Product\Product\Model\Product; | |||||
use common\logic\Product\Product\Wrapper\ProductManager; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | |||||
$productManager = ProductManager::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | |||||
$dayWeek = date('w', strtotime($date)); | $dayWeek = date('w', strtotime($date)); | ||||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | $dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | ||||
$fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek]; | $fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek]; | ||||
$html = '' ; | $html = '' ; | ||||
$count = count($productsArray) ; | $count = count($productsArray) ; | ||||
$limit = 100 ; | $limit = 100 ; | ||||
$isBig = $count > $limit ; | $isBig = $count > $limit ; | ||||
$add = false; | $add = false; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
if($product->id == $productOrder->id_product) { | if($product->id == $productOrder->id_product) { | ||||
$unit = ( Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($productOrder->unit, 'wording_short', true) ; | |||||
$unit = ( $productManager->strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($productOrder->unit, 'wording_short', true) ; | |||||
$strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />'; | $strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />'; | ||||
$add = true; | $add = true; | ||||
} | } | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
if ($quantity) { | if ($quantity) { | ||||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||||
$strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | $strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | ||||
} | } | ||||
} | } | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
if ($quantity) { | if ($quantity) { | ||||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||||
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | $html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | ||||
} | } | ||||
} | } | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $ordersArray, false, $unit); | |||||
if ($quantity) { | if ($quantity) { | ||||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||||
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | $html .= $product->name . ' (' .$quantity .$theUnit.')<br />'; | ||||
} | } | ||||
} | } |
termes. | termes. | ||||
*/ | */ | ||||
use common\models\Order ; | |||||
use common\models\Product ; | |||||
use common\helpers\Price; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use common\logic\Producer\Producer\Model\Producer; | |||||
use common\logic\Product\Product\Model\Product; | |||||
use common\logic\Product\Product\Wrapper\ProductManager; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | |||||
$productManager = ProductManager::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | |||||
$dayWeek = date('w', strtotime($date)); | $dayWeek = date('w', strtotime($date)); | ||||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | $dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | ||||
$fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek]; | $fieldInfosPointSale = 'infos_' . $dayWeekArray[$dayWeek]; | ||||
$html = '' ; | $html = '' ; | ||||
$count = count($productsArray) ; | $count = count($productsArray) ; | ||||
$limit = 100 ; | $limit = 100 ; | ||||
$isBig = $count > $limit ; | $isBig = $count > $limit ; | ||||
$add = false; | $add = false; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
if($product->id == $productOrder->id_product) { | if($product->id == $productOrder->id_product) { | ||||
$unit = ( Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($productOrder->unit, 'wording_short', true) ; | |||||
$unit = ( $productManager->strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($productOrder->unit, 'wording_short', true) ; | |||||
$strProducts .= '('.$productOrder->quantity .$unit.') '.$product->getNameExport() . '<br />'; | $strProducts .= '('.$productOrder->quantity .$unit.') '.$product->getNameExport() . '<br />'; | ||||
$add = true; | $add = true; | ||||
} | } | ||||
$html .= '<td><strong>'.number_format($order->amount_with_tax, 2) . ' € '; | $html .= '<td><strong>'.number_format($order->amount_with_tax, 2) . ' € '; | ||||
if($order->getPaymentStatus() == Order::PAYMENT_PAID) | |||||
if($orderManager->getPaymentStatus($order) == Order::PAYMENT_PAID) | |||||
{ | { | ||||
$html .= '(payé)' ; | $html .= '(payé)' ; | ||||
} | } | ||||
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID)) | |||||
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_UNPAID && $orderManager->getOrderAmount($order, Order::AMOUNT_PAID)) | |||||
{ | { | ||||
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ; | |||||
$html .= '(reste '.$orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING, true).' à payer)' ; | |||||
} | } | ||||
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) | |||||
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_SURPLUS) | |||||
{ | { | ||||
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||||
$html .= '(surplus : '.$orderManager->getOrderAmount($order, Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||||
} | } | ||||
$html .= '</strong></td>' ; | $html .= '</strong></td>' ; | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
if ($quantity) { | if ($quantity) { | ||||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||||
$strProducts .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />'; | $strProducts .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />'; | ||||
} | } | ||||
} | } | ||||
$cpt ++ ; | $cpt ++ ; | ||||
} | } | ||||
//$strProducts = substr($strProducts, 0, strlen($strProducts) - 6) ; | |||||
$html .= '<td>'.$strProducts.'</td><td></td>' ; | $html .= '<td>'.$strProducts.'</td><td></td>' ; | ||||
if($pointSale->credit) { | if($pointSale->credit) { | ||||
$html .= '<td></td>' ; | $html .= '<td></td>' ; | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $pointSale->orders, false, $unit); | |||||
if ($quantity) { | if ($quantity) { | ||||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||||
$html .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />'; | $html .= '(' .$quantity .$theUnit.') '.$product->getNameExport() . '<br />'; | ||||
} | } | ||||
} | } | ||||
$cpt = 0 ; | $cpt = 0 ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
foreach( Product::$unitsArray as $unit => $dataUnit) { | foreach( Product::$unitsArray as $unit => $dataUnit) { | ||||
$quantity = Order::getProductQuantity($product->id, $ordersArray, false, $unit); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $ordersArray, false, $unit); | |||||
if ($quantity) { | if ($quantity) { | ||||
$theUnit = ( Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. Product::strUnit($unit, 'wording_short', true) ; | |||||
$theUnit = ( $productManager->strUnit($unit, 'wording_short', true) == 'p.') ? '' : ' '. $productManager->strUnit($unit, 'wording_short', true) ; | |||||
$html .= '(' .$quantity .$theUnit.') '.$product->name . '<br />'; | $html .= '(' .$quantity .$theUnit.') '.$product->name . '<br />'; | ||||
} | } | ||||
} | } | ||||
$cpt ++ ; | $cpt ++ ; | ||||
} | } | ||||
//$html = substr($html, 0, strlen($html) - 6) ; | |||||
$html .= '</td><td><strong>'.number_format($revenues, 2).' €</strong></td></tr>' ; | $html .= '</td><td><strong>'.number_format($revenues, 2).' €</strong></td></tr>' ; | ||||
$html .= '</tbody></table>' ; | $html .= '</tbody></table>' ; |
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | ['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | ||||
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | ['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $userManager->isCurrentAdmin()], | ||||
['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $userManager->isCurrentAdmin()], | |||||
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $userManager->isCurrentAdmin()], | |||||
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $userManager->isCurrentAdmin()], | |||||
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $userManager->isCurrentAdmin()], | |||||
['label' => 'Login', 'url' => ['site/login'], 'visible' => ! $userManager->isCurrentConnected()], | ['label' => 'Login', 'url' => ['site/login'], 'visible' => ! $userManager->isCurrentConnected()], | ||||
], | ], | ||||
] | ] |
termes. | termes. | ||||
*/ | */ | ||||
use common\models\Order ; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
$orderManager = OrderManager::getInstance(); | |||||
$dayWeek = date('w', strtotime($date)); | $dayWeek = date('w', strtotime($date)); | ||||
$dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | $dayWeekArray = [0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday']; | ||||
$html .= '<td><strong>'.number_format($order->amount, 2) . ' € '; | $html .= '<td><strong>'.number_format($order->amount, 2) . ' € '; | ||||
if($order->getPaymentStatus() == Order::PAYMENT_PAID) | |||||
if($orderManager->getPaymentStatus($order) == Order::PAYMENT_PAID) | |||||
{ | { | ||||
$html .= '(payé)' ; | $html .= '(payé)' ; | ||||
} | } | ||||
elseif($order->getPaymentStatus() == Order::PAYMENT_UNPAID && $order->getAmount(Order::AMOUNT_PAID)) | |||||
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_UNPAID && $orderManager->getOrderAmount($order, Order::AMOUNT_PAID)) | |||||
{ | { | ||||
$html .= '(reste '.$order->getAmount(Order::AMOUNT_REMAINING, true).' à payer)' ; | |||||
$html .= '(reste '.$orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING, true).' à payer)' ; | |||||
} | } | ||||
elseif($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) | |||||
elseif($orderManager->getPaymentStatus($order) == Order::PAYMENT_SURPLUS) | |||||
{ | { | ||||
$html .= '(surplus : '.$order->getAmount(Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||||
$html .= '(surplus : '.$orderManager->getOrderAmount($order, Order::PAYMENT_SURPLUS, true).' à rembourser)' ; | |||||
} | } | ||||
$html .= '</strong></td>' ; | $html .= '</strong></td>' ; | ||||
$strProducts = ''; | $strProducts = ''; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $pointSale->orders); | |||||
$strQuantity = ''; | $strQuantity = ''; | ||||
if ($quantity) { | if ($quantity) { | ||||
$strQuantity = $quantity; | $strQuantity = $quantity; | ||||
{ | { | ||||
$html .= '<tr><td>'.$pointSale->name.'</td><td>' ; | $html .= '<tr><td>'.$pointSale->name.'</td><td>' ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$quantity = Order::getProductQuantity($product->id, $pointSale->orders); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $pointSale->orders); | |||||
$strQuantity = ($quantity) ? $quantity : '' ; | $strQuantity = ($quantity) ? $quantity : '' ; | ||||
if(strlen($strQuantity)) { | if(strlen($strQuantity)) { | ||||
// total | // total | ||||
$html .= '<tr><td><strong>Total</strong></td><td>' ; | $html .= '<tr><td><strong>Total</strong></td><td>' ; | ||||
foreach ($productsArray as $product) { | foreach ($productsArray as $product) { | ||||
$quantity = Order::getProductQuantity($product->id, $ordersArray); | |||||
$quantity = $orderManager->getProductQuantity($product->id, $ordersArray); | |||||
if($quantity) { | if($quantity) { | ||||
$html .= $quantity . ' '.$product->name.', ' ; | $html .= $quantity . ' '.$product->name.', ' ; | ||||
} | } |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use yii\helpers\Html ; | use yii\helpers\Html ; | ||||
$orderManager = OrderManager::getInstance(); | |||||
$this->setTitle('Tableau de bord'); | $this->setTitle('Tableau de bord'); | ||||
?> | ?> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<?php foreach($ordersArray as $order): ?> | <?php foreach($ordersArray as $order): ?> | ||||
<tr class="<?= $order->getClassHistory() ; ?>"> | |||||
<td class="infos"><?= $order->getStrOrigin(true); ?></td> | |||||
<tr class="<?= $orderManager->getHistoryClass($order) ; ?>"> | |||||
<td class="infos"><?= $orderManager->getLabelOrigin($order, true); ?></td> | |||||
<td class="date"> | <td class="date"> | ||||
<div class="block-date"> | <div class="block-date"> | ||||
<div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div> | <div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div> | ||||
</div> | </div> | ||||
</td> | </td> | ||||
<td> | <td> | ||||
<?= $order->getStrUser(); ?><br /> | |||||
<?= $orderManager->getOrderUsername($order); ?><br /> | |||||
<?php if(strlen($order->comment)): ?> | <?php if(strlen($order->comment)): ?> | ||||
<div class="comment"><span class="glyphicon glyphicon-comment"></span> <?= nl2br(Html::encode($order->comment)) ; ?></div> | <div class="comment"><span class="glyphicon glyphicon-comment"></span> <?= nl2br(Html::encode($order->comment)) ; ?></div> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</td> | </td> | ||||
<td><?= $order->getCartSummary() ; ?></td> | |||||
<td><?= $order->getPointSaleSummary() ; ?></td> | |||||
<td><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true) ; ?></td> | |||||
<td class="history"><?= $order->getStrHistory() ; ?></td> | |||||
<td><?= $orderManager->getCartSummary($order) ; ?></td> | |||||
<td><?= $orderManager->getPointSaleSummary($order) ; ?></td> | |||||
<td><?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true) ; ?></td> | |||||
<td class="history"><?= $orderManager->getHistorySummary($order) ; ?></td> | |||||
</tr> | </tr> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</tbody> | </tbody> |
public function populateFieldObject($fieldIdentifier, $fieldObject, $object) | public function populateFieldObject($fieldIdentifier, $fieldObject, $object) | ||||
{ | { | ||||
$this->$fieldIdentifier = $object->id; | |||||
$this->{$fieldIdentifier} = $object->id; | |||||
$this->populateRelation($fieldObject, $object); | $this->populateRelation($fieldObject, $object); | ||||
} | } | ||||
trigger_error("Le clonage n'est pas autorisé.", E_USER_ERROR); | trigger_error("Le clonage n'est pas autorisé.", E_USER_ERROR); | ||||
} | } | ||||
final public static function getInstance() | |||||
final public static function getInstance(): self | |||||
{ | { | ||||
$c = get_called_class(); | $c = get_called_class(); | ||||
public function init() | public function init() | ||||
{ | { | ||||
parent::init(); | |||||
$this->on(Distribution::EVENT_ACTIVE, function($event) { | $this->on(Distribution::EVENT_ACTIVE, function($event) { | ||||
SubscriptionEventSubscriber::onActiveDistribution($event->distribution); | SubscriptionEventSubscriber::onActiveDistribution($event->distribution); | ||||
}); | }); | ||||
parent::init(); | |||||
} | } | ||||
/* | /* |
public function activeDistribution(Distribution $distribution, bool $active = true): void | public function activeDistribution(Distribution $distribution, bool $active = true): void | ||||
{ | { | ||||
$this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true); | $this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true); | ||||
$distribution->active = (int) $active; | $distribution->active = (int) $active; | ||||
$this->saveUpdate($distribution); | $this->saveUpdate($distribution); | ||||
if ($active) { | if ($active) { | ||||
$distributionActiveEvent = new DistributionActiveEvent(); | $distributionActiveEvent = new DistributionActiveEvent(); | ||||
$distributionActiveEvent->distribution = $distribution; | $distributionActiveEvent->distribution = $distribution; | ||||
$distribution->trigger(Distribution::EVENT_ACTIVE, $distributionActiveEvent); | $distribution->trigger(Distribution::EVENT_ACTIVE, $distributionActiveEvent); | ||||
} | } | ||||
} | } |
{ | { | ||||
$pointSale = PointSale::findOne($order->id_point_sale); | $pointSale = PointSale::findOne($order->id_point_sale); | ||||
$distribution = Distribution::findOne($order->id_distribution); | $distribution = Distribution::findOne($order->id_distribution); | ||||
$creditFunctioning = $pointSale->getCreditFunctioning(); | |||||
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); | |||||
if ($order->id_user && $order->producerRepository->getConfig('credit') && $pointSale->credit) { | |||||
if ($order->id_user && $this->producerRepository->getConfig('credit') && $pointSale->credit) { | |||||
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | ||||
return 0; | return 0; | ||||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | } elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { |
$order->populateDistribution($distribution); | $order->populateDistribution($distribution); | ||||
$order->date = date('Y-m-d H:i:s'); | $order->date = date('Y-m-d H:i:s'); | ||||
$order->status = 'tmp-order'; | $order->status = 'tmp-order'; | ||||
$order->id_user = 0; | |||||
return $order; | return $order; | ||||
} | } | ||||
$this->initOrderBaseFromSubscription($order, $subscription); | $this->initOrderBaseFromSubscription($order, $subscription); | ||||
$this->initOrderAutoPaymentFromSubscription($order, $subscription); | $this->initOrderAutoPaymentFromSubscription($order, $subscription); | ||||
$this->addProductOrdersFromSubscription($order, $subscription); | $this->addProductOrdersFromSubscription($order, $subscription); | ||||
$this->saveUpdate($order); | |||||
} | } | ||||
public function initOrderBaseFromSubscription(Order $order, Subscription $subscription): void | public function initOrderBaseFromSubscription(Order $order, Subscription $subscription): void |
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use common\logic\SolverInterface; | use common\logic\SolverInterface; | ||||
use common\logic\User\CreditHistory\Model\CreditHistory; | |||||
use common\logic\User\CreditHistory\Service\CreditHistorySolver; | |||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\User\Service\UserSolver; | use common\logic\User\User\Service\UserSolver; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
{ | { | ||||
protected UserSolver $userSolver; | protected UserSolver $userSolver; | ||||
protected DocumentSolver $documentSolver; | protected DocumentSolver $documentSolver; | ||||
protected CreditHistorySolver $creditHistorySolver; | |||||
public function loadDependencies(): void | public function loadDependencies(): void | ||||
{ | { | ||||
$this->documentSolver = $this->loadService(DocumentSolver::class); | $this->documentSolver = $this->loadService(DocumentSolver::class); | ||||
$this->userSolver = $this->loadService(UserSolver::class); | $this->userSolver = $this->loadService(UserSolver::class); | ||||
$this->creditHistorySolver = $this->loadService(CreditHistorySolver::class); | |||||
} | } | ||||
public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string | public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string | ||||
$jsonOrder = [ | $jsonOrder = [ | ||||
'products' => [], | 'products' => [], | ||||
'amount' => $order->amount, | 'amount' => $order->amount, | ||||
'str_amount' => $order->getAmountWithTax(Order::AMOUNT_TOTAL, true), | |||||
'paid_amount' => $order->getAmount(Order::AMOUNT_PAID), | |||||
'str_amount' => $this->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true), | |||||
'paid_amount' => $this->getOrderAmount($order, Order::AMOUNT_PAID), | |||||
'comment' => $order->comment, | 'comment' => $order->comment, | ||||
]; | ]; | ||||
return json_encode($jsonOrder); | return json_encode($jsonOrder); | ||||
} | } | ||||
/** | |||||
* Retourne les informations à ajouter au commentaire du CreditHistorique | |||||
* (libellé, montant, client, action) au format HTML. | |||||
* | |||||
*/ | |||||
public function getCreditHistoryComment(CreditHistory $creditHistory): string | |||||
{ | |||||
$str = ''; | |||||
if (strlen($creditHistory->getComment())) { | |||||
$str .= '<br />'; | |||||
} | |||||
$str .= $this->creditHistorySolver->getStrWording($creditHistory); | |||||
$order = $creditHistory->getOrderObject(); | |||||
if ($order) { | |||||
$str .= '<br />Montant de la commande : ' . $this->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); | |||||
} | |||||
$user = $creditHistory->getUserObject(); | |||||
if ($user) { | |||||
$str .= '<br />Client : ' . Html::encode($user->getName() . ' ' . $user->getLastname()); | |||||
} | |||||
$userAction = $creditHistory->getUserActionObject(); | |||||
if ($userAction) { | |||||
$str .= '<br />Action : ' . Html::encode($userAction->getName() . ' ' . $userAction->getLastname()); | |||||
} | |||||
return $str; | |||||
} | |||||
} | } |
{ | { | ||||
$specificPriceArray = $product->productPrice; | $specificPriceArray = $product->productPrice; | ||||
$user = isset($params['user']) ? $params['user'] : false; | |||||
$userProducer = isset($params['user_producer']) ? $params['user_producer'] : false; | |||||
$pointSale = isset($params['point_sale']) ? $params['point_sale'] : false; | |||||
$user = isset($params['user']) ? $params['user'] : null; | |||||
$userProducer = isset($params['user_producer']) ? $params['user_producer'] : null; | |||||
$pointSale = isset($params['point_sale']) ? $params['point_sale'] : null; | |||||
$quantity = (isset($params['quantity']) && $params['quantity']) ? $params['quantity'] : 1; | $quantity = (isset($params['quantity']) && $params['quantity']) ? $params['quantity'] : 1; | ||||
if ($specificPriceArray && ($user || $pointSale)) { | if ($specificPriceArray && ($user || $pointSale)) { |
// getSpecificPricesFilterByPriorityMatch | // getSpecificPricesFilterByPriorityMatch | ||||
public function filterByPriorityMatch( | public function filterByPriorityMatch( | ||||
array $specificPrices, | array $specificPrices, | ||||
User $user, | |||||
PointSale $pointSale): array | |||||
User $user = null, | |||||
PointSale $pointSale = null): array | |||||
{ | { | ||||
$priorityMatchSpecificPrice = $this->getPriorityMatch($specificPrices, $user, $pointSale); | $priorityMatchSpecificPrice = $this->getPriorityMatch($specificPrices, $user, $pointSale); | ||||
$specificPricesFilter = []; | $specificPricesFilter = []; |
use common\logic\AbstractBuilder; | use common\logic\AbstractBuilder; | ||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Order\Order\Service\OrderSolver; | |||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\User\CreditHistory\Model\CreditHistory; | use common\logic\User\CreditHistory\Model\CreditHistory; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
class CreditHistoryBuilder extends AbstractBuilder | class CreditHistoryBuilder extends AbstractBuilder | ||||
{ | { | ||||
protected CreditHistorySolver $creditHistorySolver; | protected CreditHistorySolver $creditHistorySolver; | ||||
protected OrderSolver $orderSolver; | |||||
public function loadDependencies(): void | public function loadDependencies(): void | ||||
{ | { | ||||
$this->creditHistorySolver = $this->loadService(CreditHistorySolver::class); | $this->creditHistorySolver = $this->loadService(CreditHistorySolver::class); | ||||
$this->orderSolver = $this->loadService(OrderSolver::class); | |||||
} | } | ||||
public function instanciateCreditHistory( | public function instanciateCreditHistory( | ||||
} | } | ||||
$creditHistory = $this->instanciateCreditHistory($type, $amount, $producer, $user, $userAction, $meanPayment, $order); | $creditHistory = $this->instanciateCreditHistory($type, $amount, $producer, $user, $userAction, $meanPayment, $order); | ||||
$creditHistory->setComment($creditHistory->getComment() . $this->creditHistorySolver->getStrComment($creditHistory)); | |||||
$creditHistory->setComment($creditHistory->getComment() . $this->orderSolver->getCreditHistoryComment($creditHistory)); | |||||
$this->saveCreate($creditHistory); | $this->saveCreate($creditHistory); | ||||
$creditHistory->trigger(CreditHistory::EVENT_CREATE, new Event(['creditHistory' => $creditHistory])); | $creditHistory->trigger(CreditHistory::EVENT_CREATE, new Event(['creditHistory' => $creditHistory])); |
return $str; | return $str; | ||||
} | } | ||||
/** | |||||
* Retourne les informations à ajouter au commentaire du CreditHistorique | |||||
* (libellé, montant, client, action) au format HTML. | |||||
* | |||||
*/ | |||||
public function getStrComment(CreditHistory $creditHistory): string | |||||
{ | |||||
$str = ''; | |||||
if (strlen($creditHistory->getComment())) { | |||||
$str .= '<br />'; | |||||
} | |||||
$str .= $this->getStrWording($creditHistory); | |||||
$order = $creditHistory->getOrderObject(); | |||||
if ($order) { | |||||
$str .= '<br />Montant de la commande : ' . $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); | |||||
} | |||||
$user = $creditHistory->getUserObject(); | |||||
if ($user) { | |||||
$str .= '<br />Client : ' . Html::encode($user->getName() . ' ' . $user->getLastname()); | |||||
} | |||||
$userAction = $creditHistory->getUserActionObject(); | |||||
if ($userAction) { | |||||
$str .= '<br />Action : ' . Html::encode($userAction->getName() . ' ' . $userAction->getLastname()); | |||||
} | |||||
return $str; | |||||
} | |||||
public function getDate(CreditHistory $creditHistory, bool $format = false): string | public function getDate(CreditHistory $creditHistory, bool $format = false): string | ||||
{ | { | ||||
$date = $creditHistory->getDate(); | $date = $creditHistory->getDate(); |
termes. | termes. | ||||
*/ | */ | ||||
use common\helpers\Price; | |||||
use yii\helpers\Html; | |||||
?> | ?> | ||||
<p>Bonjour <?= Html::encode($user->name); ?>,</p> | <p>Bonjour <?= Html::encode($user->name); ?>,</p> |
termes. | termes. | ||||
*/ | */ | ||||
use common\helpers\Price; | |||||
use yii\helpers\Html; | |||||
?> | ?> | ||||
Bonjour <?= Html::encode($user->name); ?>, | Bonjour <?= Html::encode($user->name); ?>, |
use common\logic\User\CreditHistory\Model\CreditHistory; | use common\logic\User\CreditHistory\Model\CreditHistory; | ||||
?> | ?> | ||||
Bonjour <?= $user->name; ?>,</p> | Bonjour <?= $user->name; ?>,</p> | ||||
Votre producteur <?= $producer->name; ?> vient de <?php if($creditForm->type == CreditHistory::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <?= Price::format($creditForm->amount); ?> sur le site http://www.opendistrib.net/ | Votre producteur <?= $producer->name; ?> vient de <?php if($creditForm->type == CreditHistory::TYPE_CREDIT): ?>créditer<?php else: ?>débiter<?php endif; ?> votre compte de <?= Price::format($creditForm->amount); ?> sur le site http://www.opendistrib.net/ |
termes. | termes. | ||||
*/ | */ | ||||
use common\helpers\GlobalParam ; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\logic\Producer\Producer\Producer; | |||||
use common\models\Order; | |||||
$producerManager = ProducerManager::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | |||||
?> | ?> | ||||
<p>Bonjour <?= Html::encode($user->name); ?>,</p> | <p>Bonjour <?= Html::encode($user->name); ?>,</p> | ||||
<p>Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? 'N°'.$order->reference : '' ?> d'une valeur de <strong><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?></strong> a bien été prise en compte.</p> | |||||
<p>Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? 'N°'.$order->reference : '' ?> d'une valeur de <strong><?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); ?></strong> a bien été prise en compte.</p> | |||||
<p>Récapitulatif des produits commandés :</p> | <p>Récapitulatif des produits commandés :</p> | ||||
<p><?= $order->getCartSummary() ?></p> | <p><?= $order->getCartSummary() ?></p> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if(strlen($pointSale->locality) > 0): ?> situé à <?= Html::encode($pointSale->locality) ?><?php endif ?>.</p> | <?php if(strlen($pointSale->locality) > 0): ?> situé à <?= Html::encode($pointSale->locality) ?><?php endif ?>.</p> | ||||
<?php $payment_infos = Producer::getConfig('option_payment_info') ; ?> | |||||
<?php $payment_infos = $producerManager->getConfig('option_payment_info') ; ?> | |||||
<?php if($payment_infos && strlen($payment_infos) > 0): ?> | <?php if($payment_infos && strlen($payment_infos) > 0): ?> | ||||
<p><strong>Informations de paiement :</strong><br /> | <p><strong>Informations de paiement :</strong><br /> | ||||
<?= nl2br(Html::encode($payment_infos)); ?></p> | <?= nl2br(Html::encode($payment_infos)); ?></p> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php $order_infos = Producer::getConfig('order_infos') ; ?> | |||||
<?php $order_infos = $producerManager->getConfig('order_infos') ; ?> | |||||
<?php if($order_infos && strlen($order_infos) > 0): ?> | <?php if($order_infos && strlen($order_infos) > 0): ?> | ||||
<p><strong>Informations générales :</strong><br /> | <p><strong>Informations générales :</strong><br /> | ||||
<?= nl2br(Html::encode($order_infos)); ?></p> | <?= nl2br(Html::encode($order_infos)); ?></p> |
*/ | */ | ||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
use common\logic\Producer\Producer\Producer; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use yii\helpers\Html; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
$producerManager = ProducerManager::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | |||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
?> | ?> | ||||
Bonjour <?= $user->name; ?>, | Bonjour <?= $user->name; ?>, | ||||
Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? '<strong>N°'.$order->reference.'</strong>' : '' ?> d'une valeur de <?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?> a bien été prise en compte. | |||||
Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? '<strong>N°'.$order->reference.'</strong>' : '' ?> d'une valeur de <?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); ?> a bien été prise en compte. | |||||
Récapitulatif des produits commandés : | Récapitulatif des produits commandés : | ||||
<?= $order->getCartSummary(false) ?> | <?= $order->getCartSummary(false) ?> | ||||
Elle sera à retirer le <?= date('d/m/Y',strtotime($distribution->date)) ?> au point de retrait <?= $pointSale->name ?> <?php if($order->pointSale->is_bread_box && $order->pointSale->bread_box_code): ?> (Code : <?= $order->pointSale->bread_box_code; ?>) <?php endif; ?> <?php if(strlen($pointSale->locality) > 0): ?> situé à <?= Html::encode($pointSale->locality) ?><?php endif ?>. | Elle sera à retirer le <?= date('d/m/Y',strtotime($distribution->date)) ?> au point de retrait <?= $pointSale->name ?> <?php if($order->pointSale->is_bread_box && $order->pointSale->bread_box_code): ?> (Code : <?= $order->pointSale->bread_box_code; ?>) <?php endif; ?> <?php if(strlen($pointSale->locality) > 0): ?> situé à <?= Html::encode($pointSale->locality) ?><?php endif ?>. | ||||
<?php $payment_infos = Producer::getConfig('option_payment_info') ; ?> | |||||
<?php $payment_infos = $producerManager->getConfig('option_payment_info') ; ?> | |||||
<?php if($payment_infos && strlen($payment_infos) > 0): ?> | <?php if($payment_infos && strlen($payment_infos) > 0): ?> | ||||
Informations de paiement : | Informations de paiement : | ||||
<?= $payment_infos ?> | <?= $payment_infos ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php $order_infos = Producer::getConfig('order_infos') ; ?> | |||||
<?php $order_infos = $producerManager->getConfig('order_infos') ; ?> | |||||
<?php if($order_infos && strlen($order_infos) > 0): ?> | <?php if($order_infos && strlen($order_infos) > 0): ?> | ||||
Informations générales : | Informations générales : | ||||
<?= $order_infos ?> | <?= $order_infos ?> |
*/ | */ | ||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use yii\helpers\Html; | |||||
$orderManager = OrderManager::getInstance(); | |||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
?> | ?> | ||||
<p>Bonjour,</p> | <p>Bonjour,</p> | ||||
<p>Une nouvelle commande d'une valeur de <strong><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?></strong> vient d'être passée par :</p> | |||||
<p>Une nouvelle commande d'une valeur de <strong><?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); ?></strong> vient d'être passée par :</p> | |||||
<ul> | <ul> | ||||
<li><strong><?= Html::encode($user->name); ?></strong></li> | <li><strong><?= Html::encode($user->name); ?></strong></li> |
*/ | */ | ||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use yii\helpers\Html; | |||||
$orderManager = OrderManager::getInstance(); | |||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
?> | ?> | ||||
Bonjour, | Bonjour, | ||||
Une nouvelle commande d'une valeur de <?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?> vient d'être passée par : | |||||
Une nouvelle commande d'une valeur de <?= $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true); ?> vient d'être passée par : | |||||
- <?= Html::encode($user->name); ?> | - <?= Html::encode($user->name); ?> | ||||
- <?= Html::encode($user->phone); ?> | - <?= Html::encode($user->phone); ?> |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
/* @var $this yii\web\View */ | |||||
/* @var $user common\models\ User */ | |||||
$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); | $resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); | ||||
?> | ?> | ||||
<div class="password-reset"> | <div class="password-reset"> | ||||
<p>Bonjour <?= Html::encode($user->name) ?>,</p> | <p>Bonjour <?= Html::encode($user->name) ?>,</p> | ||||
termes. | termes. | ||||
*/ | */ | ||||
/* @var $this yii\web\View */ | |||||
/* @var $user common\models\ User */ | |||||
$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); | $resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); | ||||
?> | ?> | ||||
Bonjour <?= $user->name ?>, | Bonjour <?= $user->name ?>, | ||||
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\logic\Producer\Producer\Producer; | |||||
$producerManager = ProducerManager::getInstance(); | |||||
?> | ?> | ||||
<p>Vous pouvez retrouver le lien de paiement dans votre <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['credit/history','slug_producer' => $producer->slug]) ?>">historique de commandes</a>.</p> | <p>Vous pouvez retrouver le lien de paiement dans votre <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['credit/history','slug_producer' => $producer->slug]) ?>">historique de commandes</a>.</p> | ||||
<?php $payment_infos = Producer::getConfig('option_payment_info') ; ?> | |||||
<?php $payment_infos = $producerManager->getConfig('option_payment_info') ; ?> | |||||
<?php if($payment_infos && strlen($payment_infos) > 0): ?> | <?php if($payment_infos && strlen($payment_infos) > 0): ?> | ||||
<p><strong>Informations de paiement :</strong><br /> | <p><strong>Informations de paiement :</strong><br /> | ||||
<?= nl2br(Html::encode($payment_infos)); ?></p> | <?= nl2br(Html::encode($payment_infos)); ?></p> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php $order_infos = Producer::getConfig('order_infos') ; ?> | |||||
<?php $order_infos = $producerManager->getConfig('order_infos') ; ?> | |||||
<?php if($order_infos && strlen($order_infos) > 0): ?> | <?php if($order_infos && strlen($order_infos) > 0): ?> | ||||
<p><strong>Informations générales :</strong><br /> | <p><strong>Informations générales :</strong><br /> | ||||
<?= nl2br(Html::encode($order_infos)); ?></p> | <?= nl2br(Html::encode($order_infos)); ?></p> |
termes. | termes. | ||||
*/ | */ | ||||
use yii\helpers\Html; | |||||
?> | ?> | ||||
Bonjour <?= Html::encode($user->name); ?>, | Bonjour <?= Html::encode($user->name); ?>, |
termes. | termes. | ||||
*/ | */ | ||||
?> | |||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use yii\helpers\Html; | |||||
$userManager = UserManager::getInstance(); | |||||
?> | |||||
<p>Bonjour,</p> | <p>Bonjour,</p> | ||||
<p>Le client <strong><?= $user->getUsername() ?></strong> vient de passer une commande pour le <strong><?= date('d/m/Y',strtotime($distribution->date)) ?></strong> mais le paiement par carte bancaire n'a pas abouti.<br /> | |||||
<p>Le client <strong><?= $userManager->getUsername($user) ?></strong> vient de passer une commande pour le <strong><?= date('d/m/Y',strtotime($distribution->date)) ?></strong> mais le paiement par carte bancaire n'a pas abouti.<br /> | |||||
Il vient de recevoir un message pour régulariser le paiement par virement bancaire.</p> | Il vient de recevoir un message pour régulariser le paiement par virement bancaire.</p> | ||||
<p>Sa commande a été enregistrée avec l'état "non payé".</p> | <p>Sa commande a été enregistrée avec l'état "non payé".</p> |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use yii\helpers\Html; | |||||
$userManager = UserManager::getInstance(); | |||||
?> | ?> | ||||
Bonjour, | Bonjour, | ||||
Le client <?= $user->getUsername() ?> vient de passer une commande pour le <?= date('d/m/Y',strtotime($distribution->date)) ?> mais le paiement par carte bancaire n'a pas abouti. | |||||
Le client <?= $userManager->getUsername() ?> vient de passer une commande pour le <?= date('d/m/Y',strtotime($distribution->date)) ?> mais le paiement par carte bancaire n'a pas abouti. | |||||
Il vient de recevoir un message pour régulariser le paiement par virement bancaire. | Il vient de recevoir un message pour régulariser le paiement par virement bancaire. | ||||
Sa commande a été enregistrée avec l'état "non payé". | Sa commande a été enregistrée avec l'état "non payé". |
termes. | termes. | ||||
*/ | */ | ||||
?> | |||||
use yii\helpers\Html; | |||||
?> | |||||
<p>Bonjour <?= Html::encode($user->name); ?>,</p> | <p>Bonjour <?= Html::encode($user->name); ?>,</p> | ||||
<p>Nous vous confirmons que le paiement de votre commande d'un montant de <strong><?= number_format($amount, 2) ?> €</strong> a réussi.</p> | <p>Nous vous confirmons que le paiement de votre commande d'un montant de <strong><?= number_format($amount, 2) ?> €</strong> a réussi.</p> |
termes. | termes. | ||||
*/ | */ | ||||
use yii\helpers\Html; | |||||
?> | ?> | ||||
Bonjour <?= Html::encode($user->name); ?>, | Bonjour <?= Html::encode($user->name); ?>, |
*/ | */ | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\helpers\Url ; | |||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
?> | ?> |
termes. | termes. | ||||
*/ | */ | ||||
use common\helpers\Url ; | |||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
?> | ?> |
$creditFunctioning = $pointSaleManager->getPointSaleCreditFunctioning($pointSale); | $creditFunctioning = $pointSaleManager->getPointSaleCreditFunctioning($pointSale); | ||||
$creditUser = $userManager->getCredit($user, $producer); | $creditUser = $userManager->getCredit($user, $producer); | ||||
$order = $orderManager->findOneOrderById($order->id); | $order = $orderManager->findOneOrderById($order->id); | ||||
$amountRemaining = $orderManager->getAmount($order, Order::AMOUNT_REMAINING); | |||||
$amountRemaining = $orderManager->getOrderAmount($order, Order::AMOUNT_REMAINING); | |||||
if ($credit && $pointSale->credit && | if ($credit && $pointSale->credit && | ||||
(($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && $posts['use_credit']) || | (($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && $posts['use_credit']) || | ||||
} | } | ||||
} // surplus à rembourser | } // surplus à rembourser | ||||
elseif ($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) { | elseif ($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) { | ||||
$amountSurplus = $orderManager->getAmount($order, Order::AMOUNT_SURPLUS); | |||||
$amountSurplus = $orderManager->getOrderAmount($order, Order::AMOUNT_SURPLUS); | |||||
$creditHistoryManager->createCreditHistory( | $creditHistoryManager->createCreditHistory( | ||||
CreditHistory::TYPE_REFUND, | CreditHistory::TYPE_REFUND, | ||||
$amountSurplus, | $amountSurplus, | ||||
if (is_array($ordersUserArray) && count($ordersUserArray)) { | if (is_array($ordersUserArray) && count($ordersUserArray)) { | ||||
foreach ($ordersUserArray as &$order) { | foreach ($ordersUserArray as &$order) { | ||||
$order = array_merge($order->getAttributes(), [ | $order = array_merge($order->getAttributes(), [ | ||||
'amount_total' => $orderManager->getAmountWithTax($order, Order::AMOUNT_TOTAL), | |||||
'amount_total' => $orderManager->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL), | |||||
'date_distribution' => $order->distribution->date, | 'date_distribution' => $order->distribution->date, | ||||
'pointSale' => $order->pointSale->getAttributes() | 'pointSale' => $order->pointSale->getAttributes() | ||||
]); | ]); | ||||
if ($orderUser) { | if ($orderUser) { | ||||
$json['order'] = array_merge($orderUser->getAttributes(), [ | $json['order'] = array_merge($orderUser->getAttributes(), [ | ||||
'amount_total' => $orderManager->getAmountWithTax($orderUser, Order::AMOUNT_TOTAL), | |||||
'amount_paid' => $orderManager->getAmount($orderUser, Order::AMOUNT_PAID), | |||||
'amount_total' => $orderManager->getOrderAmountWithTax($orderUser, Order::AMOUNT_TOTAL), | |||||
'amount_paid' => $orderManager->getOrderAmount($orderUser, Order::AMOUNT_PAID), | |||||
]); | ]); | ||||
} | } | ||||
*/ | */ | ||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use yii\helpers\Html; | |||||
$this->setTitle('Confirmation de commande') ; | |||||
$producerManager = ProducerManager::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | |||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
$producerManager = $this->getProducerManager(); | |||||
$this->setTitle('Confirmation de commande') ; | |||||
?> | ?> | ||||
<p><strong>Produit<?php if($order->countProducts() > 1): ?>s<?php endif; ?></strong></p> | <p><strong>Produit<?php if($order->countProducts() > 1): ?>s<?php endif; ?></strong></p> | ||||
<p><?= $order->getCartSummary() ?></p> | <p><?= $order->getCartSummary() ?></p> | ||||
</li> | </li> | ||||
<li>Total : <strong><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?></strong></li> | |||||
<li>Total : <strong><?= $orderManager->getOrderAmountWithTax($order,Order::AMOUNT_TOTAL, true); ?></strong></li> | |||||
</ul> | </ul> | ||||
</div> | </div> | ||||
</div> | </div> |