if ($pointSale->load(\Yii::$app->request->post()) && $pointSale->save()) { | if ($pointSale->load(\Yii::$app->request->post()) && $pointSale->save()) { | ||||
$pointSaleModule->updatePointSalePointProduction($pointSale); | $pointSaleModule->updatePointSalePointProduction($pointSale); | ||||
$pointSaleModule->processRestrictedAccess($pointSale); | $pointSaleModule->processRestrictedAccess($pointSale); | ||||
$this->initPaymentMethodOnsiteByCreditFunctioning($pointSale); | |||||
$distributionModule->addPointSaleIncomingDistributions($pointSale); | $distributionModule->addPointSaleIncomingDistributions($pointSale); | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
$pointSaleModule->updatePointSalePointProduction($model); | $pointSaleModule->updatePointSalePointProduction($model); | ||||
$pointSaleModule->processRestrictedAccess($model); | $pointSaleModule->processRestrictedAccess($model); | ||||
$this->initPaymentMethodOnsiteByCreditFunctioning($model); | |||||
$distributionModule->addPointSaleIncomingDistributions($model); | $distributionModule->addPointSaleIncomingDistributions($model); | ||||
$this->setFlash('success', 'Point de vente modifié.'); | $this->setFlash('success', 'Point de vente modifié.'); | ||||
} | } | ||||
} | } | ||||
public function initPaymentMethodOnsiteByCreditFunctioning(PointSale $pointSale) | |||||
{ | |||||
if($this->getPointSaleModule()->getBuilder()->initPaymentMethodOnsiteByCreditFunctioning($pointSale)) { | |||||
$this->addFlash('info', 'Le paiement sur place a été ajusté par rapport au fonctionnement de la cagnotte.'); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Initialise le formulaire de création/modification. | * Initialise le formulaire de création/modification. | ||||
*/ | */ |
</div> | </div> | ||||
<div v-if="producer.credit && pointSaleActive"> | <div v-if="producer.credit && pointSaleActive"> | ||||
<span class="title">Cagnotte</span> | <span class="title">Cagnotte</span> | ||||
<template v-if="pointSaleActive.credit && pointSaleActive.credit == 1"> | |||||
<template v-if="pointSaleActive.payment_method_credit && pointSaleActive.payment_method_credit == 1"> | |||||
<template v-if="pointSaleActive.credit_functioning == 'mandatory'">Obligatoire</template> | <template v-if="pointSaleActive.credit_functioning == 'mandatory'">Obligatoire</template> | ||||
<template v-else-if="pointSaleActive.credit_functioning == 'user'">Basé sur l'utilisateur</template> | <template v-else-if="pointSaleActive.credit_functioning == 'user'">Basé sur l'utilisateur</template> | ||||
<template v-else-if="pointSaleActive.credit_functioning == 'optional'">Optionnel</template> | <template v-else-if="pointSaleActive.credit_functioning == 'optional'">Optionnel</template> | ||||
<th class="column-point-sale" v-if="idActivePointSale == 0">Point de vente</th> | <th class="column-point-sale" v-if="idActivePointSale == 0">Point de vente</th> | ||||
<th class="column-amount">Montant</th> | <th class="column-amount">Montant</th> | ||||
<th class="column-state-payment">Paiement</th> | <th class="column-state-payment">Paiement</th> | ||||
<th class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">Cagnotte</th> | |||||
<th class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.payment_method_credit == 1)">Cagnotte</th> | |||||
<th class="column-actions">Actions</th> | <th class="column-actions">Actions</th> | ||||
<th class="column-tiller" v-if="producer && producer.tiller">Tiller</th> | <th class="column-tiller" v-if="producer && producer.tiller">Tiller</th> | ||||
</tr> | </tr> | ||||
<span class="glyphicon glyphicon-time" title="Débit automatique de la cagnotte la veille de la distribution" v-if="order.amount != 0 && order.isCreditAutoPayment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span> | <span class="glyphicon glyphicon-time" title="Débit automatique de la cagnotte la veille de la distribution" v-if="order.amount != 0 && order.isCreditAutoPayment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span> | ||||
</template> | </template> | ||||
</td> | </td> | ||||
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)"> | |||||
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.payment_method_credit == 1)"> | |||||
<template v-if="order.isCreditContext"> | <template v-if="order.isCreditContext"> | ||||
<a :href="baseUrl+'/user/credit?id='+order.id_user" target="_blank" :class="order.user.credit >= 0 ? 'positive' : 'negative'"> | <a :href="baseUrl+'/user/credit?id='+order.id_user" target="_blank" :class="order.user.credit >= 0 ? 'positive' : 'negative'"> | ||||
{{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }} | {{ order.user.credit.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }} |
} | } | ||||
$html .= '</td>' ; | $html .= '</td>' ; | ||||
if($pointSale->credit) { | |||||
if($pointSale->payment_method_credit) { | |||||
$credit = '' ; | $credit = '' ; | ||||
if(isset($order->user) && $order->user->id) { | if(isset($order->user) && $order->user->id) { | ||||
$strProducts = substr($strProducts, 0, strlen($strProducts) - 6) ; | $strProducts = substr($strProducts, 0, strlen($strProducts) - 6) ; | ||||
$html .= '<td>'.$strProducts.'</td><td></td><td></td><td></td>' ; | $html .= '<td>'.$strProducts.'</td><td></td><td></td><td></td>' ; | ||||
if($pointSale->credit) { | |||||
if($pointSale->payment_method_credit) { | |||||
$html .= '<td></td>' ; | $html .= '<td></td>' ; | ||||
} | } | ||||
$html .= '<td><strong>'.Price::format($pointSale->revenues_with_tax) . '</strong></td>'; | $html .= '<td><strong>'.Price::format($pointSale->revenues_with_tax) . '</strong></td>'; |
if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) { | if (count($pointSale->orders) && strlen($pointSale->$fieldInfosPointSale)) { | ||||
$html .= '<h3>'.$pointSale->name.'</h3>' ; | $html .= '<h3>'.$pointSale->name.'</h3>' ; | ||||
$colCredit = ($pointSale->credit) ? '<th>Cagnotte</th>' : '' ; | |||||
$colCredit = ($pointSale->payment_method_credit) ? '<th>Cagnotte</th>' : '' ; | |||||
$html .= '<table class="table table-bordered">' | $html .= '<table class="table table-bordered">' | ||||
. '<thead>' | . '<thead>' | ||||
$html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 2).'</td>'; | $html .= '<td>'.substr($strProducts, 0, strlen($strProducts) - 2).'</td>'; | ||||
$html .= '<td>'.$order->comment.'</td>'; | $html .= '<td>'.$order->comment.'</td>'; | ||||
if($pointSale->credit) { | |||||
if($pointSale->payment_method_credit) { | |||||
$credit = '' ; | $credit = '' ; | ||||
if(isset($order->user) && isset($order->user->userProducer)) { | if(isset($order->user) && isset($order->user->userProducer)) { | ||||
$credit = number_format($order->user->userProducer[0]->credit,2).' €' ; | $credit = number_format($order->user->userProducer[0]->credit,2).' €' ; | ||||
$strProducts = substr($strProducts, 0, strlen($strProducts) - 2) ; | $strProducts = substr($strProducts, 0, strlen($strProducts) - 2) ; | ||||
$html .= '<td>'.$strProducts.'</td><td></td>' ; | $html .= '<td>'.$strProducts.'</td><td></td>' ; | ||||
if($pointSale->credit) { | |||||
if($pointSale->payment_method_credit) { | |||||
$html .= '<td></td>' ; | $html .= '<td></td>' ; | ||||
} | } | ||||
$html .= '<td><strong>'.number_format($pointSale->revenues, 2) . ' €</strong></td>'; | $html .= '<td><strong>'.number_format($pointSale->revenues, 2) . ' €</strong></td>'; |
'value' => function ($model) { | 'value' => function ($model) { | ||||
$html = '<ul>'; | $html = '<ul>'; | ||||
if($model->payment_method_onsite) { | if($model->payment_method_onsite) { | ||||
$html .= "<li>Sur place</li>"; | |||||
$html .= '<li><i class="bi bi-wallet2"></i> Sur place</li>'; | |||||
} | } | ||||
if ($model->payment_method_credit && isset(Producer::$creditFunctioningArray[$model->credit_functioning])) { | if ($model->payment_method_credit && isset(Producer::$creditFunctioningArray[$model->credit_functioning])) { | ||||
$html .= "<li>Cagnotte (". strtolower(Producer::$creditFunctioningArray[$model->credit_functioning]).")</li>"; | |||||
$html .= '<li><i class="bi bi-piggy-bank"></i> Cagnotte ('. strtolower(Producer::$creditFunctioningArray[$model->credit_functioning]).')</li>'; | |||||
} | } | ||||
if ($model->payment_method_online) { | if ($model->payment_method_online) { | ||||
$html .= "<li>Paiement en ligne</li>"; | |||||
$html .= '<li><i class="bi bi-credit-card"></i> Paiement en ligne</li>'; | |||||
} | } | ||||
$html .= '</ul>'; | $html .= '</ul>'; | ||||
return $html; | return $html; |
} | } | ||||
/* line 8, ../sass/point_sale/_index.scss */ | /* line 8, ../sass/point_sale/_index.scss */ | ||||
.point-sale-index table .column-payment-method ul { | .point-sale-index table .column-payment-method ul { | ||||
list-style-type: none; | |||||
padding: 0px; | padding: 0px; | ||||
padding-left: 15px; | |||||
padding-left: 5px; | |||||
margin: 0px; | margin: 0px; | ||||
} | } | ||||
} | } | ||||
.column-payment-method { | .column-payment-method { | ||||
ul { | ul { | ||||
list-style-type: none; | |||||
padding: 0px; | padding: 0px; | ||||
padding-left: 15px; | |||||
padding-left: 5px; | |||||
margin: 0px; | margin: 0px; | ||||
} | } | ||||
} | } |
$html .= '<h3>'.$pointSale->name.'</h3>' ; | $html .= '<h3>'.$pointSale->name.'</h3>' ; | ||||
$columnDeliveryNote = ($producer->option_export_display_column_delivery_note) ? '<th>BL</th>' : ''; | $columnDeliveryNote = ($producer->option_export_display_column_delivery_note) ? '<th>BL</th>' : ''; | ||||
$colCredit = ($pointSale->credit) ? '<th>Cagnotte</th>' : '' ; | |||||
$colCredit = ($pointSale->payment_method_credit) ? '<th>Cagnotte</th>' : '' ; | |||||
$html .= '<table class="">' | $html .= '<table class="">' | ||||
. '<thead>' | . '<thead>' | ||||
} | } | ||||
$html .= '<td>'.$strProducts.'</td><td></td>' ; | $html .= '<td>'.$strProducts.'</td><td></td>' ; | ||||
if($pointSale->credit) { | |||||
if($pointSale->payment_method_credit) { | |||||
$html .= '<td></td>' ; | $html .= '<td></td>' ; | ||||
} | } | ||||
if($producer->option_export_display_column_delivery_note) { | if($producer->option_export_display_column_delivery_note) { | ||||
public function columnCredit(Order $order, PointSale $pointSale): string | public function columnCredit(Order $order, PointSale $pointSale): string | ||||
{ | { | ||||
if($pointSale->credit) { | |||||
if($pointSale->payment_method_credit) { | |||||
$credit = '' ; | $credit = '' ; | ||||
if(isset($order->user) && $order->user->id) { | if(isset($order->user) && $order->user->id) { |
$order->auto_payment = 0; | $order->auto_payment = 0; | ||||
if ($subscription->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) { | if ($subscription->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) { | ||||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) { | |||||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->payment_method_credit) { | |||||
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | ||||
$order->auto_payment = 0; | $order->auto_payment = 0; | ||||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | } elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { |
if($pointSale) { | if($pointSale) { | ||||
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); | $creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); | ||||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) { | |||||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->payment_method_credit) { | |||||
if($order->mean_payment == MeanPayment::CREDIT || $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | if($order->mean_payment == MeanPayment::CREDIT || $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { | ||||
return true; | return true; | ||||
} | } | ||||
if($pointSale) { | if($pointSale) { | ||||
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); | $creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); | ||||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) { | |||||
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->payment_method_credit) { | |||||
if($order->mean_payment == MeanPayment::CREDIT | if($order->mean_payment == MeanPayment::CREDIT | ||||
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY | || $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY | ||||
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | || $creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { | ||||
public function isOrderCreditFunctioningMandatory(Order $order): bool | public function isOrderCreditFunctioningMandatory(Order $order): bool | ||||
{ | { | ||||
$pointSale = $order->pointSale; | $pointSale = $order->pointSale; | ||||
return $pointSale && $pointSale->credit && $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY; | |||||
return $pointSale && $pointSale->payment_method_credit && $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY; | |||||
} | } | ||||
public function isOrderCreditFunctioningUser(Order $order): bool | public function isOrderCreditFunctioningUser(Order $order): bool | ||||
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user); | $userProducer = $this->userProducerRepository->findOneUserProducer($order->user); | ||||
return $pointSale | return $pointSale | ||||
&& $pointSale->credit | |||||
&& $pointSale->payment_method_credit | |||||
&& $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_USER | && $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_USER | ||||
&& $userProducer | && $userProducer | ||||
&& $userProducer->credit_active; | && $userProducer->credit_active; |
{ | { | ||||
return $this->userPointSaleBuilder->createUserPointSaleIfNotExist($user, $pointSale); | return $this->userPointSaleBuilder->createUserPointSaleIfNotExist($user, $pointSale); | ||||
} | } | ||||
public function initPaymentMethodOnsiteByCreditFunctioning(PointSale $pointSale): bool | |||||
{ | |||||
if($pointSale->payment_method_credit) { | |||||
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && !$pointSale->payment_method_onsite) { | |||||
$pointSale->payment_method_onsite = true; | |||||
$this->update($pointSale); | |||||
return true; | |||||
} | |||||
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY && $pointSale->payment_method_onsite) { | |||||
$pointSale->payment_method_onsite = false; | |||||
$this->update($pointSale); | |||||
return true; | |||||
} | |||||
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY && $pointSale->payment_method_online) { | |||||
$pointSale->payment_method_online = false; | |||||
$this->update($pointSale); | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} | } |
const CREDIT_FUNCTIONING_USER = 'user'; | const CREDIT_FUNCTIONING_USER = 'user'; | ||||
const HINT_CREDIT_FUNCTIONING = | const HINT_CREDIT_FUNCTIONING = | ||||
"- Optionnelle : les utilisateurs choisissent s'ils débitent ou non leur cagnotte. L'éventuel restant à payer est à régler sur place.\n | |||||
- Obligatoire : tous les utilisateurs payent leurs commandes via la cagnotte. Le paiement sur place ne peut pas être proposé en parallèle.\n | |||||
"- Optionnelle : les utilisateurs choisissent s'ils débitent ou non leur cagnotte. L'éventuel restant à payer est à régler sur place. Le paiement sur place est automatiquement proposé en parallèle.\n | |||||
- Obligatoire : tous les utilisateurs payent leurs commandes via la cagnotte. Le paiement sur place et le paiement en ligne ne peuvent pas être proposés en parallèle.\n | |||||
- Obligatoire par utilisateur : les utilisateurs avec l'option 'Cagnotte obligatoire' activée au niveau de leur profil payent leurs commandes via la cagnotte. Les autres utilisateurs voient simplement une note explicative au sujet de ce mode de paiement."; | - Obligatoire par utilisateur : les utilisateurs avec l'option 'Cagnotte obligatoire' activée au niveau de leur profil payent leurs commandes via la cagnotte. Les autres utilisateurs voient simplement une note explicative au sujet de ce mode de paiement."; | ||||
public static $creditFunctioningArray = [ | public static $creditFunctioningArray = [ | ||||
'option_allow_user_gift' => 'Autoriser les utilisateurs à effectuer un don à la plateforme lors de leur commande', | 'option_allow_user_gift' => 'Autoriser les utilisateurs à effectuer un don à la plateforme lors de leur commande', | ||||
'credit_functioning' => 'Fonctionnement de la cagnotte', | 'credit_functioning' => 'Fonctionnement de la cagnotte', | ||||
'credit_limit' => 'Cagnotte : montant limite', | 'credit_limit' => 'Cagnotte : montant limite', | ||||
'use_credit_checked_default' => 'Cocher par défaut l\'option "Utiliser ma cagnotte" lors de la commande de l\'utilisateur', | |||||
'use_credit_checked_default' => 'Sélectionner par défaut le mode de paiement "Cagnotte" lors de la commande de l\'utilisateur (en fonctionnement optionnel)', | |||||
'background_color_logo' => 'Couleur de fond du logo', | 'background_color_logo' => 'Couleur de fond du logo', | ||||
'option_behavior_cancel_order' => 'Comportement lors de la suppression d\'une commande', | 'option_behavior_cancel_order' => 'Comportement lors de la suppression d\'une commande', | ||||
'tiller' => 'Tiller', | 'tiller' => 'Tiller', |
return ['status' => 'error', 'errors' => $errors]; | return ['status' => 'error', 'errors' => $errors]; | ||||
} | } | ||||
if ($producerModule->isOnlinePaymentActiveAndTypeOrder($producer)) { | |||||
if ($producerModule->getSolver()->isOnlinePaymentActive($producer) && $posts['payment_method'] == 'online') { | |||||
$order = $orderModule->findOneOrderById($order->id); | $order = $orderModule->findOneOrderById($order->id); | ||||
\Stripe\Stripe::setApiKey( | \Stripe\Stripe::setApiKey( | ||||
$producerModule->getPrivateKeyApiStripe($producer) | $producerModule->getPrivateKeyApiStripe($producer) | ||||
$order = $orderModule->findOneOrderById($order->id); | $order = $orderModule->findOneOrderById($order->id); | ||||
$orderModule->initOrder($order); | $orderModule->initOrder($order); | ||||
if ($credit && $pointSale->credit && | |||||
(($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && $posts['use_credit']) || | |||||
$creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY || | |||||
($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER && $userProducer->credit_active) | |||||
if ($credit | |||||
&& $pointSale->payment_method_credit | |||||
&& $posts['payment_method'] == 'credit' | |||||
&& ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL || | |||||
$creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY || | |||||
($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER && $userProducer->credit_active) | |||||
)) { | )) { | ||||
// à payer | // à payer | ||||
if ($orderModule->getPaymentStatus($order) == Order::PAYMENT_UNPAID) { | if ($orderModule->getPaymentStatus($order) == Order::PAYMENT_UNPAID) { | ||||
$dateMini = date('Y-m-d'); | $dateMini = date('Y-m-d'); | ||||
$ordersUserArray = []; | $ordersUserArray = []; | ||||
if (GlobalParam::getCurrentUserId() && !$producerModule->isOnlinePaymentActiveAndTypeOrder($producer)) { | |||||
if (GlobalParam::getCurrentUserId()) { | |||||
$conditionsOrdersUser = [ | $conditionsOrdersUser = [ | ||||
'distribution.date > :date' | |||||
'distribution.date > :date', | |||||
'order.online_payment_url IS NULL' | |||||
]; | ]; | ||||
$paramsOrdersUser = [ | $paramsOrdersUser = [ | ||||
':date' => $dateMini | ':date' => $dateMini |
} | } | ||||
} | } | ||||
echo '<li class="block point-sale point-sale-' . $pointSale->id . '" data-code="'.$dataCode.'" data-credit="'.(int) $pointSale->credit.'"><div class="contenu">' . | |||||
echo '<li class="block point-sale point-sale-' . $pointSale->id . '" data-code="'.$dataCode.'" data-credit="'.(int) $pointSale->payment_method_credit.'"><div class="contenu">' . | |||||
'<span style="display:none;" class="id">' . $pointSale->id . '</span>' . | '<span style="display:none;" class="id">' . $pointSale->id . '</span>' . | ||||
'<div class="name">' .$htmlCode. Html::encode($pointSale->name) . '</div>' . | '<div class="name">' .$htmlCode. Html::encode($pointSale->name) . '</div>' . | ||||
'<div class="address">à ' . Html::encode($pointSale->locality) . '</div>' . | '<div class="address">à ' . Html::encode($pointSale->locality) . '</div>' . |
?> | ?> | ||||
<div id="order-success"> | <div id="order-success"> | ||||
<?php if($producerModule->isOnlinePaymentActiveAndTypeOrder($producer) && $returnPayment != 'success'): ?> | |||||
<?php if($producerModule->isOnlinePaymentActive($producer) && $order->online_payment_url && $returnPayment != 'success'): ?> | |||||
<div class="alert alert-danger"> | <div class="alert alert-danger"> | ||||
<h5>Le paiement en ligne a échoué.</h5> | <h5>Le paiement en ligne a échoué.</h5> | ||||
<strong>Attention</strong>, votre commande ne sera effective qu'à la réception du paiement.<br /> | <strong>Attention</strong>, votre commande ne sera effective qu'à la réception du paiement.<br /> |
'value' => function($order) use ($producer, $producerModule, $orderModule) { | 'value' => function($order) use ($producer, $producerModule, $orderModule) { | ||||
$html = '' ; | $html = '' ; | ||||
if($orderModule->getState($order) == Order::STATE_OPEN) { | if($orderModule->getState($order) == Order::STATE_OPEN) { | ||||
if ($producerModule->isOnlinePaymentActiveAndTypeOrder($producer)) { | |||||
$paymentStatus = $orderModule->getPaymentStatus($order); | |||||
if($paymentStatus == Order::PAYMENT_UNPAID && $order->online_payment_url) { | |||||
$html .= '<a href="'.$order->online_payment_url.'" class="btn btn-default"><i class="bi bi-credit-card"></i> Payer en ligne</a>'; | |||||
} | |||||
$paymentStatus = $orderModule->getPaymentStatus($order); | |||||
if ($producerModule->isOnlinePaymentActive($producer) && $paymentStatus == Order::PAYMENT_UNPAID && $order->online_payment_url) { | |||||
$html .= '<a href="'.$order->online_payment_url.'" class="btn btn-secondary"><i class="bi bi-credit-card"></i> Payer en ligne</a>'; | |||||
} | } | ||||
else { | else { | ||||
$html .= '<a data-bs-toggle="tooltip" data-bs-placement="top" title="Modifier" href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$order->id]).'" class="btn btn-secondary"><i class="bi bi-pencil"></i></a> '. | $html .= '<a data-bs-toggle="tooltip" data-bs-placement="top" title="Modifier" href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$order->id]).'" class="btn btn-secondary"><i class="bi bi-pencil"></i></a> '. |
</div> | </div> | ||||
</div> | </div> | ||||
<template | |||||
v-if="producer.credit == 1 && pointSaleActive.credit == 1 && (pointSaleActive.credit_functioning == 'mandatory' || (pointSaleActive.credit_functioning == 'user' && user.credit_active)) && !checkCreditLimit(order) "> | |||||
<div class="alert alert-danger"> | |||||
Vous devez | |||||
<template v-if="producer.online_payment == 1"><a | |||||
href="<?= \Yii::$app->urlManager->createUrl(['credit/add']) ?>">recharger | |||||
votre cagnotte</a></template> | |||||
<template v-else>recharger votre cagnotte</template> | |||||
auprès de votre producteur ou supprimer des produits.</span> | |||||
Votre producteur n'autorise pas une cagnotte avec un montant inférieur | |||||
à <strong>{{ formatPrice(producer.credit_limit) }}</strong>. | |||||
</div> | |||||
<div class="block-actions"> | |||||
<a class="btn btn-primary" | |||||
href="<?= \Yii::$app->urlManager->createUrl(['site/index']) ?>">Retour à | |||||
l'accueil</a> | |||||
</div> | |||||
</template> | |||||
<template v-else> | |||||
<div class="card credit" v-if="user && producer.credit == 1 && pointSaleActive.credit == 1 && (pointSaleActive.credit_functioning != 'user' || (pointSaleActive.credit_functioning == 'user' && user.credit_active))"> | |||||
<div class="card-body"> | |||||
<h5 class="card-title"> | |||||
<label for="order-comment"> | |||||
<i class="bi bi-piggy-bank"></i> | |||||
Cagnotte | |||||
</label> | |||||
</h5> | |||||
<div class="card-text"> | |||||
<input type="checkbox" id="use-credit" v-model="useCredit" disabled="disabled" | |||||
v-if="pointSaleActive.credit_functioning == 'mandatory' || (pointSaleActive.credit_functioning == 'user' && user.credit_active)"/> | |||||
<input type="checkbox" id="use-credit" v-model="useCredit" v-else/> <label | |||||
for="use-credit">Utiliser ma cagnotte ({{ formatPrice(user.credit) | |||||
}})</label> | |||||
<div class="info" v-if="useCredit"> | |||||
<template v-if="order == null || order.amount_paid == 0"> | |||||
<span v-if="checkCreditLimit(order)">{{ priceTotal(true) }} seront débités</span> | |||||
<span v-else> | |||||
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/> | |||||
Restera {{ formatPrice(priceTotal() - user.credit) }} à régler. | |||||
</span> | |||||
</template> | |||||
<template | |||||
v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()"> | |||||
<span v-if="checkCreditLimit(order)">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span> | |||||
<span v-else> | |||||
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/> | |||||
Restera {{ formatPrice(priceTotal() - order.amount_paid - user.credit) }} à régler. | |||||
</span> | |||||
<div id="payment-methods" class="card" v-if="pointSaleActive.payment_method_onsite || pointSaleActive.payment_method_credit || pointSaleActive.payment_method_online"> | |||||
<div class="card-body"> | |||||
<h5 class="card-title"> | |||||
<i class="bi bi-currency-euro"></i> | |||||
Paiement | |||||
</h5> | |||||
<div class="card-text"> | |||||
<div class="row"> | |||||
<div class="col-md-4" v-if="isPaymentMethodOnsiteActive()"> | |||||
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="onsite" id="payment-method-onsite" autocomplete="off"> | |||||
<label class="btn btn-outline-success" for="payment-method-onsite"> | |||||
<i class="bi bi-wallet2"></i> | |||||
Sur place | |||||
</label> | |||||
</div> | |||||
<div class="col-md-4" v-if="isPaymentMethodCreditActive()"> | |||||
<template v-if="(pointSaleActive.credit_functioning == 'mandatory' || (pointSaleActive.credit_functioning == 'user' && user.credit_active)) && !checkCreditLimit(order) "> | |||||
<div class="alert alert-danger"> | |||||
<i class="bi bi-piggy-bank"></i> | |||||
Vous devez | |||||
<template v-if="producer.online_payment == 1"> | |||||
<a href="<?= \Yii::$app->urlManager->createUrl(['credit/add']) ?>"> | |||||
recharger votre cagnotte</a> | |||||
</template> | |||||
<template v-else>recharger votre cagnotte</template> | |||||
auprès de votre producteur ou supprimer des produits.</span> | |||||
Votre producteur n'autorise pas une cagnotte avec un montant inférieur | |||||
à {{ formatPrice(producer.credit_limit) }}.<br /> | |||||
Montant de votre cagnotte : {{ formatPrice(user.credit) }}<br /> | |||||
Montant de votre commande : {{ priceTotal(true) }} | |||||
</div> | |||||
</template> | </template> | ||||
<template v-else-if="order != null && order.amount_paid > priceTotal()"> | |||||
<span>{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span> | |||||
<template v-else> | |||||
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="credit" id="payment-method-credit" autocomplete="off"> | |||||
<label class="btn btn-outline-success" for="payment-method-credit"> | |||||
<i class="bi bi-piggy-bank"></i> | |||||
Cagnotte | |||||
</label> | |||||
<div class="infos"> | |||||
Montant de ma cagnotte : {{ formatPrice(user.credit) }}<br /> | |||||
<template v-if="paymentMethod == 'credit'"> | |||||
<template v-if="order == null || order.amount_paid == 0"> | |||||
<span v-if="checkCreditLimit(order)">{{ priceTotal(true) }} seront débités</span> | |||||
<span v-else> | |||||
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/> | |||||
Restera {{ formatPrice(priceTotal() - user.credit) }} à régler. | |||||
</span> | |||||
</template> | |||||
<template v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()"> | |||||
<span v-if="checkCreditLimit(order)">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span> | |||||
<span v-else> | |||||
{{ formatPrice(user.credit) }} seront débités. (Limite de cagnotte à {{ formatPrice(producer.credit_limit) }})<br/> | |||||
Restera {{ formatPrice(priceTotal() - order.amount_paid - user.credit) }} à régler. | |||||
</span> | |||||
</template> | |||||
<template v-else-if="order != null && order.amount_paid > priceTotal()"> | |||||
<span>{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span> | |||||
</template> | |||||
</template> | |||||
</div> | |||||
</template> | </template> | ||||
</div> | </div> | ||||
<div class="col-md-4" v-if="isPaymentMethodCreditActiveFunctioningUser(false)"> | |||||
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="credit" id="payment-method-credit" autocomplete="off" disabled> | |||||
<label class="btn btn-outline-success" for="payment-method-credit"> | |||||
<i class="bi bi-piggy-bank"></i> | |||||
Cagnotte | |||||
</label> | |||||
<div class="infos"> | |||||
Sur demande, vous pouvez mettre en place une cagnotte | |||||
chez votre producteur, n'hésitez pas à lui en parler. | |||||
</div> | |||||
</div> | |||||
<div class="col-md-4" v-if="isPaymentMethodOnlineActive()"> | |||||
<input v-model="paymentMethod" type="radio" class="btn-check" name="payment_method" value="online" id="payment-method-online" autocomplete="off"> | |||||
<label class="btn btn-outline-success" for="payment-method-online"> | |||||
<i class="bi bi-credit-card"></i> | |||||
Carte bancaire | |||||
</label> | |||||
<div class="infos"> | |||||
Paiement sécurisé via la plateforme Stripe. | |||||
</div> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | |||||
<?php if ($producerModule->isOnlinePaymentActiveAndTypeOrder($producer)): ?> | |||||
<div class="alert alert-info"> | |||||
<i class="bi bi-credit-card"></i> | |||||
La commande est à payer en ligne lors de l'étape suivante. | |||||
</div> | |||||
<?php endif; ?> | |||||
<template> | |||||
<div id="signup-guest" class="card" v-if="!user && producer.option_allow_order_guest"> | <div id="signup-guest" class="card" v-if="!user && producer.option_allow_order_guest"> | ||||
<div class="card-title"> | <div class="card-title"> | ||||
<h5>Informations personnelles</h5> | <h5>Informations personnelles</h5> |
.order-create #main #content .order-form #bar-fixed #block-confirm-order, | .order-create #main #content .order-form #bar-fixed #block-confirm-order, | ||||
.order-update #main #content .order-form #bar-fixed #block-confirm-order { | .order-update #main #content .order-form #bar-fixed #block-confirm-order { | ||||
text-align: right; | text-align: right; | ||||
margin-top: 20px; | |||||
margin-top: 40px; | |||||
} | } | ||||
/* line 377, ../sass/order/_form.scss */ | /* line 377, ../sass/order/_form.scss */ | ||||
.order-create #main #content .order-form #bar-fixed #block-confirm-order button, | .order-create #main #content .order-form #bar-fixed #block-confirm-order button, | ||||
/* line 211, ../sass/order/_order.scss */ | /* line 211, ../sass/order/_order.scss */ | ||||
.order-order #main #app-order-order .block-actions { | .order-order #main #app-order-order .block-actions { | ||||
text-align: center; | text-align: center; | ||||
margin-top: 20px; | |||||
margin-top: 40px; | |||||
} | } | ||||
/* line 218, ../sass/order/_order.scss */ | /* line 218, ../sass/order/_order.scss */ | ||||
.order-order #main #app-order-order table#points-sale td.name .the-name { | .order-order #main #app-order-order table#points-sale td.name .the-name { | ||||
color: white; | color: white; | ||||
font-size: 1.2rem; | font-size: 1.2rem; | ||||
} | } | ||||
/* line 436, ../sass/order/_order.scss */ | |||||
/* line 435, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #payment-methods .infos { | |||||
margin-top: 10px; | |||||
color: gray; | |||||
} | |||||
/* line 442, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .delivery { | .order-order #main #app-order-order #content-step-payment .delivery { | ||||
margin-bottom: 20px; | margin-bottom: 20px; | ||||
} | } | ||||
/* line 439, ../sass/order/_order.scss */ | |||||
/* line 445, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .delivery .delivery-home { | .order-order #main #app-order-order #content-step-payment .delivery .delivery-home { | ||||
margin-bottom: 20px; | margin-bottom: 20px; | ||||
} | } | ||||
/* line 448, ../sass/order/_order.scss */ | |||||
/* line 454, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .comment { | .order-order #main #app-order-order #content-step-payment .comment { | ||||
margin-bottom: 20px; | margin-bottom: 20px; | ||||
} | } | ||||
/* line 453, ../sass/order/_order.scss */ | |||||
/* line 459, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .credit .info { | .order-order #main #app-order-order #content-step-payment .credit .info { | ||||
margin-left: 20px; | margin-left: 20px; | ||||
color: gray; | color: gray; | ||||
} | } | ||||
/* line 466, ../sass/order/_order.scss */ | |||||
/* line 472, ../sass/order/_order.scss */ | |||||
#main #content .panel h3 { | #main #content .panel h3 { | ||||
font-family: "worksans_bold"; | font-family: "worksans_bold"; | ||||
margin: 0px; | margin: 0px; |
categoryCurrent: null, | categoryCurrent: null, | ||||
comment: '', | comment: '', | ||||
creditCheckbox: false, | creditCheckbox: false, | ||||
paymentMethod: 'onsite', | |||||
useCredit: false, | useCredit: false, | ||||
errors: [], | errors: [], | ||||
disableConfirmButton: false, | disableConfirmButton: false, | ||||
app.user = response.data.user; | app.user = response.data.user; | ||||
app.useCredit = response.data.producer.use_credit_checked_default; | app.useCredit = response.data.producer.use_credit_checked_default; | ||||
if (response.data.points_sale) { | if (response.data.points_sale) { | ||||
app.pointsSale = []; | app.pointsSale = []; | ||||
var orderPointSale = 0; | var orderPointSale = 0; | ||||
app.pointSaleActive = app.getPointSale(app.pointSaleActiveId); | app.pointSaleActive = app.getPointSale(app.pointSaleActiveId); | ||||
} | } | ||||
if(app.pointSaleActive) { | |||||
if(app.pointSaleActive.payment_method_credit | |||||
&& (app.pointSaleActive.credit_functioning == 'mandatory' | |||||
|| (app.pointSaleActive.credit_functioning == 'user' && app.user.credit_active) | |||||
|| (app.pointSaleActive.credit_functioning == 'optional' && response.data.producer.use_credit_checked_default))) { | |||||
app.paymentMethod = 'credit'; | |||||
} | |||||
else if(app.pointSaleActive.payment_method_onsite) { | |||||
app.paymentMethod = 'onsite'; | |||||
} | |||||
else if(app.pointSaleActive.payment_method_online) { | |||||
app.paymentMethod = 'online'; | |||||
} | |||||
} | |||||
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 ; | ||||
return thePriceWithTax; | return thePriceWithTax; | ||||
} | } | ||||
}, | }, | ||||
isPaymentMethodOnsiteActive: function() { | |||||
return this.pointSaleActive && this.pointSaleActive.payment_method_onsite | |||||
&& !this.isPaymentMethodCreditActiveFunctioningUser(true) | |||||
&& !this.isPaymentMethodCreditActiveFunctioningMandatory(); | |||||
}, | |||||
isPaymentMethodCreditActive: function() { | |||||
return this.isPaymentMethodCreditActiveFunctioningOptional() | |||||
|| this.isPaymentMethodCreditActiveFunctioningMandatory() | |||||
|| this.isPaymentMethodCreditActiveFunctioningUser(true); | |||||
}, | |||||
isPaymentMethodCreditActiveCheckBase: function() { | |||||
return this.producer && this.producer.credit | |||||
&& this.pointSaleActive && this.pointSaleActive.payment_method_credit; | |||||
}, | |||||
isPaymentMethodCreditActiveFunctioningUser: function(userCreditActive) { | |||||
return this.isPaymentMethodCreditActiveCheckBase() | |||||
&& this.pointSaleActive.credit_functioning == 'user' | |||||
&& this.user && this.user.credit_active == userCreditActive; | |||||
}, | |||||
isPaymentMethodCreditActiveFunctioningMandatory: function() { | |||||
return this.isPaymentMethodCreditActiveCheckBase() | |||||
&& this.pointSaleActive.credit_functioning == 'mandatory'; | |||||
}, | |||||
isPaymentMethodCreditActiveFunctioningOptional: function() { | |||||
return this.isPaymentMethodCreditActiveCheckBase() | |||||
&& this.pointSaleActive.credit_functioning == 'optional'; | |||||
}, | |||||
isPaymentMethodOnlineActive: function() { | |||||
return this.producer && this.producer.online_payment | |||||
&& this.pointSaleActive && this.pointSaleActive.payment_method_online | |||||
&& !this.isPaymentMethodCreditActiveFunctioningUser(true) | |||||
&& !this.isPaymentMethodCreditActiveFunctioningMandatory() | |||||
}, | |||||
confirmClick: function() { | confirmClick: function() { | ||||
var app = this ; | var app = this ; | ||||
}, | }, | ||||
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | ||||
products: productsArray, | products: productsArray, | ||||
use_credit: Number(this.useCredit), | |||||
payment_method: this.paymentMethod, | |||||
user: user | user: user | ||||
}).then(function(response) { | }).then(function(response) { | ||||
if(response.data.status == 'success') { | if(response.data.status == 'success') { |
#block-confirm-order { | #block-confirm-order { | ||||
text-align: right ; | text-align: right ; | ||||
margin-top: 20px ; | |||||
margin-top: 40px ; | |||||
button { | button { | ||||
width: 340px ; | width: 340px ; |
.block-actions { | .block-actions { | ||||
text-align: center ; | text-align: center ; | ||||
margin-top: 20px ; | |||||
margin-top: 40px ; | |||||
} | } | ||||
table#points-sale { | table#points-sale { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
#payment-methods { | |||||
.infos { | |||||
margin-top: 10px; | |||||
color: gray; | |||||
} | |||||
} | |||||
#content-step-payment { | #content-step-payment { | ||||
.delivery { | .delivery { | ||||
margin-bottom: 20px ; | margin-bottom: 20px ; | ||||