} | } | ||||
$arrayCreditUser = []; | $arrayCreditUser = []; | ||||
if (isset($order->user) && isset($order->user->userProducer)) { | |||||
if (isset($order->user) && isset($order->user->userProducer) && isset($order->user->userProducer[0])) { | |||||
$arrayCreditUser['credit'] = $order->user->userProducer[0]->credit; | $arrayCreditUser['credit'] = $order->user->userProducer[0]->credit; | ||||
} | } | ||||
0 => 'Non', | 0 => 'Non', | ||||
1 => 'Oui' | 1 => 'Oui' | ||||
], []); ?> | ], []); ?> | ||||
<?= $form->field($model, 'option_allow_order_guest') | |||||
->dropDownList([ | |||||
0 => 'Non', | |||||
1 => 'Oui' | |||||
], []); ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
}], | }], | ||||
[['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status', | [['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status', | ||||
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address', 'behavior_home_point_sale_day_list', 'behavior_order_select_distribution', 'option_payment_info', 'option_order_reference_type'], 'string'], | 'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address', 'behavior_home_point_sale_day_list', 'behavior_order_select_distribution', 'option_payment_info', 'option_order_reference_type'], 'string'], | ||||
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm', 'option_email_confirm_producer', 'option_csv_export_all_products', 'option_csv_export_by_piece', 'option_export_display_product_reference'], 'boolean'], | |||||
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm', 'option_email_confirm_producer', 'option_csv_export_all_products', 'option_csv_export_by_piece', 'option_export_display_product_reference', 'option_allow_order_guest'], 'boolean'], | |||||
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255], | [['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255], | ||||
[['free_price', 'credit_limit_reminder', 'credit_limit'], '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'], | ||||
'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)', | 'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)', | ||||
'option_order_reference_type' => 'Type de référence', | 'option_order_reference_type' => 'Type de référence', | ||||
'option_export_display_product_reference' => 'Afficher la référence des produits au moment de l\'export', | 'option_export_display_product_reference' => 'Afficher la référence des produits au moment de l\'export', | ||||
'option_allow_order_guest' => 'Autoriser les visiteurs à passer commande (création de compte à la fin du tunnel)', | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
class m210318_102840_add_option_allow_order_guest extends Migration | |||||
{ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'option_allow_order_guest', Schema::TYPE_BOOLEAN); | |||||
} | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'option_allow_order_guest'); | |||||
} | |||||
} |
public function __construct() | public function __construct() | ||||
{ | { | ||||
parent::__construct() ; | parent::__construct() ; | ||||
$this->addAsset('js','js/jquery.validate.min.js') ; | |||||
$this->addAsset('js','js/vuejs/order-order.js') ; | $this->addAsset('js','js/vuejs/order-order.js') ; | ||||
} | } | ||||
} | } |
use common\models\Order; | use common\models\Order; | ||||
use common\models\UserPointSale; | use common\models\UserPointSale; | ||||
use common\models\Product; | use common\models\Product; | ||||
use common\models\UserProducer; | |||||
use DateTime; | use DateTime; | ||||
class OrderController extends ProducerBaseController | class OrderController extends ProducerBaseController | ||||
public function behaviors() | public function behaviors() | ||||
{ | { | ||||
return [ | |||||
return []; | |||||
/*return [ | |||||
'access' => [ | 'access' => [ | ||||
'class' => AccessControl::className(), | 'class' => AccessControl::className(), | ||||
'rules' => [ | 'rules' => [ | ||||
] | ] | ||||
], | ], | ||||
], | ], | ||||
]; | |||||
];*/ | |||||
} | } | ||||
public function actionOrder($id = 0, $date = '') | public function actionOrder($id = 0, $date = '') | ||||
{ | { | ||||
$params = []; | $params = []; | ||||
if ($id) { | if ($id) { | ||||
} | } | ||||
if ($order->load($posts)) { | if ($order->load($posts)) { | ||||
$user = User::getCurrent() ; | |||||
$order = Order::find() | $order = Order::find() | ||||
->where('id_distribution = :id_distribution') | ->where('id_distribution = :id_distribution') | ||||
->andWhere('id_user = :id_user') | ->andWhere('id_user = :id_user') | ||||
->params([ | ->params([ | ||||
':id_distribution' => $posts['Order']['id_distribution'], | ':id_distribution' => $posts['Order']['id_distribution'], | ||||
':id_user' => User::getCurrentId() | |||||
':id_user' => $user ? $user->id : null | |||||
]) | ]) | ||||
->one(); | ->one(); | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
// gestion user : option_allow_order_guest | |||||
if(isset($posts['user']) && $posts['user']) { | |||||
$user = User::searchOne([ | |||||
'email' => $posts['user']['email'] | |||||
]) ; | |||||
if(!$user) { | |||||
$user = new User ; | |||||
$user->id_producer = 0; | |||||
$password = Password::generate() ; | |||||
//$password = $posts['user']['password'] ; | |||||
$user->setPassword($password); | |||||
$user->generateAuthKey(); | |||||
$user->username = $posts['user']['email']; | |||||
$user->email = $posts['user']['email']; | |||||
$user->name = $posts['user']['firstname']; | |||||
$user->lastname = $posts['user']['lastname']; | |||||
$user->phone = $posts['user']['phone']; | |||||
$user->save() ; | |||||
// liaison etablissement / user | |||||
$userProducer = new UserProducer(); | |||||
$userProducer->id_user = $user->id; | |||||
$userProducer->id_producer = $idProducer; | |||||
$userProducer->credit = 0; | |||||
$userProducer->active = 1; | |||||
$userProducer->save(); | |||||
$user->sendMailWelcome($password); | |||||
} | |||||
} | |||||
$order = new Order; | $order = new Order; | ||||
$order->load(Yii::$app->request->post()); | $order->load(Yii::$app->request->post()); | ||||
$order->id_user = User::getCurrentId(); | |||||
$order->id_user = $user ? $user->id : null; | |||||
$order->status = 'tmp-order'; | $order->status = 'tmp-order'; | ||||
$order->date = date('Y-m-d H:i:s'); | $order->date = date('Y-m-d H:i:s'); | ||||
$order->origin = Order::ORIGIN_USER; | $order->origin = Order::ORIGIN_USER; | ||||
} | } | ||||
$errors = $this->processForm($order); | |||||
$errors = $this->processForm($order, $user); | |||||
if (count($errors)) { | if (count($errors)) { | ||||
return ['status' => 'error', 'errors' => $errors]; | return ['status' => 'error', 'errors' => $errors]; | ||||
* | * | ||||
* @param Commande $order | * @param Commande $order | ||||
*/ | */ | ||||
public function processForm($order) | |||||
public function processForm($order, $user) | |||||
{ | { | ||||
$posts = Yii::$app->request->post(); | $posts = Yii::$app->request->post(); | ||||
$productsArray = []; | $productsArray = []; | ||||
$userProducer = UserProducer::searchOne([ | $userProducer = UserProducer::searchOne([ | ||||
'id_producer' => $order->distribution->id_producer, | 'id_producer' => $order->distribution->id_producer, | ||||
'id_user' => User::getCurrentId() | |||||
'id_user' => $user->id | |||||
]); | ]); | ||||
// gestion point de vente | // gestion point de vente | ||||
$order->changeOrderStatus('new-order', 'user'); | $order->changeOrderStatus('new-order', 'user'); | ||||
// ajout de l'utilisateur à l'établissement | // ajout de l'utilisateur à l'établissement | ||||
Producer::addUser(User::getCurrentId(), $distribution->id_producer); | |||||
Producer::addUser($user->id, $distribution->id_producer); | |||||
// suppression de tous les enregistrements ProductOrder | // suppression de tous les enregistrements ProductOrder | ||||
if (!is_null($order)) { | if (!is_null($order)) { | ||||
} | } | ||||
// lien utilisateur / point de vente | // lien utilisateur / point de vente | ||||
$pointSale->linkUser(User::getCurrentId()); | |||||
$pointSale->linkUser($user->id); | |||||
// credit | // credit | ||||
$credit = Producer::getConfig('credit'); | $credit = Producer::getConfig('credit'); | ||||
$creditLimit = Producer::getConfig('credit_limit'); | $creditLimit = Producer::getConfig('credit_limit'); | ||||
$creditFunctioning = $pointSale->getCreditFunctioning(); | $creditFunctioning = $pointSale->getCreditFunctioning(); | ||||
$creditUser = Yii::$app->user->identity->getCredit($distribution->id_producer); | |||||
$creditUser = $user->getCredit($distribution->id_producer); | |||||
$order = Order::searchOne([ | $order = Order::searchOne([ | ||||
'id' => $order->id | 'id' => $order->id | ||||
]); | ]); | ||||
$order->changeOrderStatus('waiting-paiement-on-delivery', 'user'); | $order->changeOrderStatus('waiting-paiement-on-delivery', 'user'); | ||||
} | } | ||||
$user = User::getCurrent() ; | |||||
$paramsEmail = [ | $paramsEmail = [ | ||||
'from_email' => $producer->getEmailOpendistrib(), | 'from_email' => $producer->getEmailOpendistrib(), | ||||
'from_name' => $producer->name, | 'from_name' => $producer->name, | ||||
] | ] | ||||
] ; | ] ; | ||||
/* | /* | ||||
* Envoi email de confirmation | * Envoi email de confirmation | ||||
*/ | */ | ||||
'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, | 'use_credit_checked_default' => $producer->use_credit_checked_default, | ||||
'credit_limit' => is_numeric($producer->credit_limit) ? $producer->credit_limit : null | |||||
'credit_limit' => is_numeric($producer->credit_limit) ? $producer->credit_limit : null, | |||||
'option_allow_order_guest' => $producer->option_allow_order_guest, | |||||
]; | ]; | ||||
// Distributions | // Distributions | ||||
$json['distributions'] = $distributionsArray; | $json['distributions'] = $distributionsArray; | ||||
// Commandes de l'utilisateur | // Commandes de l'utilisateur | ||||
$ordersUserArray = Order::searchAll([ | |||||
'id_user' => User::getCurrentId() | |||||
], [ | |||||
'conditions' => [ | |||||
'distribution.date > :date' | |||||
], | |||||
'params' => [ | |||||
':date' => $dateMini | |||||
] | |||||
]); | |||||
$ordersUserArray = [] ; | |||||
if(User::getCurrentId()) { | |||||
$ordersUserArray = Order::searchAll([ | |||||
'id_user' => User::getCurrentId() | |||||
], [ | |||||
'conditions' => [ | |||||
'distribution.date > :date' | |||||
], | |||||
'params' => [ | |||||
':date' => $dateMini | |||||
] | |||||
]); | |||||
} | |||||
if (is_array($ordersUserArray) && count($ordersUserArray)) { | if (is_array($ordersUserArray) && count($ordersUserArray)) { | ||||
foreach ($ordersUserArray as &$order) { | foreach ($ordersUserArray as &$order) { | ||||
$order = array_merge($order->getAttributes(), [ | $order = array_merge($order->getAttributes(), [ | ||||
'id_user' => User::getCurrentId() | 'id_user' => User::getCurrentId() | ||||
]); | ]); | ||||
$json['user'] = [ | |||||
'credit' => $userProducer->credit, | |||||
'credit_active' => $userProducer->credit_active, | |||||
]; | |||||
$json['user'] = false ; | |||||
if($userProducer) { | |||||
$json['user'] = [ | |||||
'credit' => $userProducer->credit, | |||||
'credit_active' => $userProducer->credit_active, | |||||
]; | |||||
} | |||||
if ($dateObject && $dateObject->format($format) === $date) { | if ($dateObject && $dateObject->format($format) === $date) { | ||||
// Commande de l'utilisateur | // Commande de l'utilisateur | ||||
$orderUser = Order::searchOne([ | |||||
'distribution.date' => $date, | |||||
'id_user' => User::getCurrentId(), | |||||
]); | |||||
$orderUser = false ; | |||||
if(User::getCurrentId()) { | |||||
$orderUser = Order::searchOne([ | |||||
'distribution.date' => $date, | |||||
'id_user' => User::getCurrentId(), | |||||
]); | |||||
} | |||||
if ($orderUser) { | if ($orderUser) { | ||||
$json['order'] = array_merge($orderUser->getAttributes(), [ | $json['order'] = array_merge($orderUser->getAttributes(), [ | ||||
} | } | ||||
} | } | ||||
$favoritePointSale = User::getCurrent()->getFavoritePointSale(); | |||||
$favoritePointSale = false ; | |||||
if(User::getCurrent()) { | |||||
$favoritePointSale = User::getCurrent()->getFavoritePointSale(); | |||||
} | |||||
if ($favoritePointSale) { | if ($favoritePointSale) { | ||||
for ($i = 0; $i < count($pointsSaleArray); $i++) { | for ($i = 0; $i < count($pointsSaleArray); $i++) { | ||||
public function actionConfirm($idOrder) | public function actionConfirm($idOrder) | ||||
{ | { | ||||
$order = Order::searchOne(['id' => $idOrder]); | $order = Order::searchOne(['id' => $idOrder]); | ||||
$producer = $this->getProducer() ; | |||||
if (!$order || $order->id_user != User::getCurrentId()) { | |||||
if (!$order || ($order->id_user != User::getCurrentId() && !$producer->option_allow_order_guest)) { | |||||
throw new \yii\base\UserException('Commande introuvable.'); | throw new \yii\base\UserException('Commande introuvable.'); | ||||
} | } | ||||
[ | [ | ||||
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander', | 'label' => '<span class="glyphicon glyphicon-plus"></span> Commander', | ||||
'url' => Yii::$app->urlManager->createUrl(['order/order']), | 'url' => Yii::$app->urlManager->createUrl(['order/order']), | ||||
'visible' => !Yii::$app->user->isGuest, | |||||
'visible' => $producer->option_allow_order_guest || !Yii::$app->user->isGuest, | |||||
'active' => $this->getControllerAction() == 'order/order', | 'active' => $this->getControllerAction() == 'order/order', | ||||
], | ], | ||||
[ | [ | ||||
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander', | 'label' => '<span class="glyphicon glyphicon-plus"></span> Commander', | ||||
'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]), | 'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->context->getProducer()->id, 'return_url' => Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order', 'slug_producer' => $this->context->getProducer()->slug])]), | ||||
'visible' => Yii::$app->user->isGuest, | |||||
'visible' => !$producer->option_allow_order_guest && Yii::$app->user->isGuest, | |||||
'active' => $this->getControllerAction() == 'order/order', | 'active' => $this->getControllerAction() == 'order/order', | ||||
], | ], | ||||
[ | [ |
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
$this->setTitle('Confirmation de commande') ; | $this->setTitle('Confirmation de commande') ; | ||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
?> | ?> | ||||
<div id="order-success"> | <div id="order-success"> | ||||
<span class="glyphicon glyphicon-ok glyphicon-big"></span> | <span class="glyphicon glyphicon-ok glyphicon-big"></span> | ||||
<div class="content"> | <div class="content"> | ||||
<h3>Votre commande a bien été prise en compte</h3> | <h3>Votre commande a bien été prise en compte</h3> | ||||
<a href="<?= Yii::$app->urlManagerProducer->createUrl(['order/history']) ?>" class="btn btn-default"> | |||||
<span class="glyphicon glyphicon-chevron-right"></span> | |||||
Voir toutes mes commandes | |||||
</a> | |||||
<?php if(!Yii::$app->user->isGuest): ?> | |||||
<a href="<?= Yii::$app->urlManagerProducer->createUrl(['order/history']) ?>" class="btn btn-default"> | |||||
<span class="glyphicon glyphicon-chevron-right"></span> | |||||
Voir toutes mes commandes | |||||
</a> | |||||
<?php endif; ?> | |||||
</div> | </div> | ||||
<div class="clr"></div> | <div class="clr"></div> | ||||
</div> | </div> |
</template> | </template> | ||||
<template v-else> | <template v-else> | ||||
<div class="credit"> | <div class="credit"> | ||||
<div v-if="producer.credit == 1 && pointSaleActive.credit == 1 && (pointSaleActive.credit_functioning != 'user' || (pointSaleActive.credit_functioning == 'user' && user.credit_active))"> | |||||
<div v-if="user && 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" 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> | <input type="checkbox" id="use-credit" v-model="useCredit" v-else /> <label for="use-credit">Utiliser mon Crédit ({{ formatPrice(user.credit) }})</label> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div id="signup-guest" v-if="!user && producer.option_allow_order_guest"> | |||||
<h3>Informations personnelles</h3> | |||||
<form action="#"> | |||||
<div class="form-group field-signupguest-email required"> | |||||
<label class="control-label" for="signupguest-email">Email</label> | |||||
<input type="email" id="signupguest-email" class="form-control" name="SignupForm[email]"> | |||||
<p class="help-block help-block-error"></p> | |||||
</div> | |||||
<!--<div class="form-group field-signupguest-password required"> | |||||
<label class="control-label" for="signupguest-password">Mot de passe</label> | |||||
<input type="password" id="signupguest-password" class="form-control" name="SignupForm[password]"> | |||||
<p class="help-block help-block-error"></p> | |||||
</div>--> | |||||
<div class="form-group field-signupguest-firstname required"> | |||||
<label class="control-label" for="signupguest-firstname">Prénom</label> | |||||
<input type="text" id="signupguest-firstname" class="form-control" name="SignupForm[firstname]"> | |||||
<p class="help-block help-block-error"></p> | |||||
</div> | |||||
<div class="form-group field-signupguest-lastname required"> | |||||
<label class="control-label" for="signupguest-lastname">Nom</label> | |||||
<input type="text" id="signupguest-lastname" class="form-control" name="SignupForm[lastname]"> | |||||
<p class="help-block help-block-error"></p> | |||||
</div> | |||||
<div class="form-group field-signupguest-phone required"> | |||||
<label class="control-label" for="signupguest-phone">Téléphone</label> | |||||
<input type="text" id="signupguest-phone" class="form-control" name="SignupForm[phone]"> | |||||
<p class="help-block help-block-error"></p> | |||||
</div> | |||||
</form> | |||||
</div> | |||||
<div class="block-actions"> | <div class="block-actions"> | ||||
<button class="btn btn-primary" disabled="disabled" v-if="disableConfirmButton">Je confirme ma commande</button> | <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> | <button class="btn btn-primary" v-else @click="confirmClick">Je confirme ma commande</button> |
} | } | ||||
}, | }, | ||||
confirmClick: function() { | confirmClick: function() { | ||||
var $signupGuestForm = $('#signup-guest form') ; | |||||
if($signupGuestForm.length > 0 && !$signupGuestForm.valid()) { | |||||
$signupGuestForm.submit() ; | |||||
return false ; | |||||
} | |||||
this.disableConfirmButton = true ; | this.disableConfirmButton = true ; | ||||
var productsArray = {} ; | var productsArray = {} ; | ||||
productsArray[this.products[key].id] = this.products[key].quantity_form ; | productsArray[this.products[key].id] = this.products[key].quantity_form ; | ||||
} | } | ||||
} | } | ||||
var user = false ; | |||||
if(this.producer.option_allow_order_guest && !this.user) { | |||||
user = { | |||||
email: $('#signupguest-email').val(), | |||||
password: $('#signupguest-password').val(), | |||||
firstname: $('#signupguest-firstname').val(), | |||||
lastname: $('#signupguest-lastname').val(), | |||||
phone: $('#signupguest-phone').val(), | |||||
} ; | |||||
} | |||||
axios.post('ajax-process', { | axios.post('ajax-process', { | ||||
Order: { | Order: { | ||||
}, | }, | ||||
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) | |||||
use_credit: Number(this.useCredit), | |||||
user: user | |||||
}).then(function(response) { | }).then(function(response) { | ||||
if(response.data.status == 'success') { | if(response.data.status == 'success') { | ||||
window.location.href = opendistrib_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ; | window.location.href = opendistrib_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ; | ||||
return orderedPointsSaleArray ; | return orderedPointsSaleArray ; | ||||
} | } | ||||
}, | |||||
updated: function () { | |||||
var app = this; | |||||
this.$nextTick(function () { | |||||
if(app.step == 'payment' && !app.user && app.producer.option_allow_order_guest) { | |||||
$("#signup-guest form").validate({ | |||||
rules: { | |||||
'SignupForm[email]': { | |||||
'email': true, | |||||
'required': true, | |||||
'minlength': 8, | |||||
'maxlength': 255 | |||||
}, | |||||
'SignupForm[password]': { | |||||
'required': true, | |||||
'minlength': 8, | |||||
"maxlength": 255 | |||||
}, | |||||
'SignupForm[firstname]': { | |||||
'required': true, | |||||
'minlength': 2, | |||||
"maxlength": 255 | |||||
}, | |||||
'SignupForm[lastname]': { | |||||
'required': true, | |||||
'minlength': 2, | |||||
"maxlength": 255 | |||||
}, | |||||
'SignupForm[phone]': { | |||||
'required': true, | |||||
'minlength': 2, | |||||
"maxlength": 255 | |||||
}, | |||||
}, | |||||
messages: { | |||||
'SignupForm[email]' : { | |||||
'required': 'Ce champs est requis.', | |||||
'email' : 'Email invalide.' | |||||
}, | |||||
'SignupForm[password]' : { | |||||
'required': 'Ce champs est requis.', | |||||
}, | |||||
'SignupForm[firstname]' : { | |||||
'required': 'Ce champs est requis.', | |||||
}, | |||||
'SignupForm[lastname]' : { | |||||
'required': 'Ce champs est requis.', | |||||
}, | |||||
'SignupForm[phone]' : { | |||||
'required': 'Ce champs est requis.', | |||||
}, | |||||
} | |||||
}) ; | |||||
} | |||||
}); | |||||
} | } | ||||
}); | }); |