Sfoglia il codice sorgente

Gestion livraison à domicile

feature/souke
Guillaume Bourgeois 1 anno fa
parent
commit
4c13438d0f
7 ha cambiato i file con 146 aggiunte e 115 eliminazioni
  1. +105
    -102
      backend/views/point-sale/_form.php
  2. +1
    -1
      common/logic/Order/Order/Service/OrderSolver.php
  3. +3
    -1
      common/logic/PointSale/PointSale/Model/PointSale.php
  4. +26
    -0
      console/migrations/m231109_072158_add_column_point_sale_home_delivery.php
  5. +7
    -0
      producer/controllers/OrderController.php
  6. +1
    -5
      producer/views/order/order.php
  7. +3
    -6
      producer/web/js/vuejs/order-order.js

+ 105
- 102
backend/views/point-sale/_form.php Vedi File

@@ -53,109 +53,112 @@ $distributionModule = DistributionModule::getInstance();

<div class="point-sale-form">

<?php $form = ActiveForm::begin(); ?>
<div class="col-md-8">
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'locality')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'address')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'id_user', [
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}',
])
->dropDownList($userModule->populateUserDropdownList(), ['class' => 'select2'])
->hint('Utilisé lors de la facturation'); ?>
<?php
$addHintCredit = '';
if (!$producerModule->getConfig('credit')):
$addHintCredit = '<br /><strong>Attention, le système de Crédit est désactivé au niveau des ' . Html::a('paramètres globaux', ['producer/update']) . '.</strong>';
endif;
echo $form->field($model, 'credit')
->checkbox()
->hint('Cochez cette case si le client peut régler ses commandes via son compte <strong>Crédit</strong> pour ce point de vente.'
. $addHintCredit);
?>
<?= $form->field($model, 'credit_functioning')
->dropDownList([
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[$producerModule->getConfig('credit_functioning')] . ')',
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL],
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY],
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER],
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING); ?>
<?php /*$form->field($model, 'product_price_percent')
<?php $form = ActiveForm::begin(); ?>
<div class="col-md-8">
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'locality')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'address')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'id_user', [
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}',
])
->dropDownList($userModule->populateUserDropdownList(), ['class' => 'select2'])
->hint('Utilisé lors de la facturation'); ?>
<?php
$addHintCredit = '';
if (!$producerModule->getConfig('credit')):
$addHintCredit = '<br /><strong>Attention, le système de Crédit est désactivé au niveau des ' . Html::a('paramètres globaux', ['producer/update']) . '.</strong>';
endif;
echo $form->field($model, 'credit')
->checkbox()
->hint('Cochez cette case si le client peut régler ses commandes via son compte <strong>Crédit</strong> pour ce point de vente.'
. $addHintCredit);
?>
<?= $form->field($model, 'credit_functioning')
->dropDownList([
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[$producerModule->getConfig('credit_functioning')] . ')',
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL],
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY],
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER],
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING); ?>
<?php /*$form->field($model, 'product_price_percent')
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?>

<?= $form->field($model, 'maximum_number_orders')->textInput() ?>

<h2>Boîte à pain</h2>
<?= $form->field($model, 'is_bread_box')->checkbox() ?>
<?= $form->field($model, 'bread_box_code')->textInput() ?>

<div id="delivery-days">
<h2>Jours de livraison</h2>
<?= $form->field($model, 'delivery_monday')->checkbox() ?>
<?= $form->field($model, 'delivery_tuesday')->checkbox() ?>
<?= $form->field($model, 'delivery_wednesday')->checkbox() ?>
<?= $form->field($model, 'delivery_thursday')->checkbox() ?>
<?= $form->field($model, 'delivery_friday')->checkbox() ?>
<?= $form->field($model, 'delivery_saturday')->checkbox() ?>
<?= $form->field($model, 'delivery_sunday')->checkbox() ?>
</div>
<div class="clr"></div>

<h2>Informations</h2>
<?= $form->field($model, 'infos_monday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_tuesday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_wednesday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_thursday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_friday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_saturday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_sunday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'maximum_number_orders')->textInput() ?>

<div id="delivery-days">
<h2>Jours de livraison</h2>
<?= $form->field($model, 'delivery_monday')->checkbox() ?>
<?= $form->field($model, 'delivery_tuesday')->checkbox() ?>
<?= $form->field($model, 'delivery_wednesday')->checkbox() ?>
<?= $form->field($model, 'delivery_thursday')->checkbox() ?>
<?= $form->field($model, 'delivery_friday')->checkbox() ?>
<?= $form->field($model, 'delivery_saturday')->checkbox() ?>
<?= $form->field($model, 'delivery_sunday')->checkbox() ?>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Accès</h3>
</div>
<div class="panel-body">
<?= $form->field($model, 'code')
->label('Code d\'accès')
->hint('Renseignez ce champs si vous souhaitez protéger ce point de vente par un code.')
?>
<?= $form->field($model, 'restricted_access')
->checkbox()
->hint('Cochez cette case si seulement un groupe restreint d\'utilisateurs peuvent accéder à ce point de vente.<br />'
. 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?>
<div id="users">
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) {
$userModule = UserModule::getInstance();
return Html::encode($userModule->getUsernameFromArray($model_user)) . '<br />'
. Html::activeTextInput(
$model,
'users_comment[' . $model_user['user_id'] . ']',
[
'class' => 'form-control commentaire',
'placeholder' => 'Commentaire',
'value' => (isset($model->users_comment[$model_user['user_id']])) ? Html::encode($model->users_comment[$model_user['user_id']]) : ''
]);
}), ['encode' => false, 'class' => '']) ?>
</div>
<div class="clr"></div>

<h2>Informations</h2>
<?= $form->field($model, 'infos_monday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_tuesday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_wednesday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_thursday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_friday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_saturday')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'infos_sunday')->textarea(['rows' => 3]) ?>

<h2>Livraison à domicile</h2>
<?= $form->field($model, 'is_home_delivery')->checkbox() ?>

<h2>Boîte à pain</h2>
<?= $form->field($model, 'is_bread_box')->checkbox() ?>
<?= $form->field($model, 'bread_box_code')->textInput() ?>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Accès</h3>
</div>
<div class="panel-body">
<?= $form->field($model, 'code')
->label('Code d\'accès')
->hint('Renseignez ce champs si vous souhaitez protéger ce point de vente par un code.')
?>
<?= $form->field($model, 'restricted_access')
->checkbox()
->hint('Cochez cette case si seulement un groupe restreint d\'utilisateurs peuvent accéder à ce point de vente.<br />'
. 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?>
<div id="users">
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) {
$userModule = UserModule::getInstance();
return Html::encode($userModule->getUsernameFromArray($model_user)) . '<br />'
. Html::activeTextInput(
$model,
'users_comment[' . $model_user['user_id'] . ']',
[
'class' => 'form-control commentaire',
'placeholder' => 'Commentaire',
'value' => (isset($model->users_comment[$model_user['user_id']])) ? Html::encode($model->users_comment[$model_user['user_id']]) : ''
]);
}), ['encode' => false, 'class' => '']) ?>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Génération des bons de livraison</h3>
</div>
<div class="panel-body">
<?= $form->field($model, 'button_generate_delivery_note_point_sale')->checkbox() ?>
<?= $form->field($model, 'button_generate_delivery_note_each_user')->checkbox() ?>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Génération des bons de livraison</h3>
</div>
<div class="panel-body">
<?= $form->field($model, 'button_generate_delivery_note_point_sale')->checkbox() ?>
<?= $form->field($model, 'button_generate_delivery_note_each_user')->checkbox() ?>
</div>
</div>

<?php if($distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)): ?>
<?php if ($distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Exports</h3>
@@ -164,14 +167,14 @@ $distributionModule = DistributionModule::getInstance();
<?= $form->field($model, 'exclude_export_shopping_cart_labels')->checkbox(); ?>
</div>
</div>
<?php endif; ?>
</div>
<div class="clr"></div>
<?php endif; ?>
</div>
<div class="clr"></div>

<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>
<?php ActiveForm::end(); ?>

</div>

+ 1
- 1
common/logic/Order/Order/Service/OrderSolver.php Vedi File

@@ -170,7 +170,7 @@ class OrderSolver extends AbstractService implements SolverInterface
$comment .= '<br /><br />';
}

$comment .= '<strong>Livraison à domicile :</strong><br />';
$comment .= '<strong>Adresse :</strong><br />';
$comment .= nl2br($order->delivery_address);
}


+ 3
- 1
common/logic/PointSale/PointSale/Model/PointSale.php Vedi File

@@ -80,7 +80,8 @@ class PointSale extends ActiveRecordCommon
[['point_production', 'credit', 'delivery_monday', 'delivery_tuesday',
'delivery_wednesday', 'delivery_thursday', 'delivery_friday',
'delivery_saturday', 'delivery_sunday', 'default', 'is_bread_box',
'button_generate_delivery_note_point_sale', 'button_generate_delivery_note_each_user', 'exclude_export_shopping_cart_labels'], 'boolean'],
'button_generate_delivery_note_point_sale', 'button_generate_delivery_note_each_user',
'exclude_export_shopping_cart_labels', 'is_home_delivery'], 'boolean'],
['point_production', 'default', 'value' => 0],
[['id_producer', 'id_user', 'maximum_number_orders', 'status'], 'integer'],
['id_producer', 'required'],
@@ -128,6 +129,7 @@ class PointSale extends ActiveRecordCommon
'button_generate_delivery_note_point_sale' => 'Activer le bouton de génération de bon de livraison par point de vente',
'button_generate_delivery_note_each_user' => 'Activer le bouton de génération de bon de livraison par client',
'exclude_export_shopping_cart_labels' => "Exclure de l'export d'étiquettes",
'is_home_delivery' => "Livraison à domicile"
];
}


+ 26
- 0
console/migrations/m231109_072158_add_column_point_sale_home_delivery.php Vedi File

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

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m231109_072158_add_column_point_sale_home_delivery
*/
class m231109_072158_add_column_point_sale_home_delivery extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('point_sale', 'is_home_delivery', Schema::TYPE_BOOLEAN);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('point_sale', 'is_home_delivery');
}
}

+ 7
- 0
producer/controllers/OrderController.php Vedi File

@@ -394,6 +394,13 @@ class OrderController extends ProducerBaseController
$order->date_delete = null; // la commande est automatiquement réactivée lors d'une modification
$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;

// on sauvegarde l'adresse de livraison dans le profil de l'utilisateur pour qu'il n'ait plus à la ressaisir
if($order->delivery_address && !$user->address) {
$user->address = $order->delivery_address;
$user->save();
}

$order->comment = isset($posts['Order']['comment']) ? $posts['Order']['comment'] : null;
if(!$isNewOrder) {
$order->date_update = date('Y-m-d H:i:s');

+ 1
- 5
producer/views/order/order.php Vedi File

@@ -439,11 +439,7 @@ $this->setTitle('Commander');
<div id="content-step-payment" v-if="step == 'payment'">
<div>
<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">
<div class="delivery-home" v-if="pointSaleActive.is_home_delivery">
<label for="deliver-address">Adresse de livraison</label>
<textarea id="deliver-address" v-model="deliveryAddress" class="form-control"
required="required"></textarea>

+ 3
- 6
producer/web/js/vuejs/order-order.js Vedi File

@@ -276,7 +276,6 @@ var app = new Vue({
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 ;
}
@@ -284,7 +283,6 @@ var app = new Vue({
}
else {
app.comment = null ;
app.delivery = false ;
app.deliveryAddress = null ;
if(app.user.address && app.user.address.length > 0) {
app.deliveryAddress = app.user.address ;
@@ -516,7 +514,7 @@ var app = new Vue({
var app = this ;

// delivery
if(app.delivery && !app.deliveryAddress) {
if(app.pointSaleActive.is_home_delivery && !app.deliveryAddress) {
this.errors = [] ;
this.errors.push('Veuillez saisir une adresse de livraison') ;
return false ;
@@ -550,13 +548,13 @@ var app = new Vue({
}

app.disableConfirmButton = true ;
axios.post('ajax-process', {
Order: {
id_distribution : this.distribution.id,
id_point_sale: this.pointSaleActive.id,
comment: this.comment,
delivery_home: this.delivery,
delivery_home: this.pointSaleActive.is_home_delivery,
delivery_address: this.deliveryAddress
},
code_point_sale: this.pointsSaleCodes[this.pointSaleActive.id],
@@ -566,7 +564,6 @@ var app = new Vue({
}).then(function(response) {
if(response.data.status == 'success') {
app.errors = [] ;

if(response.data.redirect && response.data.redirect.length > 0) {
window.location.href = response.data.redirect ;
}

Loading…
Annulla
Salva