Parcourir la source

[producer] Accueil : ajout des jours de distribution au niveau des points de vente

Commande : sélection date via une liste
refactoring
Guillaume il y a 4 ans
Parent
révision
af3f660b02
9 fichiers modifiés avec 229 ajouts et 76 suppressions
  1. +12
    -0
      backend/views/producer/update.php
  2. +9
    -1
      common/models/Producer.php
  3. +22
    -0
      console/migrations/m200601_073309_add_producer_options.php
  4. +24
    -7
      producer/controllers/SiteController.php
  5. +27
    -1
      producer/views/order/order.php
  6. +87
    -42
      producer/views/site/index.php
  7. +23
    -19
      producer/web/css/screen.css
  8. +15
    -6
      producer/web/js/vuejs/order-order.js
  9. +10
    -0
      producer/web/sass/order/_order.scss

+ 12
- 0
backend/views/producer/update.php Voir le fichier

@@ -39,6 +39,7 @@ termes.
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\helpers\Url ;
use common\models\Producer ;

\backend\assets\VuejsProducerUpdateAsset::register($this);

@@ -101,6 +102,11 @@ $this->addBreadcrumb($this->getTitle()) ;
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />';
}
?>
<?= $form->field($model, 'behavior_home_point_sale_day_list')
->dropDownList([
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK => 'Jours de la semaine',
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir',
]); ?>
</div>
</div>
@@ -204,6 +210,12 @@ $this->addBreadcrumb($this->getTitle()) ;
Producer::BEHAVIOR_DELETE_ORDER_DELETE => 'Suppression de la commande',
Producer::BEHAVIOR_DELETE_ORDER_STATUS => 'Passage de la commande en statut "supprimé"',
], []) ; ?>

<?= $form->field($model, 'behavior_order_select_distribution')
->dropDownList([
Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR => 'Calendrier',
Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST => 'Liste',
]); ?>
</div>
</div>


+ 9
- 1
common/models/Producer.php Voir le fichier

@@ -86,6 +86,12 @@ class Producer extends ActiveRecordCommon
const BEHAVIOR_DELETE_ORDER_DELETE = 'delete';
const BEHAVIOR_DELETE_ORDER_STATUS = 'status';

const BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK = 'days-of-week' ;
const BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS = 'incoming-distributions' ;

const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR = 'calendar' ;
const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST = 'list' ;

var $secret_key_payplug;

/**
@@ -127,7 +133,7 @@ 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'], 'string'],
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address', 'behavior_home_point_sale_day_list', 'behavior_order_select_distribution'], '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'], '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'],
@@ -205,6 +211,8 @@ class Producer extends ActiveRecordCommon
'document_display_orders_invoice' => 'Afficher le détail des commandes dans les factures',
'document_display_orders_delivery_note' => 'Afficher le détail des commandes dans les bons de livraison',
'document_display_prices_delivery_note' => 'Afficher le chiffrage dans les bons de livraison',
'behavior_home_point_sale_day_list' => 'Accueil : affichage des jours de distribution',
'behavior_order_select_distribution' => 'Sélection de la date de distribution',
];
}


+ 22
- 0
console/migrations/m200601_073309_add_producer_options.php Voir le fichier

@@ -0,0 +1,22 @@
<?php

use yii\db\Migration;
use yii\db\Schema;
use common\models\Producer ;

class m200601_073309_add_producer_options extends Migration
{
public function safeUp()
{
$this->addColumn('producer', 'behavior_home_point_sale_day_list', Schema::TYPE_STRING.' DEFAULT \''.Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK.'\'');
$this->addColumn('producer', 'behavior_order_select_distribution', Schema::TYPE_STRING.' DEFAULT \''.Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR.'\'');
}

public function safeDown()
{
$this->dropColumn('producer', 'behavior_home_point_sale_day_list');
$this->dropColumn('producer', 'behavior_order_select_distribution');

return false;
}
}

+ 24
- 7
producer/controllers/SiteController.php Voir le fichier

@@ -102,22 +102,39 @@ class SiteController extends ProducerBaseController
]);

// produits
$queryProducts = Product::find()
->andWhere([
'id_producer' => $this->getProducer()->id,
'active' => true
])
->orderBy('order ASC') ;
$dataProviderProducts = new ActiveDataProvider([
'query' => Product::find()
->andWhere([
'id_producer' => $this->getProducer()->id,
'active' => true
])
->orderBy('order ASC'),
'query' => $queryProducts,
'pagination' => [
'pageSize' => 50,
],
'sort' => false,
]);

$products = $queryProducts->all() ;

$hasProductPhoto = false ;
$hasProductWeight = false ;

foreach($products as $product) {
if(strlen($product->photo) > 0) {
$hasProductPhoto = true ;
}
if($product->weight && $product->weight > 0) {
$hasProductWeight = true ;
}
}

return $this->render('index', [
'dataProviderPointsSale' => $dataProviderPointsSale,
'dataProviderProducts' => $dataProviderProducts
'dataProviderProducts' => $dataProviderProducts,
'hasProductPhoto' => $hasProductPhoto,
'hasProductWeight' => $hasProductWeight
]);
}


+ 27
- 1
producer/views/order/order.php Voir le fichier

@@ -36,10 +36,16 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\helpers\GlobalParam ;
use common\models\Producer ;
use common\models\Distribution ;

\producer\assets\VuejsOrderOrderAsset::register($this);

$this->setTitle('Commander') ;

$producer = GlobalParam::getCurrentProducer() ;

?>

<div id="app-order-order" :class="{'loaded': !loadingInit}">
@@ -98,6 +104,9 @@ $this->setTitle('Commander') ;
</div>
<transition name="slide">
<div id="content-step-date" v-if="step == 'date'">
<?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
<div style="display:none ;">
<?php endif; ?>
<div id="legend">
<div><span id="distribution-date-color"></span> Prochains jours de distribution</div>
<div><span id="order-date-color"></span> Vos commandes déjà enregistrées</div>
@@ -115,8 +124,25 @@ $this->setTitle('Commander') ;
:attributes="calendar.attrs"
:available-dates="calendar.availableDates"
@dayclick='dayClick'>
></v-calendar>
></v-calendar>
</div>
<?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
</div>
<?php endif; ?>

<?php if($producer->behavior_order_select_distribution == Producer::BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST ): ?>
<div id="distributions-list">
<?php $incomingDistributions = Distribution::getIncomingDistributions(); ?>
<?php foreach($incomingDistributions as $distribution): ?>
<div class="panel panel-default">
<div class="panel-body">
<?= ucfirst(strftime('%A %d %B', strtotime($distribution->date))); ?>
<a href="javascript:void(0);" class="btn btn-primary" @click="dayClickList" data-distribution-date="<?= $distribution->date.' 00:00' ?>">Sélectionner cette distribution</a>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</transition>
<transition name="slide">

+ 87
- 42
producer/views/site/index.php Voir le fichier

@@ -36,6 +36,11 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

use common\helpers\GlobalParam ;
use common\models\Distribution;
use common\models\PointSaleDistribution;
use common\models\Producer ;

$producer = $this->context->getProducer() ;
$this->setTitle('Accueil');
$this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;
@@ -71,8 +76,35 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;
],
[
'label' => 'Jours de livraison',
'format' => 'raw',
'value' => function($model) {
return $model->getStrDeliveryDays() ;

$producer = GlobalParam::getCurrentProducer() ;

if($producer->behavior_home_point_sale_day_list == Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_WEEK) {
return $model->getStrDeliveryDays() ;
}
elseif($producer->behavior_home_point_sale_day_list == Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS) {
$html = '' ;
$incomingDistributions = Distribution::getIncomingDistributions();
$cpt = 0 ;
foreach($incomingDistributions as $distribution) {
$countPointSaleDistribution = PointSaleDistribution::searchCount([
'id_distribution' => $distribution->id,
'id_point_sale' => $model->id
]);
if($countPointSaleDistribution) {
$html .= strftime('%A %d %B', strtotime($distribution->date)).'<br />';
}

$cpt ++ ;

if($cpt >= 5) {
break ;
}
}
return $html ;
}
}
]
],
@@ -82,54 +114,67 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ;

<section id="products">
<h3><span>Produits</span></h3>
<?= GridView::widget([
'dataProvider' => $dataProviderProducts,
'summary' => '',
'columns' => [
[
'attribute' => 'photo',
'format' => 'raw',
'contentOptions' => ['class' => 'photo'],
'value' => function($model) {
if(strlen($model->photo)) {
return '<img class="photo-product" src="'.Yii::$app->urlManagerProducer->baseUrl.'/uploads/'.$model->photo.'" />' ;
}
return '' ;
}
],
[

<?php

$columnsProducts = [] ;
if($hasProductPhoto) {
$columnsProducts [] = [
'attribute' => 'photo',
'format' => 'raw',
'contentOptions' => ['class' => 'photo'],
'value' => function($model) {
if(strlen($model->photo)) {
return '<img class="photo-product" src="'.Yii::$app->urlManagerProducer->baseUrl.'/uploads/'.$model->photo.'" />' ;
}
return '' ;
}
] ;
}

$columnsProducts[] = [
'attribute' => 'name',
'format' => 'raw',
'contentOptions' => ['class' => 'name'],
'value' => function($model) {
$html = '<span class="the-name">'.Html::encode($model->name).'</span>' ;
if(strlen($model->description)) {
$html .= ' / '.Html::encode($model->description) ;
}
if(strlen($model->recipe)) {
$html .= '<br />'.Html::encode($model->recipe) ;
}
return $html ;
}
],
[
'attribute' => 'weight',
'value' => function($model) {
if($model->unit == 'piece' && strlen($model->weight)) {
return $model->weight.' g' ;
}
return '' ;
$html = '<span class="the-name">'.Html::encode($model->name).'</span>' ;
if(strlen($model->description)) {
$html .= ' / '.Html::encode($model->description) ;
}
if(strlen($model->recipe)) {
$html .= '<br />'.Html::encode($model->recipe) ;
}
return $html ;
}
],
[
] ;

if($hasProductWeight) {
$columnsProducts[] = [
'attribute' => 'weight',
'value' => function($model) {
if($model->unit == 'piece' && strlen($model->weight)) {
return $model->weight.' g' ;
}
return '' ;
}
] ;
}

$columnsProducts[] = [
'attribute' => 'price',
'value' => function($model) {
if($model->price) {
return Price::format($model->getPriceWithTax()).' ('.Product::strUnit($model->unit, 'wording_unit', true).')' ;
}
return '' ;
if($model->price) {
return Price::format($model->getPriceWithTax()).' ('.Product::strUnit($model->unit, 'wording_unit', true).')' ;
}
return '' ;
}
],
],
] ;

?>

<?= GridView::widget([
'dataProvider' => $dataProviderProducts,
'summary' => '',
'columns' => $columnsProducts
]); ?>
</section>

+ 23
- 19
producer/web/css/screen.css Voir le fichier

@@ -1439,70 +1439,74 @@ termes.
.order-order #main #app-order-order #calendar .c-day-popover-content {
font-size: 1.3rem;
}
/* line 172, ../sass/order/_order.scss */
/* line 175, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-date #distributions-list .panel .btn-primary {
float: right;
}
/* line 182, ../sass/order/_order.scss */
.order-order #main #app-order-order .block-actions {
text-align: right;
margin-top: 20px;
}
/* line 179, ../sass/order/_order.scss */
/* line 189, ../sass/order/_order.scss */
.order-order #main #app-order-order table#points-sale td.name .the-name {
font-family: "capsuularegular";
color: black;
font-size: 20px;
line-height: 25px;
}
/* line 187, ../sass/order/_order.scss */
/* line 197, ../sass/order/_order.scss */
.order-order #main #app-order-order table#points-sale td.actions {
width: 150px;
}
/* line 189, ../sass/order/_order.scss */
/* line 199, ../sass/order/_order.scss */
.order-order #main #app-order-order table#points-sale td.actions button {
width: 100%;
}
/* line 195, ../sass/order/_order.scss */
/* line 205, ../sass/order/_order.scss */
.order-order #main #app-order-order table#points-sale tr.selected td {
background-color: white;
}
/* line 203, ../sass/order/_order.scss */
/* line 213, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products td.photo img {
width: 100px;
}
/* line 209, ../sass/order/_order.scss */
/* line 219, ../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 215, ../sass/order/_order.scss */
/* line 225, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products td.name .other {
font-size: 14px;
color: #333;
}
/* line 219, ../sass/order/_order.scss */
/* line 229, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products td.name .recipe {
color: gray;
}
/* line 223, ../sass/order/_order.scss */
/* line 233, ../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 227, ../sass/order/_order.scss */
/* line 237, ../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 232, ../sass/order/_order.scss */
/* line 242, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity {
width: 175px;
}
/* line 234, ../sass/order/_order.scss */
/* line 244, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity input.quantity {
text-align: center;
border-right: 0px none;
}
/* line 238, ../sass/order/_order.scss */
/* line 248, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -1510,24 +1514,24 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 248, ../sass/order/_order.scss */
/* line 258, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .price-total {
font-size: 23px;
}
/* line 256, ../sass/order/_order.scss */
/* line 266, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .credit .info {
margin-left: 20px;
color: gray;
}
/* line 262, ../sass/order/_order.scss */
/* line 272, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .comment {
margin-bottom: 20px;
}
/* line 273, ../sass/order/_order.scss */
/* line 283, ../sass/order/_order.scss */
.order-order #main #app-order-order #infos {
margin-top: 30px;
}
/* line 275, ../sass/order/_order.scss */
/* line 285, ../sass/order/_order.scss */
.order-order #main #app-order-order #infos .panel-body {
padding-top: 0px;
white-space: pre-line;

+ 15
- 6
producer/web/js/vuejs/order-order.js Voir le fichier

@@ -211,17 +211,26 @@ var app = new Vue({
this.init() ;
}
}
},
dayClickList: function(event) {
var dateStr = event.currentTarget.getAttribute('data-distribution-date') ;
var dateObject = new Date(dateStr) ;
if(this.isAvailableDate(dateObject)) {
this.dayClickEvent(dateObject) ;
}
},
dayClick: function(day) {
if(this.isAvailableDate(day.date)) {
this.date = day.date ;
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ;
this.changeStep('point-sale') ;
this.dayClickEvent(day.date) ;
}
},
dayClickEvent: function(date) {
this.date = date ;
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ;
this.changeStep('point-sale') ;
},
isAvailableDate: function(date) {
for(var key in this.calendar.availableDates) {
if(date.getTime() == this.calendar.availableDates[key].start.getTime()) {

+ 10
- 0
producer/web/sass/order/_order.scss Voir le fichier

@@ -168,6 +168,16 @@
font-size: 1.3rem ;
}
}

#content-step-date {
#distributions-list {
.panel {
.btn-primary {
float: right ;
}
}
}
}
.block-actions {
text-align: right ;

Chargement…
Annuler
Enregistrer