Merge branch 'split_bill' of bitbucket.org:code2lab/sxrestaurant into quick_service

This commit is contained in:
Aung Myo
2018-02-22 09:39:54 +06:30
13 changed files with 92 additions and 166 deletions

View File

@@ -464,12 +464,12 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% end %>
<!-- Cashier Buttons -->

View File

@@ -59,7 +59,8 @@
</td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
</td>
<td class="p-1" width="10%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
@@ -166,21 +167,27 @@ var cashier_type = "<%= @cashier_type %>";
var sale_item_id = $(this).attr('data-id');
var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
swal({
title: "Information!",
text: "Qty and Price was successfully Updated",
}, function () {
location.reload();
});
}
});
console.log(qty + "|" + price);
if(qty > 0){
$('#' + sale_item_id + "_qtyErr").html("");
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
swal({
title: "Information!",
text: "Qty and Price was successfully Updated",
}, function () {
location.reload();
});
}
});
}else{
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
}
});
$('.void').on('click', function () {
@@ -311,4 +318,20 @@ var cashier_type = "<%= @cashier_type %>";
return false;
}
});
//check for isNumber
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
function checkQuantity(obj_value,sale_item_id) {
if(obj_value == '0'){
$("#"+sale_item_id+"_qty").val('1');
}
}
</script>

View File

@@ -318,7 +318,6 @@
<script type="text/javascript">
var split_sale_id = "";
var split_receipt_no = "";
var split_total_amount = 0;
$(document).ready(function(){
$('#back').on('click',function(){
backToOrigami();
@@ -396,7 +395,7 @@
// orderItemSplitBillProcess(cnt_items);
// }
}else{
swal("Opps","Please select at least one item!","warning");
swal("Oops","Please select at least one item!","warning");
}
});
@@ -460,7 +459,7 @@
// orderSplitBillProcess(cnt_odrs);
// }
}else{
swal("Opps","Please select at least one order!","warning");
swal("Oops","Please select at least one order!","warning");
}
});
@@ -476,28 +475,12 @@
var dining_id = $("#table_id").text();
split_sale_id = $("input[type='radio'][name='rdn_receipt']:checked").val();
split_receipt_no = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('id');
split_total_amount = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('data');
$.ajax({
type: "POST",
url: "/origami/split_bills/get_survey",
dataType: 'JSON',
data: {'dining_id':dining_id, 'receipt_no':split_receipt_no },
success: function (result) {
if(result.status){
if(parseInt(result.survey.total_customer) > 0){
$("#per_person").val(parseInt(result.survey.total_customer));
}else{
$("#per_person").val("");
}
}
}
});
if(split_sale_id != undefined && split_sale_id != ""){
$('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true});
}
else{
swal("Opps","Please select one receipt!","warning");
swal("Oops","Please select one receipt!","warning");
}
});
@@ -508,15 +491,15 @@
$("#per_personErr").html('');
$('#equal_split_modal').modal('hide');
if(person > 1){
var ajax_url = "/origami/split_bills/surveys";
var dining_id = $("#table_id").text();
var ajax_url = "/origami/split_bills/equal_person";
var dining_id = $("#table_id").text();
var type = $("#table_type").text();
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id':dining_id, 'sale_id':split_sale_id, 'receipt_no':split_receipt_no, 'total_customer': person, 'total_amount':split_total_amount },
data: { 'sale_id':split_sale_id, 'total_customer': person },
success: function (result) {
console.log(result);
if(result.status){