|
|
|
|
|
|
|
|
return false ; |
|
|
return false ; |
|
|
}, |
|
|
}, |
|
|
init: function(idActivePointSale) { |
|
|
init: function(idActivePointSale) { |
|
|
|
|
|
var app = this ; |
|
|
this.showLoading = true ; |
|
|
this.showLoading = true ; |
|
|
|
|
|
|
|
|
axios.get("ajax-infos",{params: {date : this.getDate()}}) |
|
|
axios.get("ajax-infos",{params: {date : this.getDate()}}) |
|
|
.then(response => { |
|
|
|
|
|
this.distribution = response.data.distribution ; |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
app.distribution = response.data.distribution ; |
|
|
|
|
|
|
|
|
this.products = response.data.products ; |
|
|
|
|
|
this.initCountActiveProducts() ; |
|
|
|
|
|
|
|
|
app.products = response.data.products ; |
|
|
|
|
|
app.initCountActiveProducts() ; |
|
|
|
|
|
|
|
|
this.oneDistributionWeekActive = response.data.one_distribution_week_active ; |
|
|
|
|
|
|
|
|
app.oneDistributionWeekActive = response.data.one_distribution_week_active ; |
|
|
|
|
|
|
|
|
this.countOrders = 0 ; |
|
|
|
|
|
|
|
|
app.countOrders = 0 ; |
|
|
if(response.data.orders) { |
|
|
if(response.data.orders) { |
|
|
this.orders = response.data.orders ; |
|
|
|
|
|
|
|
|
app.orders = response.data.orders ; |
|
|
|
|
|
|
|
|
for(i=0 ; i < this.orders.length ; i++) { |
|
|
|
|
|
if(!this.orders[i].date_delete) { |
|
|
|
|
|
this.countOrders ++ ; |
|
|
|
|
|
|
|
|
for(i=0 ; i < app.orders.length ; i++) { |
|
|
|
|
|
if(!app.orders[i].date_delete) { |
|
|
|
|
|
app.countOrders ++ ; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
this.orders = [] ; |
|
|
|
|
|
|
|
|
app.orders = [] ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(response.data.order_create) { |
|
|
if(response.data.order_create) { |
|
|
this.orderCreate = response.data.order_create ; |
|
|
|
|
|
|
|
|
app.orderCreate = response.data.order_create ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(response.data.points_sale) { |
|
|
if(response.data.points_sale) { |
|
|
this.pointsSale = response.data.points_sale ; |
|
|
|
|
|
this.initPointsSale(idActivePointSale) ; |
|
|
|
|
|
|
|
|
app.pointsSale = response.data.points_sale ; |
|
|
|
|
|
app.initPointsSale(idActivePointSale) ; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
this.pointsSale = [] ; |
|
|
|
|
|
|
|
|
app.pointsSale = [] ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(response.data.users) { |
|
|
if(response.data.users) { |
|
|
this.users = response.data.users ; |
|
|
|
|
|
|
|
|
app.users = response.data.users ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.calendar.attrs = [] ; |
|
|
|
|
|
|
|
|
app.calendar.attrs = [] ; |
|
|
var distributions = response.data.distributions ; |
|
|
var distributions = response.data.distributions ; |
|
|
if(distributions.length) { |
|
|
if(distributions.length) { |
|
|
for(var i= 0; i < distributions.length; i++) { |
|
|
for(var i= 0; i < distributions.length; i++) { |
|
|
this.calendar.attrs.push({ |
|
|
|
|
|
|
|
|
app.calendar.attrs.push({ |
|
|
highlight: { |
|
|
highlight: { |
|
|
backgroundColor: '#5cb85c', |
|
|
backgroundColor: '#5cb85c', |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.showLoading = false ; |
|
|
|
|
|
|
|
|
app.showLoading = false ; |
|
|
}) ; |
|
|
}) ; |
|
|
}, |
|
|
}, |
|
|
initCountActiveProducts: function() { |
|
|
initCountActiveProducts: function() { |
|
|
|
|
|
|
|
|
idProduct: event.currentTarget.getAttribute('data-id-product'), |
|
|
idProduct: event.currentTarget.getAttribute('data-id-product'), |
|
|
quantityMax: event.currentTarget.value |
|
|
quantityMax: event.currentTarget.value |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
|
|
|
}) ; |
|
|
}) ; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
idProduct: idProduct, |
|
|
idProduct: idProduct, |
|
|
active: activeProduct |
|
|
active: activeProduct |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
|
|
|
}) ; |
|
|
}) ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
idPointSale: idPointSale, |
|
|
idPointSale: idPointSale, |
|
|
delivery: deliveryPointSale |
|
|
delivery: deliveryPointSale |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
|
|
|
}) ; |
|
|
}) ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.initPointsSale() ; |
|
|
this.initPointsSale() ; |
|
|
}, |
|
|
}, |
|
|
activeDistribution: function(event) { |
|
|
activeDistribution: function(event) { |
|
|
|
|
|
var app = this ; |
|
|
axios.get("ajax-process-active-distribution",{params: { |
|
|
axios.get("ajax-process-active-distribution",{params: { |
|
|
idDistribution: this.distribution.id, |
|
|
idDistribution: this.distribution.id, |
|
|
active: event.currentTarget.getAttribute('data-active') |
|
|
active: event.currentTarget.getAttribute('data-active') |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
this.init() ; |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
app.init() ; |
|
|
}) ; |
|
|
}) ; |
|
|
}, |
|
|
}, |
|
|
activeWeekDistribution: function(event) { |
|
|
activeWeekDistribution: function(event) { |
|
|
|
|
|
var app = this ; |
|
|
axios.get("ajax-process-active-week-distribution",{params: { |
|
|
axios.get("ajax-process-active-week-distribution",{params: { |
|
|
date: this.date.getFullYear() + '-' |
|
|
date: this.date.getFullYear() + '-' |
|
|
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '-' |
|
|
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '-' |
|
|
+ ('0' + this.date.getDate()).slice(-2), |
|
|
+ ('0' + this.date.getDate()).slice(-2), |
|
|
active: event.currentTarget.getAttribute('data-active') |
|
|
active: event.currentTarget.getAttribute('data-active') |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
this.init() ; |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
app.init() ; |
|
|
}) ; |
|
|
}) ; |
|
|
}, |
|
|
}, |
|
|
pointSaleClick: function(event) { |
|
|
pointSaleClick: function(event) { |
|
|
|
|
|
|
|
|
this.init(this.idActivePointSale) ; |
|
|
this.init(this.idActivePointSale) ; |
|
|
}, |
|
|
}, |
|
|
deleteOrderClick: function(event) { |
|
|
deleteOrderClick: function(event) { |
|
|
|
|
|
var app = this ; |
|
|
var idOrder = event.currentTarget.getAttribute('data-id-order') ; |
|
|
var idOrder = event.currentTarget.getAttribute('data-id-order') ; |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-delete",{params: { |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-delete",{params: { |
|
|
idOrder: idOrder |
|
|
idOrder: idOrder |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
this.init(this.idActivePointSale) ; |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
app.init(app.idActivePointSale) ; |
|
|
}) ; |
|
|
}) ; |
|
|
}, |
|
|
}, |
|
|
updateOrderClick: function(event) { |
|
|
updateOrderClick: function(event) { |
|
|
|
|
|
|
|
|
this.showModalPayment = true ; |
|
|
this.showModalPayment = true ; |
|
|
}, |
|
|
}, |
|
|
orderPaymentClick: function(event) { |
|
|
orderPaymentClick: function(event) { |
|
|
|
|
|
var app = this ; |
|
|
var idOrder = event.currentTarget.getAttribute('data-id-order') ; |
|
|
var idOrder = event.currentTarget.getAttribute('data-id-order') ; |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-payment",{params: { |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-payment",{params: { |
|
|
idOrder: this.idOrderPayment, |
|
|
idOrder: this.idOrderPayment, |
|
|
type: event.currentTarget.getAttribute('data-type'), |
|
|
type: event.currentTarget.getAttribute('data-type'), |
|
|
amount: event.currentTarget.getAttribute('data-amount') |
|
|
amount: event.currentTarget.getAttribute('data-amount') |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
this.init(this.idActivePointSale) ; |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
app.init(app.idActivePointSale) ; |
|
|
}) ; |
|
|
}) ; |
|
|
}, |
|
|
}, |
|
|
orderViewClick: function(event) { |
|
|
orderViewClick: function(event) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
submitFormCreate: function() { |
|
|
submitFormCreate: function() { |
|
|
|
|
|
var app = this ; |
|
|
if(this.checkForm()) { |
|
|
if(this.checkForm()) { |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-create",{params: { |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-create",{params: { |
|
|
date: this.date.getFullYear() + '-' |
|
|
date: this.date.getFullYear() + '-' |
|
|
|
|
|
|
|
|
products: JSON.stringify(this.order.productOrder), |
|
|
products: JSON.stringify(this.order.productOrder), |
|
|
comment: this.order.comment |
|
|
comment: this.order.comment |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
this.order.id_point_sale = 0 ; |
|
|
|
|
|
this.order.id_user = 0 ; |
|
|
|
|
|
this.order.username = '' ; |
|
|
|
|
|
this.order.comment = '' ; |
|
|
|
|
|
for(i=0 ; i<this.order.productOrder.length ; i++) { |
|
|
|
|
|
this.order.productOrder[i] = 0 ; |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
app.order.id_point_sale = 0 ; |
|
|
|
|
|
app.order.id_user = 0 ; |
|
|
|
|
|
app.order.username = '' ; |
|
|
|
|
|
app.order.comment = '' ; |
|
|
|
|
|
for(i=0 ; i<app.order.productOrder.length ; i++) { |
|
|
|
|
|
app.order.productOrder[i] = 0 ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.$emit('ordercreatedupdated') ; |
|
|
|
|
|
|
|
|
app.$emit('ordercreatedupdated') ; |
|
|
}) ; |
|
|
}) ; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
submitFormUpdate: function() { |
|
|
submitFormUpdate: function() { |
|
|
|
|
|
var app = this ; |
|
|
if(this.checkForm()) { |
|
|
if(this.checkForm()) { |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-update",{params: { |
|
|
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-update",{params: { |
|
|
date: this.date.getFullYear() + '-' |
|
|
date: this.date.getFullYear() + '-' |
|
|
|
|
|
|
|
|
products: JSON.stringify(this.order.productOrder), |
|
|
products: JSON.stringify(this.order.productOrder), |
|
|
comment: this.comment |
|
|
comment: this.comment |
|
|
}}) |
|
|
}}) |
|
|
.then(response => { |
|
|
|
|
|
this.$emit('ordercreatedupdated') ; |
|
|
|
|
|
|
|
|
.then(function(response) { |
|
|
|
|
|
app.$emit('ordercreatedupdated') ; |
|
|
}) ; |
|
|
}) ; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |