</span> | </span> | ||||
<span v-else>{{ order.username }}</span> | <span v-else>{{ order.username }}</span> | ||||
<span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span> | <span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span> | ||||
<span v-if="order.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="glyphicon glyphicon-home"></span> | |||||
</td> | </td> | ||||
<td class="column-point-sale" v-if="idActivePointSale == 0"> | <td class="column-point-sale" v-if="idActivePointSale == 0"> | ||||
{{ order.pointSale.name }} | {{ order.pointSale.name }} | ||||
<strong><span class="glyphicon glyphicon-menu-right"></span> Commentaire</strong><br /> | <strong><span class="glyphicon glyphicon-menu-right"></span> Commentaire</strong><br /> | ||||
{{ order.comment }} | {{ order.comment }} | ||||
</div> | </div> | ||||
<div v-if="order.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="delivery"> | |||||
<strong><span class="glyphicon glyphicon-menu-right"></span> Livraison à domicile</strong><br /> | |||||
{{ order.delivery_address }} | |||||
</div> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</template> | </template> |
if($isBig) { | if($isBig) { | ||||
$html .= '<td></td>' ; | $html .= '<td></td>' ; | ||||
} | } | ||||
$html .= '<td>'.$order->comment.'</td>'; | |||||
$html .= '<td>'.$order->getCommentReport().'</td>'; | |||||
if($pointSale->credit) { | if($pointSale->credit) { | ||||
$credit = '' ; | $credit = '' ; |
0 => 'Non', | 0 => 'Non', | ||||
1 => 'Oui' | 1 => 'Oui' | ||||
], []); ?> | ], []); ?> | ||||
<?= $form->field($model, 'option_order_entry_point') | |||||
->dropDownList([ | |||||
Producer::ORDER_ENTRY_POINT_DATE => 'Date', | |||||
Producer::ORDER_ENTRY_POINT_POINT_SALE => 'Point de vente', | |||||
], []); ?> | |||||
<?= $form->field($model, 'option_delivery') | |||||
->dropDownList([ | |||||
0 => 'Non', | |||||
1 => 'Oui' | |||||
], []); ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
.distribution-index #orders table tr.view .comment { | .distribution-index #orders table tr.view .comment { | ||||
margin-top: 20px; | margin-top: 20px; | ||||
} | } | ||||
/* line 309, ../sass/distribution/_index.scss */ | |||||
/* line 304, ../sass/distribution/_index.scss */ | |||||
.distribution-index #orders table tr.view .delivery { | |||||
margin-top: 20px; | |||||
} | |||||
/* line 313, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .modal-container { | .distribution-index .modal-form-order .modal-container { | ||||
width: 100%; | width: 100%; | ||||
padding: 0px; | padding: 0px; | ||||
} | } | ||||
/* line 313, ../sass/distribution/_index.scss */ | |||||
/* line 317, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .modal-container .modal-body { | .distribution-index .modal-form-order .modal-container .modal-body { | ||||
padding-right: 15px; | padding-right: 15px; | ||||
} | } | ||||
/* line 315, ../sass/distribution/_index.scss */ | |||||
/* line 319, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .modal-container .modal-body table { | .distribution-index .modal-form-order .modal-container .modal-body table { | ||||
margin-bottom: 150px; | margin-bottom: 150px; | ||||
} | } | ||||
/* line 320, ../sass/distribution/_index.scss */ | |||||
/* line 324, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .modal-container .modal-footer { | .distribution-index .modal-form-order .modal-container .modal-footer { | ||||
border-top-color: #f4f4f4; | border-top-color: #f4f4f4; | ||||
position: fixed; | position: fixed; | ||||
text-align: center; | text-align: center; | ||||
border-top: solid 1px #e0e0e0; | border-top: solid 1px #e0e0e0; | ||||
} | } | ||||
/* line 332, ../sass/distribution/_index.scss */ | |||||
/* line 336, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form button { | .distribution-index .modal-form-order .modal-container .modal-footer .actions-form button { | ||||
float: none; | float: none; | ||||
} | } | ||||
/* line 339, ../sass/distribution/_index.scss */ | |||||
/* line 343, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .btn-credit { | .distribution-index .modal-form-order .btn-credit { | ||||
float: right; | float: right; | ||||
} | } | ||||
/* line 345, ../sass/distribution/_index.scss */ | |||||
/* line 349, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products .product-ordered td { | .distribution-index .modal-form-order table.table-products .product-ordered td { | ||||
background-color: #e9e9e9; | background-color: #e9e9e9; | ||||
} | } | ||||
/* line 349, ../sass/distribution/_index.scss */ | |||||
/* line 353, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products .product-ordered input { | .distribution-index .modal-form-order table.table-products .product-ordered input { | ||||
font-size: 16px; | font-size: 16px; | ||||
font-weight: bold; | font-weight: bold; | ||||
} | } | ||||
/* line 355, ../sass/distribution/_index.scss */ | |||||
/* line 359, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.price { | .distribution-index .modal-form-order table.table-products td.price { | ||||
width: 150px; | width: 150px; | ||||
} | } | ||||
/* line 357, ../sass/distribution/_index.scss */ | |||||
/* line 361, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.price input { | .distribution-index .modal-form-order table.table-products td.price input { | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 362, ../sass/distribution/_index.scss */ | |||||
/* line 366, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity { | .distribution-index .modal-form-order table.table-products td.quantity { | ||||
width: 165px; | width: 165px; | ||||
} | } | ||||
/* line 365, ../sass/distribution/_index.scss */ | |||||
/* line 369, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity input { | .distribution-index .modal-form-order table.table-products td.quantity input { | ||||
text-align: center; | text-align: center; | ||||
color: black; | color: black; | ||||
} | } | ||||
/* line 370, ../sass/distribution/_index.scss */ | |||||
/* line 374, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity .form-control { | .distribution-index .modal-form-order table.table-products td.quantity .form-control { | ||||
border-right: 0px none; | border-right: 0px none; | ||||
padding-right: 4px; | padding-right: 4px; | ||||
} | } | ||||
/* line 375, ../sass/distribution/_index.scss */ | |||||
/* line 379, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity .input-group-addon { | .distribution-index .modal-form-order table.table-products td.quantity .input-group-addon { | ||||
padding: 5px; | padding: 5px; | ||||
padding-left: 0px; | padding-left: 0px; | ||||
border-left: 0px none; | border-left: 0px none; | ||||
border-right: 0px none; | border-right: 0px none; | ||||
} | } | ||||
/* line 384, ../sass/distribution/_index.scss */ | |||||
/* line 388, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity-remaining { | .distribution-index .modal-form-order table.table-products td.quantity-remaining { | ||||
text-align: right; | text-align: right; | ||||
} | } | ||||
/* line 387, ../sass/distribution/_index.scss */ | |||||
/* line 391, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity-remaining.quantity-remaining, .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite { | .distribution-index .modal-form-order table.table-products td.quantity-remaining.quantity-remaining, .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite { | ||||
color: #00A65A; | color: #00A65A; | ||||
} | } | ||||
/* line 391, ../sass/distribution/_index.scss */ | |||||
/* line 395, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity-remaining.negative { | .distribution-index .modal-form-order table.table-products td.quantity-remaining.negative { | ||||
color: #DD4B39; | color: #DD4B39; | ||||
} | } | ||||
/* line 395, ../sass/distribution/_index.scss */ | |||||
/* line 399, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite, .distribution-index .modal-form-order table.table-products td.quantity-remaining.empty { | .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite, .distribution-index .modal-form-order table.table-products td.quantity-remaining.empty { | ||||
font-size: 18px; | font-size: 18px; | ||||
} | } | ||||
/* line 402, ../sass/distribution/_index.scss */ | |||||
/* line 406, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .actions-form button { | .distribution-index .modal-form-order .actions-form button { | ||||
margin-left: 15px; | margin-left: 15px; | ||||
} | } | ||||
/* line 410, ../sass/distribution/_index.scss */ | |||||
/* line 414, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-payment .info-box .info-box-icon { | .distribution-index .modal-payment .info-box .info-box-icon { | ||||
width: 50px; | width: 50px; | ||||
} | } | ||||
/* line 413, ../sass/distribution/_index.scss */ | |||||
/* line 417, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-payment .info-box .info-box-icon i { | .distribution-index .modal-payment .info-box .info-box-icon i { | ||||
font-size: 30px; | font-size: 30px; | ||||
} | } | ||||
/* line 418, ../sass/distribution/_index.scss */ | |||||
/* line 422, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-payment .info-box .info-box-content { | .distribution-index .modal-payment .info-box .info-box-content { | ||||
margin-left: 50px; | margin-left: 50px; | ||||
} | } |
.comment { | .comment { | ||||
margin-top: 20px; | margin-top: 20px; | ||||
} | } | ||||
.delivery { | |||||
margin-top: 20px; | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
return $this->hasMany(ProductDistribution::className(), ['id_distribution' => 'id']); | return $this->hasMany(ProductDistribution::className(), ['id_distribution' => 'id']); | ||||
} | } | ||||
public function getPointSaleDistribution() | |||||
{ | |||||
return $this->hasMany(PointSaleDistribution::className(), ['id_distribution' => 'id']) ; | |||||
} | |||||
/** | /** | ||||
* Retourne les options de base nécessaires à la fonction de recherche. | * Retourne les options de base nécessaires à la fonction de recherche. | ||||
* | * | ||||
$pointSaleDistribution->save(); | $pointSaleDistribution->save(); | ||||
} | } | ||||
public function isPointSaleActive($distribution, $pointSaleId) | |||||
{ | |||||
$pointSaleActive = false ; | |||||
if($distribution->pointSaleDistribution) { | |||||
foreach($distribution->pointSaleDistribution as $pointSaleDistribution) { | |||||
if($pointSaleDistribution->id_point_sale == $pointSaleId && $pointSaleDistribution->delivery) { | |||||
$pointSaleActive = true ; | |||||
} | |||||
} | |||||
} | |||||
return $pointSaleActive ; | |||||
} | |||||
/** | /** | ||||
* Active ou désactive la distribution. | * Active ou désactive la distribution. | ||||
*/ | */ |
return [ | return [ | ||||
[['id_user', 'date', 'status'], 'required', 'message' => ''], | [['id_user', 'date', 'status'], 'required', 'message' => ''], | ||||
[['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | [['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | ||||
[['auto_payment', 'tiller_synchronization'], 'boolean'], | |||||
[['status', 'reference'], 'string'], | |||||
[['auto_payment', 'tiller_synchronization', 'delivery_home'], 'boolean'], | |||||
[['status', 'reference', 'delivery_address'], 'string'], | |||||
[['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe'] | [['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe'] | ||||
]; | ]; | ||||
} | } | ||||
'id_invoice' => 'Facture', | 'id_invoice' => 'Facture', | ||||
'id_quotation' => 'Devis', | 'id_quotation' => 'Devis', | ||||
'id_delivery_note' => 'Bon de livraison', | 'id_delivery_note' => 'Bon de livraison', | ||||
'reference' => 'Référence' | |||||
'reference' => 'Référence', | |||||
'delivery_home' => 'Livraison à domicile', | |||||
'delivery_address' => 'Adresse de livraison' | |||||
]; | ]; | ||||
} | } | ||||
$this->save() ; | $this->save() ; | ||||
} | } | ||||
} | } | ||||
public function getCommentReport() | |||||
{ | |||||
$comment = '' ; | |||||
$hasComment = false ; | |||||
if($this->comment && strlen($this->comment) > 0) { | |||||
$hasComment = true ; | |||||
$comment .= $this->comment ; | |||||
} | |||||
if($this->delivery_home && $this->delivery_address && strlen($this->delivery_address) > 0) { | |||||
if($hasComment) { | |||||
$comment .= '<br /><br />' ; | |||||
} | |||||
$comment .= '<strong>Livraison à domicile :</strong><br />' ; | |||||
$comment .= nl2br($this->delivery_address) ; | |||||
} | |||||
return $comment ; | |||||
} | |||||
} | } |
const ORDER_REFERENCE_TYPE_NONE = '' ; | const ORDER_REFERENCE_TYPE_NONE = '' ; | ||||
const ORDER_REFERENCE_TYPE_YEARLY = 'yearly' ; | const ORDER_REFERENCE_TYPE_YEARLY = 'yearly' ; | ||||
const ORDER_ENTRY_POINT_DATE = 'date' ; | |||||
const ORDER_ENTRY_POINT_POINT_SALE = 'point-sale' ; | |||||
var $secret_key_payplug; | var $secret_key_payplug; | ||||
/** | /** | ||||
} | } | ||||
}], | }], | ||||
[['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'], | |||||
[['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'], | |||||
'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', 'option_order_entry_point'], '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', 'option_allow_order_guest', 'option_delivery'], '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_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)', | 'option_allow_order_guest' => 'Autoriser les visiteurs à passer commande (création de compte à la fin du tunnel)', | ||||
'option_order_entry_point' => 'Point d\'entrée par point de vente ou par date', | |||||
'option_delivery' => 'Proposer la livraison à domicile' | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
class m210326_104759_add_option_order_entry_point extends Migration | |||||
{ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'option_order_entry_point', Schema::TYPE_STRING.' DEFAULT \''.Producer::ORDER_ENTRY_POINT_DATE.'\''); | |||||
} | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'option_order_entry_point'); | |||||
} | |||||
} |
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
class m210330_072516_add_option_delivery extends Migration | |||||
{ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'option_delivery', Schema::TYPE_BOOLEAN. ' DEFAULT 0'); | |||||
$this->addColumn('order', 'delivery_home', Schema::TYPE_BOOLEAN.' DEFAULT 0'); | |||||
$this->addColumn('order', 'delivery_address', Schema::TYPE_TEXT); | |||||
} | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'option_delivery'); | |||||
$this->dropColumn('order', 'delivery_home'); | |||||
$this->dropColumn('order', 'delivery_address'); | |||||
} | |||||
} | |||||
'id' => $order->id_point_sale | 'id' => $order->id_point_sale | ||||
]); | ]); | ||||
// commentaire point de vente | |||||
$order->comment_point_sale = ($pointSale && strlen($pointSale->getComment())) ? | $order->comment_point_sale = ($pointSale && strlen($pointSale->getComment())) ? | ||||
$pointSale->getComment() : ''; | $pointSale->getComment() : ''; | ||||
// la commande est automatiquement réactivée lors d'une modification | // la commande est automatiquement réactivée lors d'une modification | ||||
$order->date_delete = null; | $order->date_delete = null; | ||||
// delivery | |||||
$order->delivery_home = isset($posts['Order']['delivery_home']) ? $posts['Order']['delivery_home'] : false ; | |||||
$order->delivery_address = (isset($posts['Order']['delivery_address']) && $order->delivery_home) ? $posts['Order']['delivery_address'] : null ; | |||||
// comment | |||||
$order->comment = isset($posts['Order']['comment']) ? $posts['Order']['comment'] : null ; | |||||
// sauvegarde de la commande | // sauvegarde de la commande | ||||
$order->save(); | $order->save(); | ||||
$format = 'Y-m-d'; | $format = 'Y-m-d'; | ||||
$dateObject = DateTime::createFromFormat($format, $date); | $dateObject = DateTime::createFromFormat($format, $date); | ||||
$user = User::getCurrent() ; | |||||
// PointSale current | // PointSale current | ||||
$pointSaleCurrent = PointSale::findOne($pointSaleId) ; | $pointSaleCurrent = PointSale::findOne($pointSaleId) ; | ||||
'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, | 'option_allow_order_guest' => $producer->option_allow_order_guest, | ||||
'option_order_entry_point' => $producer->option_order_entry_point, | |||||
'option_delivery' => $producer->option_delivery | |||||
]; | ]; | ||||
// Distributions | // Distributions | ||||
], [ | ], [ | ||||
'conditions' => ['date > :date'], | 'conditions' => ['date > :date'], | ||||
'params' => [':date' => $dateMini], | 'params' => [':date' => $dateMini], | ||||
'join_with' => ['pointSaleDistribution'], | |||||
]); | ]); | ||||
$distributionsArray = Distribution::filterDistributionsByDateDelay($distributionsArray) ; | $distributionsArray = Distribution::filterDistributionsByDateDelay($distributionsArray) ; | ||||
$json['distributions'] = $distributionsArray; | |||||
// Filtre par point de vente | |||||
if($pointSaleId && $producer->option_order_entry_point == Producer::ORDER_ENTRY_POINT_POINT_SALE) { | |||||
$distributionsArrayFilterPointSale = [] ; | |||||
for($i = 0; $i < count($distributionsArray) ; $i++) { | |||||
$distribution = $distributionsArray[$i] ; | |||||
if(Distribution::isPointSaleActive($distribution, $pointSaleId)) { | |||||
$distributionsArrayFilterPointSale[] = $distribution ; | |||||
} | |||||
} | |||||
$json['distributions'] = $distributionsArrayFilterPointSale; | |||||
} | |||||
else { | |||||
$json['distributions'] = $distributionsArray; | |||||
} | |||||
// Commandes de l'utilisateur | // Commandes de l'utilisateur | ||||
$ordersUserArray = [] ; | $ordersUserArray = [] ; | ||||
if(User::getCurrentId()) { | if(User::getCurrentId()) { | ||||
$conditionsOrdersUser = [ | |||||
'distribution.date > :date' | |||||
] ; | |||||
$paramsOrdersUser = [ | |||||
':date' => $dateMini | |||||
] ; | |||||
if($pointSaleId && $producer->option_order_entry_point == Producer::ORDER_ENTRY_POINT_POINT_SALE) { | |||||
$conditionsOrdersUser[] = 'order.id_point_sale = :id_point_sale' ; | |||||
$paramsOrdersUser[':id_point_sale'] = $pointSaleId ; | |||||
} | |||||
$ordersUserArray = Order::searchAll([ | $ordersUserArray = Order::searchAll([ | ||||
'id_user' => User::getCurrentId() | 'id_user' => User::getCurrentId() | ||||
], [ | ], [ | ||||
'conditions' => [ | |||||
'distribution.date > :date' | |||||
], | |||||
'params' => [ | |||||
':date' => $dateMini | |||||
] | |||||
'conditions' => $conditionsOrdersUser, | |||||
'params' => $paramsOrdersUser | |||||
]); | ]); | ||||
} | } | ||||
if($userProducer) { | if($userProducer) { | ||||
$json['user'] = [ | $json['user'] = [ | ||||
'address' => $user->address, | |||||
'credit' => $userProducer->credit, | 'credit' => $userProducer->credit, | ||||
'credit_active' => $userProducer->credit_active, | 'credit_active' => $userProducer->credit_active, | ||||
]; | ]; | ||||
// Commande de l'utilisateur | // Commande de l'utilisateur | ||||
$orderUser = false ; | $orderUser = false ; | ||||
if(User::getCurrentId()) { | if(User::getCurrentId()) { | ||||
$orderUser = Order::searchOne([ | |||||
$conditionOrderUser = [ | |||||
'distribution.date' => $date, | 'distribution.date' => $date, | ||||
'id_user' => User::getCurrentId(), | 'id_user' => User::getCurrentId(), | ||||
]); | |||||
] ; | |||||
if($pointSaleId) { | |||||
$conditionOrderUser['id_point_sale'] = $pointSaleId ; | |||||
} | |||||
$orderUser = Order::searchOne($conditionOrderUser); | |||||
} | } | ||||
if ($orderUser) { | if ($orderUser) { | ||||
$distribution = Distribution::initDistribution($date); | $distribution = Distribution::initDistribution($date); | ||||
$json['distribution'] = $distribution; | $json['distribution'] = $distribution; | ||||
$pointsSaleArray = PointSale::find() | |||||
->joinWith(['pointSaleDistribution' => function ($query) use ($distribution) { | |||||
$query->where(['id_distribution' => $distribution->id]); | |||||
} | |||||
]) | |||||
->with(['userPointSale' => function ($query) { | |||||
$query->onCondition(['id_user' => User::getCurrentId()]); | |||||
}]) | |||||
->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(); | |||||
$creditFunctioningProducer = Producer::getConfig('credit_functioning'); | |||||
foreach ($pointsSaleArray as &$pointSale) { | |||||
$pointSale = array_merge($pointSale->getAttributes(), [ | |||||
'pointSaleDistribution' => [ | |||||
'id_distribution' => $pointSale->pointSaleDistribution[0]->id_distribution, | |||||
'id_point_sale' => $pointSale->pointSaleDistribution[0]->id_point_sale, | |||||
'delivery' => $pointSale->pointSaleDistribution[0]->delivery | |||||
], | |||||
'userPointSale' => ($pointSale->userPointSale ? $pointSale->userPointSale[0] : '') | |||||
]); | |||||
if ($pointSale['code'] && strlen($pointSale['code'])) { | |||||
$pointSale['code'] = '***'; | |||||
} | |||||
if (!strlen($pointSale['credit_functioning'])) { | |||||
$pointSale['credit_functioning'] = $creditFunctioningProducer; | |||||
} | |||||
} | |||||
$favoritePointSale = false ; | |||||
if(User::getCurrent()) { | |||||
$favoritePointSale = User::getCurrent()->getFavoritePointSale(); | |||||
} | |||||
if ($favoritePointSale) { | |||||
for ($i = 0; $i < count($pointsSaleArray); $i++) { | |||||
if ($pointsSaleArray[$i]['id'] == $favoritePointSale->id) { | |||||
$theFavoritePointSale = $pointsSaleArray[$i]; | |||||
unset($pointsSaleArray[$i]); | |||||
} | |||||
} | |||||
if (isset($theFavoritePointSale)) { | |||||
$pointsSaleArray = array_reverse($pointsSaleArray, false); | |||||
$pointsSaleArray[] = $theFavoritePointSale; | |||||
$pointsSaleArray = array_reverse($pointsSaleArray, false); | |||||
} | |||||
} | |||||
$json['points_sale'] = $pointsSaleArray; | |||||
// Points de vente | |||||
$json['points_sale'] = $this->_initPointsSale($producer->id, $distribution); | |||||
// Commandes totales | // Commandes totales | ||||
$ordersArray = Order::searchAll([ | $ordersArray = Order::searchAll([ | ||||
// Catégories | // Catégories | ||||
$categoriesArray = ProductCategory::searchAll([], ['orderby' => 'product_category.position ASC', 'as_array' => true]) ; | $categoriesArray = ProductCategory::searchAll([], ['orderby' => 'product_category.position ASC', 'as_array' => true]) ; | ||||
array_unshift($categoriesArray, ['id' => null, 'name' => 'Catégorie par défaut']) ; | |||||
$countProductsWithoutCategories = Product::searchCount([ | |||||
'id_producer' => $this->getProducer()->id, | |||||
'product.active' => 1, | |||||
'product.id_product_category' => null | |||||
]); | |||||
if($countProductsWithoutCategories) { | |||||
array_unshift($categoriesArray, ['id' => null, 'name' => 'Catégorie par défaut']) ; | |||||
} | |||||
$json['categories'] = $categoriesArray ; | $json['categories'] = $categoriesArray ; | ||||
// Produits | // Produits | ||||
$json['products'] = $productsArray; | $json['products'] = $productsArray; | ||||
} | } | ||||
else { | |||||
$json['points_sale'] = $this->_initPointsSale($producer->id) ; | |||||
} | |||||
return $json; | return $json; | ||||
} | } | ||||
private function _initPointsSale($idProducer, $distribution = false) | |||||
{ | |||||
$pointsSaleArray = PointSale::find() ; | |||||
if($distribution) { | |||||
$pointsSaleArray = $pointsSaleArray->joinWith(['pointSaleDistribution' => function ($query) use ($distribution) { | |||||
$query->where(['id_distribution' => $distribution->id]); | |||||
} | |||||
]) ; | |||||
} | |||||
if(User::getCurrentId()) { | |||||
$pointsSaleArray = $pointsSaleArray->with(['userPointSale' => function ($query) { | |||||
$query->onCondition(['id_user' => User::getCurrentId()]); | |||||
}]) ; | |||||
} | |||||
$pointsSaleArray = $pointsSaleArray->where(['id_producer' => $idProducer]) | |||||
->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(); | |||||
$creditFunctioningProducer = Producer::getConfig('credit_functioning'); | |||||
foreach ($pointsSaleArray as &$pointSale) { | |||||
$pointSale = array_merge($pointSale->getAttributes(), [ | |||||
'pointSaleDistribution' => [ | |||||
'id_distribution' => $pointSale->pointSaleDistribution ? $pointSale->pointSaleDistribution[0]->id_distribution : false, | |||||
'id_point_sale' => $pointSale->pointSaleDistribution ? $pointSale->pointSaleDistribution[0]->id_point_sale : false, | |||||
'delivery' => $pointSale->pointSaleDistribution ? $pointSale->pointSaleDistribution[0]->delivery : false, | |||||
], | |||||
'userPointSale' => ($pointSale->userPointSale ? $pointSale->userPointSale[0] : '') | |||||
]); | |||||
if ($pointSale['code'] && strlen($pointSale['code'])) { | |||||
$pointSale['code'] = '***'; | |||||
} | |||||
if (!strlen($pointSale['credit_functioning'])) { | |||||
$pointSale['credit_functioning'] = $creditFunctioningProducer; | |||||
} | |||||
} | |||||
$favoritePointSale = false ; | |||||
if(User::getCurrent()) { | |||||
$favoritePointSale = User::getCurrent()->getFavoritePointSale(); | |||||
} | |||||
if ($favoritePointSale) { | |||||
for ($i = 0; $i < count($pointsSaleArray); $i++) { | |||||
if ($pointsSaleArray[$i]['id'] == $favoritePointSale->id) { | |||||
$theFavoritePointSale = $pointsSaleArray[$i]; | |||||
unset($pointsSaleArray[$i]); | |||||
} | |||||
} | |||||
if (isset($theFavoritePointSale)) { | |||||
$pointsSaleArray = array_reverse($pointsSaleArray, false); | |||||
$pointsSaleArray[] = $theFavoritePointSale; | |||||
$pointsSaleArray = array_reverse($pointsSaleArray, false); | |||||
} | |||||
} | |||||
return $pointsSaleArray ; | |||||
} | |||||
public function actionConfirm($idOrder) | public function actionConfirm($idOrder) | ||||
{ | { | ||||
$order = Order::searchOne(['id' => $idOrder]); | $order = Order::searchOne(['id' => $idOrder]); |
<ul> | <ul> | ||||
<?php if($order->reference && strlen($order->reference) > 0): ?><li><span class="glyphicon glyphicon-check"></span> Commande N°<strong><?= Html::encode($order->reference); ?></strong></li><?php endif; ?> | <?php if($order->reference && strlen($order->reference) > 0): ?><li><span class="glyphicon glyphicon-check"></span> Commande N°<strong><?= Html::encode($order->reference); ?></strong></li><?php endif; ?> | ||||
<li><span class="glyphicon glyphicon-time"></span>Le <?= date('d/m/Y',strtotime($order->distribution->date)) ?></li> | <li><span class="glyphicon glyphicon-time"></span>Le <?= date('d/m/Y',strtotime($order->distribution->date)) ?></li> | ||||
<li><span class="glyphicon glyphicon-map-marker"></span><?= Html::encode($order->pointSale->name) ?><?php if(strlen($order->pointSale->name)): ?> | |||||
<br /> <span class="locality">à <?= Html::encode($order->pointSale->locality) ?></span><?php endif; ?></li> | |||||
<li><span class="glyphicon glyphicon-map-marker"></span> | |||||
<?php if($order->delivery_home): ?> | |||||
Livraison à domicile | |||||
<br /><span class="locality"><?= nl2br(Html::encode($order->delivery_address)); ?></span> | |||||
<?php else: ?> | |||||
<?= Html::encode($order->pointSale->name) ?><?php if(strlen($order->pointSale->name)): ?> | |||||
<br /> <span class="locality">à <?= Html::encode($order->pointSale->locality) ?></span><?php endif; ?></li> | |||||
<?php endif; ?> | |||||
</ul> | </ul> | ||||
</div> | </div> | ||||
<div class="col-md-6"> | <div class="col-md-6"> |
?> | ?> | ||||
<script> | |||||
var appInitValues = { | |||||
}; | |||||
</script> | |||||
<div id="app-order-order" :class="{'loaded': !loadingInit}"> | <div id="app-order-order" :class="{'loaded': !loadingInit}"> | ||||
<?php if(isset($order)): ?> | <?php if(isset($order)): ?> | ||||
<span id="order-distribution-date"><?= $order->distribution->date; ?></span> | <span id="order-distribution-date"><?= $order->distribution->date; ?></span> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div> | <div> | ||||
<div id="steps"> | <div id="steps"> | ||||
<ul> | <ul> | ||||
<li id="step-date" :class="'col-md-3 '+((step == 'date') ? 'active' : '')"> | |||||
<button @click="changeStep('date')" :class="'btn '+ (step == 'date' ? 'btn-primary' : 'btn-default')"> | |||||
<span class="button-content"><span class="glyphicon glyphicon-time"></span> Date</span></span> | |||||
</button> | |||||
<div class="info-step" v-if="dateFormat"> | |||||
{{ dateFormat }} | |||||
</div> | |||||
</li> | |||||
<li id="step-point-sale" :class="'col-md-3 '+((step == 'point-sale') ? 'active ' : '')"> | |||||
<button @click="changeStep('point-sale')" :class="'btn '+ (step == 'point-sale' ? 'btn-primary' : 'btn-default')" :disabled="step == 'date'"> | |||||
<span class="button-content"><span class="glyphicon glyphicon-map-marker"></span> Points de vente</span> | |||||
</button> | |||||
<div class="info-step" v-if="pointSaleActive"> | |||||
{{ pointSaleActive.name }} | |||||
</div> | |||||
</li> | |||||
<?php if($producer->option_order_entry_point == Producer::ORDER_ENTRY_POINT_DATE): ?> | |||||
<step-date | |||||
first="true" | |||||
:step="step" | |||||
:point-sale-active="pointSaleActive" | |||||
:date-format="dateFormat" | |||||
:change-step="changeStep" | |||||
:producer="producer" | |||||
></step-date> | |||||
<step-point-sale | |||||
:step="step" | |||||
:point-sale-active="pointSaleActive" | |||||
:change-step="changeStep" | |||||
:producer="producer" | |||||
></step-point-sale> | |||||
<?php else: ?> | |||||
<step-point-sale | |||||
first="true" | |||||
:step="step" | |||||
:point-sale-active="pointSaleActive" | |||||
:change-step="changeStep" | |||||
:producer="producer" | |||||
></step-point-sale> | |||||
<step-date | |||||
:step="step" | |||||
:point-sale-active="pointSaleActive" | |||||
:date-format="dateFormat" | |||||
:change-step="changeStep" | |||||
:producer="producer" | |||||
></step-date> | |||||
<?php endif; ?> | |||||
<li id="step-products" :class="'col-md-3 '+((step == 'products') ? 'active ' : '')"> | <li id="step-products" :class="'col-md-3 '+((step == 'products') ? 'active ' : '')"> | ||||
<button @click="changeStep('products')" :class="'btn '+ (step == 'products' ? 'btn-primary' : 'btn-default')" :disabled="step == 'date' || step == 'point-sale'"> | <button @click="changeStep('products')" :class="'btn '+ (step == 'products' ? 'btn-primary' : 'btn-default')" :disabled="step == 'date' || step == 'point-sale'"> | ||||
<span class="button-content"><span class="glyphicon glyphicon-th-list"></span> Produits</span> | <span class="button-content"><span class="glyphicon glyphicon-th-list"></span> Produits</span> | ||||
</li> | </li> | ||||
</ul> | </ul> | ||||
</div> | </div> | ||||
<div v-if="loading && !step"> | |||||
Chargement ... | |||||
</div> | |||||
<transition name="slide"> | <transition name="slide"> | ||||
<div id="content-step-date" v-if="step == 'date'"> | <div id="content-step-date" v-if="step == 'date'"> | ||||
<div v-if="loading"> | |||||
Chargement ... | |||||
</div> | |||||
<div v-else> | |||||
<?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?> | <?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?> | ||||
<div style="display:none ;"> | <div style="display:none ;"> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</div> | </div> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | |||||
</div> | </div> | ||||
</transition> | </transition> | ||||
<transition name="slide"> | <transition name="slide"> | ||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<tr v-for="pointSale in orderedPointsSale" v-if="pointSale && pointSale.pointSaleDistribution.delivery" :class="(pointSaleActive && pointSale.id == pointSaleActive.id) ? 'selected' : ''"> | |||||
<tr v-for="pointSale in orderedPointsSale" v-if="pointSale && (producer.option_order_entry_point == 'point-sale' || (producer.option_order_entry_point == 'date' && pointSale.pointSaleDistribution.delivery))" :class="(pointSaleActive && pointSale.id == pointSaleActive.id) ? 'selected' : ''"> | |||||
<td class="name"> | <td class="name"> | ||||
<span class="the-name">{{ pointSale.name }}</span> | <span class="the-name">{{ pointSale.name }}</span> | ||||
<div class="comment" v-if="pointSale.userPointSale"> | <div class="comment" v-if="pointSale.userPointSale"> | ||||
</transition> | </transition> | ||||
<transition name="slide"> | <transition name="slide"> | ||||
<div id="content-step-products" v-if="step == 'products'"> | <div id="content-step-products" v-if="step == 'products'"> | ||||
<div v-if="products.length"> | |||||
<table id="products" class="table table-bordered" > | |||||
<thead> | |||||
<tr> | |||||
<th>Photo</th> | |||||
<th>Nom</th> | |||||
<th>Prix unitaire</th> | |||||
<th>Quantité</th> | |||||
<th>Total</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<template v-for="category in categories"> | |||||
<tr v-if="category.id && countProductsByCategory(category)"> | |||||
<td class="category-name" colspan="5">{{ category.name }}</td> | |||||
<div v-if="loading"> | |||||
Chargement ... | |||||
</div> | |||||
<div v-else> | |||||
<div v-if="products.length"> | |||||
<table id="products" class="table table-bordered" > | |||||
<thead> | |||||
<tr> | |||||
<th>Photo</th> | |||||
<th>Nom</th> | |||||
<th>Prix unitaire</th> | |||||
<th>Quantité</th> | |||||
<th>Total</th> | |||||
</tr> | </tr> | ||||
<tr v-for="product in products" v-if="product.id_product_category == category.id && product.productDistribution && product.productDistribution[0] && product.productDistribution[0].active == 1"> | |||||
<td class="photo"> | |||||
<img v-if="product.photo.length" class="photo-product" :src="'<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/uploads/'+product.photo" /> | |||||
</td> | |||||
<td class="name"> | |||||
<span class="name">{{ product.name }}</span> | |||||
<span class="other"> | |||||
<span v-if="product.description.length">/</span> | |||||
<span class="description">{{ product.description }}</span> | |||||
<span v-if="product.weight">({{ product.weight }} g)</span> | |||||
</span> | |||||
<span v-if="product.quantity_max > 0 && ((product.quantity_form / product.coefficient_unit == product.quantity_remaining) || ((product.quantity_remaining * product.coefficient_unit) - product.quantity_form) < product.step)" class="label label-danger"> | |||||
Épuisé | |||||
</span> | |||||
<div class="recipe" v-if="product.recipe.length">{{ product.recipe }}</div> | |||||
</td> | |||||
<td class="price-unit"> | |||||
<template v-if="product.price_with_tax > 0">{{ formatPrice(product.price_with_tax) }}<br /><span class="unit">{{ product.wording_unit }}</span></template> | |||||
</td> | |||||
<td class="td-quantity"> | |||||
<template v-if="product.price_with_tax > 0"> | |||||
<div class="input-group"> | |||||
<span class="input-group-btn"> | |||||
<button class="btn btn-default btn-moins" type="button" @click="productQuantityClick(product, product.unit == 'piece' ? -1 : -parseFloat(product.step))" :disabled="product.quantity_form == 0"><span class="glyphicon glyphicon-minus"></span></button> | |||||
</span> | |||||
<input type="text" v-model="product.quantity_form" class="form-control quantity" readonly="readonly" /> | |||||
<span class="input-group-addon">{{ product.unit == 'piece' ? 'p.' : product.unit }}</span> | |||||
<span class="input-group-btn"> | |||||
<button class="btn btn-default btn-plus" type="button" @click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))" :disabled="product.quantity_form == product.quantity_remaining && product.quantity_max > 0"><span class="glyphicon glyphicon-plus"></span></button> | |||||
</span> | |||||
</div> | |||||
</template> | |||||
</td> | |||||
<td class="price-total"> | |||||
<template v-if="product.price_with_tax > 0 && product.quantity_form > 0"> | |||||
</thead> | |||||
<tbody> | |||||
<template v-for="category in categories"> | |||||
<tr v-if="category.id && countProductsByCategory(category)"> | |||||
<td class="category-name" colspan="5" @click="setCategoryCurrent(category)"> | |||||
<span v-if="categoryCurrent && categoryCurrent.id == category.id" class="glyphicon glyphicon-triangle-bottom"></span> | |||||
<span v-else class="glyphicon glyphicon-triangle-right"></span> | |||||
{{ category.name }} | |||||
<span class="label label-default">{{ countProductsByCategory(category) }} produit<template v-if="countProductsByCategory(category) > 1">s</template></span> | |||||
<span v-if="countSelectedProductsByCategory(category) > 0" class="label label-success">{{ countSelectedProductsByCategory(category) }} produit<template v-if="countSelectedProductsByCategory(category) > 1">s</template> sélectionné<template v-if="countSelectedProductsByCategory(category) > 1">s</template></span> | |||||
</td> | |||||
</tr> | |||||
<template v-if="(categoryCurrent && categoryCurrent.id == category.id) || category.id == null"> | |||||
<tr v-for="product in products" v-if="product.id_product_category == category.id && product.productDistribution && product.productDistribution[0] && product.productDistribution[0].active == 1"> | |||||
<td class="photo"> | |||||
<img v-if="product.photo.length" class="photo-product" :src="'<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/uploads/'+product.photo" /> | |||||
</td> | |||||
<td class="name"> | |||||
<span class="name">{{ product.name }}</span> | |||||
<span class="other"> | |||||
<span v-if="product.description.length">/</span> | |||||
<span class="description">{{ product.description }}</span> | |||||
<span v-if="product.weight">({{ product.weight }} g)</span> | |||||
</span> | |||||
<span v-if="product.quantity_max > 0 && ((product.quantity_form / product.coefficient_unit == product.quantity_remaining) || ((product.quantity_remaining * product.coefficient_unit) - product.quantity_form) < product.step)" class="label label-danger"> | |||||
Épuisé | |||||
</span> | |||||
<div class="recipe" v-if="product.recipe.length">{{ product.recipe }}</div> | |||||
</td> | |||||
<td class="price-unit"> | |||||
<template v-if="product.price_with_tax > 0">{{ formatPrice(product.price_with_tax) }}<br /><span class="unit">{{ product.wording_unit }}</span></template> | |||||
</td> | |||||
<td class="td-quantity"> | |||||
<template v-if="product.price_with_tax > 0"> | |||||
<div class="input-group"> | |||||
<span class="input-group-btn"> | |||||
<button class="btn btn-default btn-moins" type="button" @click="productQuantityClick(product, product.unit == 'piece' ? -1 : -parseFloat(product.step))" :disabled="product.quantity_form == 0"><span class="glyphicon glyphicon-minus"></span></button> | |||||
</span> | |||||
<input type="text" v-model="product.quantity_form" class="form-control quantity" readonly="readonly" /> | |||||
<span class="input-group-addon">{{ product.unit == 'piece' ? 'p.' : product.unit }}</span> | |||||
<span class="input-group-btn"> | |||||
<button class="btn btn-default btn-plus" type="button" @click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))" :disabled="product.quantity_form == product.quantity_remaining && product.quantity_max > 0"><span class="glyphicon glyphicon-plus"></span></button> | |||||
</span> | |||||
</div> | |||||
</template> | |||||
</td> | |||||
<td class="price-total"> | |||||
<template v-if="product.price_with_tax > 0 && product.quantity_form > 0"> | |||||
{{ formatPrice(product.price_with_tax * (product.quantity_form / product.coefficient_unit )) }} | {{ formatPrice(product.price_with_tax * (product.quantity_form / product.coefficient_unit )) }} | ||||
</template> | |||||
</template> | |||||
</td> | |||||
</tr> | |||||
</template> | |||||
</template> | |||||
<tr class="total"> | |||||
<td class="summary" colspan="4"> | |||||
<template v-if="priceTotal() > 0"> | |||||
<h3>> Résumé</h3> | |||||
<ul> | |||||
<li v-for="product in products" v-if="product.quantity_form > 0"> | |||||
<span class="quantity">{{ product.quantity_form }} {{ product.unit == 'piece' ? 'p.' : product.unit }} x</span> | |||||
<span class="name">{{ product.name }}</span> | |||||
<span class="other"> | |||||
<span v-if="product.description.length">/</span> | |||||
<span class="description">{{ product.description }}</span> | |||||
<span v-if="product.weight">({{ product.weight }} g)</span> | |||||
</li> | |||||
</ul> | |||||
</template> | |||||
</td> | </td> | ||||
<td class="price-total">{{ priceTotal(true) }}</td> | |||||
</tr> | </tr> | ||||
</template> | |||||
<tr class="total"> | |||||
<td colspan="4"></td> | |||||
<td class="price-total">{{ priceTotal(true) }}</td> | |||||
</tr> | |||||
</tbody> | |||||
</table> | |||||
<div class="block-actions"> | |||||
<button class="btn btn-primary" @click="changeStep('payment')">Valider</button> | |||||
</tbody> | |||||
</table> | |||||
<div class="block-actions"> | |||||
<button class="btn btn-primary" @click="changeStep('payment')">Valider</button> | |||||
</div> | |||||
</div> | |||||
<div class="alert alert-warning" v-else> | |||||
Aucun produit disponible | |||||
</div> | </div> | ||||
</div> | |||||
<div class="alert alert-warning" v-else> | |||||
Aucun produit disponible | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</transition> | </transition> | ||||
<transition name="slide"> | <transition name="slide"> | ||||
<div id="content-step-payment" v-if="step == 'payment'"> | <div id="content-step-payment" v-if="step == 'payment'"> | ||||
<div class="delivery"> | |||||
<div class="delivery-home" v-if="producer.option_delivery"> | |||||
<input type="checkbox" name="delivery" id="delivery" v-model="delivery" /> | |||||
<label for="delivery">Je souhaite être livré à domicile</label> | |||||
</div> | |||||
<div class="delivery-address" v-if="delivery"> | |||||
<label for="deliver-address">Adresse de livraison</label> | |||||
<textarea id="deliver-address" v-model="deliveryAddress" class="form-control" required="required"></textarea> | |||||
</div> | |||||
</div> | |||||
<div class="comment"> | <div class="comment"> | ||||
<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> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
</div> | |||||
</div> | |||||
<script type="text/x-template" id="template-step-date"> | |||||
<li id="step-date" :class="'col-md-3'+((step == 'date') ? ' active' : '')+(first ? ' first' : '')"> | |||||
<button @click="changeStep('date')" :class="'btn '+ (step == 'date' ? 'btn-primary' : 'btn-default')" :disabled="producer && producer.option_order_entry_point == 'point-sale' && !pointSaleActive"> | |||||
<span class="button-content"><span class="glyphicon glyphicon-time"></span> Date</span></span> | |||||
</button> | |||||
<div class="info-step" v-if="dateFormat"> | |||||
{{ dateFormat }} | |||||
</div> | |||||
</li> | |||||
</script> | |||||
<script type="text/x-template" id="template-step-point-sale"> | |||||
<li id="step-point-sale" :class="'col-md-3'+((step == 'point-sale') ? ' active ' : '')+(first ? ' first' : '')"> | |||||
<button @click="changeStep('point-sale')" :class="'btn '+ (step == 'point-sale' ? 'btn-primary' : 'btn-default')" :disabled="producer && (producer.option_order_entry_point == 'date' && step == 'date')"> | |||||
<span class="button-content"><span class="glyphicon glyphicon-map-marker"></span> Points de vente</span> | |||||
</button> | |||||
<div class="info-step" v-if="pointSaleActive"> | |||||
{{ pointSaleActive.name }} | |||||
</div> | |||||
</li> | |||||
</script> |
top: 10px; | top: 10px; | ||||
} | } | ||||
/* line 61, ../sass/order/_order.scss */ | /* line 61, ../sass/order/_order.scss */ | ||||
.order-order #main #app-order-order #steps ul li#step-date { | |||||
.order-order #main #app-order-order #steps ul li.first { | |||||
padding-left: 0px; | padding-left: 0px; | ||||
} | } | ||||
/* line 65, ../sass/order/_order.scss */ | /* line 65, ../sass/order/_order.scss */ | ||||
padding-right: 0px; | padding-right: 0px; | ||||
} | } | ||||
/* line 69, ../sass/order/_order.scss */ | /* line 69, ../sass/order/_order.scss */ | ||||
.order-order #main #app-order-order #steps ul li#step-payment .btn::after, .order-order #main #app-order-order #steps ul li#step-date .btn::before { | |||||
.order-order #main #app-order-order #steps ul li#step-payment .btn::after, .order-order #main #app-order-order #steps ul li.first .btn::before { | |||||
display: none; | display: none; | ||||
} | } | ||||
/* line 74, ../sass/order/_order.scss */ | /* line 74, ../sass/order/_order.scss */ | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
padding-top: 13px; | padding-top: 13px; | ||||
} | } | ||||
/* line 233, ../sass/order/_order.scss */ | |||||
/* line 230, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products td.category-name .glyphicon-triangle-bottom, | |||||
.order-order #main #app-order-order table#products td.category-name .glyphicon-triangle-right { | |||||
font-size: 15px; | |||||
} | |||||
/* line 235, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products td.category-name span.label { | |||||
font-family: "Arial"; | |||||
font-weight: normal; | |||||
float: right; | |||||
text-transform: none; | |||||
margin-left: 15px; | |||||
} | |||||
/* line 244, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products td.category-name:hover { | |||||
cursor: pointer; | |||||
background-color: #FF7F00; | |||||
color: white; | |||||
} | |||||
/* line 252, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products td.photo img { | .order-order #main #app-order-order table#products td.photo img { | ||||
width: 100px; | width: 100px; | ||||
} | } | ||||
/* line 239, ../sass/order/_order.scss */ | |||||
/* line 258, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products td.name .name { | .order-order #main #app-order-order table#products td.name .name { | ||||
font-family: "capsuularegular"; | font-family: "capsuularegular"; | ||||
color: black; | color: black; | ||||
font-size: 20px; | font-size: 20px; | ||||
line-height: 25px; | line-height: 25px; | ||||
} | } | ||||
/* line 245, ../sass/order/_order.scss */ | |||||
/* line 264, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products td.name .other { | .order-order #main #app-order-order table#products td.name .other { | ||||
font-size: 14px; | font-size: 14px; | ||||
color: #333; | color: #333; | ||||
} | } | ||||
/* line 249, ../sass/order/_order.scss */ | |||||
/* line 268, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products td.name .recipe { | .order-order #main #app-order-order table#products td.name .recipe { | ||||
color: gray; | color: gray; | ||||
} | } | ||||
/* line 253, ../sass/order/_order.scss */ | |||||
/* line 272, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products .price-unit, .order-order #main #app-order-order table#products .price-total { | .order-order #main #app-order-order table#products .price-unit, .order-order #main #app-order-order table#products .price-total { | ||||
width: 100px; | width: 100px; | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 257, ../sass/order/_order.scss */ | |||||
/* line 276, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products .price-unit .unit, .order-order #main #app-order-order table#products .price-total .unit { | .order-order #main #app-order-order table#products .price-unit .unit, .order-order #main #app-order-order table#products .price-total .unit { | ||||
color: gray; | color: gray; | ||||
font-size: 13px; | font-size: 13px; | ||||
} | } | ||||
/* line 262, ../sass/order/_order.scss */ | |||||
/* line 281, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products .td-quantity { | .order-order #main #app-order-order table#products .td-quantity { | ||||
width: 175px; | width: 175px; | ||||
} | } | ||||
/* line 264, ../sass/order/_order.scss */ | |||||
/* line 283, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products .td-quantity input.quantity { | .order-order #main #app-order-order table#products .td-quantity input.quantity { | ||||
text-align: center; | text-align: center; | ||||
border-right: 0px none; | border-right: 0px none; | ||||
} | } | ||||
/* line 268, ../sass/order/_order.scss */ | |||||
/* line 287, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products .td-quantity .input-group-addon { | .order-order #main #app-order-order table#products .td-quantity .input-group-addon { | ||||
padding: 5px; | padding: 5px; | ||||
padding-left: 0px; | padding-left: 0px; | ||||
border-left: 0px none; | border-left: 0px none; | ||||
border-right: 0px none; | border-right: 0px none; | ||||
} | } | ||||
/* line 278, ../sass/order/_order.scss */ | |||||
/* line 298, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products tr.total .summary h3 { | |||||
margin-top: 0px; | |||||
font-family: "capsuularegular"; | |||||
text-transform: none; | |||||
margin-bottom: 5px; | |||||
} | |||||
/* line 305, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products tr.total .summary ul { | |||||
margin-bottom: 15px; | |||||
padding-left: 20px; | |||||
font-size: 23px; | |||||
} | |||||
/* line 312, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products tr.total .summary ul li .quantity { | |||||
font-size: 18px; | |||||
} | |||||
/* line 316, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products tr.total .summary ul li .name { | |||||
font-family: "capsuularegular"; | |||||
font-size: 24px; | |||||
} | |||||
/* line 320, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products tr.total .summary ul li .other { | |||||
font-family: "arial"; | |||||
font-size: 14px; | |||||
} | |||||
/* line 327, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order table#products tr.total .price-total { | .order-order #main #app-order-order table#products tr.total .price-total { | ||||
font-size: 23px; | font-size: 23px; | ||||
} | } | ||||
/* line 286, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .credit .info { | |||||
margin-left: 20px; | |||||
color: gray; | |||||
/* line 335, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .delivery { | |||||
margin-bottom: 20px; | |||||
} | |||||
/* line 338, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .delivery .delivery-home { | |||||
margin-bottom: 20px; | |||||
} | } | ||||
/* line 292, ../sass/order/_order.scss */ | |||||
/* line 347, ../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 303, ../sass/order/_order.scss */ | |||||
/* line 352, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #content-step-payment .credit .info { | |||||
margin-left: 20px; | |||||
color: gray; | |||||
} | |||||
/* line 365, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #infos { | .order-order #main #app-order-order #infos { | ||||
margin-top: 30px; | margin-top: 30px; | ||||
} | } | ||||
/* line 305, ../sass/order/_order.scss */ | |||||
/* line 367, ../sass/order/_order.scss */ | |||||
.order-order #main #app-order-order #infos .panel-body { | .order-order #main #app-order-order #infos .panel-body { | ||||
padding-top: 0px; | padding-top: 0px; | ||||
white-space: pre-line; | white-space: pre-line; | ||||
} | } | ||||
/* line 315, ../sass/order/_order.scss */ | |||||
/* line 377, ../sass/order/_order.scss */ | |||||
#main #content .panel h3 { | #main #content .panel h3 { | ||||
font-family: "highvoltageregular"; | font-family: "highvoltageregular"; | ||||
margin: 0px; | margin: 0px; |
var app = new Vue({ | var app = new Vue({ | ||||
el: '#app-order-order', | el: '#app-order-order', | ||||
data: { | |||||
loading: false, | |||||
loadingInit: true, | |||||
step: 'date', | |||||
producer: null, | |||||
user: null, | |||||
date: null, | |||||
dateFormat: null, | |||||
distributions: [], | |||||
distribution: null, | |||||
pointsSale: [], | |||||
pointSaleActive: null, | |||||
pointsSaleCodes: [], | |||||
products: [], | |||||
categories: [], | |||||
comment: '', | |||||
creditCheckbox: false, | |||||
useCredit: false, | |||||
errors: [], | |||||
disableConfirmButton: false, | |||||
calendar: { | |||||
mode: 'single', | |||||
attrs: [], | |||||
availableDates: [], | |||||
themeStyles: { | |||||
wrapper: { | |||||
background: '#F7F7F7', | |||||
color: '#333', | |||||
border: 'solid 1px #e0e0e0' | |||||
}, | |||||
header: { | |||||
padding: '10px 10px', | |||||
}, | |||||
headerHorizontalDivider: { | |||||
borderTop: 'solid rgba(255, 255, 255, 0.2) 1px', | |||||
width: '80%', | |||||
}, | |||||
weekdays: { | |||||
color: 'gray', | |||||
fontWeight: '600', | |||||
padding: '10px 10px', | |||||
fontSize: '2rem' | |||||
}, | |||||
weeks: { | |||||
padding: '0 15px 15px 15px', | |||||
}, | |||||
dayContent: function(object) { | |||||
var style = { | |||||
fontSize: '1.5rem', | |||||
padding: '20px', | |||||
}; | |||||
return style ; | |||||
data() { | |||||
return Object.assign({ | |||||
loading: false, | |||||
loadingInit: true, | |||||
step: null, | |||||
producer: null, | |||||
user: null, | |||||
date: null, | |||||
dateFormat: null, | |||||
distributions: [], | |||||
distribution: null, | |||||
pointsSale: [], | |||||
pointSaleActive: null, | |||||
pointsSaleCodes: [], | |||||
products: [], | |||||
categories: [], | |||||
categoryCurrent: null, | |||||
comment: '', | |||||
creditCheckbox: false, | |||||
useCredit: false, | |||||
errors: [], | |||||
disableConfirmButton: false, | |||||
delivery: false, | |||||
deliveryAddress: null, | |||||
calendar: { | |||||
mode: 'single', | |||||
attrs: [], | |||||
availableDates: [], | |||||
themeStyles: { | |||||
wrapper: { | |||||
background: '#F7F7F7', | |||||
color: '#333', | |||||
border: 'solid 1px #e0e0e0' | |||||
}, | |||||
header: { | |||||
padding: '10px 10px', | |||||
}, | |||||
headerHorizontalDivider: { | |||||
borderTop: 'solid rgba(255, 255, 255, 0.2) 1px', | |||||
width: '80%', | |||||
}, | |||||
weekdays: { | |||||
color: 'gray', | |||||
fontWeight: '600', | |||||
padding: '10px 10px', | |||||
fontSize: '2rem' | |||||
}, | |||||
weeks: { | |||||
padding: '0 15px 15px 15px', | |||||
}, | |||||
dayContent: function (object) { | |||||
var style = { | |||||
fontSize: '1.5rem', | |||||
padding: '20px', | |||||
}; | |||||
return style; | |||||
}, | |||||
}, | }, | ||||
}, | |||||
formats: { | |||||
dayPopover: 'DD/MM/YYYY' | |||||
formats: { | |||||
dayPopover: 'DD/MM/YYYY' | |||||
} | |||||
} | } | ||||
}, | |||||
}, window.appInitValues); | |||||
}, | }, | ||||
mounted: function() { | |||||
mounted: function() { | |||||
if($('#order-distribution-date').size() || $('#distribution-date').size()) { | if($('#order-distribution-date').size() || $('#distribution-date').size()) { | ||||
if($('#order-distribution-date').size()) { | if($('#order-distribution-date').size()) { | ||||
this.date = new Date($('#order-distribution-date').html()) ; | this.date = new Date($('#order-distribution-date').html()) ; | ||||
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' | this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' | ||||
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/' | + ('0' + (this.date.getMonth() +1)).slice(-2) + '/' | ||||
+ this.date.getFullYear() ; | + this.date.getFullYear() ; | ||||
this.changeStep('point-sale') ; | |||||
if(this.producer.option_order_entry_point == 'date') { | |||||
this.changeStep('point-sale') ; | |||||
} | |||||
} | } | ||||
this.init() ; | |||||
this.init('first') ; | |||||
this.loadingInit = false ; | this.loadingInit = false ; | ||||
}, | }, | ||||
methods: { | methods: { | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
init: function(updateOnlyProducts) { | |||||
init: function(type, oldStep, step) { | |||||
var app = this ; | var app = this ; | ||||
this.loading = true ; | this.loading = true ; | ||||
if(app.isChangeState('date', 'date', 'point-sale')) { | |||||
app.pointSaleActive = null ; | |||||
app.products = [] ; | |||||
} | |||||
axios.get("ajax-infos",{params: { | axios.get("ajax-infos",{params: { | ||||
date : this.getDate(), | date : this.getDate(), | ||||
pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0 | pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0 | ||||
}}) | }}) | ||||
.then(function(response) { | .then(function(response) { | ||||
if(!updateOnlyProducts) { | |||||
app.producer = response.data.producer; | |||||
app.user = response.data.user; | |||||
app.useCredit = response.data.producer.use_credit_checked_default; | |||||
app.calendar.attrs = []; | |||||
app.calendar.availableDates = []; | |||||
var distributions = response.data.distributions; | |||||
if (distributions.length) { | |||||
app.distributions = distributions; | |||||
var arrayDate; | |||||
for (var i = 0; i < distributions.length; i++) { | |||||
// distributions | |||||
var distributions = response.data.distributions; | |||||
app.calendar.attrs = []; | |||||
app.calendar.availableDates = []; | |||||
if (distributions.length) { | |||||
app.distributions = distributions; | |||||
var arrayDate; | |||||
for (var i = 0; i < distributions.length; i++) { | |||||
app.calendar.attrs.push({ | |||||
highlight: { | |||||
backgroundColor: '#5cb85c', | |||||
}, | |||||
contentStyle: { | |||||
color: 'white', | |||||
}, | |||||
dates: distributions[i].date, | |||||
}); | |||||
arrayDate = distributions[i].date.split('-'); | |||||
app.calendar.availableDates.push({ | |||||
start: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]), | |||||
end: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]) | |||||
}); | |||||
} | |||||
} | |||||
// distribution | |||||
if (response.data.distribution) { | |||||
app.distribution = response.data.distribution; | |||||
} | |||||
// liste commandes | |||||
var orders = []; | |||||
if (response.data.orders) { | |||||
orders = response.data.orders; | |||||
} | |||||
if (orders.length) { | |||||
for (var i = 0; i < orders.length; i++) { | |||||
arrayDate = orders[i].date_distribution.split('-'); | |||||
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]); | |||||
if (app.isAvailableDate(dateOrder)) { | |||||
app.calendar.attrs.push({ | app.calendar.attrs.push({ | ||||
highlight: { | highlight: { | ||||
backgroundColor: '#5cb85c', | |||||
backgroundColor: '#FF7F00' | |||||
}, | }, | ||||
contentStyle: { | contentStyle: { | ||||
color: 'white', | |||||
color: 'white' | |||||
}, | }, | ||||
dates: distributions[i].date, | |||||
}); | |||||
arrayDate = distributions[i].date.split('-'); | |||||
app.calendar.availableDates.push({ | |||||
start: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]), | |||||
end: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]) | |||||
popover: { | |||||
label: orders[i].pointSale.name + ' / ' + app.formatPrice(orders[i].amount_total), | |||||
hideIndicator: true | |||||
}, | |||||
dates: orders[i].date_distribution, | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
var orders = []; | |||||
if (response.data.orders) { | |||||
orders = response.data.orders; | |||||
} | |||||
} | |||||
if (orders.length) { | |||||
for (var i = 0; i < orders.length; i++) { | |||||
arrayDate = orders[i].date_distribution.split('-'); | |||||
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]); | |||||
if (app.isAvailableDate(dateOrder)) { | |||||
app.calendar.attrs.push({ | |||||
highlight: { | |||||
backgroundColor: '#FF7F00' | |||||
}, | |||||
contentStyle: { | |||||
color: 'white' | |||||
}, | |||||
popover: { | |||||
label: orders[i].pointSale.name + ' / ' + app.formatPrice(orders[i].amount_total), | |||||
hideIndicator: true | |||||
}, | |||||
dates: orders[i].date_distribution, | |||||
}); | |||||
} | |||||
} | |||||
} | |||||
// catégories | |||||
if(response.data.categories) { | |||||
app.categories = response.data.categories ; | |||||
app.setCategoryCurrent(response.data.categories[0]) ; | |||||
} | |||||
if (response.data.distribution) { | |||||
app.distribution = response.data.distribution; | |||||
} | |||||
// producer | |||||
app.producer = response.data.producer; | |||||
if (response.data.points_sale) { | |||||
app.pointsSale = []; | |||||
var orderPointSale = 0; | |||||
for (var key in response.data.points_sale) { | |||||
response.data.points_sale[key].order = orderPointSale++; | |||||
app.pointsSale[response.data.points_sale[key].id] = response.data.points_sale[key]; | |||||
app.pointsSaleCodes[response.data.points_sale[key].id] = ''; | |||||
Vue.set(app.pointsSaleCodes, response.data.points_sale[key].id, ''); | |||||
} | |||||
// user | |||||
app.user = response.data.user; | |||||
// use credit | |||||
app.useCredit = response.data.producer.use_credit_checked_default; | |||||
// points de vente | |||||
if (response.data.points_sale) { | |||||
app.pointsSale = []; | |||||
var orderPointSale = 0; | |||||
for (var key in response.data.points_sale) { | |||||
response.data.points_sale[key].order = orderPointSale++; | |||||
app.pointsSale[response.data.points_sale[key].id] = response.data.points_sale[key]; | |||||
app.pointsSaleCodes[response.data.points_sale[key].id] = ''; | |||||
Vue.set(app.pointsSaleCodes, response.data.points_sale[key].id, ''); | |||||
} | } | ||||
} | } | ||||
if(response.data.products) { | |||||
app.products = response.data.products ; | |||||
if(app.isChangeState('point-sale', 'point-sale', 'date')) { | |||||
app.date = null ; | |||||
app.dateFormat = null ; | |||||
} | } | ||||
if(response.data.categories) { | |||||
app.categories = response.data.categories ; | |||||
// update order | |||||
var updateOrder = false ; | |||||
if(app.isChangeState('date', 'point-sale', 'products') | |||||
|| app.isChangeState('date', 'date', 'point-sale') | |||||
|| app.isChangeState('point-sale', 'date', 'products') | |||||
|| app.isChangeState('point-sale', 'point-sale', 'date')) { | |||||
updateOrder = true ; | |||||
} | } | ||||
if(!updateOnlyProducts) { | |||||
if(updateOrder) { | |||||
// products | |||||
if(response.data.products) { | |||||
app.products = response.data.products ; | |||||
} | |||||
// order | |||||
app.order = null ; | app.order = null ; | ||||
if(response.data.order) { | if(response.data.order) { | ||||
app.order = response.data.order ; | app.order = response.data.order ; | ||||
app.comment = app.order.comment ; | |||||
app.delivery = app.order.delivery_home ; | |||||
if(app.order.delivery_address && app.order.delivery_address.length > 0) { | |||||
app.deliveryAddress = app.order.delivery_address ; | |||||
} | |||||
app.pointSaleActive = app.getPointSale(response.data.order.id_point_sale) ; | app.pointSaleActive = app.getPointSale(response.data.order.id_point_sale) ; | ||||
} | } | ||||
else { | else { | ||||
app.pointSaleActive = null ; | |||||
app.comment = null ; | |||||
app.delivery = false ; | |||||
app.deliveryAddress = null ; | |||||
if(app.user.address.length > 0) { | |||||
app.deliveryAddress = app.user.address ; | |||||
} | |||||
} | |||||
} | |||||
if(type == 'first') { | |||||
if(app.producer.option_order_entry_point == 'point-sale') { | |||||
app.step = 'point-sale' ; | |||||
} | |||||
else { | |||||
app.step = 'date' ; | |||||
} | } | ||||
} | } | ||||
app.loading = false ; | app.loading = false ; | ||||
}); | }); | ||||
}, | }, | ||||
isChangeState: function(entryPoint, oldStep, newStep) { | |||||
return this.producer | |||||
&& entryPoint == this.producer.option_order_entry_point | |||||
&& oldStep == this.oldStep | |||||
&& newStep == this.step ; | |||||
}, | |||||
nextStep: function() { | |||||
this.errors = [] ; | |||||
var oldStep = this.step ; | |||||
var nextStep = null ; | |||||
// par point de vente | |||||
if(this.producer && this.producer.option_order_entry_point == 'point-sale') { | |||||
if(oldStep == 'point-sale') { | |||||
nextStep = 'date' ; | |||||
} | |||||
else if(oldStep == 'date') { | |||||
nextStep = 'products' ; | |||||
} | |||||
} | |||||
// par date | |||||
else { | |||||
if(oldStep == 'date') { | |||||
nextStep = 'point-sale' ; | |||||
} | |||||
else if(oldStep == 'point-sale') { | |||||
nextStep = 'products' ; | |||||
} | |||||
} | |||||
if(nextStep) { | |||||
this.changeStep(nextStep) ; | |||||
} | |||||
}, | |||||
changeStep: function(step) { | changeStep: function(step) { | ||||
this.errors = [] ; | this.errors = [] ; | ||||
var oldStep = this.step ; | var oldStep = this.step ; | ||||
this.oldStep = oldStep ; | |||||
if(oldStep == 'products' && step == 'payment') { | if(oldStep == 'products' && step == 'payment') { | ||||
this.checkProducts() ; | this.checkProducts() ; | ||||
if(!this.errors.length) { | if(!this.errors.length) { | ||||
this.step = step ; | this.step = step ; | ||||
window.scroll(0, $('#page-title').position().top - 25) ; | window.scroll(0, $('#page-title').position().top - 25) ; | ||||
if(oldStep == 'date' && step == 'point-sale') { | |||||
this.init() ; | |||||
} | |||||
this.init('basic', oldStep, step) ; | |||||
} | } | ||||
}, | }, | ||||
dayClickList: function(event) { | dayClickList: function(event) { | ||||
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' | this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' | ||||
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/' | + ('0' + (this.date.getMonth() +1)).slice(-2) + '/' | ||||
+ this.date.getFullYear() ; | + this.date.getFullYear() ; | ||||
this.changeStep('point-sale') ; | |||||
this.nextStep() ; | |||||
}, | }, | ||||
isAvailableDate: function(date) { | isAvailableDate: function(date) { | ||||
for(var key in this.calendar.availableDates) { | for(var key in this.calendar.availableDates) { | ||||
else { | else { | ||||
this.validatePointSale(idPointSale) ; | this.validatePointSale(idPointSale) ; | ||||
} | } | ||||
app.init(true) ; | |||||
}, | }, | ||||
validatePointSale: function(idPointSale) { | validatePointSale: function(idPointSale) { | ||||
if(this.pointSaleActive.credit_functioning == 'mandatory' || (this.pointSaleActive.credit_functioning == 'user' && this.user.credit_active)) { | if(this.pointSaleActive.credit_functioning == 'mandatory' || (this.pointSaleActive.credit_functioning == 'user' && this.user.credit_active)) { | ||||
this.useCredit = true ; | this.useCredit = true ; | ||||
} | } | ||||
this.changeStep('products') ; | |||||
this.nextStep() ; | |||||
}, | }, | ||||
productQuantityClick: function(product, quantity) { | productQuantityClick: function(product, quantity) { | ||||
if( this.products[product.index].quantity_form + quantity >= 0 && | if( this.products[product.index].quantity_form + quantity >= 0 && | ||||
confirmClick: function() { | confirmClick: function() { | ||||
var app = this ; | var app = this ; | ||||
// delivery | |||||
if(app.delivery && !app.deliveryAddress) { | |||||
this.errors = [] ; | |||||
this.errors.push('Veuillez saisir une adresse de livraison') ; | |||||
return false ; | |||||
} | |||||
// guest form | |||||
var $signupGuestForm = $('#signup-guest form') ; | var $signupGuestForm = $('#signup-guest form') ; | ||||
if($signupGuestForm.length > 0 && !$signupGuestForm.valid()) { | if($signupGuestForm.length > 0 && !$signupGuestForm.valid()) { | ||||
$signupGuestForm.submit() ; | $signupGuestForm.submit() ; | ||||
return false ; | return false ; | ||||
} | } | ||||
app.disableConfirmButton = true ; | |||||
var productsArray = {} ; | |||||
for(var key in this.products) { | |||||
if( this.products[key].quantity_form != null && | |||||
this.products[key].quantity_form > 0) { | |||||
productsArray[this.products[key].id] = this.products[key].quantity_form ; | |||||
} | |||||
} | |||||
var user = false ; | var user = false ; | ||||
if(this.producer.option_allow_order_guest && !this.user) { | if(this.producer.option_allow_order_guest && !this.user) { | ||||
user = { | user = { | ||||
phone: $('#signupguest-phone').val(), | phone: $('#signupguest-phone').val(), | ||||
} ; | } ; | ||||
} | } | ||||
// products | |||||
var productsArray = {} ; | |||||
for(var key in this.products) { | |||||
if( this.products[key].quantity_form != null && | |||||
this.products[key].quantity_form > 0) { | |||||
productsArray[this.products[key].id] = this.products[key].quantity_form ; | |||||
} | |||||
} | |||||
app.disableConfirmButton = true ; | |||||
axios.post('ajax-process', { | axios.post('ajax-process', { | ||||
Order: { | Order: { | ||||
id_distribution : this.distribution.id, | id_distribution : this.distribution.id, | ||||
id_point_sale: this.pointSaleActive.id, | id_point_sale: this.pointSaleActive.id, | ||||
comment: this.comment | |||||
comment: this.comment, | |||||
delivery_home: this.delivery, | |||||
delivery_address: this.deliveryAddress | |||||
}, | }, | ||||
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id], | ||||
products: productsArray, | products: productsArray, | ||||
} | } | ||||
} | } | ||||
return count ; | return count ; | ||||
}, | |||||
countSelectedProductsByCategory: function(category) { | |||||
var count = 0 ; | |||||
for(var key in this.products) { | |||||
if(this.products[key].quantity_form > 0 && this.products[key].id_product_category == category.id) { | |||||
count ++ ; | |||||
} | |||||
} | |||||
return count ; | |||||
}, | |||||
setCategoryCurrent: function(category) { | |||||
if(this.categoryCurrent && this.categoryCurrent.id == category.id) { | |||||
this.categoryCurrent = null ; | |||||
} | |||||
else { | |||||
this.categoryCurrent = category ; | |||||
} | |||||
} | } | ||||
}, | }, | ||||
computed : { | computed : { | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
}); | |||||
}); | |||||
Vue.component('step-date',{ | |||||
props: [ | |||||
'step', | |||||
'pointSaleActive', | |||||
'dateFormat', | |||||
'changeStep', | |||||
'producer', | |||||
'first', | |||||
], | |||||
data: function() { | |||||
return { | |||||
} ; | |||||
}, | |||||
template: '#template-step-date', | |||||
methods: { | |||||
} | |||||
}) ; | |||||
Vue.component('step-point-sale',{ | |||||
props: [ | |||||
'step', | |||||
'pointSaleActive', | |||||
'changeStep', | |||||
'producer', | |||||
'first', | |||||
], | |||||
data: function() { | |||||
return { | |||||
} ; | |||||
}, | |||||
template: '#template-step-point-sale', | |||||
methods: { | |||||
} | |||||
}) ; |
position: relative ; | position: relative ; | ||||
top: 10px ; | top: 10px ; | ||||
} | } | ||||
&#step-date { | |||||
&.first { | |||||
padding-left: 0px ; | padding-left: 0px ; | ||||
} | } | ||||
} | } | ||||
&#step-payment .btn::after, | &#step-payment .btn::after, | ||||
&#step-date .btn::before { | |||||
&.first .btn::before { | |||||
display: none ; | display: none ; | ||||
} | } | ||||
table#products { | table#products { | ||||
td.category-name { | td.category-name { | ||||
//font-family: "capsuularegular" ; | |||||
font-family: "highvoltageregular" ; | font-family: "highvoltageregular" ; | ||||
font-size: 22px ; | font-size: 22px ; | ||||
line-height: 30px; | line-height: 30px; | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
padding-top: 13px ; | padding-top: 13px ; | ||||
.glyphicon-triangle-bottom, | |||||
.glyphicon-triangle-right { | |||||
font-size: 15px ; | |||||
} | |||||
span.label { | |||||
//font-family: 'capsuularegular' ; | |||||
font-family: 'Arial' ; | |||||
font-weight: normal ; | |||||
float: right ; | |||||
text-transform: none ; | |||||
margin-left: 15px ; | |||||
} | |||||
&:hover { | |||||
cursor: pointer ; | |||||
background-color: $color1 ; | |||||
color: white ; | |||||
} | |||||
} | } | ||||
td.photo { | td.photo { | ||||
} | } | ||||
tr.total { | tr.total { | ||||
.summary { | |||||
h3 { | |||||
margin-top: 0px ; | |||||
font-family: 'capsuularegular' ; | |||||
text-transform: none ; | |||||
margin-bottom: 5px ; | |||||
} | |||||
ul { | |||||
margin-bottom: 15px ; | |||||
padding-left: 20px ; | |||||
font-size: 23px ; | |||||
li { | |||||
.quantity { | |||||
font-size: 18px ; | |||||
} | |||||
.name { | |||||
font-family: 'capsuularegular' ; | |||||
font-size: 24px ; | |||||
} | |||||
.other { | |||||
font-family: 'arial' ; | |||||
font-size: 14px ; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
.price-total { | .price-total { | ||||
font-size: 23px ; | font-size: 23px ; | ||||
} | } | ||||
} | } | ||||
#content-step-payment { | #content-step-payment { | ||||
.delivery { | |||||
margin-bottom: 20px ; | |||||
.delivery-home { | |||||
margin-bottom: 20px ; | |||||
} | |||||
.delivery-address { | |||||
} | |||||
} | |||||
.comment { | |||||
margin-bottom: 20px ; | |||||
} | |||||
.credit { | .credit { | ||||
.info { | .info { | ||||
margin-left: 20px ; | margin-left: 20px ; | ||||
color: gray ; | color: gray ; | ||||
} | } | ||||
} | } | ||||
.comment { | |||||
margin-bottom: 20px ; | |||||
} | |||||
} | } | ||||
#specific-delays { | #specific-delays { |