Browse Source

[Boutique] Gestion des accessoires

feature/rotating_product
Guillaume Bourgeois 4 months ago
parent
commit
c3517b8736
3 changed files with 26 additions and 8 deletions
  1. +2
    -1
      domain/Order/Order/OrderResolver.php
  2. +1
    -1
      producer/views/order/order.php
  3. +23
    -6
      producer/web/js/vuejs/order-order.js

+ 2
- 1
domain/Order/Order/OrderResolver.php View File



public function getProductQuantityMaxOrderable(Product $product, Distribution $distribution, Order $orderCurrent = null): ?float public function getProductQuantityMaxOrderable(Product $product, Distribution $distribution, Order $orderCurrent = null): ?float
{ {
return $this->getProductQuantityRemaining($product, $distribution, $orderCurrent, true);
return $this->orderSolver->getProductQuantity($product, $orderCurrent ? [$orderCurrent] : [])
+ $this->getProductQuantityRemaining($product, $distribution, $orderCurrent);
} }


public function getQuantityOfAccessoryAvailableInDistribution( public function getQuantityOfAccessoryAvailableInDistribution(

+ 1
- 1
producer/views/order/order.php View File

<button class="btn btn-secondary btn-plus" <button class="btn btn-secondary btn-plus"
type="button" type="button"
@click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))" @click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))"
:disabled="product.quantity_remaining <= 0 || product.quantity_form >= product.quantity_max || loadingProducts">
:disabled="loadingProducts || product.quantity_remaining <= 0 || product.quantity_form >= product.quantity_max * product.coefficient_unit">
<i class="bi bi-plus-lg"></i></button> <i class="bi bi-plus-lg"></i></button>
</span> </span>
</div> </div>

+ 23
- 6
producer/web/js/vuejs/order-order.js View File

data() { data() {
return Object.assign({ return Object.assign({
order: null, order: null,
timerAjaxInfosProducts: false,
xhr: false,
loading: false, loading: false,
loadingProducts: false, loadingProducts: false,
loadingInit: true, loadingInit: true,
var app = this ; var app = this ;


if(loadingProducts) { if(loadingProducts) {
if(app.cancelTokenSource !== null) {
app.cancelTokenSource.cancel();
if (app.timerAjaxInfosProducts) {
clearTimeout(app.timerAjaxInfosProducts);
} }
app.timerAjaxInfosProducts = setTimeout(function(app) {
app.loadingProducts = true ;
if(app.xhr) {
app.xhr.abort();
}
app.xhr = $.get('ajax-infos', {
date : app.getDate(),
pointSaleId: app.pointSaleActiveId ? app.pointSaleActiveId : (app.pointSaleActive ? app.pointSaleActive.id : 0),
productsJson: JSON.stringify(app.getProductsArray()),
loadingProducts: loadingProducts
}, function(response) {
app.products = response.products;
app.loadingProducts = false;
}, 'json');
}.bind(this, app), 300);

return;
} }
else { else {
this.loading = true ; this.loading = true ;
app.products = [] ; app.products = [] ;
} }


app.cancelTokenSource = axios.CancelToken.source();
//app.cancelTokenSource = axios.CancelToken.source();
axios.get("ajax-infos",{ axios.get("ajax-infos",{
cancelToken: app.cancelTokenSource.token,
//cancelToken: app.cancelTokenSource.token,
params: { params: {
date : this.getDate(), date : this.getDate(),
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0), pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0),
}}) }})
.catch(function (thrown) { .catch(function (thrown) {
if (axios.isCancel(thrown)) { if (axios.isCancel(thrown)) {
//console.log('Request canceled', thrown.message);
//return Promise.reject(thrown);
} }
}) })
.then(function(response) { .then(function(response) {

Loading…
Cancel
Save