Merge branch 'adminbsb_material_ui' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-12-22 17:51:43 +06:30
4 changed files with 114 additions and 69 deletions

View File

@@ -145,30 +145,45 @@ $(document).on('turbolinks:load', function() {
});
/* start check first bill or not funs: */
function checkReceiptNoInFirstBillData(receipt_no) {
function checkReceiptNoInFirstBillData(receipt_no,payment=null) {
// localStorage.removeItem('receipt_lists');
var status = false;
if((receipt_no!=undefined) && (receipt_no!="")){
if(localStorage.hasOwnProperty("receipt_lists")===true){
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
console.log(arr_data)
if (payment) {
var json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
}else{
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
}
if((arr_data.length) > (json_data.length)){
status = true;
}
}
}
if (payment) {
return json_data[0]["payment"];
}else{
return status;
}
}
function createReceiptNoInFirstBillData(receipt_no) {
function createReceiptNoInFirstBillData(receipt_no,payment=null) {
var arr_data = [];
var json_data = [];
if(localStorage.hasOwnProperty("receipt_lists")===true){
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
if (payment) {
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
jdata.push({'receipt_no':receipt_no,'payment':payment});
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
}
}
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
arr_data.push({'receipt_no':receipt_no});
arr_data.push({'receipt_no':receipt_no,'payment':payment});
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
}
}

View File

@@ -596,7 +596,7 @@
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no);
createReceiptNoInFirstBillData(receipt_no,type);
location.reload();
}

View File

@@ -290,6 +290,21 @@
<script>
$(document).ready(function(){
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
if(payment_type=="Cash"){
$("#card_payment").hide();
$("#credit_payment").hide();
}else if(payment_type=="Credit"){
$("#card_payment").hide();
}
/* end check first bill or not*/
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
$("#back").on('click', function() {
@@ -380,9 +395,22 @@
});
$('#pay').click(function() {
// $('#pay').text("Processing, Please wait!")
$( "#loading_wrapper").show();
sub_total = $('#sub-total').text();
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
swal("Opps","Please Pay with MPU Payment","warning")
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Redeem Payment","warning")
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Visa Payment","warning")
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with jcb Payment","warning")
}
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Master Payment","warning")
}else{
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops" , "Insufficient Amount!" , "error" );
$( "#loading_wrapper").hide();
@@ -447,6 +475,7 @@
}
});
}
}
});
$('#void').on('click',function () {

View File

@@ -356,6 +356,7 @@
<!-- <button type="button" class="btn bg-blue btn-block" disabled >Edit</button> -->
<!-- <button type="button" id="discount" class="btn bg-blue btn-block" disabled >Discount</button> -->
<!-- <button type="button" id="other-charges" class="btn bg-blue btn-block" disabled>Charges</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<button type="button" class="btn bg-blue btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn bg-blue btn-block">Req.Bill</button>
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
@@ -607,7 +608,7 @@ $(".choose_payment").on('click', function () {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no);
createReceiptNoInFirstBillData(receipt_no,type);
location.reload();
}