<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span> | <span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span> | ||||
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span> | <span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span> | ||||
<span class="glyphicon glyphicon-time" title="Paiement automatique" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span> | |||||
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span> | |||||
</div> | </div> | ||||
</script> | </script> | ||||
<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span> | <span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span> | ||||
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span> | <span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à débiter</span> | ||||
<span class="glyphicon glyphicon-time" title="Paiement automatique" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span> | |||||
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit" v-if="order.auto_payment && producer && producer.credit && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span> | |||||
</div> | </div> | ||||
</script> | </script> | ||||
[ | [ | ||||
'attribute' => 'auto_payment', | 'attribute' => 'auto_payment', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'label' => 'Paiement automatique', | |||||
'label' => 'Débit automatique', | |||||
'headerOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], | 'headerOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], | ||||
'filterOptions' => ['class' => 'column-hide-on-mobile'], | 'filterOptions' => ['class' => 'column-hide-on-mobile'], | ||||
'contentOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], | 'contentOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], | ||||
'filter' => [0 => 'Non', 1 => 'Oui'], | 'filter' => [0 => 'Non', 1 => 'Oui'], | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
if($model->auto_payment) { | |||||
if($model->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) { | |||||
return '<span class="label label-success">Déduit</span>' ; | |||||
} | |||||
elseif($model->auto_payment == Subscription::AUTO_PAYMENT_YES) { | |||||
return '<span class="label label-success">Oui</span>' ; | return '<span class="label label-success">Oui</span>' ; | ||||
} | } | ||||
else { | else { |
use common\components\DolibarrApi; | use common\components\DolibarrApi; | ||||
use common\logic\Distribution\Distribution\Model\Distribution; | use common\logic\Distribution\Distribution\Model\Distribution; | ||||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | use common\logic\Document\DeliveryNote\Model\DeliveryNote; | ||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\Ticket\Ticket\Model\Ticket; | use common\logic\Ticket\Ticket\Model\Ticket; | ||||
use common\logic\User\CreditHistory\Model\CreditHistory; | use common\logic\User\CreditHistory\Model\CreditHistory; | ||||
'class' => \justcoded\yii2\eventlistener\components\EventListener::class, | 'class' => \justcoded\yii2\eventlistener\components\EventListener::class, | ||||
'listeners' => [], | 'listeners' => [], | ||||
'observers' => [ | 'observers' => [ | ||||
Order::class => [ | |||||
// CreditHistory : remboursement commande | |||||
common\logic\User\CreditHistory\Event\OrderObserver::class | |||||
], | |||||
CreditHistory::class => [ | CreditHistory::class => [ | ||||
// UserProducer : mise à jour du crédit | |||||
common\logic\User\UserProducer\Event\CreditHistoryObserver::class | common\logic\User\UserProducer\Event\CreditHistoryObserver::class | ||||
], | ], | ||||
Distribution::class => [ | Distribution::class => [ | ||||
// Subscription : génération des commandes sur base des abonnements | |||||
common\logic\Subscription\Subscription\Event\DistributionObserver::class | common\logic\Subscription\Subscription\Event\DistributionObserver::class | ||||
], | ], | ||||
DeliveryNote::class => [ | DeliveryNote::class => [ | ||||
// Order : assignation du bon de livraison aux commandes | |||||
common\logic\Order\Order\Event\DeliveryNoteObserver::class | common\logic\Order\Order\Event\DeliveryNoteObserver::class | ||||
], | ], | ||||
Ticket::class => [ | Ticket::class => [ | ||||
// User : envoi email nouveau ticket à l'administrateur | |||||
common\logic\User\User\Event\TicketObserver::class, | common\logic\User\User\Event\TicketObserver::class, | ||||
], | ], | ||||
], | ], |
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
/** | |||||
* Login form | |||||
*/ | |||||
class SubscriptionForm extends Model | class SubscriptionForm extends Model | ||||
{ | { | ||||
public $isAdmin = false ; | public $isAdmin = false ; | ||||
'sunday' => 'Dimanche', | 'sunday' => 'Dimanche', | ||||
'week_frequency' => 'Périodicité (semaines)', | 'week_frequency' => 'Périodicité (semaines)', | ||||
'username' => 'Nom d\'utilisateur', | 'username' => 'Nom d\'utilisateur', | ||||
'auto_payment' => 'Paiement automatique', | |||||
'auto_payment' => 'Débit automatique', | |||||
'comment' => 'Commentaire' | 'comment' => 'Commentaire' | ||||
]; | ]; | ||||
} | } | ||||
$subscription->saturday = $this->saturday; | $subscription->saturday = $this->saturday; | ||||
$subscription->sunday = $this->sunday; | $subscription->sunday = $this->sunday; | ||||
$subscription->week_frequency = $this->week_frequency; | $subscription->week_frequency = $this->week_frequency; | ||||
$subscription->auto_payment = (int) $this->auto_payment; | |||||
$subscription->auto_payment = Subscription::AUTO_PAYMENT_DEDUCTED; | |||||
$subscription->comment = $this->comment; | $subscription->comment = $this->comment; | ||||
$subscription->save(); | $subscription->save(); |
<?php | |||||
namespace common\logic\Order\Order\Event; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use yii\base\Event; | |||||
class OrderDeleteEvent extends Event | |||||
{ | |||||
public Order $order; | |||||
} |
*/ | */ | ||||
class Order extends ActiveRecordCommon | class Order extends ActiveRecordCommon | ||||
{ | { | ||||
const EVENT_DELETE = 'order.event.delete'; | |||||
var $amount = 0; | var $amount = 0; | ||||
var $amount_with_tax = 0; | var $amount_with_tax = 0; | ||||
var $amount_vat = []; | var $amount_vat = []; |
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\Producer\Producer\Repository\ProducerRepository; | use common\logic\Producer\Producer\Repository\ProducerRepository; | ||||
use common\logic\Product\Product\Service\ProductSolver; | use common\logic\Product\Product\Service\ProductSolver; | ||||
use common\logic\Subscription\Subscription\Model\Subscription; | |||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\UserProducer\Repository\UserProducerRepository; | use common\logic\User\UserProducer\Repository\UserProducerRepository; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
return intval($total / 3); | return intval($total / 3); | ||||
} | } | ||||
public function findOrdersIncomingBySubscription(Subscription $subscription, bool $begin = true) | |||||
{ | |||||
if($begin) { | |||||
$dateStart = $subscription->date_begin; | |||||
$comparatorDateStart = '>='; | |||||
} | |||||
else { | |||||
$dateStart = $subscription->date_end; | |||||
$comparatorDateStart = '>'; | |||||
} | |||||
$params = [ | |||||
':id_producer' => GlobalParam::getCurrentProducerId(), | |||||
':date_today' => date('Y-m-d'), | |||||
':date_start' => $dateStart, | |||||
':id_subscription' => $subscription->id | |||||
]; | |||||
$orders = Order::find() | |||||
->joinWith('distribution') | |||||
->where('distribution.id_producer = :id_producer') | |||||
->andWhere('distribution.date >= :date_today') | |||||
->andWhere('distribution.date ' . $comparatorDateStart . ' :date_start') | |||||
->andWhere('order.id_subscription = :id_subscription'); | |||||
$orders->params($params); | |||||
return $orders->all(); | |||||
} | |||||
} | } |
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | ||||
use common\logic\Document\Document\Model\Document; | use common\logic\Document\Document\Model\Document; | ||||
use common\logic\Document\Invoice\Model\Invoice; | use common\logic\Document\Invoice\Model\Invoice; | ||||
use common\logic\Order\Order\Event\OrderDeleteEvent; | |||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Order\Order\Repository\OrderRepository; | use common\logic\Order\Order\Repository\OrderRepository; | ||||
use common\logic\Order\ProductOrder\Model\ProductOrder; | use common\logic\Order\ProductOrder\Model\ProductOrder; | ||||
public function deleteOrdersIncomingDistributionsFromSubscription(Subscription $subscription, bool $deleteAfterDateEnd = false): int | public function deleteOrdersIncomingDistributionsFromSubscription(Subscription $subscription, bool $deleteAfterDateEnd = false): int | ||||
{ | { | ||||
$dateStart = $subscription->date_begin; | |||||
$comparatorDateStart = '>='; | |||||
if ($deleteAfterDateEnd) { | |||||
$dateStart = $subscription->date_end; | |||||
$comparatorDateStart = '>'; | |||||
} | |||||
$params = [ | |||||
':id_producer' => GlobalParam::getCurrentProducerId(), | |||||
':date_today' => date('Y-m-d'), | |||||
':date_start' => $dateStart, | |||||
':id_subscription' => $subscription->id | |||||
]; | |||||
$orders = Order::find() | |||||
->joinWith('distribution') | |||||
->where('distribution.id_producer = :id_producer') | |||||
->andWhere('distribution.date >= :date_today') | |||||
->andWhere('distribution.date ' . $comparatorDateStart . ' :date_start') | |||||
->andWhere('order.id_subscription = :id_subscription'); | |||||
$ordersArray = $this->orderRepository->findOrdersIncomingBySubscription($subscription, !$deleteAfterDateEnd); | |||||
$orders->params($params); | |||||
$ordersArray = $orders->all(); | |||||
$configCredit = $this->producerRepository->getConfig('credit'); | |||||
$countOrdersDeleted = 0; | $countOrdersDeleted = 0; | ||||
if ($ordersArray && count($ordersArray)) { | if ($ordersArray && count($ordersArray)) { | ||||
if ($this->distributionSolver->isDistributionAvailable($order->distribution)) { | if ($this->distributionSolver->isDistributionAvailable($order->distribution)) { | ||||
$theOrder = $this->orderRepository->findOneOrderById($order->id); | $theOrder = $this->orderRepository->findOneOrderById($order->id); | ||||
$this->initOrder($theOrder); | $this->initOrder($theOrder); | ||||
// remboursement de la commande | |||||
if ($theOrder->id_user && $this->orderSolver->getOrderAmount($theOrder, Order::AMOUNT_PAID) && $configCredit) { | |||||
$this->creditHistoryBuilder->createCreditHistory( | |||||
CreditHistory::TYPE_REFUND, | |||||
$this->orderSolver->getOrderAmount($theOrder, Order::AMOUNT_PAID), | |||||
$theOrder->distribution->producer, | |||||
$theOrder->user, | |||||
GlobalParam::getCurrentUser() | |||||
); | |||||
} | |||||
$this->deleteOrder($order, true); | $this->deleteOrder($order, true); | ||||
$countOrdersDeleted++; | $countOrdersDeleted++; | ||||
} | } | ||||
} | } | ||||
public function deleteOrder(Order $order, bool $force = false): bool | public function deleteOrder(Order $order, bool $force = false): bool | ||||
{ | { | ||||
$return = false; | |||||
$this->initOrder($order); | $this->initOrder($order); | ||||
// remboursement si l'utilisateur a payé pour cette commande | |||||
$amountPaid = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID); | |||||
if ($amountPaid >= 0.01) { | |||||
$this->creditHistoryBuilder->createCreditHistory( | |||||
CreditHistory::TYPE_REFUND, | |||||
$amountPaid, | |||||
GlobalParam::getCurrentProducer(), | |||||
$order->user, | |||||
$this->userSolver->getCurrent(), | |||||
MeanPayment::CREDIT, | |||||
$order | |||||
); | |||||
} | |||||
// delete | // delete | ||||
if ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE || | if ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE || | ||||
($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete)) | ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete)) | ||||
$this->productOrderBuilder->deleteProductOrdersByOrder($order); | $this->productOrderBuilder->deleteProductOrdersByOrder($order); | ||||
return $this->delete($order); | |||||
} // status 'delete' | |||||
$return = $this->delete($order); | |||||
} | |||||
// status 'delete' | |||||
elseif ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) { | elseif ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) { | ||||
$order->date_delete = date('Y-m-d H:i:s'); | $order->date_delete = date('Y-m-d H:i:s'); | ||||
$return = $this->update($order); | |||||
} | |||||
return $this->saveUpdate($order); | |||||
if($return) { | |||||
$orderDeleteEvent = new OrderDeleteEvent(); | |||||
$orderDeleteEvent->order = $order; | |||||
$order->trigger(Order::EVENT_DELETE, $orderDeleteEvent); | |||||
} | } | ||||
return false; | |||||
return $return; | |||||
} | } | ||||
/** | /** |
use common\logic\Document\Document\Model\Document; | use common\logic\Document\Document\Model\Document; | ||||
use common\logic\Document\Document\Service\DocumentSolver; | use common\logic\Document\Document\Service\DocumentSolver; | ||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Producer\Producer\Model\Producer; | |||||
use common\logic\Producer\Producer\Service\ProducerSolver; | use common\logic\Producer\Producer\Service\ProducerSolver; | ||||
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use common\logic\SolverInterface; | use common\logic\SolverInterface; | ||||
/** | /** | ||||
* Retourne une chaine de caractère décrivant l'utilisateur lié à la commande. | * Retourne une chaine de caractère décrivant l'utilisateur lié à la commande. | ||||
*/ | */ | ||||
// getStrUser | |||||
public function getOrderUsername(Order $order): string | public function getOrderUsername(Order $order): string | ||||
{ | { | ||||
if (isset($order->user)) { | if (isset($order->user)) { | ||||
/** | /** | ||||
* Retourne un bloc html présentant une date. | * Retourne un bloc html présentant une date. | ||||
*/ | */ | ||||
// getBlockDate | |||||
public function getDateAsHtml(Order $order): string | public function getDateAsHtml(Order $order): string | ||||
{ | { | ||||
return '<div class="block-date"> | return '<div class="block-date"> | ||||
/** | /** | ||||
* Retourne le montant de la commande (total, payé, restant, ou en surplus). | * Retourne le montant de la commande (total, payé, restant, ou en surplus). | ||||
*/ | */ | ||||
// getAmount | |||||
public function getOrderAmount(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | public function getOrderAmount(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | ||||
{ | { | ||||
$amount = $order->amount; | $amount = $order->amount; | ||||
return $this->_getAmountGeneric($order, $type, $amount, $format); | return $this->_getAmountGeneric($order, $type, $amount, $format); | ||||
} | } | ||||
// getAmountWithTax | |||||
public function getOrderAmountWithTax(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | public function getOrderAmountWithTax(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | ||||
{ | { | ||||
$amount = $order->amount + $this->getOrderTotalVat($order, $type); | $amount = $order->amount + $this->getOrderTotalVat($order, $type); |
'saturday' => 'Samedi', | 'saturday' => 'Samedi', | ||||
'sunday' => 'Dimanche', | 'sunday' => 'Dimanche', | ||||
'week_frequency' => 'Périodicité', | 'week_frequency' => 'Périodicité', | ||||
'auto_payment' => 'Paiement automatique', | |||||
'auto_payment' => 'Débit automatique', | |||||
'comment' => 'Commentaire' | 'comment' => 'Commentaire' | ||||
]; | ]; | ||||
} | } |
<?php | |||||
namespace common\logic\User\CreditHistory\Event; | |||||
use common\logic\Order\Order\Event\OrderDeleteEvent; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\User\CreditHistory\Wrapper\CreditHistoryManager; | |||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use justcoded\yii2\eventlistener\observers\Observer; | |||||
class OrderObserver extends Observer | |||||
{ | |||||
public function events() | |||||
{ | |||||
return [ | |||||
Order::EVENT_DELETE => 'onOrderDelete' | |||||
]; | |||||
} | |||||
public function onOrderDelete(OrderDeleteEvent $event) | |||||
{ | |||||
$order = $event->order; | |||||
$creditHistoryManager = CreditHistoryManager::getInstance(); | |||||
$userManager = UserManager::getInstance(); | |||||
$creditHistoryManager->refundOrder($order, $userManager->getCurrent()); | |||||
} | |||||
} |
public function refundOrder(Order $order, User $userAction): void | public function refundOrder(Order $order, User $userAction): void | ||||
{ | { | ||||
$this->creditHistoryBuilder->createCreditHistory( | |||||
CreditHistory::TYPE_REFUND, | |||||
$this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_PAID), | |||||
$this->getProducerContext(), | |||||
$order->user, | |||||
$userAction, | |||||
MeanPayment::CREDIT, | |||||
$order | |||||
); | |||||
$amountPaid = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID); | |||||
if ($amountPaid >= 0.01 && $order->id_user) { | |||||
$this->creditHistoryBuilder->createCreditHistory( | |||||
CreditHistory::TYPE_REFUND, | |||||
$this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID), | |||||
$this->getProducerContext(), | |||||
$order->user, | |||||
$userAction, | |||||
MeanPayment::CREDIT, | |||||
$order | |||||
); | |||||
} | |||||
} | } | ||||
public function refundSurplusOrder(Order $order, User $userAction): void | public function refundSurplusOrder(Order $order, User $userAction): void |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | ||||
use common\logic\Subscription\Subscription\Model\Subscription; | |||||
use common\logic\Subscription\Subscription\Model\SubscriptionSearch; | use common\logic\Subscription\Subscription\Model\SubscriptionSearch; | ||||
use yii\base\UserException; | use yii\base\UserException; | ||||
use yii\filters\AccessControl; | use yii\filters\AccessControl; | ||||
$model->friday = $subscription->friday; | $model->friday = $subscription->friday; | ||||
$model->saturday = $subscription->saturday; | $model->saturday = $subscription->saturday; | ||||
$model->sunday = $subscription->sunday; | $model->sunday = $subscription->sunday; | ||||
$model->auto_payment = $subscription->auto_payment; | |||||
$model->auto_payment = Subscription::AUTO_PAYMENT_DEDUCTED; | |||||
$model->week_frequency = $subscription->week_frequency; | $model->week_frequency = $subscription->week_frequency; | ||||
// produits | // produits |
<script> | <script> | ||||
var appInitValues = { | var appInitValues = { | ||||
urlLogin: '<?= \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducerCurrent()->slug])]) ?>' | |||||
urlLogin: '<?= \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducerCurrent()->slug])]) ?>', | |||||
producerOptionOrderEntryPoint: '<?= $producer->option_order_entry_point ?>', | |||||
<?php if (isset($order)): ?>pointSaleActiveId: <?= $order->id_point_sale ?><?php endif; ?> | |||||
}; | }; | ||||
</script> | </script> | ||||
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\Order\Order\Wrapper\OrderManager; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | use common\logic\Producer\Producer\Wrapper\ProducerManager; | ||||
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; | |||||
$producerManager = ProducerManager::getInstance(); | $producerManager = ProducerManager::getInstance(); | ||||
$subscriptionManager = SubscriptionManager::getInstance(); | |||||
$orderManager = OrderManager::getInstance(); | |||||
\producer\assets\VuejsSubscriptionFormAsset::register($this) ; | \producer\assets\VuejsSubscriptionFormAsset::register($this) ; | ||||
</div> | </div> | ||||
<div class="clr"></div> | <div class="clr"></div> | ||||
<h3><span>Paiement</span></h3> | |||||
<!--<h3><span>Paiement</span></h3> | |||||
<?php if($producerManager->getConfig('credit')): ?> | <?php if($producerManager->getConfig('credit')): ?> | ||||
<div class="form-group field-subscriptionform-auto_payment"> | <div class="form-group field-subscriptionform-auto_payment"> | ||||
<label><input type="checkbox" id="subscriptionform-auto_payment" name="SubscriptionForm[auto_payment]" v-model="autoPayment"> Paiement automatique</label> | <label><input type="checkbox" id="subscriptionform-auto_payment" name="SubscriptionForm[auto_payment]" v-model="autoPayment"> Paiement automatique</label> | ||||
<div class="hint-block">Cochez cette case si vous souhaitez que votre Crédit soit automatiquement débité.</div> | <div class="hint-block">Cochez cette case si vous souhaitez que votre Crédit soit automatiquement débité.</div> | ||||
<div class="help-block"></div> | <div class="help-block"></div> | ||||
</div> | </div> | ||||
<?php endif; ?> | |||||
<?php endif; ?>--> | |||||
<div class="days" v-if="pointSaleActive"> | <div class="days" v-if="pointSaleActive"> | ||||
<h3 id="step-days"><span>Jours</span></h3> | <h3 id="step-days"><span>Jours</span></h3> | ||||
<textarea id="subscriptionform-comment" class="form-control comment-textarea" v-model="comment"></textarea> | <textarea id="subscriptionform-comment" class="form-control comment-textarea" v-model="comment"></textarea> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<?php if($idSubscription): ?> | |||||
<?php | |||||
$subscription = $subscriptionManager->findOneSubscriptionById($idSubscription); | |||||
$ordersIncomingSubscriptionArray = $orderManager->findOrdersIncomingBySubscription($subscription); | |||||
?> | |||||
<?php if($subscription && $ordersIncomingSubscriptionArray): ?> | |||||
<div class="alert alert-warning"> | |||||
<span class="glyphicon glyphicon-alert"></span> | |||||
Attention, en modifiant votre abonnement, vos <?= count($ordersIncomingSubscriptionArray) ?> commande(s) à venir vont être re-générées. | |||||
</div> | |||||
<?php endif; ?> | |||||
<?php endif; ?> | |||||
<button class="btn btn-primary" disabled="disabled" v-if="disableSubmitButton">Enregistrer</button> | <button class="btn btn-primary" disabled="disabled" v-if="disableSubmitButton">Enregistrer</button> | ||||
<button class="btn btn-primary" v-else>Enregistrer</button> | <button class="btn btn-primary" v-else>Enregistrer</button> |
<div class="subscription-create"> | <div class="subscription-create"> | ||||
<?= $this->render('_form', [ | <?= $this->render('_form', [ | ||||
'idSubscription' => $idSubscription | |||||
'idSubscription' => $idSubscription, | |||||
]) ?> | ]) ?> | ||||
</div> | </div> |
], | ], | ||||
] ; | ] ; | ||||
if($producerManager->getConfig('credit')) { | |||||
/*if($producerManager->getConfig('credit')) { | |||||
$columns[] = [ | $columns[] = [ | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'label' => 'Paiement automatique', | 'label' => 'Paiement automatique', | ||||
} | } | ||||
} | } | ||||
] ; | ] ; | ||||
} | |||||
}*/ | |||||
$columns[] = [ | $columns[] = [ | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', |
distribution: null, | distribution: null, | ||||
pointsSale: [], | pointsSale: [], | ||||
pointSaleActive: null, | pointSaleActive: null, | ||||
pointSaleActiveId: null, | |||||
pointsSaleCodes: [], | pointsSaleCodes: [], | ||||
products: [], | products: [], | ||||
categories: [], | categories: [], | ||||
delivery: false, | delivery: false, | ||||
deliveryAddress: null, | deliveryAddress: null, | ||||
urlLogin: '#', | urlLogin: '#', | ||||
producerOptionOrderEntryPoint: null, | |||||
calendar: { | calendar: { | ||||
columns: 2, | columns: 2, | ||||
mode: 'single', | mode: 'single', | ||||
}, window.appInitValues); | }, window.appInitValues); | ||||
}, | }, | ||||
mounted: function() { | mounted: function() { | ||||
let fr = new Intl.Locale("fr-FR"); | |||||
var dateDefined = $('#order-distribution-date').size() || $('#distribution-date').size() ; | |||||
if(dateDefined) { | |||||
if($('#order-distribution-date').size()) { | |||||
this.date = new Date($('#order-distribution-date').html()) ; | |||||
} | |||||
else { | |||||
this.date = new Date($('#distribution-date').html()) ; | |||||
} | |||||
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' | |||||
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/' | |||||
+ this.date.getFullYear() ; | |||||
} | |||||
this.init('first') ; | |||||
this.initDate(); | |||||
this.init('first'); | |||||
}, | }, | ||||
methods: { | methods: { | ||||
initDate: function() { | |||||
var dateDefined = $('#order-distribution-date').size() || $('#distribution-date').size() ; | |||||
if(dateDefined && (this.producerOptionOrderEntryPoint != 'point-sale' || this.pointSaleActiveId)) { | |||||
if($('#order-distribution-date').size()) { | |||||
this.date = new Date($('#order-distribution-date').html()) ; | |||||
} | |||||
else { | |||||
this.date = new Date($('#distribution-date').html()) ; | |||||
} | |||||
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' | |||||
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/' | |||||
+ this.date.getFullYear() ; | |||||
} | |||||
}, | |||||
getDate: function() { | getDate: function() { | ||||
return this.formatDate(this.date) ; | return this.formatDate(this.date) ; | ||||
}, | }, | ||||
axios.get("ajax-infos",{params: { | axios.get("ajax-infos",{params: { | ||||
date : this.getDate(), | date : this.getDate(), | ||||
pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0 | |||||
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0) | |||||
}}) | }}) | ||||
.then(function(response) { | .then(function(response) { | ||||
// distributions | |||||
var distributions = response.data.distributions; | |||||
app.calendar.attrs = []; | app.calendar.attrs = []; | ||||
app.calendar.availableDates = []; | app.calendar.availableDates = []; | ||||
var distributions = response.data.distributions; | |||||
if (distributions.length) { | if (distributions.length) { | ||||
app.distributions = distributions; | app.distributions = distributions; | ||||
var arrayDate; | var arrayDate; | ||||
} | } | ||||
} | } | ||||
// distribution | |||||
if (response.data.distribution) { | if (response.data.distribution) { | ||||
app.distribution = response.data.distribution; | app.distribution = response.data.distribution; | ||||
} | } | ||||
// liste commandes | |||||
var orders = []; | var orders = []; | ||||
if (response.data.orders) { | if (response.data.orders) { | ||||
orders = response.data.orders; | orders = response.data.orders; | ||||
arrayDate = orders[i].date_distribution.split('-'); | arrayDate = orders[i].date_distribution.split('-'); | ||||
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]); | var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]); | ||||
if (app.isAvailableDate(dateOrder)) { | if (app.isAvailableDate(dateOrder)) { | ||||
app.calendar.attrs.push({ | app.calendar.attrs.push({ | ||||
highlight: true, | highlight: true, | ||||
popover: { | popover: { | ||||
hideIndicator: true | hideIndicator: true | ||||
}, | }, | ||||
dates: orders[i].date_distribution | dates: orders[i].date_distribution | ||||
/*highlight: { | |||||
backgroundColor: '#FF7F00' | |||||
}, | |||||
contentStyle: { | |||||
color: 'white' | |||||
}, | |||||
popover: { | |||||
label: orders[i].pointSale.name + ' / ' + app.formatPrice(orders[i].amount_total), | |||||
hideIndicator: true | |||||
}, | |||||
dates: orders[i].date_distribution,*/ | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// catégories | |||||
if(response.data.categories) { | if(response.data.categories) { | ||||
app.categories = response.data.categories ; | app.categories = response.data.categories ; | ||||
app.setCategoryCurrent(response.data.categories[0]) ; | app.setCategoryCurrent(response.data.categories[0]) ; | ||||
} | } | ||||
// producer | |||||
app.producer = response.data.producer; | app.producer = response.data.producer; | ||||
// user | |||||
app.user = response.data.user; | app.user = response.data.user; | ||||
// credit | |||||
app.useCredit = response.data.producer.use_credit_checked_default; | app.useCredit = response.data.producer.use_credit_checked_default; | ||||
// points de vente | |||||
if (response.data.points_sale) { | if (response.data.points_sale) { | ||||
app.pointsSale = []; | app.pointsSale = []; | ||||
var orderPointSale = 0; | var orderPointSale = 0; | ||||
} | } | ||||
} | } | ||||
if(app.pointSaleActiveId) { | |||||
app.pointSaleActive = app.getPointSale(app.pointSaleActiveId); | |||||
} | |||||
if(app.isChangeState('point-sale', 'point-sale', 'date')) { | if(app.isChangeState('point-sale', 'point-sale', 'date')) { | ||||
app.date = null ; | app.date = null ; | ||||
app.dateFormat = null ; | app.dateFormat = null ; | ||||
} | } | ||||
if(updateOrder) { | if(updateOrder) { | ||||
// products | |||||
if(response.data.products) { | if(response.data.products) { | ||||
app.products = response.data.products ; | |||||
app.products = response.data.products; | |||||
} | } | ||||
// order | |||||
app.order = null ; | app.order = null ; | ||||
if(response.data.order) { | if(response.data.order) { | ||||
app.order = response.data.order ; | app.order = response.data.order ; | ||||
} | } | ||||
if(type == 'first') { | if(type == 'first') { | ||||
if(app.producer.option_order_entry_point == 'point-sale') { | |||||
if(app.getDate() && app.pointSaleActive) { | |||||
app.step = 'products' ; | |||||
if(response.data.products) { | |||||
app.products = response.data.products; | |||||
} | |||||
} | |||||
else if(app.producer.option_order_entry_point == 'point-sale') { | |||||
app.step = 'point-sale' ; | app.step = 'point-sale' ; | ||||
} | } | ||||
else if(app.getDate() && app.producer && app.producer.option_order_entry_point == 'date') { | else if(app.getDate() && app.producer && app.producer.option_order_entry_point == 'date') { |