|
|
|
|
|
|
|
|
messageGenerateDeliveryNoteDisplayed: false, |
|
|
messageGenerateDeliveryNoteDisplayed: false, |
|
|
missingSubscriptions: false, |
|
|
missingSubscriptions: false, |
|
|
loadingUpdateProductOrder: false, |
|
|
loadingUpdateProductOrder: false, |
|
|
|
|
|
timerAjaxUpdateProductOrder: null, |
|
|
|
|
|
xhr: null, |
|
|
units: [], |
|
|
units: [], |
|
|
calendar: { |
|
|
calendar: { |
|
|
mode: 'single', |
|
|
mode: 'single', |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return JSON.stringify(productOrderArrayRequest); |
|
|
return JSON.stringify(productOrderArrayRequest); |
|
|
}, |
|
|
}, |
|
|
updateProductOrders: function (updatePricesOnUpdateOrder) { |
|
|
|
|
|
|
|
|
updateProductOrders: function (updatePrices) { |
|
|
var app = this; |
|
|
var app = this; |
|
|
app.loadingUpdateProductOrder = true; |
|
|
app.loadingUpdateProductOrder = true; |
|
|
var order = null; |
|
|
var order = null; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (order) { |
|
|
if (order) { |
|
|
axios.get(UrlManager.getBaseUrlAbsolute() + "distribution/ajax-update-product-order", { |
|
|
|
|
|
params: { |
|
|
|
|
|
idDistribution: app.distribution.id, |
|
|
|
|
|
idUser: order.id_user, |
|
|
|
|
|
idPointSale: order.id_point_sale, |
|
|
|
|
|
idOrder: order.id, |
|
|
|
|
|
productOrderFormArray: app.getProductOrderArrayRequest(order) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (app.timerAjaxUpdateProductOrder) { |
|
|
|
|
|
clearTimeout(app.timerAjaxUpdateProductOrder); |
|
|
|
|
|
} |
|
|
|
|
|
app.timerAjaxUpdateProductOrder = setTimeout(function(app) { |
|
|
|
|
|
if(app.xhr) { |
|
|
|
|
|
app.xhr.abort(); |
|
|
} |
|
|
} |
|
|
}) |
|
|
|
|
|
.then(function (response) { |
|
|
|
|
|
if (response.data) { |
|
|
|
|
|
for (idProduct in response.data) { |
|
|
|
|
|
|
|
|
|
|
|
if (app.showModalFormOrderCreate) { |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'quantity_remaining', response.data[idProduct].quantity_remaining); |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'prices', response.data[idProduct].prices); |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'active', response.data[idProduct].active); |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'price', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity, false)); |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'price_with_tax', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity, true)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
app.xhr = $.get(UrlManager.getBaseUrlAbsolute() + "distribution/ajax-update-product-order", { |
|
|
|
|
|
idDistribution: app.distribution.id, |
|
|
|
|
|
idUser: order.id_user, |
|
|
|
|
|
idPointSale: order.id_point_sale, |
|
|
|
|
|
idOrder: order.id, |
|
|
|
|
|
productOrderFormArray: app.getProductOrderArrayRequest(order) |
|
|
|
|
|
}, function (response) { |
|
|
|
|
|
if (response) { |
|
|
|
|
|
for (idProduct in response) { |
|
|
|
|
|
|
|
|
|
|
|
if (app.showModalFormOrderCreate) { |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'quantity_remaining', response[idProduct].quantity_remaining); |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'prices', response[idProduct].prices); |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'active', response[idProduct].active); |
|
|
|
|
|
|
|
|
|
|
|
if(updatePrices) { |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'price', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity, false)); |
|
|
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'price_with_tax', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity, true)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (app.showModalFormOrderUpdate && app.idOrderUpdate) { |
|
|
|
|
|
for (keyOrderUpdate in app.ordersUpdate) { |
|
|
|
|
|
if (order.id == app.idOrderUpdate) { |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'quantity_remaining', response.data[idProduct].quantity_remaining); |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'prices', response.data[idProduct].prices); |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'active', response.data[idProduct].active); |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'invoice_price', response.data[idProduct].invoice_price); |
|
|
|
|
|
|
|
|
|
|
|
if (updatePricesOnUpdateOrder) { |
|
|
|
|
|
Vue.set( |
|
|
|
|
|
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], |
|
|
|
|
|
'price', |
|
|
|
|
|
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, false)); |
|
|
|
|
|
Vue.set( |
|
|
|
|
|
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], |
|
|
|
|
|
'price_with_tax', |
|
|
|
|
|
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, true)); |
|
|
|
|
|
|
|
|
if (app.showModalFormOrderUpdate && app.idOrderUpdate) { |
|
|
|
|
|
for (keyOrderUpdate in app.ordersUpdate) { |
|
|
|
|
|
if (order.id == app.idOrderUpdate) { |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'quantity_remaining', response[idProduct].quantity_remaining); |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'prices', response[idProduct].prices); |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'active', response[idProduct].active); |
|
|
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'invoice_price', response[idProduct].invoice_price); |
|
|
|
|
|
|
|
|
|
|
|
if (updatePrices) { |
|
|
|
|
|
Vue.set( |
|
|
|
|
|
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], |
|
|
|
|
|
'price', |
|
|
|
|
|
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, false)); |
|
|
|
|
|
Vue.set( |
|
|
|
|
|
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], |
|
|
|
|
|
'price_with_tax', |
|
|
|
|
|
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, true)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (updatePricesOnUpdateOrder) { |
|
|
|
|
|
appAlerts.alert('info', 'Prix rechargés'); |
|
|
|
|
|
|
|
|
if (updatePrices) { |
|
|
|
|
|
appAlerts.alert('info', 'Prix rechargés'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
app.loadingUpdateProductOrder = false; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
app.loadingUpdateProductOrder = false; |
|
|
|
|
|
}, 'json'); |
|
|
|
|
|
}.bind(this, app), 300); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
updateInvoicePrices: function () { |
|
|
updateInvoicePrices: function () { |