Переглянути джерело

[backend] Distributions : possibilité de saisir des prix spécifiques à chaque commande

refactoring
Guillaume 4 роки тому
джерело
коміт
3344f1475c
7 змінених файлів з 88 додано та 25 видалено
  1. +10
    -3
      backend/controllers/DistributionController.php
  2. +12
    -2
      backend/controllers/OrderController.php
  3. +7
    -0
      backend/views/distribution/index.php
  4. +31
    -19
      backend/web/css/screen.css
  5. +18
    -1
      backend/web/js/vuejs/distribution-index.js
  6. +3
    -0
      backend/web/sass/_responsive.scss
  7. +7
    -0
      backend/web/sass/distribution/_index.scss

+ 10
- 3
backend/controllers/DistributionController.php Переглянути файл

@@ -156,7 +156,7 @@ class DistributionController extends BackendController
// products
$productsArray = Product::find()
->orWhere(['id_producer' => GlobalParam::getCurrentProducerId(),])
->joinWith(['productDistribution' => function ($query) use ($distribution) {
->joinWith(['taxRate','productDistribution' => function ($query) use ($distribution) {
$query->andOnCondition('product_distribution.id_distribution = ' . $distribution->id);
}])
->orderBy('product_distribution.active DESC, order ASC')
@@ -188,6 +188,10 @@ class DistributionController extends BackendController
$potentialRevenues += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['price'];
$potentialWeight += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['weight'] / 1000;
}

if(!isset($theProduct['taxRate'])) {
$theProduct['taxRate'] = $producer->taxRate ;
}
}

$json['distribution']['potential_revenues'] = Price::format($potentialRevenues);
@@ -204,6 +208,7 @@ class DistributionController extends BackendController
$productOrderArray[$productOrder->id_product] = [
'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'],
'unit' => $productOrder->unit,
'price' => Price::getPriceWithTax($productOrder->price, $productOrder->taxRate->value)
];
}

@@ -211,7 +216,8 @@ class DistributionController extends BackendController
if (!isset($productOrderArray[$product['id']])) {
$productOrderArray[$product['id']] = [
'quantity' => 0,
'unit' => $product['unit']
'unit' => $product['unit'],
'price' => Price::getPriceWithTax($product['price'], $product['taxRate']['value']),
];
}
}
@@ -296,7 +302,8 @@ class DistributionController extends BackendController
foreach ($productsArray as $product) {
$productOrderArray[$product['id']] = [
'quantity' => 0,
'unit' => $product['unit']
'unit' => $product['unit'],
'price' => Price::getPriceWithTax($product['price'], $product['taxRate']['value']),
];
}
$json['order_create'] = [

+ 12
- 2
backend/controllers/OrderController.php Переглянути файл

@@ -864,7 +864,12 @@ class OrderController extends BackendController
$productOrder->quantity = $quantity;
$productOrder->unit = $product->unit;
$productOrder->step = $product->step;
$productOrder->price = $product->price;
if($dataProductOrder->price) {
$productOrder->price = number_format(Price::getPrice($dataProductOrder->price, $product->taxRate->value), 3) ;
}
else {
$productOrder->price = $product->price;
}
$productOrder->id_tax_rate = $product->taxRate->id;
$productOrder->save();
}
@@ -928,7 +933,12 @@ class OrderController extends BackendController
$productOrder->quantity = $quantity;
$productOrder->unit = $product->unit;
$productOrder->step = $product->step;
$productOrder->price = $product->price;
if($dataProductOrder->price) {
$productOrder->price = number_format(Price::getPrice($dataProductOrder->price, $product->taxRate->value), 3) ;
}
else {
$productOrder->price = $product->price;
}
$productOrder->id_tax_rate = $product->taxRate->id;
}
}

+ 7
- 0
backend/views/distribution/index.php Переглянути файл

@@ -580,6 +580,7 @@ $this->setPageTitle('Distributions') ;
<tr>
<th></th>
<th>Nom</th>
<th>Prix unitaire</th>
<th>Quantité</th>
<th>Reste</th>
</tr>
@@ -591,6 +592,12 @@ $this->setPageTitle('Distributions') ;
<span class="label label-danger" v-else>Inactif</span>
</td>
<td>{{ product.name }}</td>
<td class="price">
<div class="input-group">
<input type="text" v-model="order.productOrder[product.id].price" class="form-control" @change="productPriceChange" :data-id-product="product.id" />
<span class="input-group-addon" id="basic-addon2">€ TTC</span>
</div>
</td>
<td class="quantity">
<div class="input-group">
<span class="input-group-btn">

+ 31
- 19
backend/web/css/screen.css Переглянути файл

@@ -2127,20 +2127,28 @@ termes.
font-weight: bold;
}
/* line 351, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price {
width: 150px;
}
/* line 353, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price input {
text-align: center;
}
/* line 358, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity {
width: 165px;
}
/* line 354, ../sass/distribution/_index.scss */
/* line 361, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center;
color: black;
}
/* line 359, ../sass/distribution/_index.scss */
/* line 366, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .form-control {
border-right: 0px none;
padding-right: 4px;
}
/* line 364, ../sass/distribution/_index.scss */
/* line 371, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -2148,35 +2156,35 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 373, ../sass/distribution/_index.scss */
/* line 380, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right;
}
/* line 376, ../sass/distribution/_index.scss */
/* line 383, ../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 380, ../sass/distribution/_index.scss */
/* line 387, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.negative {
color: #DD4B39;
}
/* line 384, ../sass/distribution/_index.scss */
/* line 391, ../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 391, ../sass/distribution/_index.scss */
/* line 398, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button {
margin-left: 15px;
}
/* line 399, ../sass/distribution/_index.scss */
/* line 406, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon {
width: 50px;
}
/* line 402, ../sass/distribution/_index.scss */
/* line 409, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px;
}
/* line 407, ../sass/distribution/_index.scss */
/* line 414, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px;
}
@@ -2440,41 +2448,45 @@ termes.
width: 50px;
height: 52px;
}
/* line 76, ../sass/_responsive.scss */
/* line 67, ../sass/_responsive.scss */
.distribution-index .modal-form-order .modal-container .modal-body table.table-products td.price {
display: none;
}
/* line 79, ../sass/_responsive.scss */
.distribution-index #orders #buttons-top-orders .left {
width: 100%;
float: none;
}
/* line 80, ../sass/_responsive.scss */
/* line 83, ../sass/_responsive.scss */
.distribution-index #orders #buttons-top-orders .right {
width: 100%;
float: none;
}
/* line 85, ../sass/_responsive.scss */
/* line 88, ../sass/_responsive.scss */
.distribution-index #orders #buttons-top-orders .btn {
padding: 8px 15px;
margin: 10px;
display: block;
width: 100%;
}
/* line 95, ../sass/_responsive.scss */
/* line 98, ../sass/_responsive.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li {
float: none;
width: 100%;
}
/* line 98, ../sass/_responsive.scss */
/* line 101, ../sass/_responsive.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li a {
display: block;
}
/* line 107, ../sass/_responsive.scss */
/* line 110, ../sass/_responsive.scss */
.distribution-index #orders table ul.dropdown-menu a {
padding: 15px;
}
/* line 111, ../sass/_responsive.scss */
/* line 114, ../sass/_responsive.scss */
.distribution-index #orders table button {
padding: 15px;
}
/* line 116, ../sass/_responsive.scss */
/* line 119, ../sass/_responsive.scss */
.distribution-index #orders table .column-origin,
.distribution-index #orders table .column-point-sale,
.distribution-index #orders table .column-state-payment,

+ 18
- 1
backend/web/js/vuejs/distribution-index.js Переглянути файл

@@ -613,9 +613,26 @@ Vue.component('order-form',{
}
if(parseFloat(this.order.productOrder[id_product].quantity) + quantity >= 0) {
var theQuantity = parseFloat(this.order.productOrder[id_product].quantity) + parseFloat(quantity) ;
Vue.set(this.order.productOrder, id_product, {quantity: theQuantity, unit: this.order.productOrder[id_product].unit});
Vue.set(this.order.productOrder, id_product, {
quantity: theQuantity,
unit: this.order.productOrder[id_product].unit,
price: this.order.productOrder[id_product].price
});
}
},
productPriceChange: function(event) {
var idProduct = event.currentTarget.getAttribute('data-id-product') ;
var price = parseFloat(event.currentTarget.value) ;
if(isNaN(price)) {
price = 0 ;
}

Vue.set(this.order.productOrder, idProduct, {
quantity: this.order.productOrder[idProduct].quantity,
unit: this.order.productOrder[idProduct].unit,
price: price
});
},
userChange: function(event) {
var app = this ;
axios.get(UrlManager.getBaseUrlAbsolute()+"distribution/ajax-point-sale-favorite",{params: {

+ 3
- 0
backend/web/sass/_responsive.scss Переглянути файл

@@ -64,6 +64,9 @@ termes.
height: 52px;
}
}
td.price {
display: none ;
}
}

}

+ 7
- 0
backend/web/sass/distribution/_index.scss Переглянути файл

@@ -348,6 +348,13 @@ termes.
}
}

td.price {
width: 150px ;
input {
text-align: center ;
}
}

td.quantity {
width: 165px;


Завантаження…
Відмінити
Зберегти