UI for credit payment
This commit is contained in:
@@ -63,10 +63,8 @@ $(document).on('turbolinks:load', function() {
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.datetimepicker').bootstrapMaterialDatePicker({
|
||||
format: 'DD-MM-YYYY - HH:mm',
|
||||
clearButton: true,
|
||||
@@ -228,6 +226,11 @@ $(document).on('turbolinks:load', function() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".credit_detail",function(){
|
||||
var sale_payment_id = $(this).attr("data-id");
|
||||
window.location.href = "/origami/cashier/credit_sales/"+sale_payment_id;
|
||||
});
|
||||
});
|
||||
|
||||
/* start check first bill or not funs: */
|
||||
@@ -480,4 +483,90 @@ function getAllMenu(){
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* String format */
|
||||
if (!String.prototype.formatUnicorn) {
|
||||
String.prototype.formatUnicorn=function(){
|
||||
var e=this.toString();
|
||||
if(!arguments.length){
|
||||
return e;
|
||||
}
|
||||
var t=typeof arguments[0],n="string"==t||"number"==t?Array.prototype.slice.call(arguments):arguments[0];
|
||||
for(var i in n){
|
||||
e=e.replace(new RegExp("\\{"+i+"\\}","gi"),n[i]==null?'':n[i]);
|
||||
}
|
||||
return e;
|
||||
};
|
||||
}
|
||||
/* String format */
|
||||
|
||||
//credit sales lists
|
||||
function timeFormat(date){
|
||||
var isPM = date.getHours() >= 12;
|
||||
var isMidday = date.getHours() == 12;
|
||||
var time = [(date.getHours()>10? date.getHours() : '0'+date.getHours()) - (isPM && !isMidday ? 12 : 0),
|
||||
(date.getMinutes()>10? date.getMinutes() : '0'+date.getMinutes()) || '00'].join(':') +
|
||||
(isPM ? ' PM' : ' AM');
|
||||
return time;
|
||||
}
|
||||
|
||||
function getCreditData(){
|
||||
var filter = $("#filter").val();
|
||||
var customer = $("#sel_customer").val();
|
||||
|
||||
var receipt_no = "";
|
||||
var customer_id = "";
|
||||
if((filter!=undefined) && (filter!=null) && (filter!="")){
|
||||
receipt_no = filter;
|
||||
}
|
||||
if((customer!=undefined) && (customer!=null) && (customer!="")){
|
||||
customer_id = customer;
|
||||
}
|
||||
getCreditSales(receipt_no, customer_id);
|
||||
}
|
||||
|
||||
function getCreditSales(filter, customer){
|
||||
$(".tbd_credit_lists").empty();
|
||||
var html_credit_items = $("#html_credit_items").html();
|
||||
var receipt_no = "";
|
||||
var customer_id = "";
|
||||
if((filter!=undefined) && (filter!=null) && (filter!="")){
|
||||
receipt_no = filter;
|
||||
}
|
||||
if((customer!=undefined) && (customer!=null) && (customer!="")){
|
||||
customer_id = customer;
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: {receipt_no: receipt_no, customer_id: customer_id},
|
||||
dataType: 'json',
|
||||
url: "/origami/cashier/credit_sales",
|
||||
success: function(data){
|
||||
// console.log(data);
|
||||
if(data.status){
|
||||
var credit_sales = data.data;
|
||||
// console.log(credit_sales);
|
||||
if(credit_sales.length > 0){
|
||||
for (var i = 0; i < credit_sales.length ; i++) {
|
||||
var sale_date = new Date(credit_sales[i].sale_date);
|
||||
var receipt_date = sale_date.getFullYear() +'-'+ (sale_date.getMonth() > 10 ? sale_date.getMonth() : '0' + sale_date.getMonth()) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate());
|
||||
$('.tbd_credit_lists').append(html_credit_items.formatUnicorn({
|
||||
'key':i,
|
||||
'sale_payment_id':credit_sales[i].sale_payment_id,
|
||||
'receipt_date':receipt_date +" "+timeFormat(sale_date),
|
||||
'receipt_no':credit_sales[i].receipt_no,
|
||||
'cashier_name':credit_sales[i].cashier_name,
|
||||
'customer_name':credit_sales[i].customer_name,
|
||||
'credit_amount':credit_sales[i].payment_amount
|
||||
}));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$(".credit_items").empty();
|
||||
$(".tbd_credit_lists").html(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//End of credit sales function
|
||||
Reference in New Issue
Block a user