$subject = '[distrib] Commandes du ' . date('d/m', strtotime($date)); | $subject = '[distrib] Commandes du ' . date('d/m', strtotime($date)); | ||||
// génération du pdf de commande | // génération du pdf de commande | ||||
Yii::$app->runAction('order/report-cron', [ | |||||
Yii::$app->runAction('distribution/report-cron', [ | |||||
'date' => $date, | 'date' => $date, | ||||
'save' => true, | 'save' => true, | ||||
'id_producer' => $producer['id'], | |||||
'idProducer' => $producer['id'], | |||||
'key' => '64ac0bdab7e9f5e48c4d991ec5201d57' | 'key' => '64ac0bdab7e9f5e48c4d991ec5201d57' | ||||
]); | ]); | ||||
$mail->attach(Yii::getAlias('@app/web/pdf/Orders-' . $date . '-' . $producer['id'] . '.pdf')); | $mail->attach(Yii::getAlias('@app/web/pdf/Orders-' . $date . '-' . $producer['id'] . '.pdf')); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
class DistributionController extends BackendController | class DistributionController extends BackendController | ||||
{ | { | ||||
public function behaviors() | |||||
{ | |||||
return [ | |||||
'access' => [ | |||||
'class' => AccessControl::className(), | |||||
'rules' => [ | |||||
[ | |||||
'actions' => ['report-cron'], | |||||
'allow' => true, | |||||
'roles' => ['?'] | |||||
], | |||||
[ | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
'matchCallback' => function ($rule, $action) { | |||||
return User::getCurrentStatus() == USER::STATUS_ADMIN | |||||
|| User::getCurrentStatus() == USER::STATUS_PRODUCER; | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
public function actionIndex($date = '') | public function actionIndex($date = '') | ||||
{ | { | ||||
$format = 'Y-m-d' ; | $format = 'Y-m-d' ; | ||||
$arrayCreditUser['credit'] = $order->user->userProducer[0]->credit ; | $arrayCreditUser['credit'] = $order->user->userProducer[0]->credit ; | ||||
} | } | ||||
$oneProductUnactivated = false ; | |||||
foreach($order->productOrder as $productOrder) { | |||||
foreach($productsArray as $product) { | |||||
if($productOrder->id_product == $product['id'] && !$product['productDistribution'][0]['active']) { | |||||
$oneProductUnactivated = true ; | |||||
} | |||||
} | |||||
} | |||||
$order = array_merge($order->getAttributes(), [ | $order = array_merge($order->getAttributes(), [ | ||||
'amount' => $order->getAmount(Order::AMOUNT_TOTAL), | 'amount' => $order->getAmount(Order::AMOUNT_TOTAL), | ||||
'amount_paid' => $order->getAmount(Order::AMOUNT_PAID), | 'amount_paid' => $order->getAmount(Order::AMOUNT_PAID), | ||||
'user' => (isset($order->user)) ? array_merge($order->user->getAttributes(), $arrayCreditUser) : null, | 'user' => (isset($order->user)) ? array_merge($order->user->getAttributes(), $arrayCreditUser) : null, | ||||
'pointSale' => ['id' => $order->pointSale->id, 'name' => $order->pointSale->name], | 'pointSale' => ['id' => $order->pointSale->id, 'name' => $order->pointSale->name], | ||||
'productOrder' => $productOrderArray, | 'productOrder' => $productOrderArray, | ||||
'creditHistory' => $creditHistoryArray | |||||
'creditHistory' => $creditHistoryArray, | |||||
'oneProductUnactivated' => $oneProductUnactivated | |||||
]) ; | ]) ; | ||||
} | } | ||||
} | } | ||||
return $json ; | return $json ; | ||||
} | } | ||||
/** | |||||
* Génére un PDF récapitulatif des des commandes d'un producteur pour une | |||||
* date donnée (Méthode appelable via CRON) | |||||
* | |||||
* @param string $date | |||||
* @param boolean $save | |||||
* @param integer $idProducer | |||||
* @param string $key | |||||
* @return PDF|null | |||||
*/ | |||||
public function actionReportCron($date = '', $save = false, $idProducer = 0, $key = '') | |||||
{ | |||||
if($key == '64ac0bdab7e9f5e48c4d991ec5201d57') { | |||||
$this->actionReport($date, $save, $idProducer) ; | |||||
} | |||||
} | |||||
/** | /** | ||||
* Génére un PDF récapitulatif des commandes d'un producteur pour une | * Génére un PDF récapitulatif des commandes d'un producteur pour une | ||||
* date donnée. | * date donnée. |
'access' => [ | 'access' => [ | ||||
'class' => AccessControl::className(), | 'class' => AccessControl::className(), | ||||
'rules' => [ | 'rules' => [ | ||||
[ | |||||
'actions' => ['report-cron'], | |||||
'allow' => true, | |||||
'roles' => ['?'] | |||||
], | |||||
[ | [ | ||||
'allow' => true, | 'allow' => true, | ||||
'roles' => ['@'], | 'roles' => ['@'], |
use common\models\Producer ; | use common\models\Producer ; | ||||
use common\models\Distribution ; | use common\models\Distribution ; | ||||
use backend\models\MailForm ; | use backend\models\MailForm ; | ||||
use common\models\UserProducer ; | |||||
/** | /** | ||||
* UserController implements the CRUD actions for User model. | * UserController implements the CRUD actions for User model. | ||||
return $this->render('credit', [ | return $this->render('credit', [ | ||||
'user' => $user, | 'user' => $user, | ||||
'userProducer' => $userProducer, | |||||
'creditForm' => $creditForm, | 'creditForm' => $creditForm, | ||||
'history' => $history | 'history' => $history | ||||
]); | ]); | ||||
} | } | ||||
else { | else { | ||||
throw new UserException("Vous ne pouvez pas créditer un utilisateur qui n'est pas associé à votre boulangerie."); | |||||
throw new UserException("Vous ne pouvez pas créditer un utilisateur qui n'est pas associé à votre établissement."); | |||||
} | } | ||||
} | } | ||||
'user' => $user | 'user' => $user | ||||
]); | ]); | ||||
} | } | ||||
/** | |||||
* Modifie l'option "credit_active" d'un utilisateur pour le producteur courant. | |||||
* Redirige vers la page de crédit de l'utilisateur. | |||||
* | |||||
* @param integer $idUser | |||||
* @param boolean $state | |||||
*/ | |||||
public function actionStateCredit($idUser, $state) | |||||
{ | |||||
$userProducer = UserProducer::searchOne([ | |||||
'id_user' => $idUser | |||||
]) ; | |||||
if($userProducer) { | |||||
$userProducer->credit_active = $state ; | |||||
$userProducer->save() ; | |||||
} | |||||
return $this->redirect(['user/credit','id' => $idUser]) ; | |||||
} | |||||
/** | /** | ||||
* Finds the User model based on its primary key value. | * Finds the User model based on its primary key value. |
</div> | </div> | ||||
</td> | </td> | ||||
<td class="column-payment"> | <td class="column-payment"> | ||||
<div class="btn-group" v-if="order.user"> | |||||
<div class="btn-group" v-if="order.user && !order.date_delete"> | |||||
<button class="btn btn-xs btn-default" v-if="order.amount_paid == order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount"> | <button class="btn btn-xs btn-default" v-if="order.amount_paid == order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount"> | ||||
<span class="glyphicon glyphicon-euro"></span> Rembourser | <span class="glyphicon glyphicon-euro"></span> Rembourser | ||||
</button> | </button> | ||||
</div> | </div> | ||||
</td> | </td> | ||||
<td class="column-actions"> | <td class="column-actions"> | ||||
<span v-if="order.oneProductUnactivated" class="glyphicon glyphicon-warning-sign" title="Contient un produit non activé"></span> | |||||
<button class="btn btn-default" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span></button> | <button class="btn btn-default" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span></button> | ||||
<button class="btn btn-default" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span></button> | <button class="btn btn-default" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span></button> | ||||
<button class="btn btn-default" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span></button> | <button class="btn btn-default" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span></button> | ||||
:points-sale="pointsSale" | :points-sale="pointsSale" | ||||
:users="users" | :users="users" | ||||
:products="products" | :products="products" | ||||
:order="order" | |||||
:order="order.clone" | |||||
@close="showModalFormOrderUpdate = false" | @close="showModalFormOrderUpdate = false" | ||||
@ordercreatedupdated="orderCreatedUpdated" | @ordercreatedupdated="orderCreatedUpdated" | ||||
></order-form> | ></order-form> | ||||
<strong><span class="glyphicon glyphicon-menu-right"></span> Produits</strong> | <strong><span class="glyphicon glyphicon-menu-right"></span> Produits</strong> | ||||
<ul> | <ul> | ||||
<li v-for="product in products" v-if="order.productOrder[product.id] > 0"> | <li v-for="product in products" v-if="order.productOrder[product.id] > 0"> | ||||
{{ order.productOrder[product.id] }} x {{ product.name }} | |||||
{{ order.productOrder[product.id] }} x {{ product.name }} <span v-if="product.productDistribution[0].active == 0" class="glyphicon glyphicon-warning-sign" title="Ce produit n'est pas activé"></span> | |||||
</li> | </li> | ||||
</ul> | </ul> | ||||
<div v-if="order.comment && order.comment.length > 0" class="comment"> | <div v-if="order.comment && order.comment.length > 0" class="comment"> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<label class="control-label" for="select-id-user">Utilisateur</label> | <label class="control-label" for="select-id-user">Utilisateur</label> | ||||
<select class="form-control" v-model="order.id_user"> | <select class="form-control" v-model="order.id_user"> | ||||
<option v-for="user in users" :value="user.id_user">{{ user.name +' '+ user.lastname }}</option> | |||||
<option v-for="user in users" :value="user.id_user">{{ user.lastname +' '+ user.name }}</option> | |||||
</select> | </select> | ||||
<input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" /> | <input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" /> | ||||
</div> | </div> |
<?= $form->field($model, 'credit_functioning') | <?= $form->field($model, 'credit_functioning') | ||||
->dropDownList([ | ->dropDownList([ | ||||
'' => 'Paramètres globaux ('.Producer::$creditFunctioningArray[Producer::getConfig('credit_functioning')].')', | '' => 'Paramètres globaux ('.Producer::$creditFunctioningArray[Producer::getConfig('credit_functioning')].')', | ||||
Producer::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | |||||
Producer::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | |||||
], []) ; ?> | |||||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL], | |||||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY], | |||||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER], | |||||
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING) ; ?> | |||||
<div id="delivery-days"> | <div id="delivery-days"> |
. 'Ils créditent leur compte en vous donnant la somme de leur choix et c\'est ensuite à vous de '.Html::a('mettre à jour', ['user/index']).' leur Crédit en ligne.<br />' | . 'Ils créditent leur compte en vous donnant la somme de leur choix et c\'est ensuite à vous de '.Html::a('mettre à jour', ['user/index']).' leur Crédit en ligne.<br />' | ||||
. 'Ceci fait, les clients paient leur commande directement via leur Crédit.') ; ?> | . 'Ceci fait, les clients paient leur commande directement via leur Crédit.') ; ?> | ||||
<?= $form->field($model, 'credit_functioning') | |||||
->dropDownList([ | |||||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL], | |||||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY], | |||||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER], | |||||
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING) ; ?> | |||||
<?= $form->field($model, 'use_credit_checked_default') | |||||
->dropDownList([ | |||||
0 => 'Non', | |||||
1 => 'Oui', | |||||
], [])->hint('Utilisation optionnelle du Crédit.') ; ?> | |||||
<?= $form->field($model, 'credit_limit_reminder',[ | <?= $form->field($model, 'credit_limit_reminder',[ | ||||
'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', | 'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', | ||||
]) | ]) | ||||
->hint("Une relance est envoyé au client dès que ce seuil est dépassé.") ; ?> | ->hint("Une relance est envoyé au client dès que ce seuil est dépassé.") ; ?> | ||||
<?= $form->field($model, 'credit_functioning') | |||||
->dropDownList([ | |||||
Producer::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | |||||
Producer::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | |||||
], []) ; ?> | |||||
<?= $form->field($model, 'credit_limit',[ | |||||
'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', | |||||
])->hint('Limite de crédit que l\'utilisateur ne pourra pas dépasser. Laisser vide pour permettre un crédit négatif et infini.'); ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
} | } | ||||
?> | ?> | ||||
<div class="col-md-12"> | |||||
<?php $form = ActiveForm::begin(); ?> | |||||
<?= $form->field($creditForm, 'type')->dropDownList([ | |||||
CreditHistory::TYPE_CREDIT => 'Crédit', | |||||
CreditHistory::TYPE_DEBIT => 'Débit', | |||||
]) ?> | |||||
<?= $form->field($creditForm, 'amount')->textInput() ?> | |||||
<?= $form->field($creditForm, 'mean_payment')->dropDownList([ | |||||
CreditHistory::MEAN_PAYMENT_MONEY => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_MONEY), | |||||
CreditHistory::MEAN_PAYMENT_CREDIT_CARD => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_CREDIT_CARD), | |||||
CreditHistory::MEAN_PAYMENT_CHEQUE => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_CHEQUE), | |||||
CreditHistory::MEAN_PAYMENT_OTHER => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_OTHER), | |||||
]) ?> | |||||
<?= $form->field($creditForm, 'comment')->textarea() ?> | |||||
<?= $form->field($creditForm, 'send_mail')->checkbox() ?> | |||||
<div class="col-md-4"> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title"> | |||||
Crédit obligatoire | |||||
<?= Html::a($userProducer->credit_active ? 'Désactiver' : 'Activer', ['user/state-credit', 'idUser' => $user->id,'state' => !$userProducer->credit_active], ['class' => 'btn btn-default btn-xs']); ?> | |||||
</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<?php if($userProducer->credit_active): ?> | |||||
<div class="alert alert-success">Activé</div> | |||||
<?php else: ?> | |||||
<div class="alert alert-danger">Désactivé</div> | |||||
<?php endif; ?> | |||||
</div> | |||||
</div> | |||||
<div class="form-group"> | |||||
<?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Crédit / débit</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<?php $form = ActiveForm::begin(); ?> | |||||
<?= $form->field($creditForm, 'type')->dropDownList([ | |||||
CreditHistory::TYPE_CREDIT => 'Crédit', | |||||
CreditHistory::TYPE_DEBIT => 'Débit', | |||||
]) ?> | |||||
<?= $form->field($creditForm, 'amount')->textInput() ?> | |||||
<?= $form->field($creditForm, 'mean_payment')->dropDownList([ | |||||
CreditHistory::MEAN_PAYMENT_MONEY => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_MONEY), | |||||
CreditHistory::MEAN_PAYMENT_CREDIT_CARD => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_CREDIT_CARD), | |||||
CreditHistory::MEAN_PAYMENT_CHEQUE => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_CHEQUE), | |||||
CreditHistory::MEAN_PAYMENT_OTHER => CreditHistory::getStrMeanPaymentBy(CreditHistory::MEAN_PAYMENT_OTHER), | |||||
]) ?> | |||||
<?= $form->field($creditForm, 'comment')->textarea() ?> | |||||
<?= $form->field($creditForm, 'send_mail')->checkbox() ?> | |||||
<div class="form-group"> | |||||
<?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?> | |||||
</div> | |||||
<?php ActiveForm::end(); ?> | |||||
</div> | |||||
</div> | </div> | ||||
<?php ActiveForm::end(); ?> | |||||
</div> | </div> | ||||
<div class="col-md-12"> | |||||
<div class="col-md-8"> | |||||
<h2>Historique <span class="the-credit"><?= number_format($user->getCredit($producer->id), 2); ?> €</span></h2> | <h2>Historique <span class="the-credit"><?= number_format($user->getCredit($producer->id), 2); ?> €</span></h2> | ||||
<table class="table table-bordered"> | <table class="table table-bordered"> | ||||
<thead> | <thead> |
'attribute' => 'credit', | 'attribute' => 'credit', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) use($producer) { | 'value' => function($model) use($producer) { | ||||
$user = User::findOne($model->id) ; | |||||
$userProducer = UserProducer::searchOne([ | |||||
'id_user' => $model->id | |||||
]) ; | |||||
$credit = $userProducer ? $userProducer->credit : 0 ; | |||||
$classBtnCredit = $userProducer->credit_active ? 'btn-success' : 'btn-default' ; | |||||
$html = '<div class="input-group"> | $html = '<div class="input-group"> | ||||
<input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($user->getCredit($producer->id),2).' €" placeholder=""> | |||||
<input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($credit,2).' €" placeholder=""> | |||||
<span class="input-group-btn"> | <span class="input-group-btn"> | ||||
'.Html::a( | '.Html::a( | ||||
'<span class="glyphicon glyphicon-euro"></span>', | '<span class="glyphicon glyphicon-euro"></span>', | ||||
Yii::$app->urlManager->createUrl(['user/credit','id' => $model->id]), | Yii::$app->urlManager->createUrl(['user/credit','id' => $model->id]), | ||||
[ | [ | ||||
'title' => 'Crédit', | 'title' => 'Crédit', | ||||
'class' => 'btn btn-default' | |||||
'class' => 'btn '.$classBtnCredit | |||||
] | ] | ||||
).' | ).' | ||||
</span> | </span> |
margin-bottom: 20px; | margin-bottom: 20px; | ||||
} | } | ||||
/* line 5, ../sass/user/_credit.scss */ | |||||
.user-credit .panel .panel-heading .btn { | |||||
float: right; | |||||
} | |||||
/* line 4, ../sass/producer/_update.scss */ | /* line 4, ../sass/producer/_update.scss */ | ||||
.producer-update #nav-params { | .producer-update #nav-params { | ||||
margin-bottom: 30px; | margin-bottom: 30px; |
app.orders = response.data.orders ; | app.orders = response.data.orders ; | ||||
for(i=0 ; i < app.orders.length ; i++) { | for(i=0 ; i < app.orders.length ; i++) { | ||||
app.orders[i].clone = app.cloneOrder(app.orders[i]) ; | |||||
if(!app.orders[i].date_delete) { | if(!app.orders[i].date_delete) { | ||||
app.countOrders ++ ; | app.countOrders ++ ; | ||||
} | } | ||||
closeModalProducts: function() { | closeModalProducts: function() { | ||||
this.showModalProducts = false ; | this.showModalProducts = false ; | ||||
this.init(this.idActivePointSale) ; | this.init(this.idActivePointSale) ; | ||||
}, | |||||
cloneOrder: function(order) { | |||||
var clone = Object.assign({}, order) ; | |||||
clone.productOrder = {} ; | |||||
for(var key in order.productOrder) { | |||||
clone.productOrder[key] = order.productOrder[key] ; | |||||
} | |||||
return clone ; | |||||
} | } | ||||
}, | }, | ||||
}); | }); | ||||
idUser: this.order.id_user, | idUser: this.order.id_user, | ||||
username: ''+this.order.username, | username: ''+this.order.username, | ||||
products: JSON.stringify(this.order.productOrder), | products: JSON.stringify(this.order.productOrder), | ||||
comment: this.comment, | |||||
comment: this.order.comment, | |||||
processCredit: processCredit | processCredit: processCredit | ||||
}}) | }}) | ||||
.then(function(response) { | .then(function(response) { |
@import "stats/_products.scss" ; | @import "stats/_products.scss" ; | ||||
@import "distribution/_index.scss" ; | @import "distribution/_index.scss" ; | ||||
@import "user/_emails.scss" ; | @import "user/_emails.scss" ; | ||||
@import "user/_credit.scss" ; | |||||
@import "producer/_update.scss" ; | @import "producer/_update.scss" ; | ||||
@import "point_sale/_index.scss" ; | @import "point_sale/_index.scss" ; |
.user-credit { | |||||
.panel { | |||||
.panel-heading { | |||||
.btn { | |||||
float: right ; | |||||
} | |||||
} | |||||
} | |||||
} |
} | } | ||||
$newCredit = $userProducer->credit ; | $newCredit = $userProducer->credit ; | ||||
if($oldCredit > $creditLimitReminder && $newCredit <= $creditLimitReminder) { | |||||
if(!is_null($creditLimitReminder) && | |||||
$oldCredit > $creditLimitReminder && $newCredit <= $creditLimitReminder) { | |||||
$user = User::findOne($this->id_user) ; | $user = User::findOne($this->id_user) ; | ||||
$producer = Producer::findOne($this->id_producer) ; | $producer = Producer::findOne($this->id_producer) ; | ||||
Yii::$app->mailer->compose( | Yii::$app->mailer->compose( |
} | } | ||||
return $str ; | return $str ; | ||||
} | } | ||||
/** | |||||
* Retourne le mode de fonctionnement du crédit du point de vente. | |||||
* | |||||
* @return string | |||||
*/ | |||||
public function getCreditFunctioning() | |||||
{ | |||||
return $this->credit_functioning ? $this->credit_functioning : Producer::getConfig('credit_functioning') ; | |||||
} | |||||
} | } |
* @property string gcs | * @property string gcs | ||||
* @property boolean option_allow_user_gift | * @property boolean option_allow_user_gift | ||||
* @property string credit_functioning | * @property string credit_functioning | ||||
* @property boolean use_credit_checked_default | |||||
* @property float credit_limit | |||||
* | |||||
*/ | */ | ||||
class Producer extends ActiveRecordCommon | class Producer extends ActiveRecordCommon | ||||
{ | { | ||||
const CREDIT_FUNCTIONING_MANDATORY = 'mandatory' ; | const CREDIT_FUNCTIONING_MANDATORY = 'mandatory' ; | ||||
const CREDIT_FUNCTIONING_OPTIONAL = 'optional' ; | const CREDIT_FUNCTIONING_OPTIONAL = 'optional' ; | ||||
const CREDIT_FUNCTIONING_USER = 'user' ; | |||||
const HINT_CREDIT_FUNCTIONING = '<ul>' | |||||
. '<li>Optionnelle : l\'utilisateur choisit s\'il utilise son Crédit ou non. Les commandes peuvent être payées ou impayées.</li>' | |||||
. '<li>Obligatoire : toutes les commandes de l\'utilisateur son comptabilisées au niveau du Crédit. Toutes les commandes sont payées.</li>' | |||||
. '<li>Basée sur l\'utilisateur : Crédit obligatoire si l\'utilisateur a le crédit activé au niveau de son compte, système de Crédit non affiché sinon.</li>' | |||||
. '</ul>' ; | |||||
public static $creditFunctioningArray = [ | public static $creditFunctioningArray = [ | ||||
self::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | self::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | ||||
self::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | self::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | ||||
self::CREDIT_FUNCTIONING_USER => 'Basée sur l\'utilisateur', | |||||
]; | ]; | ||||
var $secret_key_payplug ; | var $secret_key_payplug ; | ||||
} | } | ||||
}], | }], | ||||
[['description','mentions','gcs','order_infos','slug','secret_key_payplug'], 'string'], | [['description','mentions','gcs','order_infos','slug','secret_key_payplug'], 'string'], | ||||
[['negative_balance', 'credit', 'active','online_payment','user_manage_subscription', 'option_allow_user_gift'], 'boolean'], | |||||
[['negative_balance', 'credit', 'active','online_payment','user_manage_subscription', 'option_allow_user_gift','use_credit_checked_default'], 'boolean'], | |||||
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type','credit_functioning'], 'string', 'max' => 255], | [['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type','credit_functioning'], 'string', 'max' => 255], | ||||
[['free_price', 'credit_limit_reminder'], 'double'], | |||||
[['free_price', 'credit_limit_reminder','credit_limit'], 'double'], | |||||
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'], | ['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'], | ||||
]; | ]; | ||||
} | } | ||||
'mentions' => 'Mentions légales', | 'mentions' => 'Mentions légales', | ||||
'gcs' => 'Conditions générales de vente', | 'gcs' => 'Conditions générales de vente', | ||||
'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' => 'Utilisation du Crédit par l\'utilisateur' | |||||
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur', | |||||
'credit_limit' => 'Crédit limite', | |||||
'use_credit_checked_default' => 'Cocher par défaut l\'option "Utiliser mon crédit" lors de la commande de l\'utilisateur' | |||||
]; | ]; | ||||
} | } | ||||
$query->andFilterWhere(['like', 'phone', $params['phone']]); | $query->andFilterWhere(['like', 'phone', $params['phone']]); | ||||
} | } | ||||
$query->orderBy('user.lastname ASC, user.name ASC') ; | |||||
return $query; | return $query; | ||||
} | } | ||||
return [ | return [ | ||||
[['id_user', 'id_producer'], 'required'], | [['id_user', 'id_producer'], 'required'], | ||||
[['id_user', 'id_producer'], 'integer'], | [['id_user', 'id_producer'], 'integer'], | ||||
[['active','bookmark'], 'boolean'], | |||||
[['active','bookmark','credit_active'], 'boolean'], | |||||
[['credit'], 'double'], | [['credit'], 'double'], | ||||
]; | ]; | ||||
} | } | ||||
'id_producer' => 'Producteur', | 'id_producer' => 'Producteur', | ||||
'active' => 'Actif', | 'active' => 'Actif', | ||||
'bookmark' => 'Favoris', | 'bookmark' => 'Favoris', | ||||
'credit_active' => 'Crédit' | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\mysql\Schema; | |||||
class m190222_090304_ajout_champs_options_credit extends Migration { | |||||
public function up() { | |||||
$this->addColumn('producer', 'credit_limit', Schema::TYPE_FLOAT) ; | |||||
$this->addColumn('producer', 'use_credit_checked_default', Schema::TYPE_BOOLEAN.' DEFAULT 1') ; | |||||
} | |||||
public function down() { | |||||
$this->dropColumn('producer', 'credit_limit') ; | |||||
$this->dropColumn('producer', 'use_credit_checked_default') ; | |||||
} | |||||
} |
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\mysql\Schema; | |||||
class m190225_093245_ajout_champs_gestion_credit_utilisateur extends Migration { | |||||
public function up() { | |||||
$this->addColumn('user_producer', 'credit_active', Schema::TYPE_BOOLEAN.' DEFAULT 0') ; | |||||
} | |||||
public function down() { | |||||
$this->dropColumn('user_producer', 'credit_active') ; | |||||
} | |||||
} |
use common\models\User ; | use common\models\User ; | ||||
use common\models\Producer ; | use common\models\Producer ; | ||||
use common\models\Order ; | use common\models\Order ; | ||||
use common\models\UserPointSale ; | |||||
use DateTime; | use DateTime; | ||||
class OrderController extends ProducerBaseController | class OrderController extends ProducerBaseController | ||||
{ | { | ||||
$posts = Yii::$app->request->post(); | $posts = Yii::$app->request->post(); | ||||
$productsArray = []; | $productsArray = []; | ||||
$totalQuantity = 0; | $totalQuantity = 0; | ||||
$producer = $this->getProducer() ; | |||||
foreach ($posts['products'] as $key => $quantity) { | foreach ($posts['products'] as $key => $quantity) { | ||||
$product = Product::find()->where(['id' => (int) $key])->one(); | $product = Product::find()->where(['id' => (int) $key])->one(); | ||||
} | } | ||||
} | } | ||||
$producer = $this->getProducer() ; | |||||
// date | // date | ||||
$errorDate = false; | $errorDate = false; | ||||
} else { | } else { | ||||
$errorPointSale = true; | $errorPointSale = true; | ||||
} | } | ||||
$userPointSale = UserPointSale::searchOne([ | |||||
'id_user' => User::getCurrentId(), | |||||
'id_point_sale' => $pointSale->id | |||||
]) ; | |||||
if($pointSale->restricted_access && !$userPointSale) { | |||||
$errorPointSale = true; | |||||
} | |||||
} | } | ||||
$errors = [] ; | $errors = [] ; | ||||
if ($order->validate() && count($productsArray) && !$errorDate && !$errorPointSale) { | if ($order->validate() && count($productsArray) && !$errorDate && !$errorPointSale) { | ||||
$userProducer = UserProducer::searchOne([ | |||||
'id_producer' => $order->distribution->id_producer, | |||||
'id_user' => User::getCurrentId() | |||||
]) ; | |||||
// gestion point de vente | // gestion point de vente | ||||
$pointSale = PointSale::searchOne([ | $pointSale = PointSale::searchOne([ | ||||
'id' => $order->id_point_sale | 'id' => $order->id_point_sale | ||||
]) ; | ]) ; | ||||
$order->comment_point_sale = ($pointSale && strlen($pointSale->getComment())) ? | $order->comment_point_sale = ($pointSale && strlen($pointSale->getComment())) ? | ||||
$pointSale->getComment() : '' ; | $pointSale->getComment() : '' ; | ||||
// credit | // credit | ||||
$credit = Producer::getConfig('credit'); | $credit = Producer::getConfig('credit'); | ||||
$creditLimit = Producer::getConfig('credit_limit'); | |||||
$creditFunctioning = $pointSale->getCreditFunctioning() ; | |||||
$creditUser = Yii::$app->user->identity->getCredit($distribution->id_producer); | |||||
$order = Order::searchOne([ | $order = Order::searchOne([ | ||||
'id' => $order->id | 'id' => $order->id | ||||
]) ; | ]) ; | ||||
if($credit && $pointSale->credit && ($posts['use_credit'] || $pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY)) { | |||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||||
$amountPaid = $order->getAmount(Order::AMOUNT_PAID); | |||||
$amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING) ; | |||||
if($credit && $pointSale->credit && | |||||
( $posts['use_credit'] || | |||||
$pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_MANDATORY || | |||||
($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_USER && $userProducer->credit_active) | |||||
)) { | |||||
// à payer | // à payer | ||||
if ($order->getPaymentStatus() == Order::PAYMENT_UNPAID) { | if ($order->getPaymentStatus() == Order::PAYMENT_UNPAID) { | ||||
$amountRemaining = $order->getAmount(Order::AMOUNT_REMAINING) ; | |||||
$credit = Yii::$app->user->identity->getCredit($distribution->id_producer); | |||||
if(!is_null($creditLimit) && $amountRemaining > $creditUser - $creditLimit) { | |||||
$amountRemaining = $creditUser - $creditLimit ; | |||||
} | |||||
if ($amountRemaining > 0) { | if ($amountRemaining > 0) { | ||||
$order->saveCreditHistory( | $order->saveCreditHistory( | ||||
CreditHistory::TYPE_PAYMENT, | CreditHistory::TYPE_PAYMENT, | ||||
} | } | ||||
} | } | ||||
} | } | ||||
else { | |||||
if (!count($productsArray)) { | |||||
$errors[] = "Vous n'avez choisi aucun produit" ; | |||||
} | |||||
if ($errorDate) { | |||||
$errors[] = "Vous ne pouvez pas commander pour cette date." ; | |||||
} | |||||
if ($errorPointSale) { | |||||
$errors[] = "Point de vente invalide." ; | |||||
} | |||||
if (!count($productsArray)) { | |||||
$errors[] = "Vous n'avez choisi aucun produit" ; | |||||
} | |||||
if ($errorDate) { | |||||
$errors[] = "Vous ne pouvez pas commander pour cette date." ; | |||||
} | } | ||||
if ($errorPointSale) { | |||||
$errors[] = "Point de vente invalide." ; | |||||
} | |||||
return $errors ; | return $errors ; | ||||
} | } | ||||
'order_infos' => $producer->order_infos, | 'order_infos' => $producer->order_infos, | ||||
'credit' => $producer->credit, | 'credit' => $producer->credit, | ||||
'credit_functioning' => $producer->credit_functioning, | 'credit_functioning' => $producer->credit_functioning, | ||||
'use_credit_checked_default' => $producer->use_credit_checked_default, | |||||
'credit_limit' => is_numeric($producer->credit_limit) ? $producer->credit_limit : null | |||||
] ; | ] ; | ||||
// Distributions | // Distributions | ||||
'id_user' => User::getCurrentId() | 'id_user' => User::getCurrentId() | ||||
]) ; | ]) ; | ||||
$json['credit'] = $userProducer->credit ; | |||||
$json['user'] = [ | |||||
'credit' => $userProducer->credit, | |||||
'credit_active' => $userProducer->credit_active, | |||||
] ; | |||||
if($dateObject && $dateObject->format($format) === $date) { | if($dateObject && $dateObject->format($format) === $date) { | ||||
// distribution | // distribution | ||||
$distribution = Distribution::initDistribution($date) ; | $distribution = Distribution::initDistribution($date) ; | ||||
$json['distribution'] = $distribution ; | $json['distribution'] = $distribution ; | ||||
$pointsSaleArray = PointSale::find() | $pointsSaleArray = PointSale::find() | ||||
->joinWith(['pointSaleDistribution' => function($query) use ($distribution) { | ->joinWith(['pointSaleDistribution' => function($query) use ($distribution) { | ||||
$query->where(['id_distribution' => $distribution->id]); | $query->where(['id_distribution' => $distribution->id]); | ||||
->with(['userPointSale' => function($query) { | ->with(['userPointSale' => function($query) { | ||||
$query->onCondition(['id_user' => User::getCurrentId()]) ; | $query->onCondition(['id_user' => User::getCurrentId()]) ; | ||||
}]) | }]) | ||||
->where([ | |||||
'id_producer' => $distribution->id_producer, | |||||
]) | |||||
->where(['id_producer' => $distribution->id_producer]) | |||||
->andWhere('restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0)') | |||||
->params([':id_user' => User::getCurrentId()]) | |||||
->all(); | ->all(); | ||||
$creditFunctioningProducer = Producer::getConfig('credit_functioning') ; | $creditFunctioningProducer = Producer::getConfig('credit_functioning') ; |
if($c->date_delete) { | if($c->date_delete) { | ||||
$html .= '<span class="label label-danger">Annulée</span><br />' ; | $html .= '<span class="label label-danger">Annulée</span><br />' ; | ||||
if($c->getState() == Order::STATE_OPEN) { | |||||
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>' ; | |||||
} | |||||
} | } | ||||
else { | else { | ||||
if($c->getState() == Order::STATE_DELIVERED) { | if($c->getState() == Order::STATE_DELIVERED) { |
<label for="order-comment">Commentaire</label> | <label for="order-comment">Commentaire</label> | ||||
<textarea id="order-comment" v-model="comment" class="form-control"></textarea> | <textarea id="order-comment" v-model="comment" class="form-control"></textarea> | ||||
</div> | </div> | ||||
<div class="credit"> | |||||
<div v-if="producer.credit == 1 && pointSaleActive.credit == 1"> | |||||
<input type="checkbox" id="use-credit" v-model="useCredit" disabled="disabled" v-if="pointSaleActive.credit_functioning == 'mandatory'" /> | |||||
<input type="checkbox" id="use-credit" v-model="useCredit" v-else /> <label for="use-credit">Utiliser mon Crédit ({{ formatPrice(credit) }})</label> | |||||
<div class="info" v-if="useCredit"> | |||||
<span v-if="order == null || order.amount_paid == 0">{{ priceTotal(true) }} seront débités</span> | |||||
<span v-else-if="order != null && order.amount_paid > 0 && order.amount_paid < priceTotal()">{{ formatPrice(priceTotal() - order.amount_paid) }} seront débités</span> | |||||
<span v-else-if="order != null && order.amount_paid > priceTotal()">{{ formatPrice(order.amount_paid - priceTotal()) }} seront remboursés</span> | |||||
<template v-if="!checkCreditLimit(order) && pointSaleActive.credit_functioning == 'mandatory'"> | |||||
<div class="alert alert-danger">Vous devez recharger votre crédit ou supprimer des produits. Votre producteur n'autorise pas un crédit inférieur à <strong>{{ formatPrice(creditLimit) }}</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="credit"> | |||||
<div v-if="producer.credit == 1 && pointSaleActive.credit == 1 && (pointSaleActive.credit_functioning != 'user' || (pointSaleActive.credit_functioning == 'user' && user.credit_active))"> | |||||
<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 mon Crédit ({{ 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 crédit à {{ formatPrice(producer.credit_limit) }})<br /> | |||||
Restera {{ formatPrice(priceTotal() - 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 crédit à {{ 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> | |||||
</div> | |||||
</div> | |||||
<div v-else> | |||||
<span class="glyphicon glyphicon-chevron-right"></span> La commande sera à régler sur place. | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div v-else> | |||||
<span class="glyphicon glyphicon-chevron-right"></span> La commande sera à régler sur place. | |||||
<div class="block-actions"> | |||||
<button class="btn btn-primary" disabled="disabled" v-if="disableConfirmButton">Je confirme ma commande</button> | |||||
<button class="btn btn-primary" v-else @click="confirmClick">Je confirme ma commande</button> | |||||
</div> | </div> | ||||
</div> | |||||
<div class="block-actions"> | |||||
<button class="btn btn-primary" disabled="disabled" v-if="disableConfirmButton">Je confirme ma commande</button> | |||||
<button class="btn btn-primary" v-else @click="confirmClick">Je confirme ma commande</button> | |||||
</div> | |||||
</template> | |||||
</div> | </div> | ||||
</transition> | </transition> | ||||
</div> | </div> |
.order-order #app-order-order table#products tr.total .price-total { | .order-order #app-order-order table#products tr.total .price-total { | ||||
font-size: 23px; | font-size: 23px; | ||||
} | } | ||||
/* line 239, ../sass/order/_order.scss */ | |||||
.order-order #app-order-order #content-step-payment .credit { | |||||
margin-top: 20px; | |||||
} | |||||
/* line 242, ../sass/order/_order.scss */ | |||||
/* line 240, ../sass/order/_order.scss */ | |||||
.order-order #app-order-order #content-step-payment .credit .info { | .order-order #app-order-order #content-step-payment .credit .info { | ||||
margin-left: 20px; | margin-left: 20px; | ||||
color: gray; | color: gray; | ||||
} | } | ||||
/* line 249, ../sass/order/_order.scss */ | |||||
/* line 246, ../sass/order/_order.scss */ | |||||
.order-order #app-order-order #content-step-payment .comment { | |||||
margin-bottom: 20px; | |||||
} | |||||
/* line 251, ../sass/order/_order.scss */ | |||||
.order-order #app-order-order #infos { | .order-order #app-order-order #infos { | ||||
margin-top: 30px; | margin-top: 30px; | ||||
} | } | ||||
/* line 251, ../sass/order/_order.scss */ | |||||
/* line 253, ../sass/order/_order.scss */ | |||||
.order-order #app-order-order #infos .panel-body { | .order-order #app-order-order #infos .panel-body { | ||||
padding-top: 0px; | padding-top: 0px; | ||||
white-space: pre-line; | white-space: pre-line; |
loadingInit: true, | loadingInit: true, | ||||
step: 'date', | step: 'date', | ||||
producer: null, | producer: null, | ||||
user: null, | |||||
date: null, | date: null, | ||||
dateFormat: null, | dateFormat: null, | ||||
distributions: [], | distributions: [], | ||||
products: [], | products: [], | ||||
comment: '', | comment: '', | ||||
creditCheckbox: false, | creditCheckbox: false, | ||||
credit: 0, | |||||
useCredit: false, | useCredit: false, | ||||
errors: [], | errors: [], | ||||
disableConfirmButton: false, | disableConfirmButton: false, | ||||
}, | }, | ||||
formatPrice: function(price) { | formatPrice: function(price) { | ||||
var isNumberRegExp = new RegExp(/^[-+]?[0-9]+(\.[0-9]+)*$/); | var isNumberRegExp = new RegExp(/^[-+]?[0-9]+(\.[0-9]+)*$/); | ||||
if(isNumberRegExp.test(price) && price > 0) { | |||||
if(isNumberRegExp.test(price)) { | |||||
return Number(price).toFixed(2).replace('.',',')+' €' ; | return Number(price).toFixed(2).replace('.',',')+' €' ; | ||||
} | } | ||||
return '--' ; | |||||
return '0 €' ; | |||||
}, | }, | ||||
getPointSale: function(idPointSale) { | getPointSale: function(idPointSale) { | ||||
for(var key in this.pointsSale) { | for(var key in this.pointsSale) { | ||||
axios.get("ajax-infos",{params: {date : this.getDate()}}) | axios.get("ajax-infos",{params: {date : this.getDate()}}) | ||||
.then(function(response) { | .then(function(response) { | ||||
app.producer = response.data.producer ; | app.producer = response.data.producer ; | ||||
app.credit = response.data.credit ; | |||||
app.user = response.data.user ; | |||||
app.useCredit = response.data.producer.use_credit_checked_default ; | |||||
app.calendar.attrs = [] ; | app.calendar.attrs = [] ; | ||||
app.calendar.availableDates = [] ; | app.calendar.availableDates = [] ; | ||||
var distributions = response.data.distributions ; | var distributions = response.data.distributions ; | ||||
validatePointSale: function(idPointSale) { | validatePointSale: function(idPointSale) { | ||||
this.pointSaleActive = this.getPointSale(idPointSale) ; | this.pointSaleActive = this.getPointSale(idPointSale) ; | ||||
this.useCredit = true ; | |||||
if(this.pointSaleActive.credit_functioning == 'mandatory' || (this.pointSaleActive.credit_functioning == 'user' && this.user.credit_active)) { | |||||
this.useCredit = true ; | |||||
} | |||||
else { | |||||
this.useCredit = false ; | |||||
} | |||||
this.changeStep('products') ; | this.changeStep('products') ; | ||||
}, | }, | ||||
if(!this.oneProductOrdered()) { | if(!this.oneProductOrdered()) { | ||||
this.errors.push('Veuillez sélectionner au moins un produit.') ; | this.errors.push('Veuillez sélectionner au moins un produit.') ; | ||||
} | } | ||||
}, | |||||
checkCreditLimit: function(order) { | |||||
var total = this.priceTotal() ; | |||||
if(order != null) { | |||||
total = this.priceTotal() - order.amount_paid ; | |||||
} | |||||
return this.producer.credit_limit == null || (this.producer.credit_limit != null && (this.user.credit - total >= this.producer.credit_limit)) ; | |||||
} | } | ||||
} | } | ||||
}); | }); |
#content-step-payment { | #content-step-payment { | ||||
.credit { | .credit { | ||||
margin-top: 20px ; | |||||
.info { | .info { | ||||
margin-left: 20px ; | margin-left: 20px ; | ||||
color: gray ; | color: gray ; | ||||
} | } | ||||
} | } | ||||
.comment { | |||||
margin-bottom: 20px ; | |||||
} | |||||
} | } | ||||
#infos { | #infos { |