|
|
@@ -8,6 +8,7 @@ var app = new Vue({ |
|
|
|
loading: false, |
|
|
|
loadingProducts: false, |
|
|
|
loadingInit: true, |
|
|
|
cancelTokenSource: null, |
|
|
|
step: null, |
|
|
|
producer: null, |
|
|
|
user: null, |
|
|
@@ -131,7 +132,9 @@ var app = new Vue({ |
|
|
|
var app = this ; |
|
|
|
|
|
|
|
if(loadingProducts) { |
|
|
|
this.loadingProducts = true ; |
|
|
|
if(app.cancelTokenSource !== null) { |
|
|
|
app.cancelTokenSource.cancel(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
this.loading = true ; |
|
|
@@ -142,201 +145,207 @@ var app = new Vue({ |
|
|
|
app.products = [] ; |
|
|
|
} |
|
|
|
|
|
|
|
axios.get("ajax-infos",{params: { |
|
|
|
date : this.getDate(), |
|
|
|
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0), |
|
|
|
productsJson: this.getProductsArray(), |
|
|
|
loadingProducts: loadingProducts |
|
|
|
app.cancelTokenSource = axios.CancelToken.source(); |
|
|
|
axios.get("ajax-infos",{ |
|
|
|
cancelToken: app.cancelTokenSource.token, |
|
|
|
params: { |
|
|
|
date : this.getDate(), |
|
|
|
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0), |
|
|
|
productsJson: this.getProductsArray(), |
|
|
|
loadingProducts: loadingProducts |
|
|
|
}}) |
|
|
|
.catch(function (thrown) { |
|
|
|
if (axios.isCancel(thrown)) { |
|
|
|
//console.log('Request canceled', thrown.message); |
|
|
|
//return Promise.reject(thrown); |
|
|
|
} |
|
|
|
}) |
|
|
|
.then(function(response) { |
|
|
|
app.calendar.attrs = []; |
|
|
|
app.calendar.availableDates = []; |
|
|
|
|
|
|
|
var distributions = response.data.distributions; |
|
|
|
app.distributions = distributions; |
|
|
|
if (distributions.length) { |
|
|
|
var arrayDate; |
|
|
|
var highlightStyle = { |
|
|
|
style: { |
|
|
|
background: 'white', |
|
|
|
border: 'solid 2px #198754' |
|
|
|
}, |
|
|
|
contentStyle: { |
|
|
|
color: '#198754' |
|
|
|
} |
|
|
|
}; |
|
|
|
for (var i = 0; i < distributions.length; i++) { |
|
|
|
app.calendar.attrs.push({ |
|
|
|
highlight: highlightStyle, |
|
|
|
dates: distributions[i].date |
|
|
|
}); |
|
|
|
if(response) { |
|
|
|
app.calendar.attrs = []; |
|
|
|
app.calendar.availableDates = []; |
|
|
|
|
|
|
|
var distributions = response.data.distributions; |
|
|
|
app.distributions = distributions; |
|
|
|
if (distributions.length) { |
|
|
|
var arrayDate; |
|
|
|
var highlightStyle = { |
|
|
|
style: { |
|
|
|
background: 'white', |
|
|
|
border: 'solid 2px #198754' |
|
|
|
}, |
|
|
|
contentStyle: { |
|
|
|
color: '#198754' |
|
|
|
} |
|
|
|
}; |
|
|
|
for (var i = 0; i < distributions.length; i++) { |
|
|
|
app.calendar.attrs.push({ |
|
|
|
highlight: highlightStyle, |
|
|
|
dates: distributions[i].date |
|
|
|
}); |
|
|
|
|
|
|
|
arrayDate = distributions[i].date.split('-'); |
|
|
|
app.calendar.availableDates.push({ |
|
|
|
highlight: highlightStyle, |
|
|
|
start: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]), |
|
|
|
end: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]) |
|
|
|
}); |
|
|
|
arrayDate = distributions[i].date.split('-'); |
|
|
|
app.calendar.availableDates.push({ |
|
|
|
highlight: highlightStyle, |
|
|
|
start: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]), |
|
|
|
end: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(response.data.leave_period) { |
|
|
|
leavePeriodStartDateArray = response.data.leave_period.start.split('-'); |
|
|
|
leavePeriodEndDateArray = response.data.leave_period.end.split('-'); |
|
|
|
if (response.data.leave_period) { |
|
|
|
leavePeriodStartDateArray = response.data.leave_period.start.split('-'); |
|
|
|
leavePeriodEndDateArray = response.data.leave_period.end.split('-'); |
|
|
|
|
|
|
|
app.calendar.attrs.push({ |
|
|
|
highlight: { |
|
|
|
style: { |
|
|
|
//background: '#E09F3E' |
|
|
|
background: 'gray' |
|
|
|
app.calendar.attrs.push({ |
|
|
|
highlight: { |
|
|
|
style: { |
|
|
|
//background: '#E09F3E' |
|
|
|
background: 'gray' |
|
|
|
}, |
|
|
|
contentStyle: { |
|
|
|
color: 'white' |
|
|
|
} |
|
|
|
}, |
|
|
|
contentStyle: { |
|
|
|
color: 'white' |
|
|
|
} |
|
|
|
}, |
|
|
|
dates: { |
|
|
|
start: new Date(leavePeriodStartDateArray[0], leavePeriodStartDateArray[1] - 1, leavePeriodStartDateArray[2]), |
|
|
|
end: new Date(leavePeriodEndDateArray[0], leavePeriodEndDateArray[1] - 1, leavePeriodEndDateArray[2]) |
|
|
|
}, |
|
|
|
popover: { |
|
|
|
label: 'En congé', |
|
|
|
hideIndicator: true, |
|
|
|
isInteractive: true |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
dates: { |
|
|
|
start: new Date(leavePeriodStartDateArray[0], leavePeriodStartDateArray[1] - 1, leavePeriodStartDateArray[2]), |
|
|
|
end: new Date(leavePeriodEndDateArray[0], leavePeriodEndDateArray[1] - 1, leavePeriodEndDateArray[2]) |
|
|
|
}, |
|
|
|
popover: { |
|
|
|
label: 'En congé', |
|
|
|
hideIndicator: true, |
|
|
|
isInteractive: true |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if (response.data.distribution) { |
|
|
|
app.distribution = response.data.distribution; |
|
|
|
} |
|
|
|
if (response.data.distribution) { |
|
|
|
app.distribution = response.data.distribution; |
|
|
|
} |
|
|
|
|
|
|
|
var orders = []; |
|
|
|
if (response.data.orders) { |
|
|
|
orders = response.data.orders; |
|
|
|
} |
|
|
|
var orders = []; |
|
|
|
if (response.data.orders) { |
|
|
|
orders = response.data.orders; |
|
|
|
} |
|
|
|
|
|
|
|
if (orders.length) { |
|
|
|
for (var i = 0; i < orders.length; i++) { |
|
|
|
arrayDate = orders[i].date_distribution.split('-'); |
|
|
|
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]); |
|
|
|
if (app.isAvailableDate(dateOrder)) { |
|
|
|
app.calendar.attrs.push({ |
|
|
|
highlight: { |
|
|
|
style: { |
|
|
|
background: '#198754' |
|
|
|
if (orders.length) { |
|
|
|
for (var i = 0; i < orders.length; i++) { |
|
|
|
arrayDate = orders[i].date_distribution.split('-'); |
|
|
|
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]); |
|
|
|
if (app.isAvailableDate(dateOrder)) { |
|
|
|
app.calendar.attrs.push({ |
|
|
|
highlight: { |
|
|
|
style: { |
|
|
|
background: '#198754' |
|
|
|
}, |
|
|
|
contentStyle: { |
|
|
|
color: 'white' |
|
|
|
} |
|
|
|
}, |
|
|
|
contentStyle: { |
|
|
|
color: 'white' |
|
|
|
} |
|
|
|
}, |
|
|
|
popover: { |
|
|
|
label: orders[i].pointSale.name + ' (' + app.formatPrice(orders[i].amount_total)+')', |
|
|
|
hideIndicator: true, |
|
|
|
isInteractive: true |
|
|
|
}, |
|
|
|
dates: orders[i].date_distribution |
|
|
|
}); |
|
|
|
popover: { |
|
|
|
label: orders[i].pointSale.name + ' (' + app.formatPrice(orders[i].amount_total) + ')', |
|
|
|
hideIndicator: true, |
|
|
|
isInteractive: true |
|
|
|
}, |
|
|
|
dates: orders[i].date_distribution |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
app.producer = response.data.producer; |
|
|
|
app.user = response.data.user; |
|
|
|
app.useCredit = response.data.producer.use_credit_checked_default; |
|
|
|
app.producer = response.data.producer; |
|
|
|
app.user = response.data.user; |
|
|
|
app.useCredit = response.data.producer.use_credit_checked_default; |
|
|
|
|
|
|
|
|
|
|
|
if (response.data.points_sale) { |
|
|
|
app.pointsSale = []; |
|
|
|
var orderPointSale = 0; |
|
|
|
for (var key in response.data.points_sale) { |
|
|
|
response.data.points_sale[key].order = orderPointSale++; |
|
|
|
app.pointsSale[response.data.points_sale[key].id] = response.data.points_sale[key]; |
|
|
|
if (response.data.points_sale) { |
|
|
|
app.pointsSale = []; |
|
|
|
var orderPointSale = 0; |
|
|
|
for (var key in response.data.points_sale) { |
|
|
|
response.data.points_sale[key].order = orderPointSale++; |
|
|
|
app.pointsSale[response.data.points_sale[key].id] = response.data.points_sale[key]; |
|
|
|
|
|
|
|
if(!app.pointsSaleCodes[response.data.points_sale[key].id]) { |
|
|
|
app.pointsSaleCodes[response.data.points_sale[key].id] = ''; |
|
|
|
Vue.set(app.pointsSaleCodes, response.data.points_sale[key].id, ''); |
|
|
|
if (!app.pointsSaleCodes[response.data.points_sale[key].id]) { |
|
|
|
app.pointsSaleCodes[response.data.points_sale[key].id] = ''; |
|
|
|
Vue.set(app.pointsSaleCodes, response.data.points_sale[key].id, ''); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(app.pointSaleActiveId) { |
|
|
|
app.pointSaleActive = app.getPointSale(app.pointSaleActiveId); |
|
|
|
} |
|
|
|
|
|
|
|
if(app.pointSaleActive) { |
|
|
|
if(app.producer.credit |
|
|
|
&& app.pointSaleActive.payment_method_credit |
|
|
|
&& (app.pointSaleActive.credit_functioning == 'mandatory' |
|
|
|
|| (app.pointSaleActive.credit_functioning == 'user' && app.user.credit_active) |
|
|
|
|| (app.pointSaleActive.credit_functioning == 'optional' && response.data.producer.use_credit_checked_default))) { |
|
|
|
app.paymentMethod = 'credit'; |
|
|
|
if (app.pointSaleActiveId) { |
|
|
|
app.pointSaleActive = app.getPointSale(app.pointSaleActiveId); |
|
|
|
} |
|
|
|
else if(app.pointSaleActive.payment_method_onsite) { |
|
|
|
app.paymentMethod = 'onsite'; |
|
|
|
|
|
|
|
if (app.pointSaleActive) { |
|
|
|
if (app.producer.credit |
|
|
|
&& app.pointSaleActive.payment_method_credit |
|
|
|
&& (app.pointSaleActive.credit_functioning == 'mandatory' |
|
|
|
|| (app.pointSaleActive.credit_functioning == 'user' && app.user.credit_active) |
|
|
|
|| (app.pointSaleActive.credit_functioning == 'optional' && response.data.producer.use_credit_checked_default))) { |
|
|
|
app.paymentMethod = 'credit'; |
|
|
|
} else if (app.pointSaleActive.payment_method_onsite) { |
|
|
|
app.paymentMethod = 'onsite'; |
|
|
|
} else if (app.pointSaleActive.payment_method_online) { |
|
|
|
app.paymentMethod = 'online'; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(app.pointSaleActive.payment_method_online) { |
|
|
|
app.paymentMethod = 'online'; |
|
|
|
|
|
|
|
if (app.isChangeState('point-sale', 'point-sale', 'date')) { |
|
|
|
app.date = null; |
|
|
|
app.dateFormat = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(app.isChangeState('point-sale', 'point-sale', 'date')) { |
|
|
|
app.date = null ; |
|
|
|
app.dateFormat = null ; |
|
|
|
} |
|
|
|
// update order |
|
|
|
var updateOrder = false; |
|
|
|
if (app.isChangeState('date', 'point-sale', 'products') |
|
|
|
|| app.isChangeState('date', 'date', 'point-sale') |
|
|
|
|| app.isChangeState('point-sale', 'date', 'products') |
|
|
|
|| app.isChangeState('point-sale', 'point-sale', 'date')) { |
|
|
|
|
|
|
|
// update order |
|
|
|
var updateOrder = false ; |
|
|
|
if(app.isChangeState('date', 'point-sale', 'products') |
|
|
|
|| app.isChangeState('date', 'date', 'point-sale') |
|
|
|
|| app.isChangeState('point-sale', 'date', 'products') |
|
|
|
|| app.isChangeState('point-sale', 'point-sale', 'date')) { |
|
|
|
updateOrder = true; |
|
|
|
} |
|
|
|
|
|
|
|
updateOrder = true ; |
|
|
|
} |
|
|
|
if (updateOrder) { |
|
|
|
app.updateOrder(response); |
|
|
|
} |
|
|
|
|
|
|
|
if(updateOrder) { |
|
|
|
app.updateOrder(response); |
|
|
|
} |
|
|
|
if (type == 'first') { |
|
|
|
if (app.getDate() && app.pointSaleActive) { |
|
|
|
app.step = 'products'; |
|
|
|
if (response.data.products) { |
|
|
|
app.products = response.data.products; |
|
|
|
} |
|
|
|
|
|
|
|
if(type == 'first') { |
|
|
|
if(app.getDate() && app.pointSaleActive) { |
|
|
|
app.step = 'products' ; |
|
|
|
if(response.data.products) { |
|
|
|
app.products = response.data.products; |
|
|
|
app.updateOrder(response); |
|
|
|
} else if (app.producer.option_order_entry_point == 'point-sale') { |
|
|
|
app.step = 'point-sale'; |
|
|
|
} else if (app.getDate() && app.producer && app.producer.option_order_entry_point == 'date') { |
|
|
|
app.step = 'point-sale'; |
|
|
|
} else { |
|
|
|
app.step = 'date'; |
|
|
|
} |
|
|
|
|
|
|
|
app.updateOrder(response); |
|
|
|
} |
|
|
|
else if(app.producer.option_order_entry_point == 'point-sale') { |
|
|
|
app.step = 'point-sale' ; |
|
|
|
} |
|
|
|
else if(app.getDate() && app.producer && app.producer.option_order_entry_point == 'date') { |
|
|
|
app.step = 'point-sale' ; |
|
|
|
} |
|
|
|
else { |
|
|
|
app.step = 'date' ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(response.data.categories) { |
|
|
|
app.categories = response.data.categories ; |
|
|
|
for(keyCategory in response.data.categories) { |
|
|
|
var category = response.data.categories[keyCategory]; |
|
|
|
if(category.id && app.countProductsByCategory(category)) { |
|
|
|
app.setCategoryCurrent(category, true) ; |
|
|
|
break; |
|
|
|
if (response.data.categories) { |
|
|
|
app.categories = response.data.categories; |
|
|
|
for (keyCategory in response.data.categories) { |
|
|
|
var category = response.data.categories[keyCategory]; |
|
|
|
if (category.id && app.countProductsByCategory(category)) { |
|
|
|
app.setCategoryCurrent(category, true); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
setTimeout(function() { |
|
|
|
app.responsive(); |
|
|
|
opendistrib_products(); |
|
|
|
}, 500); |
|
|
|
setTimeout(function () { |
|
|
|
app.responsive(); |
|
|
|
opendistrib_products(); |
|
|
|
}, 500); |
|
|
|
|
|
|
|
app.loading = false ; |
|
|
|
app.loadingProducts = false ; |
|
|
|
app.loadingInit = false ; |
|
|
|
app.loading = false; |
|
|
|
app.loadingProducts = false; |
|
|
|
app.loadingInit = false; |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
updateOrder: function(response) { |
|
|
@@ -498,6 +507,7 @@ var app = new Vue({ |
|
|
|
}, |
|
|
|
productQuantityClick: function(product, quantity) { |
|
|
|
if(this.products[product.index].quantity_form + quantity >= 0 |
|
|
|
&& this.products[product.index].quantity_form + quantity <= this.products[product.index].quantity_max * this.products[product.index].coefficient_unit |
|
|
|
&& (quantity <= (this.products[product.index].quantity_remaining * this.products[product.index].coefficient_unit) |
|
|
|
|| this.products[product.index].quantity_remaining == null) |
|
|
|
) { |