Browse Source

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

dev
Guillaume 4 years ago
parent
commit
3344f1475c
7 changed files with 88 additions and 25 deletions
  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 View File

// products // products
$productsArray = Product::find() $productsArray = Product::find()
->orWhere(['id_producer' => GlobalParam::getCurrentProducerId(),]) ->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); $query->andOnCondition('product_distribution.id_distribution = ' . $distribution->id);
}]) }])
->orderBy('product_distribution.active DESC, order ASC') ->orderBy('product_distribution.active DESC, order ASC')
$potentialRevenues += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['price']; $potentialRevenues += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['price'];
$potentialWeight += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['weight'] / 1000; $potentialWeight += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['weight'] / 1000;
} }

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


$json['distribution']['potential_revenues'] = Price::format($potentialRevenues); $json['distribution']['potential_revenues'] = Price::format($potentialRevenues);
$productOrderArray[$productOrder->id_product] = [ $productOrderArray[$productOrder->id_product] = [
'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'], 'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'],
'unit' => $productOrder->unit, 'unit' => $productOrder->unit,
'price' => Price::getPriceWithTax($productOrder->price, $productOrder->taxRate->value)
]; ];
} }


if (!isset($productOrderArray[$product['id']])) { if (!isset($productOrderArray[$product['id']])) {
$productOrderArray[$product['id']] = [ $productOrderArray[$product['id']] = [
'quantity' => 0, 'quantity' => 0,
'unit' => $product['unit']
'unit' => $product['unit'],
'price' => Price::getPriceWithTax($product['price'], $product['taxRate']['value']),
]; ];
} }
} }
foreach ($productsArray as $product) { foreach ($productsArray as $product) {
$productOrderArray[$product['id']] = [ $productOrderArray[$product['id']] = [
'quantity' => 0, 'quantity' => 0,
'unit' => $product['unit']
'unit' => $product['unit'],
'price' => Price::getPriceWithTax($product['price'], $product['taxRate']['value']),
]; ];
} }
$json['order_create'] = [ $json['order_create'] = [

+ 12
- 2
backend/controllers/OrderController.php View File

$productOrder->quantity = $quantity; $productOrder->quantity = $quantity;
$productOrder->unit = $product->unit; $productOrder->unit = $product->unit;
$productOrder->step = $product->step; $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->id_tax_rate = $product->taxRate->id;
$productOrder->save(); $productOrder->save();
} }
$productOrder->quantity = $quantity; $productOrder->quantity = $quantity;
$productOrder->unit = $product->unit; $productOrder->unit = $product->unit;
$productOrder->step = $product->step; $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->id_tax_rate = $product->taxRate->id;
} }
} }

+ 7
- 0
backend/views/distribution/index.php View File

<tr> <tr>
<th></th> <th></th>
<th>Nom</th> <th>Nom</th>
<th>Prix unitaire</th>
<th>Quantité</th> <th>Quantité</th>
<th>Reste</th> <th>Reste</th>
</tr> </tr>
<span class="label label-danger" v-else>Inactif</span> <span class="label label-danger" v-else>Inactif</span>
</td> </td>
<td>{{ product.name }}</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"> <td class="quantity">
<div class="input-group"> <div class="input-group">
<span class="input-group-btn"> <span class="input-group-btn">

+ 31
- 19
backend/web/css/screen.css View File

font-weight: bold; font-weight: bold;
} }
/* line 351, ../sass/distribution/_index.scss */ /* 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 { .distribution-index .modal-form-order table.table-products td.quantity {
width: 165px; 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 { .distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center; text-align: center;
color: black; 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 { .distribution-index .modal-form-order table.table-products td.quantity .form-control {
border-right: 0px none; border-right: 0px none;
padding-right: 4px; 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 { .distribution-index .modal-form-order table.table-products td.quantity .input-group-addon {
padding: 5px; padding: 5px;
padding-left: 0px; padding-left: 0px;
border-left: 0px none; border-left: 0px none;
border-right: 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 { .distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right; 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 { .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; 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 { .distribution-index .modal-form-order table.table-products td.quantity-remaining.negative {
color: #DD4B39; 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 { .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; font-size: 18px;
} }
/* line 391, ../sass/distribution/_index.scss */
/* line 398, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button { .distribution-index .modal-form-order .actions-form button {
margin-left: 15px; margin-left: 15px;
} }
/* line 399, ../sass/distribution/_index.scss */
/* line 406, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon { .distribution-index .modal-payment .info-box .info-box-icon {
width: 50px; width: 50px;
} }
/* line 402, ../sass/distribution/_index.scss */
/* line 409, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i { .distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px; font-size: 30px;
} }
/* line 407, ../sass/distribution/_index.scss */
/* line 414, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content { .distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px; margin-left: 50px;
} }
width: 50px; width: 50px;
height: 52px; 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 { .distribution-index #orders #buttons-top-orders .left {
width: 100%; width: 100%;
float: none; float: none;
} }
/* line 80, ../sass/_responsive.scss */
/* line 83, ../sass/_responsive.scss */
.distribution-index #orders #buttons-top-orders .right { .distribution-index #orders #buttons-top-orders .right {
width: 100%; width: 100%;
float: none; float: none;
} }
/* line 85, ../sass/_responsive.scss */
/* line 88, ../sass/_responsive.scss */
.distribution-index #orders #buttons-top-orders .btn { .distribution-index #orders #buttons-top-orders .btn {
padding: 8px 15px; padding: 8px 15px;
margin: 10px; margin: 10px;
display: block; display: block;
width: 100%; width: 100%;
} }
/* line 95, ../sass/_responsive.scss */
/* line 98, ../sass/_responsive.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li { .distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li {
float: none; float: none;
width: 100%; 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 { .distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li a {
display: block; display: block;
} }
/* line 107, ../sass/_responsive.scss */
/* line 110, ../sass/_responsive.scss */
.distribution-index #orders table ul.dropdown-menu a { .distribution-index #orders table ul.dropdown-menu a {
padding: 15px; padding: 15px;
} }
/* line 111, ../sass/_responsive.scss */
/* line 114, ../sass/_responsive.scss */
.distribution-index #orders table button { .distribution-index #orders table button {
padding: 15px; padding: 15px;
} }
/* line 116, ../sass/_responsive.scss */
/* line 119, ../sass/_responsive.scss */
.distribution-index #orders table .column-origin, .distribution-index #orders table .column-origin,
.distribution-index #orders table .column-point-sale, .distribution-index #orders table .column-point-sale,
.distribution-index #orders table .column-state-payment, .distribution-index #orders table .column-state-payment,

+ 18
- 1
backend/web/js/vuejs/distribution-index.js View File

} }
if(parseFloat(this.order.productOrder[id_product].quantity) + quantity >= 0) { if(parseFloat(this.order.productOrder[id_product].quantity) + quantity >= 0) {
var theQuantity = parseFloat(this.order.productOrder[id_product].quantity) + parseFloat(quantity) ; 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) { userChange: function(event) {
var app = this ; var app = this ;
axios.get(UrlManager.getBaseUrlAbsolute()+"distribution/ajax-point-sale-favorite",{params: { axios.get(UrlManager.getBaseUrlAbsolute()+"distribution/ajax-point-sale-favorite",{params: {

+ 3
- 0
backend/web/sass/_responsive.scss View File

height: 52px; height: 52px;
} }
} }
td.price {
display: none ;
}
} }


} }

+ 7
- 0
backend/web/sass/distribution/_index.scss View File

} }
} }


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

td.quantity { td.quantity {
width: 165px; width: 165px;



Loading…
Cancel
Save