check order item split process

This commit is contained in:
phyusin
2018-02-16 15:11:16 +06:30
parent 0ddaee7444
commit d459a6e2a3
8 changed files with 199 additions and 81 deletions

View File

@@ -387,14 +387,7 @@
%>
</table>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button class='btn btn-primary waves-effect' id='add_invoice'> Add to existing invoice</button>
<button class='btn btn-primary waves-effect' id='split_bill'> Split Bill</button>
<% else %>
<button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button>
<% end %>
<% end %>
<button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
@@ -412,11 +405,6 @@
<button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show
Detail
</button>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button class='btn btn-sm btn-primary waves-effect' id='split_bill'> Split Bill</button>
<% end %>
<% end %>
</td>
</tr>
</table>
@@ -476,6 +464,11 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<% 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 %>

View File

@@ -241,7 +241,9 @@
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn bg-default btn-block waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<% if !@split_bill.nil? && @split_bill == '1' %>
<button type="button" class="btn bg-blue btn-block waves-effect" id='by_order'>By Order</button>
<% end %>
<% if @sale_status != 'completed' %>
<!-- <button type="button" class="btn bg-blue btn-block" id='move'>MOVE</button> -->
<% end %>
@@ -312,7 +314,7 @@
var order = JSON.parse('<%= @order.to_json.html_safe %>');
var arr_order = [];
arr_order.push({id : order.order_id});
var dining_id = booking[0].dining_facility_id || 0;
var type = booking[0].type || '';
var customer_id = order.customer_id || '';

View File

@@ -364,10 +364,7 @@
end
%>
</table>
<button class='btn bg-primary' id='add_invoice'> Add to existing invoice </button>
<% if !@split_bill.nil? && @split_bill == '1' %>
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
<% end %>
<button class='btn bg-primary btn-block' id='add_invoice'> Add to existing invoice </button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
@@ -440,6 +437,11 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<%end%>
<% 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 bg-blue btn-block">Pay</button>
<!-- <button type="button" id="void" class="btn bg-blue btn-block" > Void </button> -->
<% end %>

View File

@@ -200,7 +200,7 @@
<% @sale_data.each_with_index do |sale_data, sale_index| %>
<% if sale_data.sale_status != 'completed' && sale_data.sale_status != 'void' %>
<% checked = "" %>
<% if sale_index == 0 %>
<% if sale_index == 1 %>
<% checked = "checked" %>
<% end %>
<tr class="receipt-row" id=<%= sale_data.receipt_no %> data=<%= sale_data.grand_total %> >
@@ -250,7 +250,8 @@
<div class="form-horizontal">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="form-group">
<input type="text" id="per_person" name="per_person" class="form-control" onkeypress="return isNumberKey(event);"/>
<input type="text" id="per_person" name="per_person" class="form-control" onkeypress="return isNumberKey(event);"/><br>
<span id="per_personErr" style="color:red;"></span>
</div>
</div>
</div>
@@ -304,7 +305,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn bg-default" data-dismiss="modal">Close</button> &nbsp;&nbsp;
<button type="button" class="btn bg-blue btn_per_person">Split Bill</button>
<button type="button" class="btn bg-blue btn_per_person">= Split</button>
</div>
</div>
</div>
@@ -483,58 +484,68 @@
});
$('.btn_per_person').on('click', function(){
$('#equal_split_modal').modal('hide');
var person = parseInt($('#per_person').val());
if(person > 1){
var ajax_url = "/origami/split_bills/surveys";
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 },
success: function (result) {
console.log(result);
if(result.status){
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
}
});
}
}
});
var person = $('#per_person').val();
if((person!=undefined) && (person!="")){
$("#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 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 },
success: function (result) {
console.log(result);
if(result.status){
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
// location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
window.location.href = '/origami/sale/' + split_sale_id + "/payment";
}
});
}
}
});
}else{
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
// location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
window.location.href = '/origami/sale/' + split_sale_id + "/payment";
}
});
}
}else{
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
}
});
$("#per_personErr").html("can't be blank");
}
});
//equal split process