瀏覽代碼

Merge branch 'dev'

prodstable
Guillaume 4 年之前
父節點
當前提交
e86288513b
共有 10 個文件被更改,包括 248 次插入58 次删除
  1. +111
    -0
      backend/controllers/DistributionController.php
  2. +13
    -15
      backend/views/distribution/index.php
  3. +2
    -2
      backend/views/document/_download_product_line.php
  4. +9
    -5
      backend/views/document/download.php
  5. +4
    -0
      backend/views/producer/update.php
  6. +37
    -33
      backend/web/css/screen.css
  7. +48
    -1
      backend/web/js/vuejs/distribution-index.js
  8. +4
    -0
      backend/web/sass/distribution/_index.scss
  9. +3
    -2
      common/models/Producer.php
  10. +17
    -0
      console/migrations/m200429_074111_producer_option_display_price_delivery_note.php

+ 111
- 0
backend/controllers/DistributionController.php 查看文件

@@ -40,7 +40,9 @@ namespace backend\controllers;

use backend\controllers\BackendController;
use common\helpers\GlobalParam;
use common\models\DeliveryNote;
use common\models\Distribution;
use common\models\Document;
use common\models\Product;
use common\models\Producer;
use common\models\Order;
@@ -1002,6 +1004,115 @@ class DistributionController extends BackendController
return $return ;
}

public function actionAjaxValidateDeliveryNotes($idOrders)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

if (strlen($idOrders)) {
$idOrders = json_decode($idOrders, true);

if (is_array($idOrders) && count($idOrders) > 0) {
foreach($idOrders as $idOrder) {
$order = Order::searchOne([
'id' => (int)$idOrder
]);

if($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) {
$deliveryNote = DeliveryNote::searchOne([
'id' => (int) $order->id_delivery_note
]) ;

if($deliveryNote && $deliveryNote->isStatusDraft()) {
$deliveryNote->changeStatus(Document::STATUS_VALID);
$deliveryNote->save();
}
}
}

return [
'return' => 'success',
'alert' => [
'type' => 'success',
'message' => 'Bon(s) de livraison validé(s)'
]
] ;
}
}

return [
'return' => 'error',
'alert' => [
'type' => 'danger',
'message' => 'Une erreur est survenue lors de la validation des bons de livraison'
]
];
}

public function actionAjaxGenerateDeliveryNoteEachUser($idOrders)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

if (strlen($idOrders)) {
$idOrders = json_decode($idOrders, true);

if (is_array($idOrders) && count($idOrders) > 0) {

foreach ($idOrders as $idOrder) {
$order = Order::searchOne([
'id' => (int)$idOrder
]);

if($order && $order->distribution->id_producer == GlobalParam::getCurrentProducerId()) {

$deliveryNote = null ;
$idDeliveryNote = $order->id_delivery_note ;
if($idDeliveryNote) {
$deliveryNote = DeliveryNote::searchOne([
'id' => (int) $idDeliveryNote
]);
}

// on regénére le document si c'est un brouillon
if($deliveryNote && $deliveryNote->isStatusDraft()) {
$deliveryNote->delete() ;
$deliveryNote = null ;
}

if(!$deliveryNote) {
$deliveryNote = new DeliveryNote() ;
$deliveryNote->id_producer = GlobalParam::getCurrentProducerId();
$deliveryNote->id_user = $order->id_user;
$deliveryNote->name = 'Bon de livraison ' . $order->getUsername() . ' (' . date('d/m/Y', strtotime($order->distribution->date)) . ')';
$deliveryNote->address = $order->user->getFullAddress() ;
$deliveryNote->save();
}

if($deliveryNote) {
$order->id_delivery_note = $deliveryNote->id;
$order->save();
}
}
}
}

return [
'return' => 'success',
'alert' => [
'type' => 'success',
'message' => 'Bon(s) de livraison généré(s)'
]
] ;
}

return [
'return' => 'error',
'alert' => [
'type' => 'danger',
'message' => 'Une erreur est survenue lors de la génération du bon de livraison.'
]
];
}

public function actionAjaxGenerateDeliveryNote($idOrders)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

+ 13
- 15
backend/views/distribution/index.php 查看文件

@@ -249,11 +249,17 @@ $this->setPageTitle('Distributions') ;

<div id="buttons-top-orders">
<div class="right">
<a v-if="idActivePointSale > 0" @click="generateDeliveryNote" href="javascript:void(0);" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-plus"></span>
<span v-if="deliveryNoteExist(idActivePointSale)">Regénérer le bon de livraison</span>
<span v-else>Générer un bon de livraison</span>
</a>
<div class="dropdown">
<button class="btn btn-default btn-xs dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="glyphicon glyphicon-file"></span> Documents
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a v-if="idActivePointSale > 0" @click="generateDeliveryNote" href="javascript:void(0);" >Générer un bon de livraison pour ce point de vente</a></li>
<li><a @click="generateDeliveryNoteEachUser" href="javascript:void(0);">Générer un bon de livraison pour chaque client</a></li>
<li><a @click="validateDeliveryNotes" href="javascript:void(0);">Valider les bons de livraisons</a></li>
</ul>
</div>
<button id="btn-add-subscriptions" @click="addSubscriptions" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span> Importer les abonnements</button>
<template v-if="producer.tiller == true">
<button v-if="tillerIsSynchro" id="btn-tiller" class="btn btn-success btn-xs" disabled><span class="glyphicon glyphicon-refresh"></span> Synchronisé avec Tiller</button>
@@ -263,15 +269,7 @@ $this->setPageTitle('Distributions') ;
<button id="btn-add-order" @click="openModalFormOrderCreate" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-plus"></span> Ajouter une commande</button>
</div>
<div class="left">
<a v-if="deliveryNoteExist(idActivePointSale)" :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+deliveryNotes[idActivePointSale].id" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-file"></span> Bon de livraison</a>
<!--<div v-if="idActivePointSale > 0" class="btn-group">
<button type="button" class="btn btn-success btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action groupée <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a @click="generateDeliveryNote" href="javascript:void(0);">Générer un bon de livraison</a></li>
</ul>
</div>-->
<a v-if="false && deliveryNoteExist(idActivePointSale)" :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+deliveryNotes[idActivePointSale].id" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-file"></span> Bon de livraison</a>
</div>
<div class="clr"></div>
</div>
@@ -492,7 +490,7 @@ $this->setPageTitle('Distributions') ;
</td>
<td class="column-delivery-note">
<a v-if="order.id_delivery_note" class="btn btn-default btn-xs" :href="UrlManager.getBaseUrl()+'delivery-note/update?id='+order.id_delivery_note">
<span class="glyphicon glyphicon-file"></span> BL
<span class="glyphicon glyphicon-file"></span> BL #{{ order.id_delivery_note }}
</a>
</td>
</tr>

+ 2
- 2
backend/views/document/_download_product_line.php 查看文件

@@ -8,12 +8,12 @@
<br /><small><?= Html::encode($productOrder->product->description) ?></small>
<?php endif; ?>
</td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if($displayPrices): ?>
<td class="align-center"><?= Price::format($productOrder->getPrice()) ?></td>
<?php endif; ?>
<td class="align-center"><?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?></td>
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if($displayPrices): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?>
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td>
<?php endif; ?>

+ 9
- 5
backend/views/document/download.php 查看文件

@@ -1,5 +1,7 @@
<?php

$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note')) ;

?>

<div class="document-download">
@@ -40,7 +42,7 @@
<thead>
<tr>
<th class="align-left">Produit</th>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if($displayPrices): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value == 0): ?>
<th>Prix unitaire</th>
<?php else: ?>
@@ -49,7 +51,7 @@
<?php endif; ?>
<th>Quantité</th>
<th>Unité</th>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if($displayPrices): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value == 0): ?>
<th>Prix</th>
<?php else: ?>
@@ -69,12 +71,12 @@
<strong><?= Html::encode($order->getUsername()) ; ?></strong>
le <?= date('d/m/Y', strtotime($order->date)) ?>
</td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if($displayPrices): ?>
<td class="align-center"></td>
<?php endif; ?>
<td></td>
<td></td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if($displayPrices): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?>
<td class="align-center"></td>
<?php endif; ?>
@@ -85,6 +87,7 @@
<?= $this->render('_download_product_line', [
'productOrder' => $productOrder,
'displayOrders' => true,
'displayPrices' => $displayPrices
]) ?>
<?php endforeach; ?>
<?php endforeach; ?>
@@ -93,11 +96,12 @@
<?php foreach($product as $productOrder): ?>
<?= $this->render('_download_product_line', [
'productOrder' => $productOrder,
'displayPrices' => $displayPrices
]) ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if($displayPrices): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?>
<tr>
<td class="align-right" colspan="5"><strong>Total HT</strong></td>

+ 4
- 0
backend/views/producer/update.php 查看文件

@@ -316,6 +316,10 @@ $this->addBreadcrumb($this->getTitle()) ;
0 => 'Non',
1 => 'Oui'
]) ; ?>
<?= $form->field($model, 'document_display_prices_delivery_note')->dropDownList([
0 => 'Non',
1 => 'Oui'
]) ; ?>
<?= $form->field($model, 'document_infos_bottom')
->textarea(['rows' => 15]) ?>
<?= $form->field($model, 'document_infos_quotation')

+ 37
- 33
backend/web/css/screen.css 查看文件

@@ -2028,11 +2028,15 @@ termes.
.distribution-index #orders #buttons-top-orders .right {
float: right;
}
/* line 237, ../sass/distribution/_index.scss */
/* line 234, ../sass/distribution/_index.scss */
.distribution-index #orders #buttons-top-orders .dropdown {
display: inline-block;
}
/* line 241, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller {
width: 60px;
}
/* line 240, ../sass/distribution/_index.scss */
/* line 244, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller label {
font-size: 12px;
cursor: pointer;
@@ -2040,64 +2044,64 @@ termes.
top: -2px;
font-weight: normal;
}
/* line 249, ../sass/distribution/_index.scss */
/* line 253, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions {
position: relative;
text-align: right;
}
/* line 253, ../sass/distribution/_index.scss */
/* line 257, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .dropdown-menu {
top: 0px;
right: 0px;
}
/* line 258, ../sass/distribution/_index.scss */
/* line 262, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .modal-form-order,
.distribution-index #orders table td.column-actions .modal-payment {
text-align: left;
}
/* line 263, ../sass/distribution/_index.scss */
/* line 267, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .add-subscription {
position: relative;
}
/* line 266, ../sass/distribution/_index.scss */
/* line 270, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .add-subscription .glyphicon-plus {
position: absolute;
top: 4px;
right: 4px;
font-size: 7px;
}
/* line 275, ../sass/distribution/_index.scss */
/* line 279, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-state-payment {
width: 120px;
}
/* line 280, ../sass/distribution/_index.scss */
/* line 284, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-payment div.btn-group {
width: 125px;
}
/* line 286, ../sass/distribution/_index.scss */
/* line 290, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view ul {
list-style-type: none;
margin-left: 0px;
padding-left: 15px;
}
/* line 296, ../sass/distribution/_index.scss */
/* line 300, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view .comment {
margin-top: 20px;
}
/* line 305, ../sass/distribution/_index.scss */
/* line 309, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container {
width: 100%;
padding: 0px;
}
/* line 309, ../sass/distribution/_index.scss */
/* line 313, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body {
padding-right: 15px;
}
/* line 311, ../sass/distribution/_index.scss */
/* line 315, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body table {
margin-bottom: 150px;
}
/* line 316, ../sass/distribution/_index.scss */
/* line 320, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer {
border-top-color: #f4f4f4;
position: fixed;
@@ -2109,46 +2113,46 @@ termes.
text-align: center;
border-top: solid 1px #e0e0e0;
}
/* line 328, ../sass/distribution/_index.scss */
/* line 332, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form button {
float: none;
}
/* line 335, ../sass/distribution/_index.scss */
/* line 339, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .btn-credit {
float: right;
}
/* line 341, ../sass/distribution/_index.scss */
/* line 345, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered td {
background-color: #e9e9e9;
}
/* line 345, ../sass/distribution/_index.scss */
/* line 349, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered input {
font-size: 16px;
font-weight: bold;
}
/* line 351, ../sass/distribution/_index.scss */
/* line 355, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price {
width: 150px;
}
/* line 353, ../sass/distribution/_index.scss */
/* line 357, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price input {
text-align: center;
}
/* line 358, ../sass/distribution/_index.scss */
/* line 362, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity {
width: 165px;
}
/* line 361, ../sass/distribution/_index.scss */
/* line 365, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center;
color: black;
}
/* line 366, ../sass/distribution/_index.scss */
/* line 370, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .form-control {
border-right: 0px none;
padding-right: 4px;
}
/* line 371, ../sass/distribution/_index.scss */
/* line 375, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -2156,35 +2160,35 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 380, ../sass/distribution/_index.scss */
/* line 384, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right;
}
/* line 383, ../sass/distribution/_index.scss */
/* line 387, ../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 387, ../sass/distribution/_index.scss */
/* line 391, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.negative {
color: #DD4B39;
}
/* line 391, ../sass/distribution/_index.scss */
/* line 395, ../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 398, ../sass/distribution/_index.scss */
/* line 402, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button {
margin-left: 15px;
}
/* line 406, ../sass/distribution/_index.scss */
/* line 410, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon {
width: 50px;
}
/* line 409, ../sass/distribution/_index.scss */
/* line 413, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px;
}
/* line 414, ../sass/distribution/_index.scss */
/* line 418, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px;
}

+ 48
- 1
backend/web/js/vuejs/distribution-index.js 查看文件

@@ -478,7 +478,6 @@ var app = new Vue({
return false ;
},
generateDeliveryNote: function() {

if(!this.oneOrderSelected()) {
this.selectAllOrders(true) ;
}
@@ -502,7 +501,55 @@ var app = new Vue({
else {
appAlerts.alert('danger','Veuillez sélectionner au moins une commande pour générer un bon de livraison') ;
}
},
generateDeliveryNoteEachUser: function() {
if(!this.oneOrderSelected()) {
this.selectAllOrders(true) ;
}

if(this.oneOrderSelected()) {
var app = this ;
var idOrders = {} ;
for(var key in this.orders) {
if(this.orders[key].selected == true) {
idOrders[key] = this.orders[key].id ;
}
}
axios.get(UrlManager.getBaseUrlAbsolute()+"distribution/ajax-generate-delivery-note-each-user",{params: {
idOrders: JSON.stringify(idOrders)
}})
.then(function(response) {
appAlerts.alertResponse(response) ;
app.init(app.idActivePointSale) ;
}) ;
}
else {
appAlerts.alert('danger','Veuillez sélectionner au moins une commande pour générer un bon de livraison') ;
}
},
validateDeliveryNotes: function() {
if(!this.oneOrderSelected()) {
this.selectAllOrders(true) ;
}
if(this.oneOrderSelected()) {
var app = this ;
var idOrders = {} ;
for(var key in this.orders) {
if(this.orders[key].selected == true) {
idOrders[key] = this.orders[key].id ;
}
}
axios.get(UrlManager.getBaseUrlAbsolute()+"distribution/ajax-validate-delivery-notes",{params: {
idOrders: JSON.stringify(idOrders)
}})
.then(function(response) {
appAlerts.alertResponse(response) ;
app.init(app.idActivePointSale) ;
}) ;
}
else {
appAlerts.alert('danger','Veuillez sélectionner au moins une commande pour valider un bon de livraison') ;
}
},
deliveryNoteExist: function(idPointSale) {
return typeof this.deliveryNotes[this.idActivePointSale] != 'undefined' ;

+ 4
- 0
backend/web/sass/distribution/_index.scss 查看文件

@@ -230,6 +230,10 @@ termes.
.right {
float: right;
}

.dropdown {
display: inline-block ;
}
}

table {

+ 3
- 2
common/models/Producer.php 查看文件

@@ -128,7 +128,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'],
[['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'], 'boolean'],
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note'], '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'],
@@ -203,7 +203,8 @@ class Producer extends ActiveRecordCommon
'document_infos_delivery_note' => 'Informations affichées en bas des bons de livraison',
'address' => 'Adresse',
'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 commande',
'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',
];
}


+ 17
- 0
console/migrations/m200429_074111_producer_option_display_price_delivery_note.php 查看文件

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

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

class m200429_074111_producer_option_display_price_delivery_note extends Migration
{
public function safeUp()
{
$this->addColumn('producer', 'document_display_prices_delivery_note', Schema::TYPE_BOOLEAN) ;
}

public function safeDown()
{
$this->dropColumn('producer', 'document_display_prices_delivery_note') ;
}
}

Loading…
取消
儲存