Sfoglia il codice sorgente

[Producer] Prix dégressifs : affichage des prix suivant quantités #266

refactoring
Guillaume 2 anni fa
parent
commit
f5b493ed8e
6 ha cambiato i file con 93 aggiunte e 22 eliminazioni
  1. +12
    -0
      common/models/Product.php
  2. +2
    -0
      producer/controllers/OrderController.php
  3. +11
    -1
      producer/views/order/order.php
  4. +36
    -20
      producer/web/css/screen.css
  5. +11
    -0
      producer/web/js/vuejs/order-order.js
  6. +21
    -1
      producer/web/sass/order/_order.scss

+ 12
- 0
common/models/Product.php Vedi File

@@ -421,6 +421,18 @@ class Product extends ActiveRecordCommon
'price_with_tax' => $this->getPriceWithTax(),
];

usort($priceArray, function($a, $b) {
if($a['price_with_tax'] < $b['price_with_tax']) {
return 1;
}
elseif($a['price_with_tax'] > $b['price_with_tax']) {
return -1;
}
else {
return 0;
}
});

return $priceArray;
}


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

@@ -857,6 +857,8 @@ class OrderController extends ProducerBaseController
$quantityOrder = Order::getProductQuantity($product['id'], $ordersArray);
$product['quantity_ordered'] = $quantityOrder;
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder;
$product['wording_unit'] = Product::strUnit($product['unit'], 'wording_unit', true);
$product['wording_unit_ref'] = Product::strUnit($product['unit'], 'wording_short', true);

if ($orderUser) {
$quantityOrderUser = Order::getProductQuantity($product['id'], [$orderUser], true);

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

@@ -304,7 +304,17 @@ $producer = GlobalParam::getCurrentProducer() ;
</td>
<td class="price-unit">
<template v-if="productHasPrice(product)">
{{ formatPrice(getBestProductPrice(product.id, product.quantity_form)) }}<br /><span class="unit">{{ product.wording_unit }}</span>
<div>
{{ formatPrice(getBestProductPrice(product.id, product.quantity_form)) }}<br />
<span class="unit">{{ product.wording_unit }}</span>
</div>
<div v-if="productHasPriceWithFromQuantity(product)" class="alert alert-info decreasing-prices">
<ul>
<li v-for="price in product.prices" v-if="price.from_quantity > 0">
<strong>{{ formatPrice(price.price_with_tax) }}</strong><br />à partir de {{ price.from_quantity }} {{ product.wording_unit_ref }}
</li>
</ul>
</div>
</template>
</td>
<td class="td-quantity">

+ 36
- 20
producer/web/css/screen.css Vedi File

@@ -1548,26 +1548,42 @@ termes.
.order-order #main #app-order-order table#products td.name .recipe {
color: gray;
}
/* line 284, ../sass/order/_order.scss */
/* line 286, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .price-unit .decreasing-prices {
margin-top: 10px;
font-size: 10px;
padding-top: 6px;
padding-bottom: 2px;
margin-bottom: 0px;
}
/* line 294, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .price-unit .decreasing-prices ul li {
margin-bottom: 5px;
}
/* line 296, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .price-unit .decreasing-prices ul li strong {
font-weight: bold;
}
/* line 304, ../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;
width: 120px;
text-align: center;
}
/* line 288, ../sass/order/_order.scss */
/* line 308, ../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 293, ../sass/order/_order.scss */
/* line 313, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity {
width: 175px;
}
/* line 295, ../sass/order/_order.scss */
/* line 315, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity input.quantity {
text-align: center;
border-right: 0px none;
}
/* line 299, ../sass/order/_order.scss */
/* line 319, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products .td-quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -1575,69 +1591,69 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 310, ../sass/order/_order.scss */
/* line 330, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary h3 {
margin-top: 0px;
font-family: "capsuularegular";
text-transform: none;
margin-bottom: 5px;
}
/* line 317, ../sass/order/_order.scss */
/* line 337, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul {
margin-bottom: 15px;
padding-left: 20px;
font-size: 23px;
}
/* line 324, ../sass/order/_order.scss */
/* line 344, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul li .quantity {
font-size: 18px;
}
/* line 328, ../sass/order/_order.scss */
/* line 348, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul li .name {
font-family: "capsuularegular";
font-size: 24px;
}
/* line 332, ../sass/order/_order.scss */
/* line 352, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .summary ul li .other {
font-family: "arial";
font-size: 14px;
}
/* line 339, ../sass/order/_order.scss */
/* line 359, ../sass/order/_order.scss */
.order-order #main #app-order-order table#products tr.total .price-total {
font-size: 23px;
}
/* line 347, ../sass/order/_order.scss */
/* line 367, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .delivery {
margin-bottom: 20px;
}
/* line 350, ../sass/order/_order.scss */
/* line 370, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .delivery .delivery-home {
margin-bottom: 20px;
}
/* line 359, ../sass/order/_order.scss */
/* line 379, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .comment {
margin-bottom: 20px;
}
/* line 364, ../sass/order/_order.scss */
/* line 384, ../sass/order/_order.scss */
.order-order #main #app-order-order #content-step-payment .credit .info {
margin-left: 20px;
color: gray;
}
/* line 371, ../sass/order/_order.scss */
/* line 391, ../sass/order/_order.scss */
.order-order #main #app-order-order #specific-delays {
margin-top: 15px;
}
/* line 379, ../sass/order/_order.scss */
/* line 399, ../sass/order/_order.scss */
.order-order #main #app-order-order #infos {
margin-top: 30px;
}
/* line 381, ../sass/order/_order.scss */
/* line 401, ../sass/order/_order.scss */
.order-order #main #app-order-order #infos .panel-body {
padding-top: 0px;
white-space: pre-line;
}

/* line 391, ../sass/order/_order.scss */
/* line 411, ../sass/order/_order.scss */
#main #content .panel h3 {
font-family: "highvoltageregular";
margin: 0px;

+ 11
- 0
producer/web/js/vuejs/order-order.js Vedi File

@@ -478,6 +478,17 @@ var app = new Vue({
productHasPrice: function(product) {
return product.prices && product.prices.length > 0;
},
productHasPriceWithFromQuantity: function(product) {
if(this.productHasPrice(product)) {
for(var i = 0; i < product.prices.length; i++) {
if(product.prices[i].from_quantity > 0) {
return true;
}
}
}

return false;
},
getBestProductPrice: function(idProduct, theQuantity) {
var thePriceWithTax = 9999;
var product = this.getProduct(idProduct);

+ 21
- 1
producer/web/sass/order/_order.scss Vedi File

@@ -281,8 +281,28 @@
color: gray ;
}
}

.price-unit {
.decreasing-prices {
margin-top: 10px;
font-size: 10px;
padding-top: 6px;
padding-bottom: 2px;
margin-bottom: 0px;

ul {
li {
margin-bottom: 5px;
strong {
font-weight: bold;
}
}
}
}
}

.price-unit, .price-total {
width: 100px ;
width: 120px ;
text-align: center ;
.unit {

Loading…
Annulla
Salva