'tiller' => $producer->tiller | 'tiller' => $producer->tiller | ||||
]; | ]; | ||||
$json['means_payment'] = MeanPayment::getAll() ; | |||||
$distributionsArray = Distribution::searchAll([ | $distributionsArray = Distribution::searchAll([ | ||||
'active' => 1 | 'active' => 1 | ||||
], [ | ], [ |
* @param string $processCredit | * @param string $processCredit | ||||
*/ | */ | ||||
public function actionAjaxCreate( | public function actionAjaxCreate( | ||||
$date, $idPointSale, $idUser, $username, $products, $comment, $processCredit = 0) | |||||
$date, $idPointSale, $idUser, $username, $meanPayment, $products, $comment, $processCredit = 0) | |||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$order = new Order; | $order = new Order; | ||||
$order->date = date('Y-m-d H:i:s') ; | $order->date = date('Y-m-d H:i:s') ; | ||||
$order->id_point_sale = $idPointSale; | $order->id_point_sale = $idPointSale; | ||||
$order->mean_payment = $meanPayment ; | |||||
$order->id_distribution = $distribution->id; | $order->id_distribution = $distribution->id; | ||||
$order->origin = Order::ORIGIN_ADMIN; | $order->origin = Order::ORIGIN_ADMIN; | ||||
$order->comment = $comment; | $order->comment = $comment; | ||||
* @param string $comment | * @param string $comment | ||||
*/ | */ | ||||
public function actionAjaxUpdate( | public function actionAjaxUpdate( | ||||
$date, $idOrder, $idPointSale, $idUser, $username, $products, $comment = '', $processCredit = 0) | |||||
$date, $idOrder, $idPointSale, $idUser, $username, $meanPayment, $products, $comment = '', $processCredit = 0) | |||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$order->id_point_sale = $idPointSale; | $order->id_point_sale = $idPointSale; | ||||
$order->date_update = date('Y-m-d H:i:s'); | $order->date_update = date('Y-m-d H:i:s'); | ||||
$order->mean_payment = $meanPayment; | |||||
$order->comment = $comment; | $order->comment = $comment; | ||||
if ($idUser) { | if ($idUser) { |
de modification et de redistribution accordés par cette licence, il n'est | de modification et de redistribution accordés par cette licence, il n'est | ||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | ||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | seule une responsabilité restreinte pèse sur l'auteur du programme, le | ||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
titulaire des de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | A cet égard l'attention de l'utilisateur est attirée sur les risques | ||||
associés au chargement, à l'utilisation, à la modification et/ou au | associés au chargement, à l'utilisation, à la modification et/ou au | ||||
:date="date" | :date="date" | ||||
:order="orderCreate" | :order="orderCreate" | ||||
:points-sale="pointsSale" | :points-sale="pointsSale" | ||||
:means-payment="meansPayment" | |||||
:users="users" | :users="users" | ||||
:products="products" | :products="products" | ||||
:producer="producer" | :producer="producer" | ||||
:date="date" | :date="date" | ||||
:id-point-sale="idActivePointSale" | :id-point-sale="idActivePointSale" | ||||
:points-sale="pointsSale" | :points-sale="pointsSale" | ||||
:means-payment="meansPayment" | |||||
:users="users" | :users="users" | ||||
:products="products" | :products="products" | ||||
:order="ordersUpdate[key]" | :order="ordersUpdate[key]" | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<label class="control-label" for="select-id-point-sale">Point de vente</label> | <label class="control-label" for="select-id-point-sale">Point de vente</label> | ||||
<select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale"> | <select class="form-control" id="select-id-point-sale" v-model="order.id_point_sale"> | ||||
<option value="0">--</option> | |||||
<option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id">{{ pointSale.name }}</option> | <option v-for="pointSale in pointsSale" v-if="pointSale.pointSaleDistribution[0].delivery == 1" :value="pointSale.id">{{ pointSale.name }}</option> | ||||
</select> | </select> | ||||
</div> | </div> | ||||
<div class="form-group"> | |||||
<label class="control-label" for="select-mean-payment">Moyen de paiement</label> | |||||
<select class="form-control" id="select-mean-payment" v-model="order.mean_payment"> | |||||
<option value="0">--</option> | |||||
<option v-for="(wordingMeanPayment, keyMeanPayment) in meansPayment" :value="keyMeanPayment">{{ wordingMeanPayment }}</option> | |||||
</select> | |||||
</div> | |||||
<div class="form-group"> | <div class="form-group"> | ||||
<label class="control-label" for="textarea-comment">Commentaire</label> | <label class="control-label" for="textarea-comment">Commentaire</label> | ||||
<textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea> | <textarea class="form-control" id="textarea-comment" v-model="order.comment"></textarea> |
products: [], | products: [], | ||||
countActiveProducts: 0, | countActiveProducts: 0, | ||||
pointsSale: [], | pointsSale: [], | ||||
meansPayment: [], | |||||
idActivePointSale: 0, | idActivePointSale: 0, | ||||
idDefaultPointSale: 0, | idDefaultPointSale: 0, | ||||
countActivePointsSale: 0, | countActivePointsSale: 0, | ||||
app.producer = response.data.producer ; | app.producer = response.data.producer ; | ||||
app.products = response.data.products ; | app.products = response.data.products ; | ||||
app.initCountActiveProducts() ; | app.initCountActiveProducts() ; | ||||
app.meansPayment = response.data.means_payment ; | |||||
app.oneDistributionWeekActive = response.data.one_distribution_week_active ; | app.oneDistributionWeekActive = response.data.one_distribution_week_active ; | ||||
}) | }) | ||||
Vue.component('order-form',{ | Vue.component('order-form',{ | ||||
props: ['date', 'pointsSale', 'users', 'products', 'order', 'producer'], | |||||
props: ['date', 'pointsSale','meansPayment', 'users', 'products', 'order', 'producer'], | |||||
data: function() { | data: function() { | ||||
return { | return { | ||||
errors: [], | errors: [], | ||||
idPointSale: this.order.id_point_sale, | idPointSale: this.order.id_point_sale, | ||||
idUser: this.order.id_user, | idUser: this.order.id_user, | ||||
username: this.order.username, | username: this.order.username, | ||||
meanPayment: this.order.mean_payment, | |||||
products: JSON.stringify(this.order.productOrder), | products: JSON.stringify(this.order.productOrder), | ||||
comment: this.order.comment, | comment: this.order.comment, | ||||
processCredit: processCredit | processCredit: processCredit | ||||
+ ('0' + this.date.getDate()).slice(-2), | + ('0' + this.date.getDate()).slice(-2), | ||||
idOrder: this.order.id, | idOrder: this.order.id, | ||||
idPointSale: this.order.id_point_sale, | idPointSale: this.order.id_point_sale, | ||||
meanPayment: this.order.mean_payment, | |||||
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), |
} | } | ||||
} | } | ||||
/** | |||||
* etourne tous les moyens de paiement sour forme de tableau. | |||||
* | |||||
* @return array | |||||
*/ | |||||
public static function getAll() | |||||
{ | |||||
return [ | |||||
self::CREDIT => self::getStrBy(self::CREDIT), | |||||
self::CREDIT_CARD => self::getStrBy(self::CREDIT_CARD), | |||||
self::MONEY => self::getStrBy(self::MONEY), | |||||
self::CHEQUE => self::getStrBy(self::CHEQUE), | |||||
self::TRANSFER => self::getStrBy(self::TRANSFER), | |||||
self::OTHER => self::getStrBy(self::OTHER), | |||||
self::CREDIT => self::getStrBy(self::CREDIT), | |||||
] ; | |||||
} | |||||
} | } |
} elseif ($this->isTypeDebit()) { | } elseif ($this->isTypeDebit()) { | ||||
$userProducer->credit -= $this->amount; | $userProducer->credit -= $this->amount; | ||||
} | } | ||||
$userProducer->save(); | |||||
// set mean payment | |||||
$order = Order::searchOne(['id' => $this->id_order]) ; | |||||
$paymentStatus = $order->getPaymentStatus() ; | |||||
if($paymentStatus == Order::PAYMENT_PAID | |||||
|| $paymentStatus == Order::PAYMENT_SURPLUS) { | |||||
$order->mean_payment = MeanPayment::CREDIT ; | |||||
$order->save() ; | |||||
} | |||||
// seuil limite de crédit | |||||
$newCredit = $userProducer->credit ; | $newCredit = $userProducer->credit ; | ||||
if(!is_null($creditLimitReminder) && | if(!is_null($creditLimitReminder) && | ||||
$oldCredit > $creditLimitReminder && $newCredit <= $creditLimitReminder) { | $oldCredit > $creditLimitReminder && $newCredit <= $creditLimitReminder) { | ||||
->setSubject('[distrib] Seuil limite de crédit dépassé') | ->setSubject('[distrib] Seuil limite de crédit dépassé') | ||||
->send(); | ->send(); | ||||
} | } | ||||
$userProducer->save(); | |||||
} | } | ||||
} | } | ||||