Procházet zdrojové kódy

Merge branch 'dev'

master
Guillaume před 3 roky
rodič
revize
87f93c3a1b
16 změnil soubory, kde provedl 913 přidání a 349 odebrání
  1. +6
    -0
      backend/views/distribution/index.php
  2. +1
    -1
      backend/views/distribution/report.php
  3. +12
    -0
      backend/views/producer/update.php
  4. +26
    -22
      backend/web/css/screen.css
  5. +4
    -0
      backend/web/sass/distribution/_index.scss
  6. +20
    -0
      common/models/Distribution.php
  7. +27
    -3
      common/models/Order.php
  8. +7
    -2
      common/models/Producer.php
  9. +18
    -0
      console/migrations/m210326_104759_add_option_order_entry_point.php
  10. +24
    -0
      console/migrations/m210330_072516_add_option_delivery.php
  11. +130
    -63
      producer/controllers/OrderController.php
  12. +8
    -3
      producer/views/order/confirm.php
  13. +172
    -81
      producer/views/order/order.php
  14. +74
    -20
      producer/web/css/screen.css
  15. +314
    -146
      producer/web/js/vuejs/order-order.js
  16. +70
    -8
      producer/web/sass/order/_order.scss

+ 6
- 0
backend/views/distribution/index.php Zobrazit soubor

@@ -328,6 +328,7 @@ $this->setPageTitle('Distributions') ;
</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.delivery_home && order.delivery_address && order.delivery_address.length > 0" class="glyphicon glyphicon-home"></span>
</td>
<td class="column-point-sale" v-if="idActivePointSale == 0">
{{ order.pointSale.name }}
@@ -515,6 +516,11 @@ $this->setPageTitle('Distributions') ;
<strong><span class="glyphicon glyphicon-menu-right"></span> Commentaire</strong><br />
{{ order.comment }}
</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>
</tr>
</template>

+ 1
- 1
backend/views/distribution/report.php Zobrazit soubor

@@ -109,7 +109,7 @@ foreach ($pointsSaleArray as $pointSale) {
if($isBig) {
$html .= '<td></td>' ;
}
$html .= '<td>'.$order->comment.'</td>';
$html .= '<td>'.$order->getCommentReport().'</td>';
if($pointSale->credit) {
$credit = '' ;

+ 12
- 0
backend/views/producer/update.php Zobrazit soubor

@@ -289,6 +289,18 @@ $this->addBreadcrumb($this->getTitle()) ;
0 => 'Non',
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>


+ 26
- 22
backend/web/css/screen.css Zobrazit soubor

@@ -2102,20 +2102,24 @@ termes.
.distribution-index #orders table tr.view .comment {
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 {
width: 100%;
padding: 0px;
}
/* line 313, ../sass/distribution/_index.scss */
/* line 317, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body {
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 {
margin-bottom: 150px;
}
/* line 320, ../sass/distribution/_index.scss */
/* line 324, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer {
border-top-color: #f4f4f4;
position: fixed;
@@ -2127,46 +2131,46 @@ termes.
text-align: center;
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 {
float: none;
}
/* line 339, ../sass/distribution/_index.scss */
/* line 343, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .btn-credit {
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 {
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 {
font-size: 16px;
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 {
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 {
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 {
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 {
text-align: center;
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 {
border-right: 0px none;
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 {
padding: 5px;
padding-left: 0px;
@@ -2174,35 +2178,35 @@ termes.
border-left: 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 {
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 {
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 {
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 {
font-size: 18px;
}
/* line 402, ../sass/distribution/_index.scss */
/* line 406, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button {
margin-left: 15px;
}
/* line 410, ../sass/distribution/_index.scss */
/* line 414, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon {
width: 50px;
}
/* line 413, ../sass/distribution/_index.scss */
/* line 417, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px;
}
/* line 418, ../sass/distribution/_index.scss */
/* line 422, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px;
}

+ 4
- 0
backend/web/sass/distribution/_index.scss Zobrazit soubor

@@ -300,6 +300,10 @@ termes.
.comment {
margin-top: 20px;
}

.delivery {
margin-top: 20px;
}
}
}
}

+ 20
- 0
common/models/Distribution.php Zobrazit soubor

@@ -103,6 +103,11 @@ class Distribution extends ActiveRecordCommon
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.
*
@@ -413,6 +418,21 @@ class Distribution extends ActiveRecordCommon
$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.
*/

+ 27
- 3
common/models/Order.php Zobrazit soubor

@@ -102,8 +102,8 @@ class Order extends ActiveRecordCommon
return [
[['id_user', 'date', 'status'], 'required', 'message' => ''],
[['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']
];
}
@@ -125,7 +125,9 @@ class Order extends ActiveRecordCommon
'id_invoice' => 'Facture',
'id_quotation' => 'Devis',
'id_delivery_note' => 'Bon de livraison',
'reference' => 'Référence'
'reference' => 'Référence',
'delivery_home' => 'Livraison à domicile',
'delivery_address' => 'Adresse de livraison'
];
}

@@ -996,4 +998,26 @@ class Order extends ActiveRecordCommon
$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 ;
}
}

+ 7
- 2
common/models/Producer.php Zobrazit soubor

@@ -95,6 +95,9 @@ class Producer extends ActiveRecordCommon
const ORDER_REFERENCE_TYPE_NONE = '' ;
const ORDER_REFERENCE_TYPE_YEARLY = 'yearly' ;

const ORDER_ENTRY_POINT_DATE = 'date' ;
const ORDER_ENTRY_POINT_POINT_SALE = 'point-sale' ;

var $secret_key_payplug;

/**
@@ -136,8 +139,8 @@ class Producer extends ActiveRecordCommon
}
}],
[['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],
[['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'],
@@ -229,6 +232,8 @@ class Producer extends ActiveRecordCommon
'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_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'
];
}


+ 18
- 0
console/migrations/m210326_104759_add_option_order_entry_point.php Zobrazit soubor

@@ -0,0 +1,18 @@
<?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');
}

}

+ 24
- 0
console/migrations/m210330_072516_add_option_delivery.php Zobrazit soubor

@@ -0,0 +1,24 @@
<?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');
}

}


+ 130
- 63
producer/controllers/OrderController.php Zobrazit soubor

@@ -355,12 +355,20 @@ class OrderController extends ProducerBaseController
'id' => $order->id_point_sale
]);

// commentaire point de vente
$order->comment_point_sale = ($pointSale && strlen($pointSale->getComment())) ?
$pointSale->getComment() : '';

// la commande est automatiquement réactivée lors d'une modification
$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
$order->save();

@@ -583,6 +591,8 @@ class OrderController extends ProducerBaseController
$format = 'Y-m-d';
$dateObject = DateTime::createFromFormat($format, $date);

$user = User::getCurrent() ;

// PointSale current
$pointSaleCurrent = PointSale::findOne($pointSaleId) ;

@@ -597,6 +607,8 @@ class OrderController extends ProducerBaseController
'use_credit_checked_default' => $producer->use_credit_checked_default,
'credit_limit' => is_numeric($producer->credit_limit) ? $producer->credit_limit : null,
'option_allow_order_guest' => $producer->option_allow_order_guest,
'option_order_entry_point' => $producer->option_order_entry_point,
'option_delivery' => $producer->option_delivery
];

// Distributions
@@ -608,22 +620,47 @@ class OrderController extends ProducerBaseController
], [
'conditions' => ['date > :date'],
'params' => [':date' => $dateMini],
'join_with' => ['pointSaleDistribution'],
]);
$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
$ordersUserArray = [] ;
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([
'id_user' => User::getCurrentId()
], [
'conditions' => [
'distribution.date > :date'
],
'params' => [
':date' => $dateMini
]
'conditions' => $conditionsOrdersUser,
'params' => $paramsOrdersUser
]);
}

@@ -648,6 +685,7 @@ class OrderController extends ProducerBaseController

if($userProducer) {
$json['user'] = [
'address' => $user->address,
'credit' => $userProducer->credit,
'credit_active' => $userProducer->credit_active,
];
@@ -658,10 +696,16 @@ class OrderController extends ProducerBaseController
// Commande de l'utilisateur
$orderUser = false ;
if(User::getCurrentId()) {
$orderUser = Order::searchOne([
$conditionOrderUser = [
'distribution.date' => $date,
'id_user' => User::getCurrentId(),
]);
] ;

if($pointSaleId) {
$conditionOrderUser['id_point_sale'] = $pointSaleId ;
}

$orderUser = Order::searchOne($conditionOrderUser);
}

if ($orderUser) {
@@ -675,59 +719,8 @@ class OrderController extends ProducerBaseController
$distribution = Distribution::initDistribution($date);
$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
$ordersArray = Order::searchAll([
@@ -736,7 +729,14 @@ class OrderController extends ProducerBaseController

// Catégories
$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 ;

// Produits
@@ -801,10 +801,77 @@ class OrderController extends ProducerBaseController

$json['products'] = $productsArray;
}
else {
$json['points_sale'] = $this->_initPointsSale($producer->id) ;
}

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)
{
$order = Order::searchOne(['id' => $idOrder]);

+ 8
- 3
producer/views/order/confirm.php Zobrazit soubor

@@ -69,9 +69,14 @@ $producer = GlobalParam::getCurrentProducer() ;
<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; ?>
<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 />&nbsp; &nbsp; &nbsp;<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 />&nbsp; &nbsp; &nbsp;<span class="locality">à <?= Html::encode($order->pointSale->locality) ?></span><?php endif; ?></li>
<?php endif; ?>
</ul>
</div>
<div class="col-md-6">

+ 172
- 81
producer/views/order/order.php Zobrazit soubor

@@ -48,7 +48,13 @@ $producer = GlobalParam::getCurrentProducer() ;

?>

<script>
var appInitValues = {
};
</script>

<div id="app-order-order" :class="{'loaded': !loadingInit}">

<?php if(isset($order)): ?>
<span id="order-distribution-date"><?= $order->distribution->date; ?></span>
<?php endif; ?>
@@ -62,22 +68,38 @@ $producer = GlobalParam::getCurrentProducer() ;
<div>
<div id="steps">
<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 ' : '')">
<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>
@@ -102,8 +124,15 @@ $producer = GlobalParam::getCurrentProducer() ;
</li>
</ul>
</div>
<div v-if="loading && !step">
Chargement ...
</div>
<transition name="slide">
<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 ): ?>
<div style="display:none ;">
<?php endif; ?>
@@ -166,6 +195,7 @@ $producer = GlobalParam::getCurrentProducer() ;
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
</transition>
<transition name="slide">
@@ -184,7 +214,7 @@ $producer = GlobalParam::getCurrentProducer() ;
</tr>
</thead>
<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">
<span class="the-name">{{ pointSale.name }}</span>
<div class="comment" v-if="pointSale.userPointSale">
@@ -215,79 +245,118 @@ $producer = GlobalParam::getCurrentProducer() ;
</transition>
<transition name="slide">
<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 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 }}&nbsp;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 }}&nbsp;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 )) }}
</template>
</template>
</td>
</tr>
</template>
</template>
<tr class="total">
<td class="summary" colspan="4">
<template v-if="priceTotal() > 0">
<h3>&gt; 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 }}&nbsp;g)</span>
</li>
</ul>
</template>
</td>
<td class="price-total">{{ priceTotal(true) }}</td>
</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 class="alert alert-warning" v-else>
Aucun produit disponible
</div>
</div>
</transition>
<transition name="slide">
<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">
<label for="order-comment">Commentaire</label>
<textarea id="order-comment" v-model="comment" class="form-control"></textarea>
@@ -429,4 +498,26 @@ $producer = GlobalParam::getCurrentProducer() ;
</div>
<?php endif; ?>
</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>

+ 74
- 20
producer/web/css/screen.css Zobrazit soubor

@@ -1359,7 +1359,7 @@ termes.
top: 10px;
}
/* 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;
}
/* line 65, ../sass/order/_order.scss */
@@ -1367,7 +1367,7 @@ termes.
padding-right: 0px;
}
/* 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;
}
/* line 74, ../sass/order/_order.scss */
@@ -1503,46 +1503,65 @@ termes.
text-transform: uppercase;
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 {
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 {
font-family: "capsuularegular";
color: black;
font-size: 20px;
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 {
font-size: 14px;
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 {
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 {
width: 100px;
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 {
color: gray;
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 {
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 {
text-align: center;
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 {
padding: 5px;
padding-left: 0px;
@@ -1550,30 +1569,65 @@ termes.
border-left: 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 {
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 {
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 {
margin-top: 30px;
}
/* line 305, ../sass/order/_order.scss */
/* line 367, ../sass/order/_order.scss */
.order-order #main #app-order-order #infos .panel-body {
padding-top: 0px;
white-space: pre-line;
}

/* line 315, ../sass/order/_order.scss */
/* line 377, ../sass/order/_order.scss */
#main #content .panel h3 {
font-family: "highvoltageregular";
margin: 0px;

+ 314
- 146
producer/web/js/vuejs/order-order.js Zobrazit soubor

@@ -1,66 +1,72 @@

var app = new Vue({
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()) {
this.date = new Date($('#order-distribution-date').html()) ;
@@ -72,10 +78,13 @@ var app = new Vue({
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ 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 ;
},
methods: {
@@ -105,112 +114,209 @@ var app = new Vue({
}
}
},
init: function(updateOnlyProducts) {
init: function(type, oldStep, step) {

var app = this ;
this.loading = true ;

if(app.isChangeState('date', 'date', 'point-sale')) {
app.pointSaleActive = null ;
app.products = [] ;
}

axios.get("ajax-infos",{params: {
date : this.getDate(),
pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0
}})
.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({
highlight: {
backgroundColor: '#5cb85c',
backgroundColor: '#FF7F00'
},
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 ;
if(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) ;
}
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 ;
});
},

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) {
this.errors = [] ;
var oldStep = this.step ;
this.oldStep = oldStep ;
if(oldStep == 'products' && step == 'payment') {
this.checkProducts() ;
@@ -218,9 +324,7 @@ var app = new Vue({
if(!this.errors.length) {
this.step = step ;
window.scroll(0, $('#page-title').position().top - 25) ;
if(oldStep == 'date' && step == 'point-sale') {
this.init() ;
}
this.init('basic', oldStep, step) ;
}
},
dayClickList: function(event) {
@@ -240,7 +344,8 @@ var app = new Vue({
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ;
this.changeStep('point-sale') ;

this.nextStep() ;
},
isAvailableDate: function(date) {
for(var key in this.calendar.availableDates) {
@@ -274,8 +379,6 @@ var app = new Vue({
else {
this.validatePointSale(idPointSale) ;
}

app.init(true) ;
},

validatePointSale: function(idPointSale) {
@@ -283,8 +386,8 @@ var app = new Vue({
if(this.pointSaleActive.credit_functioning == 'mandatory' || (this.pointSaleActive.credit_functioning == 'user' && this.user.credit_active)) {
this.useCredit = true ;
}
this.changeStep('products') ;
this.nextStep() ;
},
productQuantityClick: function(product, quantity) {
if( this.products[product.index].quantity_form + quantity >= 0 &&
@@ -333,22 +436,21 @@ var app = new Vue({
confirmClick: function() {

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') ;
if($signupGuestForm.length > 0 && !$signupGuestForm.valid()) {
$signupGuestForm.submit() ;
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 ;
if(this.producer.option_allow_order_guest && !this.user) {
user = {
@@ -359,12 +461,25 @@ var app = new Vue({
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', {
Order: {
id_distribution : this.distribution.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],
products: productsArray,
@@ -401,6 +516,24 @@ var app = new Vue({
}
}
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 : {
@@ -472,4 +605,39 @@ var app = new Vue({
}
});
}
});
});

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: {
}
}) ;

+ 70
- 8
producer/web/sass/order/_order.scss Zobrazit soubor

@@ -57,8 +57,8 @@
position: relative ;
top: 10px ;
}
&#step-date {
&.first {
padding-left: 0px ;
}
@@ -67,7 +67,7 @@
}
&#step-payment .btn::after,
&#step-date .btn::before {
&.first .btn::before {
display: none ;
}
@@ -221,12 +221,31 @@
table#products {

td.category-name {
//font-family: "capsuularegular" ;
font-family: "highvoltageregular" ;
font-size: 22px ;
line-height: 30px;
text-transform: uppercase;
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 {
@@ -275,6 +294,36 @@
}
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 {
font-size: 23px ;
}
@@ -282,16 +331,29 @@
}
#content-step-payment {

.delivery {
margin-bottom: 20px ;

.delivery-home {
margin-bottom: 20px ;
}

.delivery-address {

}
}

.comment {
margin-bottom: 20px ;
}

.credit {
.info {
margin-left: 20px ;
color: gray ;
}
}
.comment {
margin-bottom: 20px ;
}
}

#specific-delays {

Načítá se…
Zrušit
Uložit