This commit is contained in:
Kaung Sint Ko Ko
2025-06-03 11:24:37 +06:30
parent 24327e402a
commit 14cffc2e29
2 changed files with 66 additions and 22 deletions

View File

@@ -214,16 +214,19 @@
<td style="padding:2px;" class="item-attr <%= params[:modify] ? '' : 'text-right'%>"><strong id="sub_total">0.00</strong></td>
</tr>
</table>
<% if params[:update] %>
<button type="button" class="btn btn-primary action-btn create col-md-12 m-t-5" id="create_pay_order" disabled="disabled" data-toggle="modal" data-target="#read_modal" style=" height: 50px; width: 100%;">Update Order & Pay</button>
<% else %>
<% if @sale_id.nil?%>
<button type="button" class="btn btn-primary action-btn create col-md-4 d-inline" id="create_pay_order" disabled="disabled" data-toggle="modal" data-target="#read_modal" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<% else %>
<button type="button" class="btn btn-primary action-btn create col-md-4 d-inline" id="add_to_existing_order" disabled="disabled" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<div class="row gap-3 d-flex justify-content-between">
<% if params[:update] %>
<button type="button" class="btn btn-primary action-btn create col-md-12 m-t-5" id="create_pay_order" disabled="disabled" data-toggle="modal" data-target="#read_modal" style=" height: 50px; width: 100%;">Update Order & Pay</button>
<% else %>
<% if @sale_id.nil?%>
<button type="button" class="btn btn-primary action-btn create col-md-6 d-inline" id="create_pay_order" disabled="disabled" data-toggle="modal" data-target="#read_modal" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<% else %>
<button type="button" class="btn btn-primary action-btn create col-md-6 d-inline" id="add_to_existing_order" disabled="disabled" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<% end %>
<button type="button" class="btn btn-warning action-btn create col-md-6 d-inline" id="mmqr" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">MMQR</button>
</div>
<button type="button" class="btn btn-primary w-full action-btn create col-12 d-inline" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<% end %>
<button type="button" class="btn btn-primary action-btn create col-md-7 m-l-15 d-inline" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<% end %>
</div>
</div>
</div>
@@ -875,4 +878,47 @@ function create_order(data,paymentMethod = "") {
},
});
}
$('#mmqr').click(function() {
// alert("MMQR");
const paymentMethod = 'MMQR';
const $serverMode = $('#server_mode');
const $createOrderBtn = $('#create_order');
const $createPayOrderBtn = $('#create_pay_order');
const params = {
order_source: "food_court",
order_type: "dine_in",
customer_id: $("#customer_id").text(),
guest_info: "",
table_id: $("#table_id").text(),
order_items: JSON.stringify(get_order_item_rows()),
create_type: "create_pay",
};
$.ajax({
url: '/foodcourt/addorders/create',
method: 'POST',
contentType: 'application/json',
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
},
data: JSON.stringify(params),
success: function(result) {
const booking_id = result.booking_id;
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
// customer_display_view(null, "reload");
}
},
error: function(xhr) {
$('#oqs_loading_wrapper').hide();
$createOrderBtn.prop('disabled', false);
$createPayOrderBtn.prop('disabled', false);
const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
swal("Error", errorMsg, "error");
}
});
})
</script>

View File

@@ -8,8 +8,6 @@
<p style="text-align: center; font-weight: bolder; color: black; font-size: larger">Please tap NFC Card or Scan Code</p>
<div style="text-align: center;">
<img src="/image/nfc.png" style="height: 200px"><br>
<button type="button" class="btn btn-primary" id="mmqr" >MMQR</button>
</div>
</div>
<div class="modal-footer" style="justify-content: center;">
@@ -84,17 +82,17 @@
});
})
function get_order_item_rows(){
var order_items = [];
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
var order_item = {};
// function get_order_item_rows(){
// var order_items = [];
// var item_row = $('.summary-items tbody tr');
// $(item_row).each(function(i){
// var order_item = {};
// order_item.item_name = $(item_row[i]).attr('data-item-name');
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
// // order_item.item_name = $(item_row[i]).attr('data-item-name');
// order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
order_items.push(order_item);
});
return order_items;
}
// order_items.push(order_item);
// });
// return order_items;
// }
</script>