separate foodcourt module
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
//middle edit
|
||||
$(function() {
|
||||
$("#loading_wrapper").show();
|
||||
getAllMenu();
|
||||
//get menu item cache
|
||||
function getAllMenu(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/foodcourt/get_all_menu',
|
||||
data: {},
|
||||
success:function(result){
|
||||
console.log(result)
|
||||
localStorage.setItem("menus", JSON.stringify(result));
|
||||
var menu = localStorage.getItem("menus");
|
||||
if (menu != null ) {
|
||||
$( "#loading_wrapper").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var role = $('#role').val();
|
||||
var second_display_lookup = $("#display_type").val();
|
||||
type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court");
|
||||
@@ -623,7 +641,7 @@ $(function() {
|
||||
row = "<h5>"+attributes[field]["type"]+"</h5>";
|
||||
|
||||
$(value).each(function(i){
|
||||
disabled = ""
|
||||
disabled = "false";
|
||||
status ="";
|
||||
if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
|
||||
status = "selected-attribute";
|
||||
@@ -1041,7 +1059,11 @@ $(function() {
|
||||
}else if(result.data == 'OK'){
|
||||
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
|
||||
}else{
|
||||
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment";
|
||||
if(result.current_user_role == 'foodcourt_cashier'){
|
||||
window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment"; }
|
||||
else{
|
||||
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
591
app/assets/javascripts/foodcourt.js
Normal file
591
app/assets/javascripts/foodcourt.js
Normal file
@@ -0,0 +1,591 @@
|
||||
//= require jquery
|
||||
//= require tether
|
||||
//= require jquery_ujs
|
||||
//= require bootstrap/js/popper.min
|
||||
//= require bootstrap/js/bootstrap-material-design.min
|
||||
//= require momentjs/moment
|
||||
//= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker
|
||||
//= require jquery-slimscroll/jquery.slimscroll.js
|
||||
//= require bootstrap-notify/bootstrap-notify.js
|
||||
//= require node-waves/waves.js
|
||||
//= require sweetalert/sweetalert.min.js
|
||||
//= require fileinput.min
|
||||
//= require cable
|
||||
//= require turbolinks
|
||||
//= require BSBMaterial/turbolink_admin.js
|
||||
//= require BSBMaterial/demo.js
|
||||
|
||||
/* Constant Varaibles */
|
||||
_CREDIT_PAYMENTS_ = "/ CREDIT PAYMENTS";
|
||||
_CUSTOMERS_ = "/ CUSTOMERS";
|
||||
_DISCOUNTS_ = "/ DISCOUNTS";
|
||||
_IN_DUTIES_ = "/ IN DUTIES";
|
||||
_JCB_ = "/ JCB PAYMENT";
|
||||
_MASTER_ = "/ MASTER PAYMENT";
|
||||
_MPU_ = "/ MPU PAYMENT";
|
||||
_ALIPAY_ = "/ Alipay";
|
||||
_JUNCTIONPAY_ = "/ JunctionPay";
|
||||
_PAYMAL_ = "/ PAYMAL";
|
||||
_DINGA_ = "/ DINGA PAYMENT";
|
||||
_GIFT_VOUCHER_ = "/ GIFT VOUCHER";
|
||||
_OTHER_CHARGES_ = "/ CHARGES";
|
||||
_OTHER_PAYMENTS_ = "/ OTHER PAYMENT";
|
||||
_PAYMENTS_ = "/ PAYMENT";
|
||||
_PAYPAR_PAYMENT_ = "/ PAYPAR PAYMENT";
|
||||
_COMMISSIONS_ = "/ COMMISSIONS";
|
||||
_REDEEM_PAYMENT_ = "/ REDEEM PAYMENT";
|
||||
_SALE_EDIT_ = "/ SALE EDIT";
|
||||
_SPLIT_BILL_ = "/ SPLIT BILL";
|
||||
_UNION_ = "/ UNION PAYMENT";
|
||||
_VISA_ = "/ VISA PAYMENT";
|
||||
_VOUCHER_ = "/ VOUCHER";
|
||||
_SURVEY_ = "/ SURVEY";
|
||||
/* Constant Varaibles */
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
|
||||
$("#customer_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
$('.datetimepicker').bootstrapMaterialDatePicker({
|
||||
format: 'DD-MM-YYYY - HH:mm',
|
||||
clearButton: true,
|
||||
weekStart: 1
|
||||
});
|
||||
|
||||
$('.datepicker').bootstrapMaterialDatePicker({
|
||||
format: 'DD-MM-YYYY',
|
||||
clearButton: true,
|
||||
weekStart: 1,
|
||||
time: false
|
||||
});
|
||||
|
||||
$('.timepicker').bootstrapMaterialDatePicker({
|
||||
format: 'HH:mm',
|
||||
clearButton: true,
|
||||
date: false
|
||||
});
|
||||
|
||||
// For selected order return
|
||||
var order_status = "";
|
||||
order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim();
|
||||
|
||||
// Enable/Disable Button
|
||||
//control_button(order_status);
|
||||
|
||||
$(".orders").on('click', function(){
|
||||
$("#order-sub-total").text('');
|
||||
// $("#order-food").text('');
|
||||
// $("#order-beverage").text('');
|
||||
$("#order-discount").text('');
|
||||
$("#order-Tax").text('');
|
||||
$("#order-grand-total").text('');
|
||||
|
||||
var zone_name=$(this).find(".orders-table").text();
|
||||
var receipt_no=$(this).find(".orders-receipt-no").text();
|
||||
var unique_id = $(this).find(".orders-id").text();
|
||||
var order_status=$(this).find(".orders-order-status").text().trim();
|
||||
|
||||
// Enable/Disable Button
|
||||
//control_button(order_status);
|
||||
|
||||
var customer_id=$(this).find(".customer-id").text();
|
||||
show_customer_details(customer_id);
|
||||
|
||||
$("#re-print").val(unique_id);
|
||||
|
||||
var cashier="";
|
||||
var receipt_date="";
|
||||
var sub_total=0.0;
|
||||
var discount_amount=0;
|
||||
var tax_amount=0;
|
||||
var grand_total_amount=0;
|
||||
|
||||
$("#order-title").text("ORDER DETAILS - " + zone_name);
|
||||
// clear order items
|
||||
$("#order-items-table").children("tbody").empty();
|
||||
|
||||
// AJAX call for order
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/" + unique_id,
|
||||
data: { 'booking_id' : unique_id },
|
||||
success:function(result){
|
||||
for (i = 0; i < result.length; i++) {
|
||||
var data = JSON.stringify(result[i]);
|
||||
var parse_data = JSON.parse(data);
|
||||
var show_date = "";
|
||||
|
||||
// Receipt Header
|
||||
receipt_no = result[i].receipt_no;
|
||||
cashier = result[i].cashier_name;
|
||||
if(result[i].receipt_date != null){
|
||||
receipt_date = new Date(result[i].receipt_date);
|
||||
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
||||
}
|
||||
|
||||
//Receipt Charges
|
||||
sub_total += parseFloat(parse_data.price);
|
||||
|
||||
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
||||
tax_amount = parse_data.tax_amount;
|
||||
grand_total_amount = parse_data.grand_total_amount;
|
||||
|
||||
// Ordered Items
|
||||
var order_items_rows = "<tr>" +
|
||||
"<td class='item-name'>" + parse_data.item_name + "</td>" +
|
||||
"<td class='item-attr'>" + parse_data.qty + "</td>" +
|
||||
"<td class='item-attr'>" + parse_data.price + "</td>" +
|
||||
"</tr>";
|
||||
|
||||
$("#order-items-table").children("tbody").append(order_items_rows);
|
||||
}
|
||||
|
||||
// Cashier Info
|
||||
$("#receipt_no").text(receipt_no);
|
||||
$("#cashier").text(cashier == null ? "" : cashier);
|
||||
$("#receipt_date").text(show_date);
|
||||
|
||||
// Payment Info
|
||||
$("#order-sub-total").text(sub_total);
|
||||
// $("#order-food").text('');
|
||||
// $("#order-beverage").text('');
|
||||
$("#order-discount").text(discount_amount);
|
||||
$("#order-Tax").text(tax_amount);
|
||||
$("#order-grand-total").text(grand_total_amount);
|
||||
}
|
||||
});
|
||||
// End AJAX Call
|
||||
|
||||
$('.orders').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
});
|
||||
|
||||
// Payment for Bill
|
||||
$('#pay-bill').click(function() {
|
||||
var sale_id=$(".selected-item").find(".orders-id").text().substr(0,16);
|
||||
if(sale_id!=""){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment"
|
||||
}
|
||||
else {
|
||||
alert("Please select an order!");
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('click', '.access_modal', function(event){
|
||||
type = $(this).data("type");
|
||||
$(".ok").attr("data-action",type);
|
||||
$('#AccessCodeModal').modal('show');
|
||||
});
|
||||
|
||||
$(document).on('click', '.access_number', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value = $('#access_code').val();
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value){
|
||||
$('#access_code').val(original_value + input_value);
|
||||
}else{
|
||||
$('#access_code').val(original_value + input_value);
|
||||
}
|
||||
break;
|
||||
case 'ok':
|
||||
var type = $(this).attr("data-action");
|
||||
code = $('#access_code').val();
|
||||
check_emp_access_code(code,type)
|
||||
break;
|
||||
case 'clr':
|
||||
$('#access_code').val("");
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".credit_detail",function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
var cashier_type = $(this).attr("data-type");
|
||||
if(cashier_type=='cashier'){
|
||||
window.location.href = "/origami/cashier/credit_sales/"+sale_id;
|
||||
}else{
|
||||
window.location.href = "/origami/quick_service/credit_sales/"+sale_id;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* start check first bill or not funs: */
|
||||
function checkReceiptNoInFirstBillData(receipt_no,payment) {
|
||||
// localStorage.removeItem('receipt_lists');
|
||||
var status = false;
|
||||
var json_data = [];
|
||||
if((receipt_no!=undefined) && (receipt_no!="")){
|
||||
if(localStorage.hasOwnProperty("receipt_lists")===true){
|
||||
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||
if (payment) {
|
||||
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||
}else{
|
||||
json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||
}
|
||||
|
||||
if((arr_data.length) > (json_data.length)){
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (payment) {
|
||||
if (json_data.length>0) {
|
||||
return json_data[0]["payment"];
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
function createReceiptNoInFirstBillData(receipt_no,payment) {
|
||||
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,'payment':payment});
|
||||
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
|
||||
}
|
||||
}
|
||||
|
||||
function deleteReceiptNoInFirstBillData(receipt_no) {
|
||||
if(localStorage.hasOwnProperty("receipt_lists") ===true ){
|
||||
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
|
||||
}
|
||||
}
|
||||
/* end check first bill or not funs: */
|
||||
|
||||
//start CB ECR integration
|
||||
//set CB com port data
|
||||
function setCommPorts(comPortLists) {
|
||||
var sale_id = $('#sale_id').val();
|
||||
$('#com_port_name').html("");
|
||||
var jsonPortLists = $.parseJSON(comPortLists);
|
||||
// alert(jsonPortLists);
|
||||
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){
|
||||
$.each(jsonPortLists,function(key,value){
|
||||
$('#com_port_name').append("<option value='"+value+"'>"+value+"</option>");
|
||||
});
|
||||
}
|
||||
else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: 'Payment device has been disconnected! Please plug it in.',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/others_payment";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** pay with CB bank **/
|
||||
function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) {
|
||||
$("#loading_wrapper").show();
|
||||
var com_port = $("#com_port_name").val();
|
||||
reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type);
|
||||
}
|
||||
|
||||
//add req data to card_sale_trans table
|
||||
function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type) {
|
||||
var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/bank_integration/sale_trans",
|
||||
data: {type:"request", data: jobj},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.status == "success"){
|
||||
card_sale_trans_id = data.card_sale_trans_id;
|
||||
resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//add res data to card_sale_trans table
|
||||
function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type) {
|
||||
|
||||
var resMsg = "";
|
||||
var card_payment_type="";
|
||||
if($("#loading_wrapper").is(":visible")){
|
||||
if(payment_type=="mpu" || payment_type=="visa" || payment_type=="master" || payment_type=="jcb" || payment_type=="unionpay"){
|
||||
card_payment_type = "CARD";
|
||||
}
|
||||
else if(payment_type == "alipay"){
|
||||
card_payment_type = "EWALLET";
|
||||
}
|
||||
|
||||
bnk_bill_amount = parseFloat(bnk_bill_amount);
|
||||
|
||||
resMsg = code2lab.reqBankPayment(cmd_type,card_payment_type,bnk_bill_amount,receipt_no,com_port);
|
||||
}
|
||||
|
||||
if(resMsg.includes("STATUS")){
|
||||
var jobj = $.parseJSON(resMsg);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/bank_integration/sale_trans",
|
||||
data: {type:"response", card_sale_trans_id: card_sale_trans_id, data: jobj},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == "success"){
|
||||
resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type);
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
if(payment_type!="master"){
|
||||
payment_type = payment_type.toUpperCase();
|
||||
}else{
|
||||
payment_type = "Master";
|
||||
}
|
||||
|
||||
$("#loading_wrapper").hide();
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: resMsg.toString(),
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type) {
|
||||
$("#loading_wrapper").hide();
|
||||
var jobj = $.parseJSON(resMsg);
|
||||
$("#reference_no").val(jobj.REFNUM);
|
||||
if(jobj.STATUS == "Approved"){
|
||||
$.ajax({type: "POST",
|
||||
url: "/origami/payment/"+payment_type,
|
||||
data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id + "&ref_no=" + jobj.REFNUM,
|
||||
success:function(result){
|
||||
if(result){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Payment Successfully",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/"+url_param;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
if(payment_type!="master"){
|
||||
payment_type = payment_type.toUpperCase();
|
||||
}else{
|
||||
payment_type = "Master";
|
||||
}
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: "Transaction is " + (jobj.STATUS).toLowerCase(),
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type;
|
||||
});
|
||||
}
|
||||
}
|
||||
//end CB ECR integration
|
||||
|
||||
function setHeaderBreadCrumb(params){
|
||||
$("#others_payment").html(params);
|
||||
}
|
||||
|
||||
//show hide nav bar for webview
|
||||
function showHideNavbar(webview,page){
|
||||
if(webview){
|
||||
$("nav.navbar").addClass("hidden");
|
||||
$("section").addClass("section-margin");
|
||||
$(".page-loader-wrapper").addClass("hidden");
|
||||
if(page!=undefined){
|
||||
$("#back").hide();
|
||||
}
|
||||
}else{
|
||||
$("nav.navbar").removeClass("hidden");
|
||||
$("section").removeClass("section-margin");
|
||||
$(".page-loader-wrapper").removeClass("hidden");
|
||||
if(page!=undefined){
|
||||
$("#back").show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAccessCode(code) {
|
||||
localStorage.setItem("access_code",code);
|
||||
}
|
||||
|
||||
//get menu item cache
|
||||
function getAllMenu(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/origami/get_all_menu',
|
||||
data: {},
|
||||
success:function(result){
|
||||
console.log(result)
|
||||
localStorage.setItem("menus", JSON.stringify(result));
|
||||
|
||||
var menu = localStorage.getItem("menus");
|
||||
if (menu != null ) {
|
||||
$( "#loading_wrapper").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* 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(cashier_type){
|
||||
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, cashier_type);
|
||||
}
|
||||
|
||||
function getCreditSales(filter, customer, cashier_type){
|
||||
// $(".credit_items").hide();
|
||||
$(".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_type+"/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){
|
||||
$(".credit_items").show();
|
||||
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()+1) : '0' + (sale_date.getMonth()+1)) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate());
|
||||
$('.tbd_credit_lists').append(html_credit_items.formatUnicorn({
|
||||
'key':i,
|
||||
'sale_id':credit_sales[i].sale_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,
|
||||
'cashier_type':cashier_type
|
||||
}));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$(".tbd_credit_lists").html(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//End of credit sales function
|
||||
729
app/assets/stylesheets/foodcourt.scss
Normal file
729
app/assets/stylesheets/foodcourt.scss
Normal file
@@ -0,0 +1,729 @@
|
||||
@import "material_icons";
|
||||
@import "tether";
|
||||
@import "bootstrap/css/bootstrap-material-design.min";
|
||||
@import "node-waves/waves";
|
||||
@import "animate-css/animate";
|
||||
@import "sweetalert/sweetalert.css";
|
||||
@import "multi-select/css/multi-select.css";
|
||||
@import "bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker";
|
||||
@import "morrisjs/morris";
|
||||
@import "BSBMaterial/style";
|
||||
@import "BSBMaterial/themes/all-themes";
|
||||
@import "reset";
|
||||
@import "fileinput.min";
|
||||
|
||||
|
||||
/* Reset */
|
||||
.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col-auto, .col-lg, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-auto, .col-md, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-md-auto, .col-sm, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-auto {
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.col-lg-1, .col-md-1, .col-sm-1,col-xl-1{
|
||||
padding-left: 1px ;
|
||||
padding-right: 1px ;
|
||||
}
|
||||
|
||||
.ls-closed section.content {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
section.content {
|
||||
margin: 70px 5px 0 225px;
|
||||
}
|
||||
|
||||
.table {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
select.form-control {
|
||||
height: inherit !important;
|
||||
}
|
||||
|
||||
.form-horizontal .form-group {
|
||||
margin-right: 0px !important;
|
||||
}
|
||||
|
||||
.card-columns {
|
||||
font-size: 18px !important;
|
||||
}
|
||||
|
||||
@media (min-width:769px) and (max-width:1024px) {
|
||||
.btn-block {
|
||||
font-size: 11px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* End Reset */
|
||||
|
||||
#back {
|
||||
padding: 0px 0px 7px 0px;
|
||||
}
|
||||
|
||||
/*
|
||||
.order-info {
|
||||
min-height:300px;
|
||||
max-height:500px;
|
||||
overflow:auto
|
||||
}
|
||||
*/
|
||||
|
||||
.others-payment{
|
||||
line-height:100px;
|
||||
text-align:center;
|
||||
color:white;
|
||||
width:300px;
|
||||
height:100px;
|
||||
font-size:18px;
|
||||
}
|
||||
|
||||
.orders-table {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cashier_number{
|
||||
width: 33%;
|
||||
height:58px;
|
||||
line-height:58px;
|
||||
text-align:center;
|
||||
background:#54A5AF;
|
||||
// float:left;
|
||||
// margin:2px;
|
||||
font-size:20px;
|
||||
color:white;
|
||||
// cursor:pointer;
|
||||
}
|
||||
|
||||
.access_number{
|
||||
width: 33%;
|
||||
height:58px;
|
||||
line-height:58px;
|
||||
text-align:center;
|
||||
background:#54A5AF;
|
||||
// float:left;
|
||||
// margin:2px;
|
||||
font-size:20px;
|
||||
color:white;
|
||||
// cursor:pointer;
|
||||
}
|
||||
|
||||
.del_cashier_number{
|
||||
opacity:0.6,
|
||||
}
|
||||
|
||||
.pay{
|
||||
width: 86%;
|
||||
height:174px;
|
||||
line-height:174px;
|
||||
text-align:center;
|
||||
font-size:20px;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.move_table{
|
||||
width: 100%;
|
||||
height:74px;
|
||||
line-height:74px;
|
||||
text-align:center;
|
||||
font-size:20px;
|
||||
color:white;
|
||||
}
|
||||
|
||||
|
||||
.payment{
|
||||
height:50px;
|
||||
line-height:50px;
|
||||
align:center;
|
||||
color:white;
|
||||
font-size:16px;
|
||||
margin:5px;
|
||||
}
|
||||
|
||||
.font-12 {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.cash-color{
|
||||
background-color:#2196F3;
|
||||
}
|
||||
|
||||
.credit-color{
|
||||
background-color:#FFA500;
|
||||
}
|
||||
|
||||
.other-payment-color{
|
||||
background-color:#795548;
|
||||
}
|
||||
|
||||
.others-color{
|
||||
background-color:#E1BEE7;
|
||||
height: 30px !important;
|
||||
line-height: 30px !important;
|
||||
}
|
||||
|
||||
|
||||
.cashier_number:hover{
|
||||
background:#A9F5F2;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
white-space: normal !important;
|
||||
height: 60px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.radius-btn {
|
||||
border-radius:5px;
|
||||
color:#fff;
|
||||
background-color:red;
|
||||
}
|
||||
|
||||
.bottom-5 {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.fluid {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.style2 {
|
||||
border-top: 3px double #8c8b8b;
|
||||
}
|
||||
|
||||
.long{
|
||||
width:43%;
|
||||
}
|
||||
|
||||
.sold {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.paid {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.selected-item {
|
||||
color: #fff !important;
|
||||
background-color: blue !important;
|
||||
}
|
||||
|
||||
.selected-account {
|
||||
color: #fff !important;
|
||||
background-color: blue !important;
|
||||
}
|
||||
|
||||
.selected-payment {
|
||||
color: #fff !important;
|
||||
background-color: blue !important;
|
||||
}
|
||||
.payment_btn {
|
||||
white-space: normal !important;
|
||||
margin-bottom: 15px;
|
||||
margin-right: 15px;
|
||||
color:#fff !important;
|
||||
# background-color: green !important;
|
||||
}
|
||||
|
||||
/* Reciept Style */
|
||||
#order-charges-table td {
|
||||
border-top: none !important;
|
||||
}
|
||||
|
||||
.charges-name {
|
||||
width: 80%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
width: 60%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.item-attr {
|
||||
width: 20%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.item-attr-edit{
|
||||
width: 10%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.display-none{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.text-white{
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Colors */
|
||||
.purple {
|
||||
background-color:#7a62d3;
|
||||
}
|
||||
|
||||
.orange{
|
||||
background-color:#FF7F50;
|
||||
}
|
||||
|
||||
.red {
|
||||
background-color:#F44336;
|
||||
}
|
||||
|
||||
.green{
|
||||
background-color: #009900;
|
||||
}
|
||||
|
||||
.orange{
|
||||
background-color: #FF8C00;
|
||||
}
|
||||
|
||||
.blue{
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
/* End Colors */
|
||||
|
||||
.left{
|
||||
margin-left:1px;
|
||||
}
|
||||
|
||||
.dtp-date .left{
|
||||
margin-left:0px;
|
||||
}
|
||||
|
||||
.bottom{
|
||||
margin-bottom:1px;
|
||||
}
|
||||
|
||||
/* Discount */
|
||||
|
||||
.required abbr{
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
.border-top{
|
||||
border-top:1px solid #fff;
|
||||
}
|
||||
|
||||
.border-right{
|
||||
border-right:1px solid #fff;
|
||||
}
|
||||
|
||||
.border-left{
|
||||
border-left:1px solid #fff;
|
||||
}
|
||||
|
||||
#sxModal {
|
||||
display: none;
|
||||
overflow: auto;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #000;
|
||||
background-color: rgba(0,0,0,0.4);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 1100;
|
||||
}
|
||||
|
||||
#sxModal-Content {
|
||||
position: relative;
|
||||
left: 42%;
|
||||
top: 30%;
|
||||
background-color: #32ad1a;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
padding-top: 5%;
|
||||
border-radius: 100px;
|
||||
z-index: 1101;
|
||||
}
|
||||
|
||||
/*Loading gif for payment*/
|
||||
|
||||
#loading_wrapper{
|
||||
position: fixed;
|
||||
background-color: #C8C8C8 ;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
opacity: 0.6;
|
||||
top: 0;
|
||||
z-index: 9999999;
|
||||
}
|
||||
|
||||
#loading{
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-image: url('../../../image/loading-ajax.gif');
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100); /* ie */
|
||||
-moz-opacity: 1; /* mozilla */
|
||||
|
||||
}
|
||||
|
||||
/* For Payment Page */
|
||||
|
||||
.payment-long {
|
||||
width:43%;
|
||||
}
|
||||
|
||||
.payment-left {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
/* End Payment Page */
|
||||
|
||||
/* Logout Icon */
|
||||
|
||||
i.logout_icon{
|
||||
position: relative;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
/* End Logout Icon */
|
||||
|
||||
/* Notify */
|
||||
|
||||
#notify-wrapper {
|
||||
position: absolute;
|
||||
top: 55px;
|
||||
left: 10px;
|
||||
z-index: 9999;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
[data-notify="container"] {
|
||||
margin-bottom: 5px !important;
|
||||
margin-left:5px !important;
|
||||
position:relative !important;
|
||||
top: 25% !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* End Notify */
|
||||
|
||||
/* selected color for split bills */
|
||||
.selected-split-item {
|
||||
color: #fff !important;
|
||||
background-color: #5DADE2 !important;
|
||||
}
|
||||
|
||||
/* Start Is Member Modal */
|
||||
#is_memberModal .modal-body {
|
||||
height: 260px !important;
|
||||
}
|
||||
|
||||
#is_memberModal .btn {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
#is_paymemberModal .modal-body {
|
||||
height: 150px !important;
|
||||
}
|
||||
|
||||
#is_paymemberModal .btn {
|
||||
width: 80%;
|
||||
}
|
||||
/* End Is Member Modal */
|
||||
|
||||
/* Start iframe */
|
||||
iframe {
|
||||
border: none;
|
||||
overflow: hidden !important;
|
||||
width: 400px;
|
||||
height: 550px;
|
||||
}
|
||||
|
||||
#pdfModal .btn {
|
||||
width: 150%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#receipt_pdf {
|
||||
height: 400px;
|
||||
}
|
||||
/* End iframe */
|
||||
|
||||
/* section class for webview */
|
||||
.section-margin {
|
||||
margin-top: -50px;
|
||||
}
|
||||
|
||||
.tax-btn-box {
|
||||
width: 230px;
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
/*Pagination*/
|
||||
nav.pagination {
|
||||
margin:10px;
|
||||
|
||||
}
|
||||
nav.pagination .current{
|
||||
background-color:#1f91f3;
|
||||
color:#fff;
|
||||
padding:4px 10px;
|
||||
margin-top:-4px;
|
||||
}
|
||||
nav.pagination .page a,.next a,.last a,.prev a,.first a{
|
||||
padding:6.5px 10px;
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
nav.pagination .page a:hover,
|
||||
a:focus {
|
||||
background-color: #ccc;
|
||||
text-decoration: none;
|
||||
|
||||
}
|
||||
nav.pagination .page a:hover,
|
||||
.first a:hover,.last a:hover,.prev a:hover,.next a:hover{
|
||||
background-color: #ccc;
|
||||
text-decoration: none;
|
||||
|
||||
}
|
||||
|
||||
#oqs_loading_wrapper{
|
||||
position: fixed;
|
||||
background-color: #C8C8C8 ;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
opacity: 0.6;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
#oqs_loading{
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-image: url('../../../image/loading-ajax.gif');
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
opacity: 1;
|
||||
z-index: 101;
|
||||
filter: alpha(opacity=100); /* ie */
|
||||
-moz-opacity: 1; /* mozilla */
|
||||
}
|
||||
.existing_invoice{
|
||||
background-color:#ffab51;
|
||||
color:#fff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*----chane font_size (Amount Due && Balance)----*/
|
||||
#balance{
|
||||
height: 50%;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.amount_balance{
|
||||
height: 50%;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
|
||||
#amount_due{
|
||||
height: 50%;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/*customer modal UI */
|
||||
.wizard {
|
||||
background: #f1f1f1;
|
||||
padding: 10px;
|
||||
}
|
||||
.wizard .nav-tabs {
|
||||
position: relative;
|
||||
border: 0px;
|
||||
}
|
||||
.wizard > div.wizard-inner {
|
||||
position: relative;
|
||||
margin: 0 0 0 145px !important;
|
||||
}
|
||||
.connecting-line{
|
||||
height:12px;
|
||||
background: #e0e0e0;
|
||||
position: absolute;
|
||||
width: 110%;
|
||||
margin: 0 auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top:38%;
|
||||
z-index: 1;
|
||||
border-radius: 15px;
|
||||
}
|
||||
.active-line{
|
||||
height:12px;
|
||||
background: #e0e0e0;
|
||||
position: absolute;
|
||||
width: 5%;
|
||||
margin: 0 auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top:61%;
|
||||
z-index: 1;
|
||||
border-radius: 15px !important;
|
||||
}
|
||||
.connecting-line a.active{
|
||||
background-color: #2ED4E0;
|
||||
}
|
||||
.border-right{
|
||||
border-radius: 15px 0 0 15px;
|
||||
}
|
||||
.border-left{
|
||||
border-radius: 0;
|
||||
}
|
||||
.wizard .nav-tabs > li {
|
||||
margin-bottom: -20px;
|
||||
}
|
||||
.wizard .nav-tabs > li > a.active > a, .wizard .nav-tabs > li > a.active > a:hover, .wizard .nav-tabs > li > a.active > a:focus {
|
||||
cursor: default;
|
||||
border: 0;
|
||||
color:#2ED4E0;
|
||||
border-bottom-color: transparent;
|
||||
}
|
||||
.wizard .nav-tabs li p{
|
||||
padding-top:40px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
.list-inline{
|
||||
text-align: center;
|
||||
}
|
||||
span.round-tab {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
display: inline-block;
|
||||
border-radius: 100px;
|
||||
background:#DFE3E4;
|
||||
border: 2px solid #fff;
|
||||
z-index:1;
|
||||
position:absolute;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
}
|
||||
.wizard li > a.active span.round-tab{
|
||||
background:#2196F3;
|
||||
color:white;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
span.round-tab:hover{
|
||||
color: white;
|
||||
border: 1px solid #fff;
|
||||
background-color:#2196F3;
|
||||
}
|
||||
.wizard .nav-tabs > li {
|
||||
width: 25%;
|
||||
}
|
||||
.wizard .nav-tabs > li a{
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
margin: 18px auto;
|
||||
border-radius: 100%;
|
||||
padding: 0;
|
||||
color: #777;
|
||||
}
|
||||
.wizard .tab-pane {
|
||||
position: relative;
|
||||
padding-top: 5px;
|
||||
border-top: 1px solid #fff;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.next-step:hover, .next-step, .prev-step:hover, .prev-step{
|
||||
position: relative;
|
||||
background-color: #2196F3;
|
||||
font-size: 14px;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
/*customer modal UI */
|
||||
|
||||
.payment-btn-box {
|
||||
width: 130px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 785px) {
|
||||
section.content{
|
||||
margin: 80px 15px 0 225px;
|
||||
}
|
||||
|
||||
.mbl_view{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navbar-brand-txt{
|
||||
margin-top: -15px;
|
||||
}
|
||||
|
||||
.toggle_mbl {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.toggle_mbl img{
|
||||
width: 24px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.toggle_mbl a:hover, a:focus{
|
||||
background-color: unset;
|
||||
}
|
||||
|
||||
.col-mbl-view{
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.info-box .icon{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mbl_product_div{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar .menu{
|
||||
top: 10px;
|
||||
}
|
||||
|
||||
.page-header{
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.ls-closed .bars:after, .ls-closed .bars:before{
|
||||
top: 14px;
|
||||
}
|
||||
|
||||
.mbl_card{
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.mbl_lbl{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mbl-style{
|
||||
padding: 10px 10px;
|
||||
}
|
||||
|
||||
.m-auto{
|
||||
width: 33%;
|
||||
}
|
||||
|
||||
.online_order{
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.mbl-right-btn{
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,15 @@ class Api::ApiController < ActionController::API
|
||||
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
before_action :core_allow
|
||||
def core_allow
|
||||
headers['Access-Control-Allow-Origin'] = '*'
|
||||
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
|
||||
headers['Access-Control-Request-Method'] = '*'
|
||||
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
|
||||
end
|
||||
private
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
#response format must be set to JSON
|
||||
|
||||
58
app/controllers/base_foodcourt_controller.rb
Normal file
58
app/controllers/base_foodcourt_controller.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
class BaseFoodcourtController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "foodcourt"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :current_token
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
# redirect_to origami_root_path
|
||||
redirect_to origami_dashboard_path
|
||||
end
|
||||
|
||||
def check_user
|
||||
if check_mobile
|
||||
if current_user.nil?
|
||||
return render status: 401, json: {
|
||||
message: "User using other device!"
|
||||
}.to_json
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# def checkin_process
|
||||
# CheckinJob.set(wait: 1.minute).perform_later()
|
||||
# end
|
||||
|
||||
##already in LoginVerification
|
||||
# Get current Cashier
|
||||
# def get_cashier
|
||||
# @cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
# end
|
||||
|
||||
#check webview
|
||||
def check_mobile
|
||||
status = false
|
||||
authenticate_with_http_token do |token, options|
|
||||
if token
|
||||
session[:webview] = true
|
||||
session[:session_token] = token
|
||||
end
|
||||
end
|
||||
|
||||
if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i
|
||||
status = true
|
||||
end
|
||||
|
||||
return status
|
||||
end
|
||||
end
|
||||
@@ -18,7 +18,7 @@ module LoginVerification
|
||||
|
||||
def current_shop
|
||||
begin
|
||||
shop_code ='262'
|
||||
shop_code ='263'
|
||||
@shop =Shop.find_by_shop_code(shop_code)
|
||||
return @shop
|
||||
rescue
|
||||
@@ -42,7 +42,7 @@ module LoginVerification
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
shop_code ='262'
|
||||
shop_code ='263'
|
||||
@shop = Shop.find_by_shop_code(shop_code)
|
||||
return @shop
|
||||
end
|
||||
|
||||
310
app/controllers/foodcourt/addorders_controller.rb
Executable file
310
app/controllers/foodcourt/addorders_controller.rb
Executable file
@@ -0,0 +1,310 @@
|
||||
class Foodcourt::AddordersController < BaseFoodcourtController
|
||||
# before_action :set_dining, only: [:detail]
|
||||
|
||||
def index
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
||||
@all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
||||
end
|
||||
|
||||
def detail
|
||||
@cashier_type = params[:type]
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
# if params[:menu] == "true"
|
||||
@menus = []
|
||||
@menu = []
|
||||
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_item_instance
|
||||
@instance = MenuItemInstance.find(params[:id])
|
||||
end
|
||||
|
||||
def get_menu()
|
||||
if (params[:id])
|
||||
#Pull this menu
|
||||
@menu = Menu.find_by_id(params[:id])
|
||||
@menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc")
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
Menu.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_sub_category ()
|
||||
|
||||
id = params[:id]
|
||||
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_all_product()
|
||||
@product = Product.all
|
||||
end
|
||||
|
||||
def create
|
||||
if params[:booking_id].present?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
end
|
||||
if params[:table_id].present?
|
||||
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
booking = table.get_current_booking
|
||||
end
|
||||
end
|
||||
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
if i["parent_order_item_id"];
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
|
||||
else
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
# begin
|
||||
if params[:order_source] == "quick_service" && params[:table_id].to_i == 0
|
||||
customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
else
|
||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
end
|
||||
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = customer_id
|
||||
@order.items = items_arr
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.shop_code =@shop.shop_code
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
if @status && @booking
|
||||
#send order broadcast to order_channel
|
||||
if @order.table_id.to_i > 0
|
||||
table = DiningFacility.find(@booking.dining_facility_id)
|
||||
type = 'order'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
|
||||
end
|
||||
|
||||
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
||||
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
end
|
||||
end
|
||||
|
||||
# Order.send_customer_view(@booking)
|
||||
|
||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
|
||||
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||
|
||||
# for second display
|
||||
if @order.source == 'quick_service'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
|
||||
end
|
||||
#end
|
||||
result = {:status=> @status, :data => @sale ,:current_user_role =>current_user.role}
|
||||
render :json => result.to_json
|
||||
end
|
||||
else
|
||||
result = {:status=> @status, :data => 0 }
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def process_order_queue(order_id,table_id,order_source)
|
||||
print_status = nil
|
||||
cup_status = nil
|
||||
|
||||
#Send to background job for processing
|
||||
order = Order.find(order_id)
|
||||
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code)
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
end
|
||||
|
||||
if print_status
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
end
|
||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
end
|
||||
else
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
cup_start = `#{"sudo service cups start"}`
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
end
|
||||
|
||||
if print_status
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
end
|
||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
||||
end
|
||||
else
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
from = ""
|
||||
msg = ' Print Error ! Please contact to service'
|
||||
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from
|
||||
end
|
||||
if !sidekiq.nil?
|
||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
end
|
||||
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_cup_status(status)
|
||||
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
#get cloud domain
|
||||
def getCloudDomain
|
||||
from = ""
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain.to_s + "." + request.domain.to_s
|
||||
end
|
||||
|
||||
return from
|
||||
end
|
||||
|
||||
end
|
||||
27
app/controllers/foodcourt/card_payments_controller.rb
Executable file
27
app/controllers/foodcourt/card_payments_controller.rb
Executable file
@@ -0,0 +1,27 @@
|
||||
class Foodcourt::CardPaymentsController < BaseFoodcourtController
|
||||
def index
|
||||
@membership_rebate_balance = 0
|
||||
@membership_id = 0
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
|
||||
if membership_data["status"]==true
|
||||
membership_account_data = membership_data["data"];
|
||||
membership_account_data.each do |acc_data|
|
||||
if acc_data["accountable_type"] == "REBATEACCOUNT"
|
||||
@membership_rebate_balance=acc_data["balance"]
|
||||
else
|
||||
@membership_rebate_balance = 0
|
||||
end
|
||||
end
|
||||
else
|
||||
@membership_rebate_balance = 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
end
|
||||
44
app/controllers/foodcourt/cash_ins_controller.rb
Executable file
44
app/controllers/foodcourt/cash_ins_controller.rb
Executable file
@@ -0,0 +1,44 @@
|
||||
class Foodcourt::CashInsController < BaseFoodcourtController
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
reference = params[:reference]
|
||||
remark = params[:remark]
|
||||
amount = params[:amount]
|
||||
payment_method = params[:payment_method]
|
||||
payment_method_reference = params[:payment_method_reference]
|
||||
type = params[:type]
|
||||
|
||||
p_jour = PaymentJournal.new
|
||||
|
||||
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
if shift
|
||||
emp = Employee.find_by_id(shift.employee_id)
|
||||
shift = ShiftSale.current_open_shift(emp)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_shift)
|
||||
end
|
||||
else
|
||||
# shift = Employee.find(current_shift.employee_id).name
|
||||
shift =current_shift
|
||||
end
|
||||
end
|
||||
puts shift.to_json
|
||||
shift.cash_in = shift.cash_in + amount.to_f
|
||||
shift.save
|
||||
end
|
||||
|
||||
end
|
||||
39
app/controllers/foodcourt/cash_outs_controller.rb
Executable file
39
app/controllers/foodcourt/cash_outs_controller.rb
Executable file
@@ -0,0 +1,39 @@
|
||||
class Foodcourt::CashOutsController < BaseFoodcourtController
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
reference = params[:reference]
|
||||
remark = params[:remark]
|
||||
amount = params[:amount]
|
||||
p_jour = PaymentJournal.new
|
||||
p_jour.cash_out(reference, remark, amount, current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
if shift
|
||||
emp = Employee.find_by_id(shift.employee_id)
|
||||
shift = ShiftSale.current_open_shift(emp)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_shift)
|
||||
end
|
||||
else
|
||||
# shift = Employee.find(current_shift.employee_id).name
|
||||
shift =current_shift
|
||||
end
|
||||
end
|
||||
shift.cash_out = shift.cash_out + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
|
||||
end
|
||||
193
app/controllers/foodcourt/customers_controller.rb
Normal file
193
app/controllers/foodcourt/customers_controller.rb
Normal file
@@ -0,0 +1,193 @@
|
||||
class Foodcourt::CustomersController < BaseFoodcourtController
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
end
|
||||
|
||||
# GET /crm/customers/1
|
||||
# GET /crm/customers/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
def get_customer
|
||||
filter = params[:filter]
|
||||
type = params[:type]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
# search account no from paypar
|
||||
if !@crm_customers.present? && type == "card"
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if response["status"] == true
|
||||
@crm_customers = Customer.new
|
||||
@crm_customers.name = response["customer_data"]["name"]
|
||||
@crm_customers.contact_no = response["customer_data"]["phone"]
|
||||
@crm_customers.email = response["customer_data"]["email"]
|
||||
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
|
||||
@crm_customers.nrc_no = response["customer_data"]["NRC"]
|
||||
@crm_customers.address = response["customer_data"]["address"]
|
||||
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
|
||||
@crm_customers.paypar_account_no = filter
|
||||
@crm_customers.membership_id = response["customer_data"]["id"]
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
else
|
||||
@crm_customers = [{"customer_id": response["status"],"message": response["message"] }]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render :json => @crm_customers.to_json
|
||||
end
|
||||
|
||||
def add_customer
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
@page = params[:dir_page]
|
||||
|
||||
if(@sale_id[0,3] == "SAL")
|
||||
@booking = Booking.find_by_sale_id(@sale_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
else
|
||||
@dining_facility = nil
|
||||
end
|
||||
|
||||
else
|
||||
@booking_order = BookingOrder.find_by_order_id(@sale_id)
|
||||
@booking = Booking.find(@booking_order.booking_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
else
|
||||
@dining_facility = nil
|
||||
end
|
||||
end
|
||||
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("customer_id") #.page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20)
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
.order("group_type ASC,order_by ASC")
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type")
|
||||
#get paypar accountno
|
||||
@paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no")
|
||||
#for create customer on/off
|
||||
@create_flag = true
|
||||
lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings')
|
||||
if !lookup_customer.empty?
|
||||
lookup_customer.each do |create_setting|
|
||||
if create_setting[0].downcase == "create"
|
||||
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
||||
@create_flag = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { render :template => "crm/customers/index" }
|
||||
format.html { render action: "index"}
|
||||
format.json { render json: @crm_customers }
|
||||
end
|
||||
end
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
order_source = params[:type]
|
||||
# Check and find with card no
|
||||
# if(!customer_id.include? "CUS")
|
||||
# customer = Customer.find_by_paypar_account_no(customer_id)
|
||||
# if(customer != nil)
|
||||
# customer_id = customer.customer_id
|
||||
# end
|
||||
# end
|
||||
|
||||
if(id == "SAL")
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: customer_id)
|
||||
sale.sale_orders.each do |sale_order|
|
||||
order = Order.find(sale_order.order_id)
|
||||
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
|
||||
end
|
||||
action_by = current_user.id
|
||||
remark = "Assign Customer Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Customer ID ->#{customer.customer_id}- Customer Name ->#{customer.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ASSIGNCUSTOMER" )
|
||||
|
||||
else
|
||||
@booking = BookingOrder.find_by_order_id(params[:sale_id])
|
||||
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)
|
||||
|
||||
@orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
if(id == "SAL")
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
end
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
|
||||
def send_account
|
||||
amount = params[:amount]
|
||||
account_no = params[:account_no]
|
||||
receipt_no = params[:receipt_no]
|
||||
sale = Sale.find_by_receipt_no(receipt_no)
|
||||
@out = []
|
||||
action_by = current_user.name
|
||||
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no)
|
||||
|
||||
if membership_data["status"]==true
|
||||
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
|
||||
else
|
||||
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Remark : #{membership_data[:message]}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
|
||||
end
|
||||
@out = membership_data
|
||||
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
121
app/controllers/foodcourt/dashboard_controller.rb
Normal file
121
app/controllers/foodcourt/dashboard_controller.rb
Normal file
@@ -0,0 +1,121 @@
|
||||
class Foodcourt::DashboardController < BaseFoodcourtController
|
||||
|
||||
def index
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
|
||||
@display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale(@shop,'card', today, current_user)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
else
|
||||
@sale_data = nil
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(@shop,today,current_user)
|
||||
@total_accounts = Sale.total_account(@shop,today,current_user)
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(@shop,account.account_id, today,current_user)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
else
|
||||
@account_data = nil
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(@shop,today,current_user)
|
||||
@total_foc_items = Sale.total_foc_items(@shop,today,current_user)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@current_user = current_user
|
||||
#dine-in cashier
|
||||
dinein_cashier = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
@dinein_cashier = 0
|
||||
if !dinein_cashier[0].nil?
|
||||
@dinein_cashier = dinein_cashier[0][1]
|
||||
end
|
||||
|
||||
#quick service
|
||||
quick_service = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quick_service')
|
||||
@quick_service = 0
|
||||
if !quick_service[0].nil?
|
||||
@quick_service = quick_service[0][1]
|
||||
end
|
||||
|
||||
#fourt court
|
||||
food_court = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('food_court')
|
||||
@food_court = 0
|
||||
@food_court_name = nil
|
||||
if !food_court[0].nil?
|
||||
@food_court = food_court[0][1]
|
||||
@food_court_name = food_court[0][0]
|
||||
end
|
||||
|
||||
#order reservation
|
||||
order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
|
||||
@order_reservation = 0
|
||||
if !order_reservation.empty?
|
||||
order_reservation.each do |order_reserve|
|
||||
if order_reserve[0] == 'OrderReservation'
|
||||
@order_reservation = order_reserve[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#dashboard settings on/off for supervisor and cashier
|
||||
dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings')
|
||||
@setting_flag = true
|
||||
if !dashboard_settings.empty?
|
||||
dashboard_settings.each do |setting|
|
||||
if setting[0].to_s.downcase == current_user.role.downcase && setting[1] == '0'
|
||||
@setting_flag = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#reservation
|
||||
reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation')
|
||||
@reservation = 0
|
||||
if !reservation.empty?
|
||||
reservation.each do |reserve|
|
||||
if reserve[0] == 'Reservation'
|
||||
@reservation = reserve[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_all_menu
|
||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'")
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
def get_credit_sales
|
||||
credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
if !credit_sales.nil?
|
||||
result = {:status=> true, :data=> credit_sales }
|
||||
else
|
||||
result = {:status=> false, :message=>"There is no record." }
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
end
|
||||
336
app/controllers/foodcourt/discounts_controller.rb
Executable file
336
app/controllers/foodcourt/discounts_controller.rb
Executable file
@@ -0,0 +1,336 @@
|
||||
class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
authorize_resource :class => false
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def index
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
sale_id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
if @sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
else
|
||||
@table = nil
|
||||
end
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def create
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
overall_discount = params[:overall_discount]
|
||||
sub_total = params[:sub_total]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table = nil
|
||||
table_id = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_discount = overall_discount.to_f
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||
# sale.save
|
||||
if discount_items.length > 0
|
||||
|
||||
#save sale item for discount
|
||||
discount_items.each do |di|
|
||||
origin_sale_item = SaleItem.find(di["id"])
|
||||
|
||||
sale_item = SaleItem.new
|
||||
|
||||
# if !origin_sale_item.nil?
|
||||
# menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
|
||||
# if !menu_category.nil?
|
||||
# sale_item.menu_category_code = menu_category.code
|
||||
# sale_item.menu_category_name = menu_category.name
|
||||
# end
|
||||
# end
|
||||
|
||||
sale_item.menu_category_code = origin_sale_item.menu_category_code
|
||||
sale_item.menu_category_name = origin_sale_item.menu_category_name
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
sale_item.product_name = di["name"]
|
||||
sale_item.item_instance_code = origin_sale_item.item_instance_code
|
||||
sale_item.product_alt_name = ""
|
||||
sale_item.status = "Discount"
|
||||
|
||||
sale_item.qty = -1
|
||||
sale_item.unit_price = di["price"].to_f * -1
|
||||
sale_item.taxable_price = di["price"]
|
||||
sale_item.is_taxable = 1
|
||||
sale_item.account_id = origin_sale_item.account_id
|
||||
|
||||
sale_item.price = di["price"]
|
||||
sale_item.save
|
||||
|
||||
action_by = current_user.name
|
||||
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
if overall_discount.to_f > 0
|
||||
action_by = current_user.name
|
||||
if table.nil?
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- no Table "
|
||||
else
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
|
||||
end
|
||||
sale.compute_by_sale_items(overall_discount.to_f, nil,order_source)
|
||||
if !table.nil?
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Success" }
|
||||
end
|
||||
else
|
||||
if !table.nil?
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Please, Check Again!" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
# Remove selected discount Items
|
||||
def remove_discount_items
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
if discount_items.length > 0
|
||||
#destroy sale item for discount
|
||||
discount_items.each do |di|
|
||||
sale_item = SaleItem.find(di["id"])
|
||||
sale.total_amount = (sale.total_amount + sale_item.price.abs)
|
||||
|
||||
action_by = current_user.name
|
||||
if table.nil?
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table "
|
||||
else
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEITEMDISCOUNT" )
|
||||
|
||||
sale_item.destroy
|
||||
end
|
||||
end
|
||||
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.save
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
else
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
# Remove all discount Items
|
||||
def remove_all_discount
|
||||
sale_id = params[:id]
|
||||
order_source = params[:type]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
table_type = table.type
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
table_type = nil
|
||||
end
|
||||
|
||||
discount_items = []
|
||||
#destroy all discount sale item
|
||||
sale.sale_items.each do |si|
|
||||
if si.status == "Discount" && si.price < 0
|
||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||
discount_items.push(si)
|
||||
end
|
||||
end
|
||||
|
||||
# sale.total_discount = 0
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.save
|
||||
|
||||
#destroy in sale.sale_items
|
||||
sale.sale_items.destroy(discount_items)
|
||||
|
||||
action_by = current_user.name
|
||||
if table.nil?
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- No Table"
|
||||
else
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(0, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
else
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
# Member Discount
|
||||
def member_discount
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
is_card = params[:is_card]
|
||||
sub_total = params[:sub_total]
|
||||
tax_type = params[:tax_type]
|
||||
sale = Sale.find(sale_id)
|
||||
if is_card == 'true'
|
||||
is_card = true
|
||||
else is_card.to_s == 'false'
|
||||
is_card = false
|
||||
end
|
||||
# Check for Card Payment
|
||||
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
|
||||
|
||||
# if is_card != "true"
|
||||
account_types = Account.where("discount=?",true)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
|
||||
# Get Prices for each accounts (eg: food, beverage)
|
||||
account_price = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
acc_prices = Array.new;
|
||||
|
||||
account_types.each do |at|
|
||||
account_price.each do |pc|
|
||||
if pc[:name] == at.title && pc[:price]>0
|
||||
str={type:pc[:name],amount:pc[:price]}
|
||||
acc_prices.push(str)
|
||||
end
|
||||
end
|
||||
end
|
||||
generic_customer_id = sale.customer.membership_id
|
||||
receipt_no = sale.receipt_no
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("member_discount")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
account_no = sale.customer.paypar_account_no rescue nil
|
||||
|
||||
# Check for items for Paypar Cloud
|
||||
if acc_prices.length > 0
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { account_no: account_no,
|
||||
generic_customer_id:generic_customer_id ,
|
||||
campaign_type_id: campaign_type_id,
|
||||
receipt_no: receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
campaign_method:acc_prices.to_json,
|
||||
total_sale_transaction_amount: sale.grand_total,
|
||||
is_card: is_card,
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {"status": false, "message": "Http party error" }
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = {"status": false, "message": "Connection TIme out " }
|
||||
rescue OpenURI::HTTPError
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
|
||||
rescue SocketError
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
end
|
||||
else
|
||||
response = {"status": false, "message": "You have no selected discount item" }
|
||||
end
|
||||
Rails.logger.debug "-------------- Member Discount Osaka ---------"
|
||||
Rails.logger.debug response.to_json
|
||||
# Re-calc All Amount in Sale
|
||||
if response["status"] == true
|
||||
discount_amount = response["discount_earned"]
|
||||
if response["discount_bonus_earned"]
|
||||
discount_amount = discount_amount + response["discount_bonus_earned"]
|
||||
end
|
||||
sale.compute_by_sale_items(discount_amount, 'member_discount', order_source, tax_type)
|
||||
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
||||
elsif response["status"] == "500"
|
||||
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||
else
|
||||
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
|
||||
# end #end Is Card Payment
|
||||
end
|
||||
|
||||
end
|
||||
201
app/controllers/foodcourt/food_court_controller.rb
Normal file
201
app/controllers/foodcourt/food_court_controller.rb
Normal file
@@ -0,0 +1,201 @@
|
||||
class Foodcourt::FoodCourtController < ApplicationController
|
||||
# before_action :set_dining, only: [:detail]
|
||||
before_action :check_user
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
# if params[:menu] == "true"
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@cashier_type = "food_court"
|
||||
#checked quick_service only
|
||||
@quick_service_only = true
|
||||
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "dineincashier"
|
||||
if dine_in[1] == '1'
|
||||
@quick_service_only = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render "foodcourt/addorders/detail"
|
||||
end
|
||||
|
||||
def modify_order
|
||||
@cashier_type = "food_court"
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
# if params[:menu] == "true"
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
if(params[:id][0,3] == "BKI")
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
else
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
end
|
||||
|
||||
@sale_id = @booking.sale_id
|
||||
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
|
||||
render "foodcourt/addorders/detail"
|
||||
end
|
||||
|
||||
def update_modify_order
|
||||
booking = Booking.find(params[:booking_id])
|
||||
sale = booking.sale
|
||||
if sale && sale.sale_status != 'new'
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
cashier_type = "food_court"
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
if i["parent_order_item_id"]
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
|
||||
else
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
|
||||
# begin
|
||||
order = Order.new
|
||||
order.source = params[:order_source]
|
||||
order.order_type = params[:order_type]
|
||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
order.items = items_arr
|
||||
order.guest = params[:guest_info]
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
order.waiters = current_login_employee.name
|
||||
order.employee_name = current_login_employee.name
|
||||
|
||||
order.is_extra_time = is_extra_time
|
||||
order.extra_time = extra_time
|
||||
|
||||
order.new_booking = false
|
||||
order.booking_id = booking.booking_id
|
||||
|
||||
if order.generate
|
||||
if sale
|
||||
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||
render :json => { :status => true, :data => sale }
|
||||
else
|
||||
render :json => { :status => true, :data => 'OK' }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_menu_sub_category ()
|
||||
id = params[:id]
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_all_product()
|
||||
@product = Product..where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
168
app/controllers/foodcourt/home_controller.rb
Executable file
168
app/controllers/foodcourt/home_controller.rb
Executable file
@@ -0,0 +1,168 @@
|
||||
class Foodcourt::HomeController < BaseFoodcourtController
|
||||
authorize_resource :class => false
|
||||
before_action :set_dining, only: [:show]
|
||||
|
||||
def index
|
||||
@webview = check_mobile
|
||||
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
end
|
||||
|
||||
# origami table detail
|
||||
def show
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
|
||||
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
|
||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
@dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
|
||||
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
|
||||
@order_items = Array.new
|
||||
@dining_booking.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
# @assigned_order_items = Array.new
|
||||
if booking.booking_orders.empty?
|
||||
@booking = booking
|
||||
else
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
@date = order.created_at
|
||||
@booking= booking
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
|
||||
# if !assigned_order_items.nil?
|
||||
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
|
||||
# end
|
||||
end
|
||||
@account_arr = Array.new
|
||||
if @customer.tax_profiles
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find_by_id(acc)
|
||||
if !account.nil?
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@booking= booking
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
@customer = sale.customer
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find_by_id(acc)
|
||||
if !account.nil?
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
@sale_taxes = []
|
||||
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@sale_taxes.push(sale_tax)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#for bank integration
|
||||
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
|
||||
|
||||
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
@tax_arr.push(acc.name)
|
||||
end
|
||||
|
||||
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
|
||||
#for edit order on/off
|
||||
@edit_order_origami = true
|
||||
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
|
||||
if !lookup_edit_order.empty?
|
||||
lookup_edit_order.each do |edit_order|
|
||||
if edit_order[0].downcase == "editorderorigami"
|
||||
if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter')
|
||||
@edit_order_origami = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def check_emp_access_code
|
||||
pin_code = params[:code]
|
||||
employee = Employee.find_by_emp_id(pin_code)
|
||||
if employee && (employee.role == "manager" || employee.role == "supervisor")
|
||||
result = {:status=> true, :message=>"Success" }
|
||||
else
|
||||
result = {:status=> false, :message=>"Invalid Access Code" }
|
||||
end
|
||||
render :json => result.to_json
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_dining
|
||||
@dining = DiningFacility.find(params[:dining_id])
|
||||
end
|
||||
|
||||
end
|
||||
96
app/controllers/foodcourt/orders_controller.rb
Executable file
96
app/controllers/foodcourt/orders_controller.rb
Executable file
@@ -0,0 +1,96 @@
|
||||
class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
def show
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@order = Order.find(params[:order_id])
|
||||
booking = Booking.select('bookings.booking_id, bookings.dining_facility_id')
|
||||
.joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id")
|
||||
.where("bo.order_id='#{params[:order_id]}'").first()
|
||||
|
||||
@booking = Array.new
|
||||
if !booking.nil?
|
||||
if booking.dining_facility_id.to_i > 0
|
||||
dining_facilities = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => dining_facilities.type})
|
||||
else
|
||||
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => nil})
|
||||
end
|
||||
|
||||
end
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
|
||||
sale_order = SaleOrder.find_by_order_id(@order.order_id)
|
||||
if sale_order
|
||||
unless sale_order.sale_id.nil?
|
||||
sale = Sale.find(sale_order.sale_id)
|
||||
@sale_status = sale.sale_status
|
||||
end
|
||||
end
|
||||
|
||||
@order.order_items.each_with_index do |item, order_item_index|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
@order.order_items[order_item_index].set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
|
||||
# bookings = Booking.all
|
||||
# if !bookings.today.nil?
|
||||
# @order_items_count = Hash.new
|
||||
# bookings.each do |booking|
|
||||
# if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
# if !booking.booking_orders.empty?
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# if !order.order_items.empty?
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# if !booking.sale_id.nil?
|
||||
# sale = Sale.find(booking.sale_id)
|
||||
# if sale.sale_status !='completed'
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] = sale.sale_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
def app_orders
|
||||
@bookings = Booking.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||
.where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}'").order("created_at desc")
|
||||
end
|
||||
def app_order_by_booking
|
||||
|
||||
end
|
||||
end
|
||||
85
app/controllers/foodcourt/other_charges_controller.rb
Executable file
85
app/controllers/foodcourt/other_charges_controller.rb
Executable file
@@ -0,0 +1,85 @@
|
||||
class Foodcourt::OtherChargesController < BaseFoodcourtController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
if @sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
else
|
||||
@table = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
other_charges_items = JSON.parse(params[:other_charges_items])
|
||||
sub_total = params[:sub_total]
|
||||
cashier_type = params[:cashier_type]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||
# sale.save
|
||||
if other_charges_items.length > 0
|
||||
#save sale item for discount
|
||||
other_charges_items.each do |di|
|
||||
# origin_sale_item = SaleItem.find(di["id"])
|
||||
sale_item = SaleItem.new
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.menu_category_code = "0.0"
|
||||
sale_item.menu_category_name = "Other Charges"
|
||||
sale_item.product_code = "Other Charges"
|
||||
sale_item.product_name = "*" + di["name"]
|
||||
sale_item.product_alt_name = ""
|
||||
sale_item.status = "Other Charges"
|
||||
|
||||
sale_item.qty = 1
|
||||
sale_item.unit_price = di["price"]
|
||||
sale_item.taxable_price = di["price"] * 1
|
||||
sale_item.is_taxable = di["is_taxable"]
|
||||
sale_item.account_id = 0
|
||||
|
||||
sale_item.price = di["price"] * 1
|
||||
sale_item.save
|
||||
|
||||
action_by = current_user.name
|
||||
if table.nil?
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->"
|
||||
else
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||
end
|
||||
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_name, action_by,remark,"ADDOTHERCHARGES" )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, cashier_type)
|
||||
end
|
||||
if !table.nil?
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
render :json => dining.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
97
app/controllers/foodcourt/paymal_controller.rb
Normal file
97
app/controllers/foodcourt/paymal_controller.rb
Normal file
@@ -0,0 +1,97 @@
|
||||
class Foodcourt::PaymalController < BaseFoodcourtController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = sale_data.receipt_no
|
||||
# @shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
# @rounding_adj = sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "paypar"
|
||||
@payparcount = @payparcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@payment_prices = sale_data.grand_total - @payparcount -others
|
||||
|
||||
|
||||
if sale_data
|
||||
if sale_data.customer_id
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if customer_data
|
||||
@membership_id = customer_data.membership_id
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||
if membership_data["status"]==true
|
||||
@membership_rebate_balance=membership_data["balance"]
|
||||
@out = true, @membership_rebate_balance,@membership_id
|
||||
end
|
||||
else
|
||||
@out =false,0
|
||||
end
|
||||
else
|
||||
@out = false,0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:payment_amount]
|
||||
sale_id = params[:sale_id]
|
||||
transaction_ref = params[:transaction_ref]
|
||||
account_no = params[:account_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale,@membership_data = sale_payment.process_payment(saleObj, current_user, cash, "paymal",account_no)
|
||||
|
||||
if status == true && @membership_data["status"] == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, @membership_data["message"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
691
app/controllers/foodcourt/payments_controller.rb
Executable file
691
app/controllers/foodcourt/payments_controller.rb
Executable file
@@ -0,0 +1,691 @@
|
||||
class Foodcourt::PaymentsController < BaseFoodcourtController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
member_info = nil
|
||||
type = params[:type]
|
||||
tax_type = params[:tax_type]
|
||||
path = request.fullpath
|
||||
latest_order_no = nil
|
||||
is_kbz = params[:is_kbz]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
#shop_detail = Shop.first
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total - saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||
if is_kbz == 'false'
|
||||
Rails.logger.info '################ CASH PAYMENT #################'
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
else
|
||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
if !path.include? ("credit_payment")
|
||||
rebate_amount = nil
|
||||
# For Cashier by Zone
|
||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
bookings = Booking.find_by_sale_id(sale_id)
|
||||
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
if bookings.dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
|
||||
type = 'payment'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
end
|
||||
|
||||
# For Print
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.all
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code = "ReceiptBillPdf"
|
||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code = "ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||
if receipt_bilA5[1] == '1'
|
||||
unique_code = "ReceiptBillA5Pdf"
|
||||
# else
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
member_info = Customer.get_member_account(customer)
|
||||
|
||||
if member_info["status"] == true
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
#orders print out
|
||||
if type == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
|
||||
if !latest_order.nil?
|
||||
latest_order_no = latest_order.order_id
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
# Order.pay_process_order_queue(order.order_id, table_id)
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.pay_process_order_queue(order.order_id, table_id)
|
||||
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#for card sale data
|
||||
card_data = Array.new
|
||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||
if !card_sale_trans_ref_no.nil?
|
||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||
card_no = cash_sale_trans.pan.last(4)
|
||||
card_no = card_no.rjust(19,"**** **** **** ")
|
||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||
end
|
||||
end
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
#end
|
||||
end
|
||||
logger.debug 'saleObj++++++++++++++++++++++++++'
|
||||
logger.debug saleObj.to_json
|
||||
if !saleObj.nil?
|
||||
# InventoryJob.perform_now(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
end
|
||||
end
|
||||
|
||||
# status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, nil, nil)
|
||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||
end
|
||||
|
||||
def show
|
||||
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
path = request.fullpath
|
||||
sale_id = params[:sale_id]
|
||||
@trans_flag = true
|
||||
if params[:type] == "transaction"
|
||||
@trans_flag = false
|
||||
@cashier_type = "cashier"
|
||||
else
|
||||
@cashier_type = params[:type]
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||
@membership_rebate_balance=0
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@cash = 0.0
|
||||
@kbz_pay_amount = 0.0
|
||||
@other = 0.0
|
||||
@ppamount = 0.0
|
||||
@visacount= 0.0
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@alipaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@paymalcount = 0.0
|
||||
@dingacount = 0.0
|
||||
@giftvouchercount = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# @shop = shop_detail #show shop info
|
||||
|
||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !saleObj.equal_persons.nil?
|
||||
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
|
||||
end
|
||||
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.grand_total / 25 # Division
|
||||
# #not calculate rounding if modulus is 0 and division is even
|
||||
# #calculate rounding if modulus is zero or not zero and division are not even
|
||||
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
|
||||
@sale_data.grand_total = new_total
|
||||
@sale_data.old_grand_total = saleObj.grand_total
|
||||
@sale_data.rounding_adjustment = @rounding_adj
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@balance = @balance.to_f + res["balance"].to_f
|
||||
# @accountable_type = res["accountable_type"]
|
||||
@accountable_type = "Rebate Balance"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#end customer amount
|
||||
|
||||
#paymal payment
|
||||
|
||||
@sale_data.bookings.each do |sbk|
|
||||
if sbk.dining_facility_id.to_i >0
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
@dining = df
|
||||
break
|
||||
else
|
||||
@table_no = nil
|
||||
@checkin_time = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
|
||||
else
|
||||
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
|
||||
end
|
||||
@sale_payment_data.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash += spay.payment_amount
|
||||
end
|
||||
if spay.payment_method !="creditnote"
|
||||
@other_payment += spay.payment_amount
|
||||
end
|
||||
|
||||
if spay.payment_method == "mpu"
|
||||
@other += spay.payment_amount
|
||||
elsif spay.payment_method == "paypar"
|
||||
@ppamount += spay.payment_amount
|
||||
elsif spay.payment_method == "visa"
|
||||
@visacount += spay.payment_amount
|
||||
elsif spay.payment_method == "jcb"
|
||||
@jcbcount += spay.payment_amount
|
||||
elsif spay.payment_method == "master"
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "JunctionPay"
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "paymal"
|
||||
@paymalcount += spay.payment_amount
|
||||
elsif spay.payment_method == "alipay"
|
||||
@alipaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "dinga"
|
||||
@dingacount += spay.payment_amount
|
||||
elsif spay.payment_method == "giftvoucher"
|
||||
@giftvouchercount += spay.payment_amount
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reprint
|
||||
sale_id = params[:sale_id]
|
||||
member_info = nil
|
||||
latest_order_no = nil
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
latest_order = booking.booking_orders.joins(" JOIN orders ON orders.order_id = booking_orders.order_id").where("orders.source = 'quick_service'").order("order_id DESC").limit(1).first()
|
||||
if !latest_order.nil?
|
||||
latest_order_no = latest_order.order_id
|
||||
end
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
end
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||
if receipt_bilA5[1] == '1'
|
||||
unique_code = "ReceiptBillA5Pdf"
|
||||
else
|
||||
unique_code = "ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
|
||||
#for card sale data
|
||||
card_data = Array.new
|
||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||
if !card_sale_trans_ref_no.nil?
|
||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||
card_no = cash_sale_trans.pan.last(4)
|
||||
card_no = card_no.rjust(19,"**** **** **** ")
|
||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||
end
|
||||
end
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount,transaction_ref= SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
end
|
||||
|
||||
def foc
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
sub_total = params[:sub_total]
|
||||
remark = params[:remark]
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
order_source = params[:type]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
#calculate cash acmount
|
||||
cash = saleObj.total_amount
|
||||
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
saleObj.compute_by_sale_items(0, nil, order_source)
|
||||
end
|
||||
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
|
||||
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
type = 'payment'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
end
|
||||
|
||||
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
end
|
||||
|
||||
# Re-call Sale Data
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code="ReceiptBillPdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
|
||||
unique_code="ReceiptBillA5Pdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code="ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
Order.pay_process_order_queue(order.order_id,table_id)
|
||||
end
|
||||
end
|
||||
# end
|
||||
if !saleObj.nil?
|
||||
#InventoryJob.perform_now(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def rounding_adj
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#print function for receipt
|
||||
def print
|
||||
filename = params[:filename]
|
||||
receipt_no = params[:receipt_no]
|
||||
printer_name = params[:printer_name]
|
||||
cashier_type = params[:type]
|
||||
|
||||
if cashier_type.strip.downcase == "doemal_order"
|
||||
unique_code = "ReceiptBillOrderPdf"
|
||||
else
|
||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
if !print_settings.nil?
|
||||
print_settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code = "ReceiptBillPdf"
|
||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code = "ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||
if receipt_bilA5[1] == '1'
|
||||
unique_code = "ReceiptBillA5Pdf"
|
||||
# else
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
Rails.logger.debug "$$$$$$$$$ result ::"
|
||||
Rails.logger.debug result
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# render :json => {status: true}
|
||||
end
|
||||
|
||||
#changable tax for sale
|
||||
def change_tax
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:cashier_type]
|
||||
tax_type = params[:tax_type]
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
|
||||
|
||||
render json: JSON.generate({:status => true})
|
||||
end
|
||||
|
||||
#get cloud domain
|
||||
def getCloudDomain
|
||||
from = ""
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain.to_s + "." + request.domain.to_s
|
||||
end
|
||||
|
||||
return from
|
||||
end
|
||||
end
|
||||
32
app/controllers/foodcourt/paypar_payments_controller.rb
Executable file
32
app/controllers/foodcourt/paypar_payments_controller.rb
Executable file
@@ -0,0 +1,32 @@
|
||||
class Foodcourt::PayparPaymentsController < BaseFoodcourtController
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
redeem_amount = params[:redeem_amount]
|
||||
membership_id = params[:membership_id]
|
||||
payment_method = "paypar"
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
# shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
end
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
status,msg =sale_payment.process_payment(saleObj, current_user, redeem_amount,payment_method)
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, "Please try again payment!"
|
||||
end
|
||||
else
|
||||
@out = false, "There has no sale record!"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
113
app/controllers/foodcourt/request_bills_controller.rb
Executable file
113
app/controllers/foodcourt/request_bills_controller.rb
Executable file
@@ -0,0 +1,113 @@
|
||||
class Foodcourt::RequestBillsController < ApplicationController
|
||||
before_action :check_user
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
# Print Request Bill and add to sale tables
|
||||
def print
|
||||
if !ShiftSale.current_shift(@shop.shop_code).nil?
|
||||
order_id = params[:id] # order_id
|
||||
order = Order.find(order_id)
|
||||
booking = order.booking
|
||||
if booking.checkin_at.utc > Time.now.utc && booking.checkout_at.nil?
|
||||
@status = false
|
||||
@error_message = "Operation failed, Could not request bill!"
|
||||
else
|
||||
table = DiningFacility.find_by(id: booking.dining_facility_id)
|
||||
|
||||
if sale_data = booking.sale
|
||||
@status = true
|
||||
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
||||
@status = true
|
||||
# in-duty update
|
||||
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||
if !in_duties.empty?
|
||||
in_duties.each do |in_duty|
|
||||
induty = InDuty.find(in_duty.id)
|
||||
induty.sale_id = sale_data.sale_id
|
||||
induty.out_time = Time.now.utc
|
||||
induty.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
# @sale_data.shift_sale_id = shift.id
|
||||
# @sale_data.save
|
||||
|
||||
action_by = current_user.name
|
||||
type = "REQUEST_BILL"
|
||||
|
||||
remark = "Request bill Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(sale_data,@shop.shop_code)
|
||||
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
|
||||
if order.source == "cashier" || order.source == "quick_service"
|
||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||
end
|
||||
if order.source == "quick_service" || order.source == "food_court"
|
||||
result = {:status=> @status, :data => sale_data.sale_id }
|
||||
render :json => result.to_json
|
||||
else
|
||||
#check checkInOut pdf print
|
||||
checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
||||
if !booking.dining_facility_id.nil?
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@status = true
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
end
|
||||
|
||||
# Not Use for these printed bill cannot give customer
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
# #shop detail
|
||||
# shop_details = Shop.find(1)
|
||||
# # customer= Customer.where('customer_id=' +.customer_id)
|
||||
# customer= Customer.find(@sale_data.customer_id)
|
||||
# # get member information
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# # get printer info
|
||||
# print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# # find order id by sale id
|
||||
# # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
|
||||
# # Calculate price_by_accounts
|
||||
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
|
||||
# printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
end
|
||||
|
||||
end
|
||||
232
app/controllers/foodcourt/sale_edit_controller.rb
Executable file
232
app/controllers/foodcourt/sale_edit_controller.rb
Executable file
@@ -0,0 +1,232 @@
|
||||
class Foodcourt::SaleEditController < BaseFoodcourtController
|
||||
authorize_resource class: false
|
||||
# Index for sale item void OR edit
|
||||
def edit
|
||||
sale_id = params[:sale_id]
|
||||
if params[:table_id]
|
||||
@table_id = params[:table_id]
|
||||
@table_type = DiningFacility.find(@table_id).type
|
||||
else
|
||||
@table_id = nil
|
||||
@table_type = nil
|
||||
end
|
||||
|
||||
@cashier_type = params[:type]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
end
|
||||
|
||||
# create item void. make duplicate old record and update qty and price
|
||||
def item_void
|
||||
saleitemId = params[:sale_item_id]
|
||||
remark = params[:remark]
|
||||
access_code = params[:access_code]
|
||||
order_source = params[:type]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.status = 'void'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
# @newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.is_taxable = 1
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
|
||||
# booking = Booking.find_by_sale_id(saleitemObj.sale_id)
|
||||
# booking.booking_orders.each do |bo|
|
||||
# order = Order.find(bo.order_id)
|
||||
# order.order_items.each do |o|
|
||||
# if saleitemObj.product_code == o.item_code
|
||||
# o.qty = saleitemObj.qty * -1
|
||||
# o.price = saleitemObj.price * -1
|
||||
# o.save
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMVOID" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
def item_foc
|
||||
saleitemId = params[:sale_item_id]
|
||||
remark = params[:remark]
|
||||
access_code = params[:access_code]
|
||||
order_source = params[:type]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.status = 'foc'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.unit_price = saleitemObj.unit_price * 1
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMFOC" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
# def item_edit
|
||||
# saleitemId = params[:sale_item_id]
|
||||
# update_qty = params[:update_qty]
|
||||
# update_price = params[:update_price]
|
||||
# saleitemObj = SaleItem.find(saleitemId)
|
||||
# saleitemObj.status = 'void'
|
||||
# saleitemObj.save
|
||||
# @newsaleitem = SaleItem.new
|
||||
# @newsaleitem = saleitemObj.dup
|
||||
# @newsaleitem.save
|
||||
# @newsaleitem.qty = update_qty
|
||||
# @newsaleitem.price = update_price
|
||||
# @newsaleitem.unit_price = update_price
|
||||
# @newsaleitem.taxable_price = update_price
|
||||
# @newsaleitem.is_taxable = 0
|
||||
# @newsaleitem.remark = 'edit'
|
||||
# @newsaleitem.product_name = saleitemObj.product_name + " - updated"
|
||||
# @newsaleitem.save
|
||||
# end
|
||||
|
||||
def item_edit
|
||||
saleitemId = params[:sale_item_id]
|
||||
update_qty = params[:update_qty]
|
||||
update_price = params[:update_price]
|
||||
access_code = params[:access_code]
|
||||
order_source = params[:type]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
original_qty = saleitemObj.qty
|
||||
original_price = saleitemObj.unit_price
|
||||
sale = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
saleitemObj.qty = update_qty
|
||||
saleitemObj.price = update_qty.to_f * update_price.to_f
|
||||
saleitemObj.unit_price = update_price
|
||||
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
|
||||
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
remark = "Update From Qty=>#{original_qty} Price=>[#{original_price}] to qty=>#{update_qty} Price =>[#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMEDIT" )
|
||||
# saleitemObj.remark = 'edit'
|
||||
|
||||
unless saleitemObj.product_name.include? 'UPDATED'
|
||||
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
|
||||
end
|
||||
|
||||
saleitemObj.save
|
||||
|
||||
# re-calc tax
|
||||
# saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
# order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
# order = Order.find(order_id)
|
||||
|
||||
# order.order_items.each do |o|
|
||||
# if saleitemObj.product_code == o.item_code
|
||||
# o.qty = update_qty
|
||||
# o.price = update_price
|
||||
# o.save
|
||||
# end
|
||||
# end
|
||||
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
|
||||
end
|
||||
|
||||
# make cancel void item
|
||||
def item_void_cancel
|
||||
saleitemId = params[:sale_item_id]
|
||||
access_code = params[:access_code]
|
||||
order_source = params[:type]
|
||||
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
|
||||
saleObj = saleitemObj.sale
|
||||
|
||||
saleObj.sale_items.where(product_code: saleitemObj.product_code)
|
||||
.where(qty: saleitemObj.qty.abs)
|
||||
.where(unit_price: saleitemObj.unit_price)
|
||||
.where(status: saleitemObj.status).first.update(status: nil, remark: nil)
|
||||
|
||||
saleitemObj.destroy
|
||||
# re-calc tax
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.remove_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
# remove all void items
|
||||
def cancel_all_void
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.sale_items.each do |item|
|
||||
if item.qty.to_i < 0
|
||||
item.destroy
|
||||
else
|
||||
item.status = nil
|
||||
end
|
||||
item.save
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
saleObj.sale_items.reset
|
||||
# re-calc tax
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount,nil, order_source)
|
||||
end
|
||||
|
||||
def apply_void
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.compute_without_void(order_source)
|
||||
saleObj.sale_items.each do |item|
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
78
app/controllers/foodcourt/sales_controller.rb
Executable file
78
app/controllers/foodcourt/sales_controller.rb
Executable file
@@ -0,0 +1,78 @@
|
||||
class Foodcourt::SalesController < BaseFoodcourtController
|
||||
def show
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@rooms = Room.unscoped.all.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier",@shop.shop_code)
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
if Booking.find(@booking).dining_facility_id.to_i>0
|
||||
@table_id = Booking.find(@booking).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
else
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
def add_to_existing_invoice
|
||||
dining = params[:dining_id]
|
||||
sale_id = params[:sale_id]
|
||||
tax_type = params[:tax_type]
|
||||
sale_data = []
|
||||
table = DiningFacility.find(dining)
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
table.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ").each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
order_array = []
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
order.status = 'billed'
|
||||
order.order_items.each do |item|
|
||||
item.order_item_status = 'billed'
|
||||
end
|
||||
# create sale item
|
||||
saleobj = Sale.find(sale_id)
|
||||
order.order_items.each do |orer_item|
|
||||
saleobj.add_item (orer_item)
|
||||
if !orer_item.set_menu_items.nil?
|
||||
saleobj.add_sub_item(orer_item.set_menu_items)
|
||||
end
|
||||
sale_data.push(orer_item)
|
||||
end
|
||||
|
||||
# Re-compute for add
|
||||
saleobj.compute(order.source,tax_type)
|
||||
saleobj.save
|
||||
order.save
|
||||
booking.save
|
||||
|
||||
order_array.push(order.order_id)
|
||||
end
|
||||
|
||||
receipt_no = Sale.find(sale_id).receipt_no
|
||||
action_by = current_user.name
|
||||
type = "ADD_TO_EXISTING"
|
||||
|
||||
remark = "#{action_by} add to existing order #{order_array} to Receipt No=>#{receipt_no} in #{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
bo.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
34
app/controllers/foodcourt/second_display_controller.rb
Normal file
34
app/controllers/foodcourt/second_display_controller.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class Foodcourt::SecondDisplayController < BaseFoodcourtController
|
||||
|
||||
def index
|
||||
@display_images = DisplayImage.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def customer_view
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i == 2
|
||||
if params[:status]!= "billed"
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
else
|
||||
tax_profiles = nil
|
||||
end
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from
|
||||
end
|
||||
# end
|
||||
end
|
||||
#Shop Name in Navbor
|
||||
# helper_method :shop_detail
|
||||
# def shop_detail
|
||||
# @shop = Shop.first
|
||||
# end
|
||||
|
||||
|
||||
end
|
||||
158
app/controllers/foodcourt/shifts_controller.rb
Executable file
158
app/controllers/foodcourt/shifts_controller.rb
Executable file
@@ -0,0 +1,158 @@
|
||||
class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
def index
|
||||
end
|
||||
|
||||
def show
|
||||
@cashier_type = params[:type]
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
#for bank integration
|
||||
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@float = Lookup.where('lookup_type=?','float_value')
|
||||
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
def create
|
||||
opening_balance = params[:opening_balance]
|
||||
cashier_terminal_param = params[:cashier_terminal]
|
||||
|
||||
# Multiple Cashier
|
||||
cashier_terminal = CashierTerminal.find(cashier_terminal_param)
|
||||
if cashier_terminal.is_currently_login
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' }
|
||||
end
|
||||
end
|
||||
|
||||
# Update Cashier Terminal
|
||||
cashier_terminal.is_currently_login = 1
|
||||
cashier_terminal.save
|
||||
|
||||
@shift_sale = ShiftSale.new
|
||||
@shift_sale.create(opening_balance,cashier_terminal_param, current_user)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def update_shift
|
||||
closing_balance = params[:closing_balance]
|
||||
shift_id = params[:shift_id]
|
||||
@shift = ShiftSale.find_by_id(shift_id)
|
||||
if @shift
|
||||
@shift.shift_closed_at = DateTime.now.utc
|
||||
@shift.closing_balance = closing_balance.to_f
|
||||
@shift.save
|
||||
|
||||
# Multiple Cashier
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
cashier_terminal.is_currently_login = 0
|
||||
cashier_terminal.save
|
||||
|
||||
#add shift_sale_id to card_settle_trans
|
||||
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
|
||||
if !bank_integration.nil?
|
||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||
|
||||
card_settle_trans.each do |data|
|
||||
card_sett_trans = CardSettleTran.find(data.id)
|
||||
card_sett_trans.shift_sale_id = @shift.id
|
||||
card_sett_trans.save()
|
||||
end
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
|
||||
|
||||
# if !close_cashier_print[0].nil?
|
||||
# @close_cashier_print = close_cashier_print[0][1]
|
||||
# end
|
||||
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[1] == '1'
|
||||
unique_code="CloseCashierCustomisePdf"
|
||||
else
|
||||
unique_code="CloseCashierPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
shop_details = shop_detail
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
sale_items = ''
|
||||
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
|
||||
if @lookup.to_i == 1
|
||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||
other_charges = Sale.get_other_charges()
|
||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||
end
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
||||
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
# print close cashier setting
|
||||
close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||
if close_cashier_print.empty?
|
||||
@settings_lookup = Lookup.new(lookup_type: "close_cashier_print", name: "CloseCashierPrint", value: "1")
|
||||
@settings_lookup.save
|
||||
end
|
||||
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||
if find_close_cashier_print[0][1].to_i > 0
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
end
|
||||
end
|
||||
end
|
||||
Employee.logout(@shop,session[:session_token])
|
||||
session[:session_token] = nil
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def sale_summary
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
# @shift = ShiftSale.find_by_id(shift_id)
|
||||
if @shift
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
112
app/controllers/foodcourt/surveys_controller.rb
Normal file
112
app/controllers/foodcourt/surveys_controller.rb
Normal file
@@ -0,0 +1,112 @@
|
||||
class Foodcourt::SurveysController < BaseFoodcourtController
|
||||
def new
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@survey = Survey.new
|
||||
@id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
if(@id[0,3] == "SAL")
|
||||
@sale = Sale.find(@id)
|
||||
@receipt_no = @sale.receipt_no
|
||||
@grand_total = @sale.grand_total
|
||||
@booking = Booking.find_by_sale_id(@id)
|
||||
|
||||
if @booking.dining_facility_id.to_i>0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
|
||||
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
end
|
||||
else
|
||||
@dining_facility = nil
|
||||
@table_type = nil
|
||||
end
|
||||
|
||||
else
|
||||
@dining_facility = DiningFacility.find(@id)
|
||||
@table_type = @dining_facility.type
|
||||
@receipt_no = nil
|
||||
@grand_total = nil
|
||||
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@type = params[:cashier_type]
|
||||
@sale_id = params[:sale_id]
|
||||
if params[:table_id].to_i>0
|
||||
@dining_facility = DiningFacility.find(params[:table_id])
|
||||
if params[:sale_id].to_i > 0
|
||||
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# set cashier
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
current_shift_user =Employee.find_by_id(current_user.employee_id)
|
||||
if open_cashier.count>0
|
||||
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0])
|
||||
else
|
||||
shift_by_terminal = ShiftSale.current_open_shift(current_shift_user)
|
||||
end
|
||||
else
|
||||
sale = Sale.find(@sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||
end
|
||||
else
|
||||
sale = Sale.find(@sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||
end
|
||||
|
||||
if @type == "quick_service" || @type == "food_court"
|
||||
@url = "/foodcourt/sale/"+@sale_id+"/"+@type+"/payment"
|
||||
else
|
||||
@url = "/foodcourt/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||
end
|
||||
|
||||
|
||||
if params[:survey_id].nil? || params[:survey_id] == ""
|
||||
@survey = Survey.new(survey_params)
|
||||
@survey.shift_id = shift_by_terminal.id
|
||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
@survey.shop_code = @shop.shop_code
|
||||
# respond_to do |format|
|
||||
if @survey.save
|
||||
redirect_to @url
|
||||
end
|
||||
# end
|
||||
else
|
||||
survey = Survey.find_by_id(params[:survey_id])
|
||||
survey.child = params["survey"]["child"]
|
||||
survey.adult = params["survey"]["adult"]
|
||||
survey.male = params["survey"]["male"]
|
||||
survey.female = params["survey"]["female"]
|
||||
survey.local = params["survey"]["local"]
|
||||
survey.dining_name = params["survey"]["dining_name"]
|
||||
survey.receipt_no = params["survey"]["receipt_no"]
|
||||
survey.shift_id = shift_by_terminal.id
|
||||
survey.created_by = params["survey"]["created_by"]
|
||||
survey.total_customer = params["survey"]["total_customer"]
|
||||
survey.total_amount = params["survey"]["total_amount"]
|
||||
survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
if survey.save!
|
||||
redirect_to @url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def survey_params
|
||||
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
|
||||
end
|
||||
|
||||
end
|
||||
171
app/controllers/foodcourt/void_controller.rb
Executable file
171
app/controllers/foodcourt/void_controller.rb
Executable file
@@ -0,0 +1,171 @@
|
||||
class Foodcourt::VoidController < BaseFoodcourtController
|
||||
authorize_resource :class => false
|
||||
def overall_void
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
remark = params[:remark]
|
||||
order_source = params[:type] #tax profile source
|
||||
access_code = params[:access_code]
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
sale.compute_by_sale_items(0, nil, order_source)
|
||||
end
|
||||
|
||||
# update count for shift sale
|
||||
if(sale.sale_status == "completed")
|
||||
if sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift.calculate(sale_id, "void")
|
||||
end
|
||||
else
|
||||
# void before sale payment complete
|
||||
if sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift.total_void = shift.total_void + sale.grand_total
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
|
||||
sale.rounding_adjustment = 0.0
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
# No Need
|
||||
# bookings = sale.bookings
|
||||
# bookings.each do |booking|
|
||||
# orders = booking.orders
|
||||
# orders.each do |order|
|
||||
# # order.status = 'void'
|
||||
# end
|
||||
# end
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
end
|
||||
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" )
|
||||
|
||||
# For Print
|
||||
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# get printer info
|
||||
# print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf
|
||||
#
|
||||
# if !print_settings.nil?
|
||||
# unique_code = 'ReceiptBillPdf'
|
||||
# elsif
|
||||
# unique_code = 'ReceiptBillStarPdf'
|
||||
# end
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code="ReceiptBillPdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
|
||||
unique_code="ReceiptBillA5Pdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code="ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
aoi.delivery_status = 1
|
||||
aoi.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
145
app/controllers/foodcourt/waste_spoile_controller.rb
Executable file
145
app/controllers/foodcourt/waste_spoile_controller.rb
Executable file
@@ -0,0 +1,145 @@
|
||||
class Foodcourt::WasteSpoileController < BaseFoodcourtController
|
||||
def waste_and_spoilage
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
remark = params[:remark]
|
||||
order_source = params[:type]
|
||||
access_code = params[:access_code] #tax profile source
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
|
||||
existing_tax.delete
|
||||
end
|
||||
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
|
||||
sale.payment_status = remark
|
||||
sale.sale_status = remark
|
||||
sale.save
|
||||
|
||||
# add to sale item with foc
|
||||
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
|
||||
|
||||
sale.sale_items.each do|item|
|
||||
# SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
|
||||
item.status = remark
|
||||
item.remark = remark
|
||||
item.save
|
||||
end
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
|
||||
end
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
|
||||
|
||||
# For Print
|
||||
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
|
||||
|
||||
unique_code="ReceiptBillPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'ReceiptBillPdf'
|
||||
unique_code="ReceiptBillPdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
|
||||
unique_code="ReceiptBillA5Pdf"
|
||||
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
|
||||
unique_code="ReceiptBillStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
aoi.delivery_status = 1
|
||||
aoi.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -78,6 +78,9 @@ class HomeController < ApplicationController
|
||||
elsif @employee.role == "kitchen"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to oqs_root_path
|
||||
elsif @employee.role == "foodcourt_cashier"
|
||||
session[:session_token] = @employee.token_session
|
||||
route_by_role(@employee)
|
||||
else
|
||||
render :index
|
||||
end
|
||||
@@ -221,6 +224,14 @@ class HomeController < ApplicationController
|
||||
redirect_to origami_dashboard_path
|
||||
elsif employee.role == "account"
|
||||
redirect_to reports_dailysale_index_path
|
||||
elsif employee.role == "foodcourt_cashier"
|
||||
#check if cashier has existing open cashier
|
||||
shift = ShiftSale.current_open_shift(employee)
|
||||
if !shift.nil?
|
||||
redirect_to foodcourt_food_court_path
|
||||
else
|
||||
redirect_to new_foodcourt_shift_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
|
||||
result = {
|
||||
:filepath => filename,
|
||||
@@ -278,7 +278,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
@@ -288,7 +288,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
#end
|
||||
end
|
||||
@@ -600,7 +600,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
@@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -711,7 +711,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
|
||||
@@ -145,7 +145,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -119,7 +119,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -206,7 +206,7 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
@@ -218,7 +218,7 @@ authorize_resource :class => false
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
|
||||
@@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController
|
||||
# GET /settings/cashier_terminals
|
||||
# GET /settings/cashier_terminals.json
|
||||
def index
|
||||
@settings_cashier_terminals = CashierTerminal.all
|
||||
@settings_cashier_terminals = CashierTerminal.where("shop_code=?",@shop.shop_code)
|
||||
end
|
||||
|
||||
# GET /settings/cashier_terminals/1
|
||||
|
||||
@@ -364,7 +364,7 @@ class Transactions::SalesController < ApplicationController
|
||||
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -29,7 +29,7 @@ class Ability
|
||||
can :manage, Order
|
||||
can :manage, Booking
|
||||
can :manage, Sale
|
||||
|
||||
|
||||
|
||||
can :manage, Customer
|
||||
can :manage, DiningQueue
|
||||
@@ -57,8 +57,8 @@ class Ability
|
||||
can :show, :product_sale
|
||||
|
||||
can :get_customer, Customer
|
||||
can :add_customer, Customer
|
||||
can :update_sale_by_customer, Customer
|
||||
can :add_customer, Customer
|
||||
can :update_sale_by_customer, Customer
|
||||
|
||||
can :index, :other_charge
|
||||
can :create, :other_charge
|
||||
@@ -73,11 +73,11 @@ class Ability
|
||||
can :create, :payment
|
||||
can :reprint, :payment
|
||||
can :rounding_adj, :payment
|
||||
can :foc, :payment
|
||||
can :print, :payment
|
||||
can :foc, :payment
|
||||
can :print, :payment
|
||||
can :change_tax, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
can :move_dining, :moveroom
|
||||
@@ -123,11 +123,11 @@ class Ability
|
||||
can :print, :print
|
||||
can :print_order_summary, :print
|
||||
|
||||
can :read, ShiftSale
|
||||
can :update, ShiftSale
|
||||
can :read, ShiftSale
|
||||
can :update, ShiftSale
|
||||
|
||||
elsif user.role == "cashier" || user.role =="foodcourt_cashier"
|
||||
|
||||
elsif user.role == "cashier"
|
||||
|
||||
# can :overall_void, :void
|
||||
can :index, :home
|
||||
can :show, :home
|
||||
@@ -136,10 +136,10 @@ class Ability
|
||||
can :update, Order
|
||||
can :manage, Booking
|
||||
can :manage, OrderQueueStation
|
||||
can :read, Sale
|
||||
can :update, Sale
|
||||
can :read, Sale
|
||||
can :update, Sale
|
||||
|
||||
can :manage, Customer
|
||||
can :manage, Customer
|
||||
|
||||
can :manage, OrderReservation
|
||||
|
||||
@@ -160,11 +160,11 @@ class Ability
|
||||
can :create, :payment
|
||||
can :reprint, :payment
|
||||
can :rounding_adj, :payment
|
||||
can :foc, :payment
|
||||
can :foc, :payment
|
||||
can :print, :payment
|
||||
can :change_tax, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
can :move_dining, :moveroom
|
||||
@@ -204,7 +204,7 @@ class Ability
|
||||
can :item_edit, :sale_edit
|
||||
|
||||
can :overall_void, :void
|
||||
|
||||
|
||||
elsif user.role == "account"
|
||||
|
||||
can :index, :dailysale
|
||||
@@ -228,14 +228,14 @@ class Ability
|
||||
|
||||
elsif user.role == "supervisor"
|
||||
can :manage, Employee
|
||||
|
||||
|
||||
can :edit, :sale_edit
|
||||
can :item_void, :sale_edit
|
||||
can :item_foc, :sale_edit
|
||||
can :item_edit, :sale_edit
|
||||
can :item_void_cancel, :sale_edit
|
||||
can :cancel_all_void, :sale_edit
|
||||
can :apply_void, :sale_edit
|
||||
can :cancel_all_void, :sale_edit
|
||||
can :apply_void, :sale_edit
|
||||
can :overall_void, :void
|
||||
|
||||
can :index, :other_charge
|
||||
@@ -246,7 +246,7 @@ class Ability
|
||||
can :remove_all_discount, :discount
|
||||
can :member_discount, :discount
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
can :move_dining, :moveroom
|
||||
@@ -297,9 +297,9 @@ class Ability
|
||||
|
||||
elsif user.role == "waiter"
|
||||
can :index, :home
|
||||
can :show, :home
|
||||
can :show, :home
|
||||
|
||||
can :manage, Customer
|
||||
can :manage, Customer
|
||||
can :get_customer, Customer
|
||||
can :add_customer, Customer
|
||||
can :update_sale_by_customer, Customer
|
||||
@@ -313,7 +313,7 @@ class Ability
|
||||
can :member_discount, :discount
|
||||
|
||||
#ability for move table
|
||||
can :move_dining, :movetable
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
can :move_dining, :moveroom
|
||||
@@ -339,7 +339,7 @@ class Ability
|
||||
can :print_order_summary, :print
|
||||
|
||||
elsif user.role == "kitchen"
|
||||
|
||||
|
||||
#oqs Home
|
||||
can :manage, OrderQueueStation
|
||||
can :index, :home
|
||||
|
||||
@@ -203,7 +203,7 @@ class OrderReservation < ApplicationRecord
|
||||
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_details, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_details, "Paid",nil,nil,other_amount,nil,nil, order_reservation,nil)
|
||||
#receipt bill pdf setting
|
||||
|
||||
result = {:status=> true,
|
||||
|
||||
@@ -188,20 +188,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation,transaction_ref)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
if !printer_settings.nil?
|
||||
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
|
||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
||||
settings = PrintSetting.where("shop_code='#{shop_details.shop_code}'")
|
||||
if !settings.nil?
|
||||
settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||
pdf = ReceiptBillStarPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
pdf = ReceiptBillStarPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -211,7 +211,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||
if receipt_bilA5[1] == '1'
|
||||
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
||||
# else
|
||||
# pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
end
|
||||
|
||||
@@ -2088,7 +2088,6 @@ end
|
||||
|
||||
def unique_tax_profiles(order_source, customer_id)
|
||||
tax_data = TaxProfile.where(group_type: order_source,shop_code: self.shop_code)
|
||||
|
||||
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
|
||||
if customer_tax_profiles.present?
|
||||
tax_data = tax_data.where(id: customer_tax_profiles.tax_profiles)
|
||||
|
||||
@@ -150,6 +150,7 @@ class SaleAudit < ApplicationRecord
|
||||
|
||||
def self.getCardBalanceAmount(sale_id)
|
||||
card_balance_amount = 0
|
||||
transaction_ref =''
|
||||
sale_audits = SaleAudit.where("sale_id='#{sale_id}' AND action='PAYMAL'")
|
||||
if !sale_audits.nil?
|
||||
sale_audits.each do |sale_audit|
|
||||
@@ -159,6 +160,7 @@ class SaleAudit < ApplicationRecord
|
||||
if remark[0]
|
||||
if remark[0]["status"]
|
||||
card_balance_amount = remark[0]["card_balance_amount"]
|
||||
transaction_ref = remark[0]["transaction_ref"]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -166,7 +168,7 @@ class SaleAudit < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
return card_balance_amount
|
||||
return card_balance_amount,transaction_ref
|
||||
end
|
||||
|
||||
def self.valid_json(json)
|
||||
|
||||
@@ -227,14 +227,14 @@ class SalePayment < ApplicationRecord
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Errno::ECONNREFUSED
|
||||
response = { "status" => false, "message" => "Can't open membership server"}
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
response = { "status" => false, "message" => "No internet connection " }
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
response = { "status" => false, "message" => "No internet connection "}
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
response = { "status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
Rails.logger.debug "Get Paypar Account "
|
||||
Rails.logger.debug response.to_json
|
||||
|
||||
@@ -16,7 +16,6 @@ class ShiftSale < ApplicationRecord
|
||||
belongs_to :cashier_terminal
|
||||
belongs_to :employee, :foreign_key => 'employee_id'
|
||||
has_many :sales
|
||||
belongs_to :shop
|
||||
|
||||
def self.current_shift(shop_code)
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
@@ -84,6 +83,7 @@ class ShiftSale < ApplicationRecord
|
||||
self.shift_started_at = DateTime.now
|
||||
self.employee_id = current_user.id
|
||||
self.opening_balance = opening_balance
|
||||
self.shop_code = current_user.shop_code
|
||||
self.other_sales = 0
|
||||
self.save
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref)
|
||||
self.page_width = printer_settings.page_width
|
||||
self.page_height = printer_settings.page_height
|
||||
self.header_font_size = printer_settings.header_font_size.to_i
|
||||
@@ -73,11 +73,12 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
#end card sale trans data
|
||||
#start card blanace amount
|
||||
if !card_balance_amount.nil?
|
||||
if !card_balance_amount.nil? && card_balance_amount >0
|
||||
card_balance_data(card_balance_amount)
|
||||
card_transaction_ref(transaction_ref)
|
||||
end
|
||||
#end card blanace amount
|
||||
|
||||
|
||||
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
|
||||
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
|
||||
end
|
||||
@@ -100,7 +101,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
if shop_details.note && !shop_details.note.nil?
|
||||
shop_note(printed_status)
|
||||
end
|
||||
|
||||
|
||||
footer(printed_status)
|
||||
end
|
||||
|
||||
@@ -130,7 +131,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size+2,:align => :left
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
@@ -154,7 +155,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
bounding_box([self.item_description_width, y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width - 2,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -172,7 +173,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
|
||||
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
|
||||
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
|
||||
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
|
||||
# :size => self.item_font_size,:align => :right
|
||||
# end
|
||||
@@ -209,7 +210,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
|
||||
def add_line_item_row(sale_items,precision,delimiter)
|
||||
|
||||
|
||||
if precision.to_i > 0
|
||||
item_name_width = (self.item_width+self.price_width)
|
||||
item_qty_front_width = (self.item_width+self.price_width) + 5
|
||||
@@ -229,17 +230,17 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
sub_total = 0.0
|
||||
total_qty = 0.0
|
||||
sale_items.each do |item|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
|
||||
show_price = Lookup.find_by_lookup_type("show_price")
|
||||
|
||||
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
|
||||
if item.status != 'Discount' && item.qty > 0
|
||||
if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
else
|
||||
if item.price != 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -272,7 +273,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
# end
|
||||
text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
|
||||
end
|
||||
|
||||
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||
@@ -297,10 +298,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.item_width) do
|
||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
if show_alt_name
|
||||
if !(item.product_alt_name).empty?
|
||||
@@ -370,7 +371,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
move_down line_move
|
||||
@@ -383,12 +384,12 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
|
||||
sale_payment(sale_data,precision,delimiter)
|
||||
|
||||
|
||||
end
|
||||
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
stroke_horizontal_rule
|
||||
# move_down 10
|
||||
sql = "SELECT SUM(payment_amount)
|
||||
@@ -419,13 +420,13 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
if sale_data.amount_received > 0
|
||||
if sale_data.amount_received > 0
|
||||
y_position = cursor
|
||||
move_down line_move
|
||||
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
|
||||
@@ -435,12 +436,12 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
#move_down line_move
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# show member information
|
||||
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
|
||||
if rebate_amount != nil
|
||||
if rebate_amount != nil
|
||||
if rebate_amount["status"] == true
|
||||
stroke_horizontal_rule
|
||||
total = 0
|
||||
@@ -469,8 +470,8 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
# Total Rebate Amount if birthday
|
||||
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate"
|
||||
rebate_balance = rebate_balance + res["deposit"]
|
||||
@@ -482,7 +483,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
#end Total rebate if birthday
|
||||
end
|
||||
|
||||
@@ -505,7 +506,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -515,7 +516,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
total_balance = total_balance + res["balance"]
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
move_down line_move
|
||||
@@ -527,7 +528,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def customer(customer_name)
|
||||
@@ -555,7 +556,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
end
|
||||
@@ -571,7 +572,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
end
|
||||
@@ -584,7 +585,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
move_down line_move
|
||||
end
|
||||
|
||||
#individual payment per person
|
||||
@@ -623,17 +624,17 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
JOIN sale_audits sa
|
||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
|
||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
|
||||
if payment.payment_method == "creditnote"
|
||||
|
||||
y_position = cursor
|
||||
stroke_horizontal_rule
|
||||
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
move_down 70
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
move_down 73
|
||||
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||
@@ -650,8 +651,8 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
move_down 70
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
if sale_data.payment_status == "foc"
|
||||
|
||||
if sale_data.payment_status == "foc"
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
move_down 73
|
||||
text "Acknowledged By" , :size => self.item_font_size,:align => :center
|
||||
@@ -661,10 +662,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
move_down 73
|
||||
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def shop_note(shop)
|
||||
@@ -674,8 +675,8 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
move_down line_move
|
||||
y_position = cursor
|
||||
|
||||
text "#{shop.note}", :size => self.item_font_size,:align => :left
|
||||
|
||||
text "#{shop.note}", :size => self.item_font_size,:align => :left
|
||||
|
||||
move_down line_move
|
||||
end
|
||||
@@ -688,10 +689,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.item_description_width) do
|
||||
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
move_down line_move
|
||||
end
|
||||
@@ -721,7 +722,6 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
#start card balance data
|
||||
def card_balance_data(card_balance_amount)
|
||||
if card_balance_amount > 0
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
@@ -729,11 +729,24 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
#start card transaction_ref
|
||||
def card_transaction_ref(transaction_ref)
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "Transaction ref: ",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{transaction_ref}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
#check ReceiptBillAltName included
|
||||
@@ -753,4 +766,4 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
return status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,13 +78,13 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
|
||||
def cashier_info(sale_data, customer_name, latest_order_no,order_reservation)
|
||||
move_down line_move
|
||||
|
||||
|
||||
# move_down 2
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "Order Date " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{order_reservation.created_at.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -92,7 +92,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "Requested Date Time " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{order_reservation.requested_time.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -100,7 +100,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "Payment Type" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{order_reservation.payment_type}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -108,7 +108,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "#{customer_name} " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Online Order", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -167,14 +167,14 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
total_qty = 0.0
|
||||
show_price = Lookup.find_by_lookup_type("show_price")
|
||||
sale_items.each do |item|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
|
||||
if item.status != 'Discount' && item.qty > 0
|
||||
if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
else
|
||||
if item.price != 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -191,7 +191,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
qty = item.qty
|
||||
total_price = item.price #item.qty*item.unit_price - comment for room charges
|
||||
price = item.unit_price
|
||||
|
||||
|
||||
# end
|
||||
if !show_price.nil? && show_price.value.to_i>0
|
||||
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||
@@ -220,24 +220,24 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
|
||||
bounding_box([self.description_width - 48,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if order_reservation.total_tax > 0
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do
|
||||
text "Tax " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do
|
||||
text "Convenience Charges " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -250,8 +250,8 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Change items rows
|
||||
@@ -277,10 +277,10 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.item_width) do
|
||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
if show_alt_name
|
||||
if !(item.product_alt_name).empty?
|
||||
@@ -310,10 +310,10 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
# sale_payment(sale_data,precision,delimiter)
|
||||
# sale_payment(sale_data,precision,delimiter)
|
||||
end
|
||||
|
||||
#Change Footer
|
||||
@@ -326,10 +326,10 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "#{printed_status}",:style => :bold, :size => header_font_size - 1,:align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size - 1,:align => :left
|
||||
end
|
||||
end
|
||||
|
||||
move_down line_move
|
||||
end
|
||||
@@ -351,4 +351,4 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
end
|
||||
return status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||
|
||||
def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
|
||||
def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref)
|
||||
self.page_width = printer_settings.page_width
|
||||
self.page_height = printer_settings.page_height
|
||||
self.header_font_size = printer_settings.header_font_size.to_i
|
||||
@@ -76,8 +76,9 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
#end card sale trans data
|
||||
#start card blanace amount
|
||||
if !card_balance_amount.nil?
|
||||
if !card_balance_amount.nil? && card_balance_amount >0
|
||||
card_balance_data(card_balance_amount)
|
||||
card_transaction_ref(transaction_ref)
|
||||
end
|
||||
#end card blanace amount
|
||||
|
||||
@@ -797,7 +798,6 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
#start card balance data
|
||||
def card_balance_data(card_balance_amount)
|
||||
if card_balance_amount > 0
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
@@ -809,6 +809,19 @@ class ReceiptBillPdf < Prawn::Document
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
#start card transaction_ref
|
||||
def card_transaction_ref(transaction_ref)
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "Transaction ref: ",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{transaction_ref}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||
|
||||
def initialize(printer_settings, status, qr , sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
|
||||
def initialize(printer_settings, status, qr , sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref)
|
||||
self.page_width = printer_settings.page_width
|
||||
self.page_height = printer_settings.page_height
|
||||
self.header_font_size = printer_settings.header_font_size.to_i
|
||||
@@ -75,8 +75,9 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
end
|
||||
#end card sale trans data
|
||||
#start card blanace amount
|
||||
if !card_balance_amount.nil?
|
||||
if !card_balance_amount.nil? && card_balance_amount >0
|
||||
card_balance_data(card_balance_amount)
|
||||
card_transaction_ref(transaction_ref)
|
||||
end
|
||||
#end card blanace amount
|
||||
|
||||
@@ -722,19 +723,32 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
|
||||
#start card balance data
|
||||
def card_balance_data(card_balance_amount)
|
||||
if card_balance_amount > 0
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
#start card balance data
|
||||
def card_transaction_ref(transaction_ref)
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "Transaction ref: ",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{transaction_ref}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
#check ReceiptBillAltName included
|
||||
|
||||
81
app/views/foodcourt/addorders/_menu_item.json.jbuilder
Executable file
81
app/views/foodcourt/addorders/_menu_item.json.jbuilder
Executable file
@@ -0,0 +1,81 @@
|
||||
# Format for attributes json
|
||||
attr_format = []
|
||||
# Format for attributes json
|
||||
if item.item_attributes.count > 0
|
||||
item_attributes = MenuItemAttribute.where(id: item.item_attributes)
|
||||
attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
if item.item_options.count > 0
|
||||
item_options = MenuItemOption.where(id: item.item_options)
|
||||
opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
||||
end
|
||||
|
||||
|
||||
#Menu Item Information
|
||||
json.id item.id
|
||||
json.code item.item_code
|
||||
json.name item.name
|
||||
json.alt_name item.alt_name
|
||||
json.image item.image_path.url
|
||||
json.description item.description
|
||||
json.information item.information
|
||||
json.type item.type
|
||||
json.account_id item.account_id
|
||||
json.min_qty item.min_qty
|
||||
json.is_available item.is_available
|
||||
json.is_sub_item item.is_sub_item
|
||||
json.unit item.unit
|
||||
|
||||
# Item Sets of Menu Item
|
||||
json.item_sets item.item_sets.includes(:menu_item_instances) do |its|
|
||||
json.id its.id
|
||||
json.name its.name
|
||||
json.alt_name its.alt_name
|
||||
json.min_selectable_qty its.min_selectable_qty
|
||||
json.max_selectable_qty its.max_selectable_qty
|
||||
json.instances its.menu_item_instances do |i|
|
||||
json.id i.id
|
||||
end
|
||||
end
|
||||
|
||||
json.attributes attr_format
|
||||
json.options opt_format
|
||||
# json.min_selectable_item item.min_selectable_item
|
||||
# json.max_selectable_item item.max_selectable_item
|
||||
|
||||
#Item instance
|
||||
# if item.menu_item_instances.count == 1 then
|
||||
# item_instance = item.menu_item_instances[0]
|
||||
# json.price = item_instance.price
|
||||
# json.is_available = item_instance.is_available
|
||||
# json.is_on_promotion = item_instance.is_on_promotion
|
||||
# json.promotion_price = item_instance.promotion_price
|
||||
# json.item_attributes = item_instance.item_attributes
|
||||
|
||||
json.instances item.menu_item_instances do |is|
|
||||
if is.is_available
|
||||
# Convert id to name for attributes
|
||||
instance_attr = MenuItemAttribute.where(id: item.item_attributes).pluck(:name)
|
||||
|
||||
json.id is.id
|
||||
json.code is.item_instance_code
|
||||
json.name is.item_instance_name
|
||||
json.price is.price
|
||||
json.is_available is.is_available
|
||||
json.is_default is.is_default
|
||||
json.is_on_promotion is.is_on_promotion
|
||||
json.promotion_price is.promotion_price
|
||||
json.values instance_attr
|
||||
end
|
||||
end
|
||||
|
||||
#Child Menu items
|
||||
# if (item.children) then
|
||||
# json.set_items item.children.each do |item|
|
||||
# json.partial! 'api/restaurant/menu/menu_item', item: item
|
||||
# end
|
||||
# end
|
||||
15
app/views/foodcourt/addorders/create.json.jbuilder
Executable file
15
app/views/foodcourt/addorders/create.json.jbuilder
Executable file
@@ -0,0 +1,15 @@
|
||||
if @status == true
|
||||
json.status :success
|
||||
json.id @order.id
|
||||
json.booking_id @booking.id
|
||||
json.order_items do
|
||||
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark
|
||||
end
|
||||
else
|
||||
json.status :error
|
||||
if @error_messages
|
||||
json.error_messages @error_messages
|
||||
else
|
||||
json.error_messages @order.errors
|
||||
end
|
||||
end
|
||||
810
app/views/foodcourt/addorders/detail.html.erb
Normal file
810
app/views/foodcourt/addorders/detail.html.erb
Normal file
@@ -0,0 +1,810 @@
|
||||
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %>
|
||||
|
||||
|
||||
<% type = request.path_info.include?('quick_service') || request.path_info.include?('food_court')%>
|
||||
<% modify_order = request.path_info.include?('modify_order')%>
|
||||
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
|
||||
<div id="oqs_loading_wrapper" style="display:none;">
|
||||
<div id="oqs_loading"></div>
|
||||
</div>
|
||||
<input type="hidden" name="type" id="role" value="<%= current_user.role%>">
|
||||
<input type="hidden" name="cashier_type" id="cashier_type" value="<%= type%>">
|
||||
<input type="hidden" name="link_type" id="link_type" value="<%= @cashier_type %>">
|
||||
<input type="hidden" name="display_type" id="display_type" value="<%= @display_type%>">
|
||||
<div class="row m-t--20">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_data">
|
||||
<li class="list-menu">
|
||||
<a href="javascript:void(0);" class="menu-toggle dropdown-toggle toggled my-toggle " style="">
|
||||
|
||||
<span class="main_menu" id="main_menu menu_name" >
|
||||
<%if @menu.present? %>
|
||||
<%=@menus[0].name%>
|
||||
<% end%>
|
||||
</span>
|
||||
</a>
|
||||
<ul class="ml-menu menu_list aria-hidden " style="border-top: 1px solid #fff">
|
||||
<% @menus.each do |menu| %>
|
||||
<li class="nav-item menu_click" data-name="<%=menu.name%>" data-id="<%=menu.id%>" style="">
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab" style="text-transform: lowercase;"><%=menu.name%></a>
|
||||
</li>
|
||||
<%end%>
|
||||
</ul>
|
||||
</li>
|
||||
<div id="menu1-slimscroll" data-height="0">
|
||||
<ul class="nav nav-tabs flex-column category_list" role="tablist" id="ul-navbar">
|
||||
<li class="nav-item product" data-ref="<%= foodcourt_get_all_product_path %>">
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
|
||||
</li>
|
||||
<% @menu.each do |menu| %>
|
||||
<% if !menu.valid_time.nil? %>
|
||||
<% if menu.menu_category_id.nil? %>
|
||||
<!--if type quick_service or cashier for table -->
|
||||
<% if type %>
|
||||
<% if !menu.code.include? "SPL" %>
|
||||
<li class="nav-item">
|
||||
<p class="hidden menu-id"><%= menu.id %></p>
|
||||
<a class="nav-link menu_category sub_click first_<%=menu.id%>" data-toggle="tab" href="" role="tab" data-id="<%=menu.id%>" data-sub-id="<%=menu.get_sub_category%>"> <%= menu.name%>
|
||||
</a>
|
||||
<ul class="sub_category_list hidden fadeInTop animated" id="sub_category_list">
|
||||
</ul>
|
||||
</li>
|
||||
<% end%>
|
||||
<!-- else quick_service or cashier for table -->
|
||||
<% else %>
|
||||
<% if @table.get_current_checkout_booking.nil? %>
|
||||
<% if !menu.code.include? "SPL" %>
|
||||
<li class="nav-item ">
|
||||
<p class="hidden menu-id"><%= menu.id %></p>
|
||||
<a class="nav-link menu_category sub_click first_<%=menu.id%>" data-toggle="tab" href="" role="tab" data-id="<%=menu.id%>" data-sub-id="<%=menu.get_sub_category%>"> <%= menu.name%>
|
||||
</a>
|
||||
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
|
||||
</ul>
|
||||
</li>
|
||||
<% end%>
|
||||
<% else %>
|
||||
<li class="nav-item ">
|
||||
<p class="hidden menu-id"><%= menu.id %></p>
|
||||
<a class="nav-link menu_category sub_click first_<%=menu.id%>" data-toggle="tab" href="" role="tab" data-id="<%=menu.id%>" data-sub-id="<%=menu.get_sub_category%>"> <%= menu.name%>
|
||||
</a>
|
||||
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
|
||||
</ul>
|
||||
</li>
|
||||
<% end%>
|
||||
<!-- end quick_service or cashier for table -->
|
||||
<% end %>
|
||||
<% end%>
|
||||
<% end %>
|
||||
<%end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_cache">
|
||||
<li class="list-menu">
|
||||
<a href="javascript:void(0);" class="menu-toggle dropdown-toggle toggled my-toggle " style="">
|
||||
<span class="main_menu menu_cache_name" id="main_menu menu_cache_name"></span>
|
||||
</a>
|
||||
<ul class="ml-menu menu_list aria-hidden menu_cache_list" style="border-top: 1px solid #fff">
|
||||
</ul>
|
||||
</li>
|
||||
<div id="menu-slimscroll" data-height="0">
|
||||
<ul class="nav nav-tabs flex-column category_list category_cache_list" role="tablist" id="ul-navbar">
|
||||
<li class="nav-item product" data-ref="<%= foodcourt_get_all_product_path %>">
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
|
||||
<div class="card">
|
||||
<div class="card-block" style="">
|
||||
<div class="card-text" id="custom-slimscroll">
|
||||
<div class="row menu_items_list" style="margin:0px 1px 0px 1px ;">
|
||||
<!-- append data -->
|
||||
<% @menu.each do |menu| %>
|
||||
<% if !menu.valid_time.nil? %>
|
||||
<% if menu.menu_category_id.nil? %>
|
||||
<!--if type quick_service or cashier for table -->
|
||||
<% if type %>
|
||||
<% if !menu.code.include? "SPL" %>
|
||||
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
|
||||
<div class='card-block custom-card-block'>
|
||||
<p><%=menu.name%> <p>
|
||||
<p><%=menu.code%> <p>
|
||||
</div>
|
||||
</div>
|
||||
<% end%>
|
||||
<!-- else quick_service or cashier for table -->
|
||||
<% else %>
|
||||
<% if @table.get_current_checkout_booking.nil? %>
|
||||
<% if !menu.code.include? "SPL" %>
|
||||
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
|
||||
<div class='card-block custom-card-block'>
|
||||
<p><%=menu.name%> <p>
|
||||
<p><%=menu.code%> <p>
|
||||
</div>
|
||||
</div>
|
||||
<% end%>
|
||||
<% else %>
|
||||
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
|
||||
<div class='card-block custom-card-block'>
|
||||
<p><%=menu.name%> <p>
|
||||
<p><%=menu.code%> <p>
|
||||
</div>
|
||||
</div>
|
||||
<% end%>
|
||||
<!-- end quick_service or cashier for table -->
|
||||
<% end %>
|
||||
<% end%>
|
||||
<% end %>
|
||||
<%end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 col-lg-3 col-sm-3 m-t-10">
|
||||
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-12" id='app_order'>App Order
|
||||
</button>
|
||||
<br>
|
||||
<div class="card-header" style="padding: 0.12rem 0.25rem">
|
||||
<% if type %>
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-6 col-lg-6 col-sm-12">
|
||||
<strong id="order-title" class="font-13">ORDER DETAILS </strong>
|
||||
</div>
|
||||
|
||||
<% if modify_order %>
|
||||
<% if @table.nil? %>
|
||||
|
||||
<div class="col-md-3 col-lg-3 col-sm-3">Table : </div>
|
||||
<p class="hidden" id="table_id"><%=@table_id%></p>
|
||||
<p class="hidden" id="table_type"></p>
|
||||
<p class="hidden" id="table_get_current"></p>
|
||||
<% else%>
|
||||
|
||||
<div class="col-md-3 col-lg-3 col-sm-3">Table : <%=@table.name%></div>
|
||||
<p class="hidden" id="table_id"><%=@table_id%></p>
|
||||
<p class="hidden" id="table_type"><%=@table.type%></p>
|
||||
<p class="hidden" id="table_get_current"><%=@table.get_current_checkout_booking%></p>
|
||||
<% end%>
|
||||
|
||||
<p class="hidden" id="booking_id"><%=@booking_id%></p>
|
||||
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : '---'%></p>
|
||||
<p class="hidden" id="sale_id"><%=@sale_id%></p>
|
||||
|
||||
<div class="col-md-1 col-lg-1 col-sm-1">
|
||||
<button type="button" class="btn btn-xs btn-danger waves-effect float-left" id='clear_all'> Clear
|
||||
</button>
|
||||
</div>
|
||||
<% else%>
|
||||
<p class="hidden" id="table_type"></p>
|
||||
<div class="col-md-2 col-lg-2 col-sm-2">
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 col-lg-3 col-sm-3">
|
||||
<button type="button" class="btn btn-xs btn-danger waves-effect float-left" id='clear_all'> Clear
|
||||
</button>
|
||||
</div>
|
||||
<% end%>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="row ">
|
||||
<div class="col-md-9 col-lg-9 col-sm-9 ">
|
||||
<strong id="order-title" class="font-14 p-l-10">ORDER DETAILS </strong>| <span class="font-14">Table-<%=@table.name%></span>
|
||||
|
||||
|
||||
<p class="hidden" id="table_id"><%=@table_id%></p>
|
||||
<p class="hidden" id="table_type"><%=@table.type%></p>
|
||||
<p class="hidden" id="booking_id"><%=@booking_id%></p>
|
||||
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : ''%></p>
|
||||
<p class="hidden" id="table_get_current"><%=@table.get_current_checkout_booking%></p>
|
||||
</div>
|
||||
<div class="col-md-3 col-lg-3 col-sm-3">
|
||||
<button type="button" class="btn btn-xs btn-danger waves-effect" id='clear_all'>Clear
|
||||
</button>
|
||||
</div>
|
||||
<% end%>
|
||||
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-text" id="order-detail-slimscroll" data-height="140">
|
||||
<table class="table table-striped summary-items" id="order-items-table" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-qty">QTY</th>
|
||||
<th class="item-attr">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="font-13" >
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
|
||||
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
|
||||
<td style="padding:2px;" width="15%"><strong id="total_qty">0</strong></td>
|
||||
|
||||
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
|
||||
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_pay_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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class=" modal" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true" style="">
|
||||
<div class="modal-dialog custom-modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-body">
|
||||
<table width="100%" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="">Item Name</th>
|
||||
<th style="">Quantity</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="item_name" id="modal-item-name"></td>
|
||||
<td>
|
||||
<input type="number" name="qty" class="form-control col-md-12 input-number" data-value="0" id="modal-qty" value="" min="1" max="10000">
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row bottom p-l-15 p-r-15 m-t-10">
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="3" data-type="num">3</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="4" data-type="num">4</div>
|
||||
</div>
|
||||
<div class="row bottom p-l-15 p-r-15">
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="6" data-type="num">6</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="8" data-type="num">8</div>
|
||||
</div>
|
||||
<div class="row bottom p-l-15 p-r-15">
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="9" data-type="num">9</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left" data-value="00" data-type="num">00</div>
|
||||
<div class="col-md-3 cashier_number border-top border-left bg-orange" data-type="clr">Clr</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" id="close">Close</button>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-primary " data-dismiss="modal" id="save">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Menu Item modal -->
|
||||
|
||||
<div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog custom-modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
|
||||
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row no-set-item">
|
||||
<div class="col-md-5">
|
||||
<p style="text-align: center;" id="modal_box_img"></p>
|
||||
<div class="input-group">
|
||||
<input type="text" value="1" id="count" class="change_qty keypress_qty form-control col-md-6 ">
|
||||
<span class="input-group-btn col-md-3">
|
||||
<button type="button" class="btn btn-danger btn-block btn-number" value="-" id="minus">
|
||||
<i class="material-icons">remove</i>
|
||||
|
||||
</button>
|
||||
</span>
|
||||
|
||||
<span class="input-group-btn col-md-3">
|
||||
<button type="button" class="btn btn-success btn-block btn-number" value="+" id="plus">
|
||||
<i class="material-icons">add</i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<p class="hidden" id="unit_price"></p>
|
||||
<p class="hidden" id="instance_code"></p>
|
||||
<p class="hidden" id="instance_name"></p>
|
||||
<p class="hidden" id="promotion_price"></p>
|
||||
<p class="hidden" id="item_instances"></p>
|
||||
<p class="hidden" id="item_code"></p>
|
||||
</div>
|
||||
<div class="col-md-7 item-detail">
|
||||
<h5>Attributes</h5>
|
||||
<div class="attributes-list">
|
||||
</div>
|
||||
<hr>
|
||||
<h5>Options</h5>
|
||||
<div class="options-list">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="mr-auto">
|
||||
<h4 class=" pull-left">Total : <span id="total_price"></span></h4>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<button type="button" class="btn btn-default " data-dismiss="modal" id="close">Close</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-primary add_to_order " data-dismiss="modal" id="add_to_order">Add to Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Large modal -->
|
||||
<div class="modal sx_item_set_detailModal" id="sx_item_set_detailModal" tabindex="-1" role="dialog" aria-labelledby="sx_item_set_detailLabel" aria-hidden="true" >
|
||||
<div class="modal-dialog custom-modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
|
||||
<h4 class="modal-title" style="color:#fff;" id="set_name"></h4>
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||
</div>
|
||||
<div class="modal-body" id="set-menu-item-slimscroll" data-height="50">
|
||||
<div class="row set-item">
|
||||
<div class="col-md-4">
|
||||
<p class="set_default_option" style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
|
||||
<!-- <div class="form-group">
|
||||
<label class="col-md-6" style="margin-top:5px">Quantity</label>
|
||||
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="set_change_qty" value="" min="1" max="100">
|
||||
</div> -->
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="btn btn-danger btn-number" value="-" id="set_minus">
|
||||
<i class="material-icons">remove</i>
|
||||
</button>
|
||||
</span>
|
||||
<input type="text" value="1" id="set_count" class="set_change_qty keypress_qty form-control col-md-12 ">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="btn btn-success btn-number" value="+" id="set_plus">
|
||||
<i class="material-icons">add</i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="hidden" id="set_unit_price"></p>
|
||||
<p class="hidden" id="set_instance_code"></p>
|
||||
<p class="hidden" id="set_instance_name"></p>
|
||||
<p class="hidden" id="set_promotion_price"></p>
|
||||
<p class="hidden" id="set_item_instances"></p>
|
||||
<p class="hidden" id="set_item_code"></p>
|
||||
<p></p>
|
||||
|
||||
<div class="" id="modal-set-slimscroll" data-height="100">
|
||||
<div class="options-list" style="margin-top:-5px">
|
||||
</div>
|
||||
|
||||
<div class='selected-set-list'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="instance-list row"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="mr-auto">
|
||||
<h4 class=" pull-left">Total : <span id="set_total_price"></span></h4>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" id="close">Close</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-primary set_order" data-dismiss="modal" id="set_order">Add to Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% if type && !modify_order%>
|
||||
<div class="modal fade" id="TableModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="margin-top: -1rem;">
|
||||
<!-- <h4 class="modal-title" id="TableModalLabel">Select Table</h4> -->
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="margin-top: -0.75rem;padding-top:5px">
|
||||
<%@zone.each do |zone| %>
|
||||
<h5>Zone : <%=zone.name%></h5>
|
||||
<div class="card-columns" style="column-count: 7;">
|
||||
<%zone.tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<% color="red"%>
|
||||
<% else %>
|
||||
<% color="orange"%>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<% color="blue"%>
|
||||
<% else %>
|
||||
<% color="orange"%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% color="green"%>
|
||||
<% end %>
|
||||
<div class="card tables <%=color%> text-white table_<%= table.id %>" data-id="<%= table.id %>" data-type="<%= table.type %>" data-name="<%= table.name %>">
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
</div>
|
||||
</div>
|
||||
<%end%>
|
||||
|
||||
<%zone.rooms.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<% color="red"%>
|
||||
<% else %>
|
||||
<% color="orange"%>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<% color="blue"%>
|
||||
<% else %>
|
||||
<% color="orange"%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% color="green"%>
|
||||
<% end %>
|
||||
<div class="card tables <%=color%> text-white table_<%= table.id %>" data-id="<%= table.id %>" data-type="<%= table.type %>" data-name="<%= table.name %>">
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
</div>
|
||||
</div>
|
||||
<%end%>
|
||||
</div>
|
||||
<%end%>
|
||||
<div class="modal-footer p-r-30">
|
||||
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect confirm_table" data-dismiss="modal">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<input type="hidden" name="server_mode" value="<%=ENV["SERVER_MODE"]%>" id="server_mode">
|
||||
</div>
|
||||
<style type="text/css">
|
||||
.fadeInRight{
|
||||
-webkit-animation-duration: 350ms !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
var cashier_type = $('#cashier_type').val();
|
||||
jQuery(function(){
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
var id = menus[0]["categories"][0]["id"];
|
||||
// console.log(id);
|
||||
}else{
|
||||
var id = 1;
|
||||
}
|
||||
jQuery('.first_'+id).click();
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
menu_cache_append(menus);
|
||||
}else{
|
||||
$("#menu_data").removeClass("hidden");
|
||||
}
|
||||
|
||||
function menu_cache_append(menus){
|
||||
$("#menu_cache").removeClass("hidden");
|
||||
$(".menu_cache_name").text(menus[0]["name"])
|
||||
for(var i in menus) {
|
||||
menu_list_template(menus[i]);
|
||||
}
|
||||
var category = menus[0]["categories"];
|
||||
|
||||
for(var ii in category) {
|
||||
if (category[ii]["is_available"]== true){
|
||||
if (category[ii]["valid_time"]== true){
|
||||
if (category[ii]["parent_id"] == null ){
|
||||
if(cashier_type){
|
||||
if (category[ii]["code"].includes("SPL") != true) {
|
||||
category_list_template(category[ii]);
|
||||
}
|
||||
}else{
|
||||
if ($("#table_get_current").text()) {
|
||||
if (category[ii]["code"].includes("SPL") != true) {
|
||||
category_list_template(category[ii]);
|
||||
}else {
|
||||
category_list_template(category[ii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(".tables").on('click', function () {
|
||||
$('.tables').css('background-color','');
|
||||
$('.tables').removeClass('purple')
|
||||
var dining_id = $(this).attr("data-id");
|
||||
var name = $(this).attr("data-name");
|
||||
var type = $(this).attr("data-type");
|
||||
$(this).css('background-color','purple');
|
||||
$(this).addClass('purple')
|
||||
$('.confirm_table').attr("data-id",dining_id)
|
||||
$('.confirm_table').attr("data-name",name)
|
||||
$('.confirm_table').attr("data-type",type)
|
||||
});
|
||||
|
||||
$(".confirm_table").on('click', function () {
|
||||
var dining_id = $(this).attr("data-id");
|
||||
var name = $(this).attr("data-name");
|
||||
var type = $(this).attr("data-type");
|
||||
$('#table_id').val(dining_id);
|
||||
$('#table_type').text(type);
|
||||
$('.select_table').text(name);
|
||||
});
|
||||
|
||||
$('#pending_order').on('click', function () {
|
||||
window.location.href = '/foodcourt/'+'<%= @cashier_type %>'+'/pending_order';
|
||||
});
|
||||
$('#app_order').on('click', function () {
|
||||
window.location.href = '/en/foodcourt/app_orders';
|
||||
});
|
||||
|
||||
$(document).on('click', '.menu_click', function(event){
|
||||
var menu_id = $(this).attr("data-id");
|
||||
var name = $(this).attr("data-name");
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
|
||||
if (menus != null) {
|
||||
menu_click_cache_append(name,menus,menu_id);
|
||||
}else{
|
||||
var url = "get_menu/"+menu_id;
|
||||
show_menu_cat_list(name, url);
|
||||
}
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
function menu_click_cache_append(name,menus,menu_id) {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
var menu_cat = $('.category_list');
|
||||
menu_cat.empty();
|
||||
|
||||
$(".main_menu").text(name);
|
||||
|
||||
// row = ' <li class="nav-item product" data-ref="<%= foodcourt_get_all_product_path %>">'
|
||||
// +'<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>'
|
||||
// +'</li>';
|
||||
// $(".category_cache_list").append(row);
|
||||
|
||||
for(var i in menus) {
|
||||
|
||||
if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
|
||||
|
||||
// menu_list_template(menus[i]);
|
||||
var category = menus[i]["categories"];
|
||||
|
||||
for(var ii in category) {
|
||||
if (category[ii]["is_available"]== true){
|
||||
if (category[ii]["valid_time"]== true){
|
||||
if (category[ii]["parent_id"] == null ){
|
||||
if(cashier_type){
|
||||
if (category[ii]["code"].includes("SPL") != true) {
|
||||
category_list_template(category[ii]);
|
||||
}
|
||||
}else{
|
||||
if ($("#table_get_current").text()) {
|
||||
if (category[ii]["code"].includes("SPL") != true) {
|
||||
category_list_template(category[ii]);
|
||||
}else {
|
||||
category_list_template(category[ii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function category_list_template(menu) {
|
||||
row = '<li class="nav-item">'
|
||||
+'<p class="hidden menu-id">'+menu.id+'</p> '
|
||||
+'<a class="nav-link menu_category sub_click first_'+menu.id+'" '
|
||||
+'data-toggle="tab" href="" role="tab" data-id="'+menu.id+'" '
|
||||
+'data-sub-id="'+menu.sub_category+'">'+menu.name+''
|
||||
+'</a>'
|
||||
+'<ul class="sub_category_list hidden fadeInTop animated" '
|
||||
+'id="sub_category_list">'
|
||||
+'</ul>'
|
||||
|
||||
+' </li>';
|
||||
$(".category_cache_list").append(row);
|
||||
}
|
||||
|
||||
function menu_list_template(menu) {
|
||||
row = '<li class="nav-item menu_click" data-name="'+menu.name+'" '
|
||||
+' data-id="'+menu.id+'" style="">'
|
||||
+' <a class="nav-link" data-toggle="tab" href="" role="tab"'
|
||||
+' style="text-transform: lowercase;">'+menu.name+'</a>'
|
||||
+'</li>';
|
||||
$(".menu_cache_list").append(row);
|
||||
}
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_cat_list(name, url_item){
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
var menu_cat = $('.category_list');
|
||||
menu_cat.empty();
|
||||
|
||||
$(".main_menu").text(name);
|
||||
cashier_type = window.location.href.indexOf("quick_service");
|
||||
modify_order = window.location.href.indexOf("modify_order");
|
||||
if (cashier_type != -1 && modify_order != -1) {
|
||||
url_item = '../../../addorders/'+url_item;
|
||||
}
|
||||
if(modify_order == -1 && cashier_type != -1){
|
||||
url_item = 'addorders/'+url_item
|
||||
}
|
||||
if (cashier_type ==-1 && modify_order == -1){
|
||||
url_item = url_item;
|
||||
}
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
for(var i in data) {
|
||||
if (data[i].is_available == true) {
|
||||
row = '<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="'+ data[i].id +'">'
|
||||
+' <div class="card-block custom-card-block">'
|
||||
+' <p>'+ data[i].name +'<p>'
|
||||
+' <p>'+ data[i].code +' <p>'
|
||||
+' </div>'
|
||||
+' </div>';
|
||||
$('.menu_items_list').append(row);
|
||||
|
||||
list = '<li class="nav-item menu_category sub_click" data-id="'+ data[i].id +'">'
|
||||
+'<p class="hidden menu-id">'+ data[i].id +'</p> '
|
||||
+'<a class="nav-link" data-toggle="tab" href="" role="tab"> '+ data[i].name +''
|
||||
+'<ul class=" sub_category_list hidden fadeInTop animated"'
|
||||
+'id="sub_category_list">'
|
||||
+'</ul>'
|
||||
+'</a>'
|
||||
+'</li>';
|
||||
$('.category_list').append(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
}
|
||||
//end show list function
|
||||
|
||||
$(document).on('click', '#clear_all', function(event){
|
||||
$(".summary-items tbody").empty();
|
||||
$('#sub_total').text("0.00");
|
||||
$('#total_qty').text("0");
|
||||
$(".create").attr("disabled","disabled");
|
||||
customer_display_view(null,"reload");
|
||||
});
|
||||
|
||||
function customer_display_view(data,status) {
|
||||
url = '../../../../foodcourt/customer_view';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {"data":data,"status":status},
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#modal-qty').attr('data-value');
|
||||
original_qty = $('#modal-qty').val();
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0"){
|
||||
$('#modal-qty').val(input_value);
|
||||
$('#modal-qty').attr('data-value',input_value);
|
||||
// update_total_amount();
|
||||
}else{
|
||||
$('#modal-qty').val(original_qty + input_value);
|
||||
$('#modal-qty').attr('data-value',original_qty + input_value);
|
||||
// update_total_amount();
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
|
||||
case 'del' :
|
||||
|
||||
case 'clr':
|
||||
$('#modal-qty').val(1);
|
||||
$('#modal-qty').attr('data-value',0);
|
||||
// update_total_amount();
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/* check webview loaded*/
|
||||
var webview = '';
|
||||
<%if @webview %>
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
<% end %>
|
||||
});
|
||||
</script>
|
||||
4
app/views/foodcourt/addorders/get_all_product.json.jbuilder
Executable file
4
app/views/foodcourt/addorders/get_all_product.json.jbuilder
Executable file
@@ -0,0 +1,4 @@
|
||||
|
||||
json.array! @product, :id, :item_code, :name, :alt_name,:image_path,
|
||||
:description,:information,:taxable,:unit_price, :created_at,
|
||||
:updated_at, :created_by
|
||||
@@ -0,0 +1,39 @@
|
||||
if(@instance)
|
||||
menu_item = MenuItem.find(@instance.menu_item_id)
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
menu_item.item_options.each do|opt|
|
||||
menu_opt = MenuItemOption.find(opt)
|
||||
if opt_format.count == 0
|
||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||
next
|
||||
end
|
||||
|
||||
opt_format.each do |of|
|
||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||
if menu_opt.option_type == of[:type]
|
||||
of[:values].push(menu_opt.name)
|
||||
end
|
||||
else
|
||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||
opt_format.push(new_opt)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
json.success true
|
||||
json.id @instance.id
|
||||
json.name @instance.item_instance_name
|
||||
json.code @instance.item_instance_code
|
||||
|
||||
json.item_id @instance.menu_item_id
|
||||
json.attributes @instance.item_attributes
|
||||
json.price @instance.price
|
||||
json.is_default @instance.is_default
|
||||
|
||||
json.options opt_format
|
||||
else
|
||||
json.success false
|
||||
end
|
||||
1
app/views/foodcourt/addorders/get_menu.json.jbuilder
Normal file
1
app/views/foodcourt/addorders/get_menu.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @menu_category
|
||||
8
app/views/foodcourt/addorders/get_menu_category.json.jbuilder
Executable file
8
app/views/foodcourt/addorders/get_menu_category.json.jbuilder
Executable file
@@ -0,0 +1,8 @@
|
||||
if @menu.menu_items
|
||||
json.menu_items @menu.menu_items do |item|
|
||||
if item.is_available
|
||||
json.partial! 'foodcourt/addorders/menu_item', item: item
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
if @sub_menu
|
||||
json.sub_category @sub_menu.each do |sub_cat|
|
||||
json.id sub_cat.id
|
||||
json.code sub_cat.code
|
||||
json.name sub_cat.name
|
||||
json.menu_id sub_cat.menu_id
|
||||
json.menu_category_id sub_cat.menu_category_id
|
||||
end
|
||||
end
|
||||
101
app/views/foodcourt/cash_ins/new.html.erb
Executable file
101
app/views/foodcourt/cash_ins/new.html.erb
Executable file
@@ -0,0 +1,101 @@
|
||||
<div class="container-fluid">
|
||||
<div class='row'>
|
||||
<div class="col-lg-10 col-md-10 col-sm-10">
|
||||
<h2> <%= t :cash_in %> </h2>
|
||||
<br>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td> <%= t :payment_reference %>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" placeholder="Reference" id="reference">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= t("views.right_panel.detail.remark") %>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" placeholder="Remark" id="remark">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= t :payment_method %>
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn bg- waves-effect payment-type' data-id='cash' id='cash' style="background-color: #7a62d3;"><%= t("views.btn.cash") %></button>
|
||||
<button class='btn bg- waves-effect payment-type' data-id='mpu' id='mpu' style="background-color: #7a62d3;"><%= t("views.btn.mpu") %></button>
|
||||
<button class='btn bg- waves-effect payment-type' data-id='visa' id='visa' style="background-color: #7a62d3;"><%= t("views.btn.visa") %></button>
|
||||
<button class='btn bg- waves-effect payment-type' data-id='jcb' id='jcb' style="background-color: #7a62d3;"><%= t("views.btn.jcb") %></button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= t :reference_number %>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" id="payment_method_reference">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= t("views.right_panel.detail.amount") %>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" placeholder="Amount" id="amount">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 ">
|
||||
<br>
|
||||
<div class="button-demo m-t-40">
|
||||
<button type="button" class="btn bg-default waves-effect btn-" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
|
||||
<button type="button" class="btn bg-blue waves-effect btn-" id='cash_in'> <%= t("views.btn.cash_in") %> </button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
cashier_type = '<%= @cashier_type %>';
|
||||
console.log(cashier_type)
|
||||
|
||||
var payment_method = "";
|
||||
$('.payment-type').on('click',function(){
|
||||
$('.payment-type').css("background-color","#7a62d3");
|
||||
$(this).css("background-color","green");
|
||||
var type = $(this).attr('data-id')
|
||||
if(type == 'cash'){
|
||||
payment_method = 'cash';
|
||||
}else if(type == 'mpu'){
|
||||
payment_method = "mpu";
|
||||
}else if(type == 'visa'){
|
||||
payment_method = "visa";
|
||||
}else if(type == 'jcb'){
|
||||
payment_method = "jcb";
|
||||
}
|
||||
})
|
||||
$('#cash_in').on('click',function(){
|
||||
var reference = $('#reference').val();
|
||||
var remark = $('#remark').val();
|
||||
var amount = $('#amount').val();
|
||||
var payment_method_reference = $('#payment_method_reference').val();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= foodcourt_cash_ins_path %>",
|
||||
data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount + "&payment_method="+payment_method + "&payment_method_reference="+ payment_method_reference,
|
||||
success:function(result){
|
||||
if (cashier_type == 'quick_service' || cashier_type == 'food_court') {
|
||||
window.location.href = '/foodcourt/'+cashier_type+'/pending_order';
|
||||
}else{
|
||||
window.location.href = '/foodcourt';
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
$('#back').on('click',function(){
|
||||
if (cashier_type == 'quick_service' || cashier_type == 'food_court') {
|
||||
window.location.href = '/foodcourt/'+cashier_type+'/pending_order';
|
||||
}else{
|
||||
window.location.href = '/foodcourt';
|
||||
}
|
||||
})
|
||||
</script>
|
||||
2
app/views/foodcourt/cash_mgmt/create.html.erb
Executable file
2
app/views/foodcourt/cash_mgmt/create.html.erb
Executable file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#create</h1>
|
||||
<p>Find me in app/views/cash_mgmt/create.html.erb</p>
|
||||
2
app/views/foodcourt/cash_mgmt/index.html.erb
Executable file
2
app/views/foodcourt/cash_mgmt/index.html.erb
Executable file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#index</h1>
|
||||
<p>Find me in app/views/cash_mgmt/index.html.erb</p>
|
||||
3
app/views/foodcourt/cash_mgmt/new.html.erb
Executable file
3
app/views/foodcourt/cash_mgmt/new.html.erb
Executable file
@@ -0,0 +1,3 @@
|
||||
<h1>CashMgmt#new</h1>
|
||||
<p>Find me in app/views/cash_mgmt/new.html.erb</p>
|
||||
|
||||
53
app/views/foodcourt/cash_outs/new.html.erb
Executable file
53
app/views/foodcourt/cash_outs/new.html.erb
Executable file
@@ -0,0 +1,53 @@
|
||||
<div class="container-fluid">
|
||||
<div class='row'>
|
||||
<div class="col-lg-10 col-md-10 col-sm-10">
|
||||
<h2><%= t :cash_out %></h2>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td> <%= t :payment_reference %></td>
|
||||
<td><input type="text" class="form-control" placeholder="Reference" id="reference"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= t("views.right_panel.detail.remark") %></td>
|
||||
<td><input type="text" class="form-control" placeholder="Remark" id="remark"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <%= t("views.right_panel.detail.amount") %> </td>
|
||||
<td><input type="text" class="form-control" placeholder="Amount" id="amount"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<br><br>
|
||||
<button type="button" class="btn bg-default btn-block" id='back'> <i class="material-icons">reply</i><%= t("views.btn.back") %> </button>
|
||||
<button type="button" class="btn bg-blue btn-block" id='cash_out'> <%= t("views.btn.cash_out") %> </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
cashier_type = '<%= @cashier_type %>';
|
||||
$('#cash_out').on('click',function(){
|
||||
var reference = $('#reference').val();
|
||||
var remark = $('#remark').val();
|
||||
var amount = $('#amount').val();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= foodcourt_cash_outs_path %>",
|
||||
data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount,
|
||||
success:function(result){
|
||||
if (cashier_type == 'quick_service' || cashier_type == 'food_court') {
|
||||
window.location.href = '/foodcourt/'+cashier_type+'/pending_order';
|
||||
}else{
|
||||
window.location.href = '/foodcourt';
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('#back').on('click',function(){
|
||||
if (cashier_type == 'quick_service' || cashier_type == 'food_court') {
|
||||
window.location.href = '/foodcourt/'+cashier_type+'/pending_order';
|
||||
}else{
|
||||
window.location.href = '/foodcourt';
|
||||
}
|
||||
})
|
||||
</script>
|
||||
715
app/views/foodcourt/customers/index.html.erb
Normal file
715
app/views/foodcourt/customers/index.html.erb
Normal file
@@ -0,0 +1,715 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<div class="row p-t-20 p-l-20">
|
||||
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10">
|
||||
<% path ="/foodcourt/#{@sale_id}/#{@cashier_type}/customers/#{@page}" %>
|
||||
<%= form_tag path, :id => "filter_form", :method => :get do %>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
|
||||
|
||||
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12">
|
||||
|
||||
</div>
|
||||
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
|
||||
<button type="submit" class="btn bg-blue waves-effect waves-effect" style="height: 30%;margin-right: 10px;">Search</button>
|
||||
<!-- </div> -->
|
||||
|
||||
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;">Member Card</button>
|
||||
|
||||
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.qr_code") %></button>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<button type="button" class="btn btn-md btn-block btn-default waves-effect" id='back'>
|
||||
<i class="material-icons">reply</i>Back
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
|
||||
<%= paginate @crm_customers %>
|
||||
<div class="main-box-body clearfix" id="order-detail-slimscroll" style="">
|
||||
<div class="table-responsive">
|
||||
<table id="origami-crm-table" class="table table-striped" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><%= t("views.right_panel.detail.sr_no") %></th>
|
||||
<th><%= t :customer %> <%= t("views.right_panel.detail.type") %></th>
|
||||
<th><%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t("views.right_panel.detail.card_no") %></th>
|
||||
<th><%= t("views.right_panel.detail.membership_type") %></th>
|
||||
<th style="width:20%"><%= t("views.right_panel.detail.contact_no") %></th>
|
||||
<th style="width:20%"><%= t("views.right_panel.detail.email") %></th>
|
||||
<!-- <th>Paypar No</th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% if @crm_customers.count > 0 %>
|
||||
<% @i = 0 %>
|
||||
<% @crm_customers.each do |crm_customer| %>
|
||||
|
||||
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
|
||||
<td>
|
||||
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
||||
<td>
|
||||
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
|
||||
<%= @i += 1 %>
|
||||
<%else%>
|
||||
-
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= crm_customer.customer_type rescue '-' %></td>
|
||||
<td><%= crm_customer.name %></td>
|
||||
<td><%= crm_customer.card_no rescue '-' %></td>
|
||||
<td>
|
||||
<% if !@membership_types.nil? %>
|
||||
<% @membership_types.each do |member_type| %>
|
||||
<% if member_type[1] == crm_customer.membership_type %>
|
||||
<%= member_type[0] %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td style="width:20%;word-break: break-all;"><%= crm_customer.contact_no %></td>
|
||||
<td style="width:20%;word-break: break-all;"><%= crm_customer.email %></td>
|
||||
<!-- <td><%= crm_customer.paypar_account_no %></td> -->
|
||||
|
||||
</tr>
|
||||
<% end %>
|
||||
<%else%>
|
||||
<tr><td colspan="5"><p style="text-align:center"><strong>There are no record for your search</strong></p></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- .end-of-col-md-8 -->
|
||||
<div class="col-sm-4 col-md-4 col-lg-4">
|
||||
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
|
||||
<input type="hidden" id="type" name="type" value="<%= @cashier_type %>" />
|
||||
<input type="hidden" id="page" name="page" value="<%= @page %>" />
|
||||
<%if !@dining_facility.nil?%>
|
||||
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
|
||||
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
|
||||
<input type="hidden" id="table_type" name="table_type" value="<%= @dining_facility.type %>" />
|
||||
<% elsif @cashier_type == 'quick_service' || @cashier_type == "food_court" %>
|
||||
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
|
||||
<input type="hidden" id="type" name="type" value="<%= @cashier_type %>" />
|
||||
<input type="hidden" id="page" name="page" value="<%= @page %>" />
|
||||
<%else%>
|
||||
<input type="hidden" id="table_id" name="table_id" value="" />
|
||||
<input type="hidden" id="type" name="type" value="" />
|
||||
<input type="hidden" id="table_type" name="table_type" value="" />
|
||||
<%end%>
|
||||
|
||||
<section>
|
||||
<div class="wizard">
|
||||
<div class="wizard-inner">
|
||||
<div class="active-line"></div>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="nav-item">
|
||||
<div class="connecting-line border-right"></div>
|
||||
<a href="#step1" class="nav-link active" data-toggle="tab" aria-controls="step1" role="tab" title="Step 1">
|
||||
<span class="round-tab">
|
||||
1
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation" class="nav-item disabled">
|
||||
<div class="connecting-line"></div>
|
||||
<a href="#complete" class="nav-link disable" data-toggle="tab" aria-controls="complete" role="tab" title="Complete">
|
||||
<span class="round-tab">
|
||||
2
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<%= f.error_notification %>
|
||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" role="tabpanel" id="step1">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label><%= t("views.right_panel.detail.sr_no") %></label>
|
||||
<div class="form-line disabled">
|
||||
<input type="text" name="" value="<%=@count_customer%>" class="form-control" disabled="" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label for="customer[salutation]" class="control-label"> <%= t("views.right_panel.detail.salutation") %> :</label><br>
|
||||
<label class="font-12 radio-inline">
|
||||
<%= f.radio_button :salutation,"Mr", :class => "salutation mr with-gap radio-col-indigo", :value=>"Mr"%><%= t("views.right_panel.detail.mr") %>
|
||||
</label>
|
||||
<label class="font-12 radio-inline">
|
||||
<%= f.radio_button :salutation,"Mrs", :class => "salutation mrs with-gap radio-col-indigo", :value=>"Mrs"%><%= t("views.right_panel.detail.miss") %>
|
||||
</label>
|
||||
<label class="font-12 radio-inline">
|
||||
<%= f.radio_button :salutation,"Miss", :class => "salutation miss with-gap radio-col-indigo", :value=>"Miss"%><%= t("views.right_panel.detail.mrs") %>
|
||||
</label>
|
||||
<label class="font-12 radio-inline">
|
||||
<%= f.radio_button :salutation,"Mdm", :class => "salutation mdm with-gap radio-col-indigo", :value=>"Mdm"%><%= t("views.right_panel.detail.mdm") %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :name, :class => "form-control name", :required => true %>
|
||||
|
||||
<% flash.each do |name, msg| %>
|
||||
<% str="[\"#{msg['name']}\"]"
|
||||
str.gsub!('["', '')
|
||||
str.gsub!('"]', '') %>
|
||||
<span class="help-block"><%= str %></span>
|
||||
<% end -%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :contact_no, :class => "form-control contact_no" ,:required => true%>
|
||||
|
||||
<% flash.each do |name, msg| %>
|
||||
<% str="[\"#{msg['contact_no']}\"]"
|
||||
str.gsub!('["', '')
|
||||
str.gsub!('"]', '') %>
|
||||
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :email, :class => "form-control email" ,:required => true%>
|
||||
|
||||
<% flash.each do |name, msg| %>
|
||||
<% str="[\"#{msg['email']}\"]"
|
||||
str.gsub!('["', '')
|
||||
str.gsub!('"]', '') %>
|
||||
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12" align="right">
|
||||
<button type="button" class="btn btn-md bg-blue btn-info-full next-step">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- .end-of-step1 -->
|
||||
<div class="tab-pane" role="tabpanel" id="complete">
|
||||
<!-- <h4>Step 2</h4> -->
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label><%= t("views.right_panel.detail.customer_photo") %></label>
|
||||
<div class="panel padding-10">
|
||||
<div class="menu-item-img">
|
||||
<% if f.object.image_path? %>
|
||||
<p><%= f.object.name %></p>
|
||||
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
|
||||
<% else %>
|
||||
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.file_field :image_path, :class => "img-thumbnail" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label for="customer[gender]" class="control-label"><%= t("views.right_panel.detail.gender") %> :</label><br>
|
||||
<label class="font-12 radio-inline">
|
||||
<%= f.radio_button :gender,"Male", :class => "gender male", :value=>"Male"%><%= t("views.right_panel.detail.male") %></label>
|
||||
<label class="font-12 radio-inline">
|
||||
<%= f.radio_button :gender,"Female", :class => "gender female", :value=>"Female"%><%= t("views.right_panel.detail.female") %></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :company, :class => "form-control col-md-6 company"%>
|
||||
|
||||
<% flash.each do |name, msg| %>
|
||||
<% str="[\"#{msg['company']}\"]"
|
||||
str.gsub!('["', '')
|
||||
str.gsub!('"]', '') %>
|
||||
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
|
||||
<% end -%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label class="control-label"><%= t("views.right_panel.detail.date_of_birth") %></label>
|
||||
<%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :address, :class => "form-control address" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label><%= t("views.right_panel.detail.select_customer_type") %></label>
|
||||
<select class="form-control col-md-12 selectpicker show-tick" id="customer_type" name="customer[customer_type]" style="height: " >
|
||||
<% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
|
||||
<option value="<%= ct.value %>">
|
||||
<%= ct.name %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control tax_profiles" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<%= f.input :card_no, :class => "form-control card_no"%>
|
||||
<% flash.each do |name, msg| %>
|
||||
<% str="[\"#{msg['card_no']}\"]"
|
||||
str.gsub!('["', '')
|
||||
str.gsub!('"]', '') %>
|
||||
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label class="control-label"><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
|
||||
<div class="-group">
|
||||
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
|
||||
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label class="control-label"><%= t("views.right_panel.detail.select_membership_group") %></label>
|
||||
<select class="form-control col-md-12 selectpicker show-tick" name="member_group_id" style="height: " >
|
||||
<option value=""><%= t("views.right_panel.detail.select_membership_group") %></option>
|
||||
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
|
||||
<option value="<%= member.value %>">
|
||||
<%= member.name %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12" align="right">
|
||||
<button type="button" class="btn btn-md bg-blue prev-step">Prev</button>
|
||||
<%= f.submit t("views.btn.submit"),:class => 'btn bg-blue btn-md waves-effect', :id => 'submit_customer' %>
|
||||
<!-- <%= f.button :submit, "Update",:class => 'btn bg-blue btn-block', :disabled =>'', :id => 'update_customer' %> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- .end-of-step2 -->
|
||||
</div> <!-- .end-of-tab-content -->
|
||||
<% end %>
|
||||
</div> <!-- .end-of-wizard -->
|
||||
</section> <!-- .end-of-section -->
|
||||
</div><!-- .end-of-col-md-4 -->
|
||||
</div> <!-- .end-of-row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sxModal">
|
||||
<div id="sxModal-Content"><h3>Card Tap</h3></div>
|
||||
<div class="m-r-20" align="right">
|
||||
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
var page = "<%= @page %>";
|
||||
var paypar_account_no = [];
|
||||
$(function() {
|
||||
paypar_account_no = JSON.parse('<%= @paypar_accountno.to_json.html_safe %>', function (key, value) {
|
||||
var type;
|
||||
if (value && typeof value === 'object') {
|
||||
type = value.type;
|
||||
if (typeof type === 'string' && typeof window[type] === 'function') {
|
||||
return new(window[type])(value);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
console.log(paypar_account_no);
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
|
||||
localStorage.setItem("member_card",false);
|
||||
/*$('.datepicker').datepicker({
|
||||
setDate: '12-12-1999',
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');*/
|
||||
|
||||
// Read Card Reader
|
||||
$("#paypar_account_no").on('focus', function(e){
|
||||
if($(this).val() == ''){
|
||||
$("#sxModal").show();
|
||||
setTimeout(function(){
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
},100);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
setHeaderBreadCrumb(_CUSTOMERS_);
|
||||
|
||||
});
|
||||
// Read Card Reader
|
||||
$("#member_acc_no").on('click', function(e){
|
||||
localStorage.setItem("member_card",true);
|
||||
var cardNo = "";
|
||||
var customer_id = '';
|
||||
var customer_name = '';
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var customer_mamber_card_no = 0;
|
||||
$("#sxModal").show();
|
||||
setTimeout(function(){
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
customer_mamber_card_no = $("#search").val();
|
||||
|
||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/"+sale_id+"/get_customer" ,
|
||||
data: { filter : customer_mamber_card_no ,type :"card"},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data[0].customer_id == false) {
|
||||
swal("Alert!", data[0].message, "error");
|
||||
// $.alert({
|
||||
// title: 'Alert!',
|
||||
// content: data[0].message,
|
||||
// type: 'red',
|
||||
// typeAnimated: true,
|
||||
// btnClass: 'btn-danger',
|
||||
// });
|
||||
}else{
|
||||
customer_id = data[0].customer_id;
|
||||
customer_name = data[0].name;
|
||||
update_sale(customer_id, customer_name,sale_id);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
},100);
|
||||
});
|
||||
|
||||
/*new customer UI func:*/
|
||||
//Initialize tooltips
|
||||
$('.nav-tabs > li a[title]').tooltip();
|
||||
|
||||
//Wizard
|
||||
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
|
||||
|
||||
var $target = $(e.target);
|
||||
|
||||
if ($target.parent().hasClass('disabled')) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$(".next-step").click(function (e) {
|
||||
var $active = $('.wizard .nav-tabs li a.active');
|
||||
$active.parent().next().removeClass('disabled');
|
||||
nextTab($active);
|
||||
$('.wizard .nav-tabs li.active .connecting-line').css({"border-bottom-left-radius": 0, "border-top-left-radius": 0});
|
||||
});
|
||||
$(".prev-step").click(function (e) {
|
||||
|
||||
var $active = $('.wizard .nav-tabs li a.active');
|
||||
prevTab($active);
|
||||
|
||||
});
|
||||
/*new customer UI func:*/
|
||||
});
|
||||
|
||||
/*customer UI tab btn*/
|
||||
function nextTab(elem) {
|
||||
$(elem).parent().next().find('a[data-toggle="tab"]').click();
|
||||
}
|
||||
function prevTab(elem) {
|
||||
$(elem).parent().prev().find('a[data-toggle="tab"]').click();
|
||||
}
|
||||
/*customer UI tab btn*/
|
||||
|
||||
|
||||
// Read NFC card no from java
|
||||
function getCardNo(){
|
||||
code2lab.readNFC();
|
||||
}
|
||||
|
||||
// get CardNo from Java
|
||||
function setCardNo(cardNo){
|
||||
check_member = localStorage.getItem("member_card");
|
||||
if(cardNo.length == 16){
|
||||
if(check_member == "true"){
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
$("#search").val(cardNo);
|
||||
$("#type").val("card");
|
||||
}else{
|
||||
if($.inArray(cardNo, paypar_account_no) !== -1){
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: 'CardNo already registered, Please try another card!',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}else{
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
$("#search").val(cardNo);
|
||||
$("#type").val("card");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// QR Code Reader
|
||||
$("#qr_code").on('click', function(e){
|
||||
var code = "";
|
||||
var customer_id = '';
|
||||
var customer_name = '';
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var customer_mamber_card_no = 0;
|
||||
|
||||
setTimeout(function(){
|
||||
code=getQRCode();
|
||||
setQRCode(code);
|
||||
}, 100);
|
||||
|
||||
customer_mamber_card_no = $("#search").val();
|
||||
|
||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/"+sale_id+"/get_customer" ,
|
||||
data: { filter : customer_mamber_card_no ,type :"card"},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data[0].customer_id == false) {
|
||||
swal("Alert!", data[0].message, "error");
|
||||
// $.alert({
|
||||
// title: 'Alert!',
|
||||
// content: data[0].message,
|
||||
// type: 'red',
|
||||
// typeAnimated: true,
|
||||
// btnClass: 'btn-danger',
|
||||
// });
|
||||
}else{
|
||||
customer_id = data[0].customer_id;
|
||||
customer_name = data[0].name;
|
||||
update_sale(customer_id, customer_name,sale_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Read qrcode from java
|
||||
function getQRCode(){
|
||||
return code2lab.readQRCode();
|
||||
}
|
||||
|
||||
// get QRCode from Java
|
||||
function setQRCode(code){
|
||||
$("#qr_code").text(code);
|
||||
$("#search").val(code);
|
||||
}
|
||||
|
||||
$(document).on('click',".customer_tr",function(){
|
||||
// if(this.checked){
|
||||
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var customer_id = $(this).attr('data-ref');
|
||||
var customer_name = $(this).children("td:nth-child(3)").text();
|
||||
console.log(sale_id);
|
||||
if(sale_id != 0){
|
||||
// var url = "/"+customer_id;
|
||||
update_sale(customer_id, customer_name,sale_id);
|
||||
}else{
|
||||
|
||||
var url = "customers/"+customer_id;
|
||||
}
|
||||
|
||||
// Need To Clean?
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
var taxes = JSON.stringify(data.tax_profiles);
|
||||
var parse_taxes = JSON.parse(taxes);
|
||||
$.each(parse_taxes, function(i, value){
|
||||
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
|
||||
});
|
||||
|
||||
$('#customer_id').val(data.id);
|
||||
$('#customer_name').val(data.name);
|
||||
$('#customer_company').val(data.company);
|
||||
$('#customer_contact_no').val(data.contact_no);
|
||||
$('#customer_email').val(data.email);
|
||||
$('#customer_date_of_birth').val(data.date_of_birth);
|
||||
$('#customer_membership_type').val(data.membership_type);
|
||||
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
|
||||
$('.membership_authentication_code').val(data.membership_authentication_code);
|
||||
$('#customer_card_no').val(data.card_no);
|
||||
$('#customer_type').val(data.customer_type);
|
||||
$('#customer_salutation').val(data.salutation);
|
||||
$('#customer_nrc_no').val(data.nrc_no);
|
||||
$('#paypar_account_no').val(data.paypar_account_no);
|
||||
|
||||
if (data.gender == 'Male') {
|
||||
$('.male').prop( "checked", true )
|
||||
}else{
|
||||
$('.female').prop( "checked", true )
|
||||
}
|
||||
|
||||
if (data.salutation == 'Mr') {
|
||||
$('.mr').prop( "checked", true )
|
||||
} else if(data.salutation == 'Miss') {
|
||||
$('.miss').prop( "checked", true )
|
||||
}else if(data.salutation == 'Mrs'){
|
||||
$('.mrs').prop( "checked", true )
|
||||
}else{
|
||||
$('.mdm').prop( "checked", true )
|
||||
}
|
||||
|
||||
$('#update_customer').removeAttr('disabled').val('');
|
||||
$('#update_customer').attr('value', 'Update');
|
||||
// $('#submit_customer').attr('disabled','disabled');
|
||||
|
||||
$("#new_customer").attr('class', 'simple_form edit_customer');
|
||||
var id = "edit_customer_"+$('#customer_id').val();
|
||||
$("#new_customer").attr('id', id);
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".patch_method").append('<input type="hidden" name="_method" value="patch">');
|
||||
//$(".edit_customer").attr('method', 'PATCH');
|
||||
}
|
||||
});
|
||||
// }else{
|
||||
|
||||
// }
|
||||
})
|
||||
|
||||
function update_sale(customer_id, customer_name, sale_id) {
|
||||
var customer="";
|
||||
if(customer_name != ""){
|
||||
customer = '(' + customer_name + ')';
|
||||
}
|
||||
|
||||
swal({
|
||||
title: "Confirmation !",
|
||||
text: 'Are You Sure to assign this customer' + customer + '!',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "green",
|
||||
confirmButtonText: "Yes!",
|
||||
cancelButtonClass: 'btn btn-danger',
|
||||
closeOnConfirm: false,
|
||||
}, function () {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
|
||||
data: {customer_id:customer_id,sale_id:sale_id},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == true)
|
||||
{
|
||||
var id = $("#table_id").val();
|
||||
var type = $("#table_type").val();
|
||||
var booking_id = "";
|
||||
<% if !@booking_order.nil? %>
|
||||
booking_id = "<%= @booking_order.booking_id %>";
|
||||
<% end %>
|
||||
if (cashier_type == "quick_service" || cashier_type == "food_court") {
|
||||
if(booking_id!= "" && page == "pending"){
|
||||
window.location.href = '/foodcourt/'+cashier_type+'/pending_order/'+booking_id;
|
||||
}else{
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}
|
||||
}else{
|
||||
if(page == "payment"){
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if (type=="Table") {
|
||||
window.location.href = '/foodcourt/table/'+id
|
||||
}else{
|
||||
window.location.href = '/foodcourt/room/'+id
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
swal("Alert!", "Record not found!", "error");
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$('#back').on('click',function(){
|
||||
var id = $("#table_id").val();
|
||||
var type = $("#table_type").val();
|
||||
var sale_id = $("#sale_id").val();
|
||||
if (cashier_type == "quick_service" || cashier_type == "food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if(page == "pending"){
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/pending/';
|
||||
}
|
||||
else if(page == "payment"){
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if (type=="Table") {
|
||||
window.location.href = '/foodcourt/table/'+id;
|
||||
}else{
|
||||
window.location.href = '/foodcourt/room/'+id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$("#sxModal .btn_cancel").on('click',function(){
|
||||
$("#sxModal").hide();
|
||||
});
|
||||
|
||||
</script>
|
||||
112
app/views/foodcourt/dashboard/_menu.json.jbuilder
Normal file
112
app/views/foodcourt/dashboard/_menu.json.jbuilder
Normal file
@@ -0,0 +1,112 @@
|
||||
json.id menu.id
|
||||
json.name menu.name
|
||||
json.is_ordering menu.is_ordering
|
||||
json.is_active menu.is_active
|
||||
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
|
||||
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
|
||||
|
||||
if (menu.menu_categories)
|
||||
order_by = Lookup.find_by_lookup_type("order_by")
|
||||
# if !order_by.nil? && order_by.value == "name"
|
||||
# categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc")
|
||||
# else
|
||||
# categories = menu.menu_categories
|
||||
# end
|
||||
categories = menu.menu_categories
|
||||
json.categories categories do |category|
|
||||
if category.is_available
|
||||
parent_category = category.parent
|
||||
if !parent_category.nil?
|
||||
json.sub_category "true"
|
||||
else
|
||||
json.sub_category "false"
|
||||
end
|
||||
valid_time = category.valid_time
|
||||
json.valid_time valid_time
|
||||
|
||||
json.id category.id
|
||||
json.code category.code
|
||||
json.order_by category.order_by
|
||||
json.name category.name
|
||||
json.alt_name category.alt_name
|
||||
json.order_by category.order_by
|
||||
json.parent_id category.menu_category_id
|
||||
json.is_available category.is_available
|
||||
|
||||
if !order_by.nil? && order_by.value == "name"
|
||||
menu_items = category.menu_items.sort_by(&:name)
|
||||
else
|
||||
menu_items = category.menu_items
|
||||
end
|
||||
|
||||
if category.menu_items
|
||||
json.items menu_items do |item|
|
||||
if item.is_available
|
||||
# Format for attributes json
|
||||
attr_format = []
|
||||
# Format for attributes json
|
||||
if item.item_attributes.count > 0
|
||||
item_attributes = @item_attributes.select{ |x| item.item_attributes.include?(x.id.to_s) }
|
||||
attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
if item.item_options.count > 0
|
||||
item_options = @item_options.select{ |x| item.item_options.include?(x.id.to_s) }
|
||||
opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
||||
end
|
||||
|
||||
#Menu Item Information
|
||||
json.id item.id
|
||||
json.code item.item_code
|
||||
json.name item.name
|
||||
json.alt_name item.alt_name
|
||||
json.image item.image_path.url
|
||||
json.description item.description
|
||||
json.information item.information
|
||||
json.type item.type
|
||||
json.account_id item.account_id
|
||||
json.min_qty item.min_qty
|
||||
json.is_available item.is_available
|
||||
json.is_sub_item item.is_sub_item
|
||||
json.unit item.unit
|
||||
|
||||
# Item Sets of Menu Item
|
||||
json.item_sets item.item_sets.map { |its|
|
||||
{ id: its.id,
|
||||
name: its.name,
|
||||
alt_name: its.alt_name,
|
||||
min_selectable_qty: its.min_selectable_qty,
|
||||
max_selectable_qty: its.max_selectable_qty,
|
||||
instances: its.menu_item_instances.pluck(:id).map { |id| {id: id}}
|
||||
}
|
||||
}
|
||||
|
||||
json.attributes attr_format
|
||||
json.options opt_format
|
||||
|
||||
json.instances item.menu_item_instances do |is|
|
||||
if is.is_available
|
||||
# Convert id to name for attributes
|
||||
instance_attr = @item_attributes.select{ |x| item.item_attributes.include?(x.id) }.pluck(:name)
|
||||
|
||||
json.id is.id
|
||||
json.code is.item_instance_code
|
||||
json.name is.item_instance_name
|
||||
json.price is.price
|
||||
json.is_available is.is_available
|
||||
json.is_default is.is_default
|
||||
json.is_on_promotion is.is_on_promotion
|
||||
json.promotion_price is.promotion_price
|
||||
json.values instance_attr
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
18
app/views/foodcourt/dashboard/get_all_menu.json.jbuilder
Normal file
18
app/views/foodcourt/dashboard/get_all_menu.json.jbuilder
Normal file
@@ -0,0 +1,18 @@
|
||||
menu_json = json.array! @menus do |menu|
|
||||
|
||||
if !menu.is_ordering
|
||||
json.id menu.id
|
||||
json.name menu.name
|
||||
json.valid_days menu.valid_days
|
||||
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
|
||||
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
|
||||
|
||||
json.partial! 'foodcourt/dashboard/menu', menu: menu
|
||||
# if (@current_menu)
|
||||
# json.current_menu do
|
||||
# json.partial! 'api/restaurant/menu/menu', menu: @current_menu
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
end
|
||||
281
app/views/foodcourt/dashboard/index.html.erb
Normal file
281
app/views/foodcourt/dashboard/index.html.erb
Normal file
@@ -0,0 +1,281 @@
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<div class="block-header">
|
||||
<!-- <h2><%= t :dashboard %></h2> -->
|
||||
<h2><%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></h2>
|
||||
</div>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
|
||||
<!-- Widgets -->
|
||||
<div class="row clearfix">
|
||||
<% if @quick_service == '1' %>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-10 qs_view">
|
||||
<div class="info-box bg-purple">
|
||||
<div class="icon" >
|
||||
<i class="material-icons">arrow_forward</i>
|
||||
</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :quick_service %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @food_court == '1' %>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-10 fc_view">
|
||||
<div class="info-box bg-pink">
|
||||
<div class="icon" >
|
||||
<i class="material-icons">arrow_forward</i>
|
||||
</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= @food_court_name %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @dinein_cashier == '1' %>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-10 cashier_view">
|
||||
<div class="info-box bg-green">
|
||||
<div class="icon" >
|
||||
<i class="material-icons">arrow_forward</i>
|
||||
</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :dine_in_cashier %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @reservation == '1' %>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-10 reservation">
|
||||
<div class="info-box bg-orange">
|
||||
<div class="icon" >
|
||||
<i class="material-icons">arrow_forward</i>
|
||||
</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :reservation %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @order_reservation == '1' %>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-10 order_reservation">
|
||||
<div class="info-box bg-blue">
|
||||
<div class="icon" >
|
||||
<i class="material-icons">arrow_forward</i>
|
||||
</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :order_reservation %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- #END# Widgets -->
|
||||
<% if !@current_user.nil? && @current_user.role != 'waiter' && @setting_flag %>
|
||||
<!-- CPU Usage -->
|
||||
<div class="row clearfix">
|
||||
|
||||
<% if !@summ_sale.nil? %>
|
||||
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<h6><%= t :sale %></h6>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.receipt") %> : </td>
|
||||
<td align="right"><%= @summ_sale.total_receipt %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%>
|
||||
<td><%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : </td>
|
||||
<td align="right"><%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="table">
|
||||
<% if !(@total_payment_methods.nil?) %>
|
||||
<% @total_payment_methods.each do |payment| %>
|
||||
<% if !@sale_data[0].empty? %>
|
||||
<% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %>
|
||||
<tr>
|
||||
<% if payment.payment_method == 'paypar' %>
|
||||
<td>Redeem Sale : </td>
|
||||
<% else %>
|
||||
<td><%= payment.payment_method.to_s.capitalize %> Sale : </td>
|
||||
<% end %>
|
||||
<td align="right">
|
||||
<% @sale_data.each do |data| %>
|
||||
<% pay_mth = payment.payment_method %>
|
||||
<%= data[""+pay_mth+""] %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %>
|
||||
<% if !total_card.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.other_payment") %> : </td>
|
||||
<td align="right">
|
||||
<%= total_card["card"].to_f %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<h6><%= t :customer %></h6>
|
||||
<table class="table">
|
||||
<% if !@total_customer.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t :customer %> : </td>
|
||||
<td align="right"><%= @total_customer %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@total_dinein.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.dine_in") %> : </td>
|
||||
<td align="right"><%= @total_dinein %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@total_takeaway.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.takeaway") %> : </td>
|
||||
<td align="right"><%= @total_takeaway %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- <% if !@total_other_customer.nil? %>
|
||||
<tr>
|
||||
<td><%= t :customer %> : </td>
|
||||
<td align="right"><%= @total_other_customer.total_cus %></td>
|
||||
</tr>
|
||||
<% end %> -->
|
||||
<% if !@total_membership.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.membership") %> : </td>
|
||||
<td align="right"><%= @total_membership %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<h6><%= t("views.right_panel.detail.order") %></h6>
|
||||
<table class="table">
|
||||
<% if !@total_order.nil? %>
|
||||
<tr>
|
||||
<td width="40px"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.order") %> : </td>
|
||||
<td align="right" width="60px"><%= @total_order.total_order %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if !@total_accounts.nil? %>
|
||||
<% @total_accounts.each do |account| %>
|
||||
<tr>
|
||||
<td width="40px"><%= account.title %> (Account) : </td>
|
||||
<td align="right" width="60px">
|
||||
<% @account_data.each do |data| %>
|
||||
<% acc = account.title %>
|
||||
<%= data[""+acc+""] %> <% if !data[''+acc+''].nil? %> ( <%= data[''+acc+'_amount'] %> ) <% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if !@top_items.nil? %>
|
||||
<tr>
|
||||
<td width="40px"><%= t :top %> <%= t("views.right_panel.detail.item") %> : </td>
|
||||
<td align="right" width="60px"><%= @top_items.item_name %>
|
||||
<br>(<%= @top_items.item_total_price %>)</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@total_foc_items.nil? %>
|
||||
<tr>
|
||||
<td width="40px"><%= t("views.right_panel.detail.total") %> <%= t("views.btn.foc") %> <%= t("views.right_panel.detail.item") %> : </td>
|
||||
<td align="right" width="60px"><%= @total_foc_items.to_int %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<button type="button" data-href="<%=foodcourt_second_display_index_path%>" target="_blank" id="second_view" class="btn action-btn bg-blue waves-effect second_view hidden" style="height: 45px">Customer View</button>
|
||||
<input type="hidden" name="server_mode" value="<%=ENV["SERVER_MODE"]%>" id="server_mode">
|
||||
<script>
|
||||
$(function() {
|
||||
$("#loading_wrapper").show();
|
||||
getAllMenu();
|
||||
|
||||
$(".cashier_view").on('click', function() {
|
||||
window.location.href = '/foodcourt';
|
||||
});
|
||||
|
||||
$(".qs_view").on('click', function() {
|
||||
var display_type = '<%= @display_type %>';
|
||||
if (display_type.length>0) {
|
||||
display_type = '<%= @display_type %>';
|
||||
}else{
|
||||
display_type = null;
|
||||
}
|
||||
if ($('#server_mode').val() != "cloud" && display_type == 2) {
|
||||
document.getElementById('second_view').click();
|
||||
}
|
||||
window.location.href = '/foodcourt/quick_service';
|
||||
});
|
||||
|
||||
$(".fc_view").on('click', function() {
|
||||
var display_type = '<%= @display_type %>';
|
||||
if (display_type.length>0) {
|
||||
display_type = '<%= @display_type %>';
|
||||
}else{
|
||||
display_type = null;
|
||||
}
|
||||
if ($('#server_mode').val() != "cloud" && display_type == 2) {
|
||||
document.getElementById('second_view').click();
|
||||
}
|
||||
window.location.href = '/foodcourt/food_court';
|
||||
});
|
||||
|
||||
$(".order_reservation").on('click', function() {
|
||||
window.location.href = '/foodcourt/order_reservation';
|
||||
});
|
||||
|
||||
$("#second_view").on('click', function () {
|
||||
var url = $(this).attr("data-href");
|
||||
window.open(url,'_blank');
|
||||
});
|
||||
|
||||
$(".reservation").on("click", function(){
|
||||
window.location.href = '/foodcourt/reservation';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
919
app/views/foodcourt/discounts/index.html.erb
Executable file
919
app/views/foodcourt/discounts/index.html.erb
Executable file
@@ -0,0 +1,919 @@
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<% if !@print_settings.nil? %>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<!-- Order Details -->
|
||||
<div class="card" >
|
||||
<!-- <div class="card-header">
|
||||
<div><strong id="order-title">ORDER DETAILS</strong></div>
|
||||
</div> -->
|
||||
<div class="card-block">
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<%if !@table.nil?%>
|
||||
<span class="hidden" id ="table_id" value="<%=@table.id%>"><%=@table.id%></span>
|
||||
<span class="hidden" id="table_type" value="<%=@table.type%>"><%=@table.type%></span>
|
||||
<%else%>
|
||||
<span class="hidden" id ="table_id" value="<%=@table%>"><%=@table%></span>
|
||||
<span class="hidden" id="table_type" value="<%=@table%>"><%=@table%></span>
|
||||
<%end%>
|
||||
|
||||
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
|
||||
<p class="m-l-10">Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
|
||||
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p class="m-r-10">Date: <span id="receipt_date"> <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="order-detail-slimscroll" data-height="160">
|
||||
<div class="card-text dining">
|
||||
<span id="discount_itemsErr" style="color:red;"></span>
|
||||
<table class="table table-default" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</th>
|
||||
<th class="item-attr">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% sub_total = 0 %>
|
||||
<% @sale_data.sale_items.each do |sale_item| %>
|
||||
<% sub_total += sale_item.qty * sale_item.unit_price %>
|
||||
<% if sale_item.price > 0 && sale_item.status.blank? %>
|
||||
<tr class="item-row item" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
|
||||
<span id="item-account-qty" class="hidden"><%=sale_item.qty%></span>
|
||||
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-qty"><%=sale_item.qty%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% elsif sale_item.price < 0 && sale_item.status == "Discount" %>
|
||||
<tr class="item-row discount" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
|
||||
<span id="item-account-qty" class="hidden"><%=sale_item.qty%></span>
|
||||
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-qty"><%=sale_item.qty.abs%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td class="charges-name"><strong>Food:</strong></td>
|
||||
<td class="item-attr"><strong id="order-food"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Beverage:</strong></td>
|
||||
<td class="item-attr"><strong id="order-beverage"></strong></td>
|
||||
</tr> -->
|
||||
<tr>
|
||||
<%if @sale_data.discount_type == 'member_discount'%>
|
||||
<td class="charges-name"><strong>Member Discount:</strong></td>
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
|
||||
<td class="item-attr">(<strong id="order-discount"><%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong>)</td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<!-- Discount Amount -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">Discount Control</strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<div class="form-horizontal">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<input type="text" id="discount-amount" name="discount-amount" value="0" class="form-control" />
|
||||
<span id="discount-amountErr" style="color:red;"></span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<% @accounts.each do |acc| %>
|
||||
<button id="account-<%= acc.id %>" class="accounts-type btn bg-default"><%= acc.title %></button>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<div class="p-l-20">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="5" data-type="add">5%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="1" data-type="num" style="margin-left: 6px;">1</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom clearfix">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="10" data-type="add">10%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="4" data-type="num" style="margin-left: 6px;">4</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="15" data-type="add">15%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="7" data-type="num" style="margin-left: 6px;">7</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="20" data-type="add">20%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" data-value="0" data-type="num" style="margin-left: 6px;">0</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="30" data-type="add">30%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="row">
|
||||
<div class="col-md-3 cashier_number" style="margin-left: 6px;"></div>
|
||||
<div class="col-md-3 left cashier_number red" data-type="del">DEL</div>
|
||||
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<button id="net" class="btn bg-info fluid action-btn">Nett</button>
|
||||
<button id="percentage" class="btn bg-primary fluid action-btn" style="font-size: 12.4px">Percentage</button>
|
||||
<button id="remove-item" class="btn bg-default fluid action-btn">Clear Discount</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">Promo Code</strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<div class="form-horizontal">
|
||||
<div class="p-l-20">
|
||||
<div class="row">
|
||||
<div class="col-md-8 form-group">
|
||||
<div class="form-group">
|
||||
<input type="text" id="promo-code" name="promo-code" value="" class="form-control" /></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button id="" class="btn bg-primary btn-block action-btn">Promo</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Action Panel -->
|
||||
<div>
|
||||
<button type="button" class="btn bg-default btn-block" id="back" ><i class="material-icons">reply</i> Back </button>
|
||||
<button id="remove-item-discount" class="btn btn-primary btn- action-btn">Remove Item Discount</button>
|
||||
<button id="remove-all" class="btn bg-primary btn-block action-btn">Remove All</button>
|
||||
<button id="pay-discount" class="btn bg-primary btn-block action-btn">Enter</button>
|
||||
<% if @member_discount%>
|
||||
<!-- <hr />
|
||||
<button id="member-discount" class="btn btn-success btn-block action-btn
|
||||
<%= @sale_data.customer.membership_id ? " " : "disabled"%>">Member Discount</button> -->
|
||||
<%end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
var totalAmount = <%= sub_total %>;
|
||||
var totalDiscount = <%= @sale_data.total_discount %>
|
||||
var precision = <%= precision %>;
|
||||
$(document).ready(function(){
|
||||
setHeaderBreadCrumb(_DISCOUNTS_);
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
|
||||
$('#back').on('click',function(){
|
||||
var id = $("#table_id").text();
|
||||
var type = $("#table_type").text();
|
||||
var sale_id = $('#sale-id').text();
|
||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if (type=="Table") {
|
||||
window.location.href = '/foodcourt/table/'+id
|
||||
}else{
|
||||
window.location.href = '/foodcourt/room/'+id
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$(".cashier_number").on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value=0;
|
||||
original_value = $('#discount-amount').val();
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0.0"){
|
||||
$('#discount-amount').val(input_value);
|
||||
}
|
||||
else{
|
||||
$('#discount-amount').val(original_value + '' + input_value);
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value);
|
||||
$('#discount-amount').val(amount);
|
||||
break;
|
||||
case 'del' :
|
||||
var discount_text=$('#discount-amount').val();
|
||||
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
|
||||
break;
|
||||
case 'clr':
|
||||
$('#discount-amount').val("0.0");
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Select Sale Item
|
||||
$('#order-items-table').on('click', '.item-row', function(){
|
||||
if($(this).hasClass('selected-item') == true){
|
||||
$(this).removeClass('selected-item');
|
||||
}
|
||||
else {
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
});
|
||||
|
||||
// Select for account types
|
||||
$(".accounts-type").on('click', function(e){
|
||||
var account_id = $(this).attr('id').substr(8);
|
||||
if($(this).hasClass('selected-account') == true){
|
||||
$(this).removeClass('selected-account');
|
||||
$(".item-row").each(function(i){
|
||||
if($(this).children().find("#item-account-type").text() == account_id){
|
||||
$(this).removeClass("selected-item");
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$(this).addClass('selected-account');
|
||||
$(".item-row").each(function(i){
|
||||
if($(this).children().find("#item-account-type").text() == account_id){
|
||||
if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){
|
||||
$(this).addClass("selected-item");
|
||||
}
|
||||
else{
|
||||
console.log("discount item");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate Net Discount for Payment
|
||||
$("#net").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_value = $('#discount-amount').val();
|
||||
var sub_total = parseFloat($('#order-sub-total').text());
|
||||
var ajax_url = "/foodcourt/" + sale_id + "/discount";
|
||||
|
||||
if(discount_value!=""){
|
||||
if(discount_value > 0){
|
||||
if(parseFloat(discount_value) > sub_total){
|
||||
$("#discount-amount").val("");
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}else{
|
||||
$("#discount-amountErr").html("");
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
|
||||
// Selected Account
|
||||
var account_types = get_selected_account_types();
|
||||
|
||||
if(sale_items.length == 0 && account_types.length == 0){
|
||||
calculate_overall_discount(0, discount_value);
|
||||
}
|
||||
else if(sale_items.length > 0){
|
||||
calculate_item_discount(0, discount_value, sale_items, account_types);
|
||||
}
|
||||
|
||||
// Remove Selection
|
||||
selection_remove();
|
||||
}
|
||||
}else{
|
||||
$("#discount-amountErr").html("Discount must be greater than 0!");
|
||||
}
|
||||
}else{
|
||||
$("#discount-amountErr").html("can't be blank");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Calculate Percentage Discount for Payment
|
||||
$("#percentage").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_value = $('#discount-amount').val();
|
||||
var ajax_url = "/foodcourt/" + sale_id + "/discount";
|
||||
|
||||
if(discount_value!=""){
|
||||
if(discount_value > 0){
|
||||
$("#discount-amountErr").val("");
|
||||
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
// Selected Account
|
||||
var account_types = get_selected_account_types();
|
||||
|
||||
if(sale_items.length == 0 && account_types.length == 0){
|
||||
calculate_overall_discount(1, discount_value);
|
||||
} else if(sale_items.length > 0){
|
||||
calculate_item_discount(1, discount_value, sale_items, account_types);
|
||||
}
|
||||
}else{
|
||||
$("#discount-amountErr").html("Discount must be greater than 0!");
|
||||
}
|
||||
}else{
|
||||
$("#discount-amountErr").html("can't be blank");
|
||||
}
|
||||
|
||||
// Remove Selection
|
||||
selection_remove();
|
||||
});
|
||||
|
||||
// Remove selected discount items
|
||||
$("#remove-item").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var origin_sub_total = parseFloat($("#order-sub-total").text());
|
||||
// var total = 0;
|
||||
|
||||
$('.item-row.new-discount').each(function(i){
|
||||
var amount = parseFloat($(this).find('#item-total-price').text());
|
||||
totalAmount += Math.abs(amount)
|
||||
// total = total + Math.abs(amount);
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
$("#order-sub-total").text(totalAmount);
|
||||
$("#order-discount").text(totalDiscount.toFixed(<%= precision.to_i %>));
|
||||
});
|
||||
|
||||
// Pay Discount for Payment
|
||||
$("#pay-discount").on('click', function(e){
|
||||
e.preventDefault();
|
||||
if($('#pay-discount').is(":visible")) {
|
||||
$('#pay-discount').prop("disabled",true);
|
||||
}
|
||||
$("#loading_wrapper").show();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_items = JSON.stringify(get_new_discount_item_rows());
|
||||
var overall_discount = $("#order-discount").text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var ajax_url = "/foodcourt/" + sale_id + "/discount";
|
||||
|
||||
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
success:function(result){
|
||||
$("#loading_wrapper").hide();
|
||||
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.status,
|
||||
type: "success"
|
||||
}, function () {
|
||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/foodcourt/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/foodcourt/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Remove selected given discount item
|
||||
$("#remove-item-discount").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_items = [];
|
||||
|
||||
var sale_items = get_selected_discount_items();
|
||||
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(sale_items[i].price < 0){
|
||||
discount_items.push(sale_items[i]);
|
||||
}
|
||||
else {
|
||||
swal ("Oops" , "You have no selected item!" , "error" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var params = { 'cashier_type': cashier_type,'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/" + sale_id + "/remove_discount_items",
|
||||
data: params,
|
||||
success: function(result){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.status,
|
||||
type: "success",
|
||||
}, function () {
|
||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/foodcourt/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/foodcourt/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#remove-all").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/foodcourt/" + sale_id + "/" + cashier_type + "/remove_all_discount",
|
||||
success: function(result){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.status,
|
||||
type: "success",
|
||||
}, function () {
|
||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/foodcourt/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/foodcourt/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Pay Discount for membership
|
||||
$("#member-discount").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var ajax_url = "/foodcourt/" + sale_id + "/member_discount";
|
||||
|
||||
// Selected Account
|
||||
//var account_types = JSON.stringify(get_selected_account_types());
|
||||
|
||||
// if($('.accounts-type').hasClass('selected-account') == true){
|
||||
|
||||
// var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
|
||||
|
||||
var params = {'cashier_type': cashier_type,'sale_id':sale_id, 'sub_total':sub_total };
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
success:function(result){
|
||||
if (result.status == "Success") {
|
||||
type = 'success'
|
||||
btn_color = 'green'
|
||||
}else{
|
||||
type = 'error'
|
||||
btn_color = 'red'
|
||||
}
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.status,
|
||||
confirmButtonText: 'OK',
|
||||
confirmButtonColor: btn_color,
|
||||
}, function () {
|
||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/foodcourt/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/foodcourt/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});//end member discount
|
||||
});
|
||||
|
||||
/* Remove Selection */
|
||||
function selection_remove(){
|
||||
$(".item-row").removeClass("selected-item");
|
||||
$(".accounts-type").removeClass("selected-account");
|
||||
}
|
||||
|
||||
/* Get Item rows but not discount*/
|
||||
function get_item_rows(){
|
||||
var sale_items = [];
|
||||
$('.item-row.item').not('.discount').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id').substr(0,16);
|
||||
sale_item.name = $(this).find('#item-name-price').text().split('@')[0];
|
||||
sale_item.account_id = $(this).find('#item-account-type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get discount Item rows */
|
||||
function get_new_discount_item_rows(){
|
||||
var sale_items = [];
|
||||
$('.item-row.new-discount').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id');
|
||||
sale_item.name = $(this).find('#item-name-price').text();
|
||||
sale_item.account_id = $(this).find('#item_account_type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get discount Item rows */
|
||||
function get_selected_discount_items(){
|
||||
var sale_items = [];
|
||||
$('.item-row.discount.selected-item').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id');
|
||||
sale_item.name = $(this).find('#item-name-price').text();
|
||||
sale_item.account_id = $(this).find('#item_account_type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get Selected Sale Item's ID and Price */
|
||||
function get_selected_sale_items(){
|
||||
var sale_items = [];
|
||||
$('.item-row.item.selected-item').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id').substr(0,16);
|
||||
sale_item.name = $(this).find('#item-name-price').text().split('@')[0];
|
||||
sale_item.account_id = $(this).find('#item-account-type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get Selected Accounts ID and Price */
|
||||
function get_selected_account_types(){
|
||||
var account_types = [];
|
||||
|
||||
$('.selected-account').each(function(i){
|
||||
var account= {};
|
||||
account.id = $(this).attr('id').substr(8);
|
||||
account.name = $(this).text();
|
||||
account_types.push(account);
|
||||
});
|
||||
return account_types;
|
||||
}
|
||||
|
||||
/* Calculate Overall Discount*/
|
||||
function calculate_overall_discount(type, amount){
|
||||
var origin_sub_total = parseFloat($("#order-sub-total").text()) + parseFloat($("#order-discount").text());
|
||||
var dis_amount = 0;
|
||||
var sub_total = 0;
|
||||
var total_discount = 0;
|
||||
|
||||
// For Net Pay
|
||||
if(type == 0){
|
||||
total_discount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
}
|
||||
|
||||
// For Percentage Pay
|
||||
if(type == 1){
|
||||
if(amount > 100 ){
|
||||
swal({
|
||||
title:"Oops!",
|
||||
text:'Percentage Value over 100!',
|
||||
type: "error",
|
||||
confirmButtonText: 'OK',
|
||||
confirmButtonColor:"red"
|
||||
});
|
||||
}
|
||||
else{
|
||||
total_discount = Math.round(totalAmount * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
}
|
||||
}
|
||||
|
||||
sub_total = parseFloat(totalAmount) - parseFloat(total_discount)
|
||||
|
||||
$("#order-discount").text(parseFloat(total_discount).toFixed(<%= precision.to_i %>));
|
||||
}
|
||||
|
||||
/* Calculate Items Discount*/
|
||||
function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
var origin_sub_total = parseFloat($("#order-sub-total").text());
|
||||
var dis_amount = 0;
|
||||
var sub_total = 0;
|
||||
var total_discount = 0;
|
||||
var arrItemName = "";
|
||||
|
||||
$("#discount_itemsErr").html("");
|
||||
$("#discount-amountErr").html("");
|
||||
// For Net Pay
|
||||
if(origin_sub_total > 0){
|
||||
if(type == 0){
|
||||
dis_amount = -Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
// if(account_types.length > 0){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(sale_items[i].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
if(parseFloat(amount) > parseFloat(sale_items[i].price)){
|
||||
arrItemName += ", " + sale_items[i].name;
|
||||
}else{
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
total_discount = parseFloat(total_discount) + parseFloat(amount);
|
||||
|
||||
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
}else{
|
||||
total_discount = parseFloat(total_discount) - parseFloat(amount);
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
if(arrItemName!=""){
|
||||
arrItemName = arrItemName.substr(2);
|
||||
if(arrItemName.match(/,/g || []) != null){
|
||||
if(arrItemName.match(/,/g || []).length >= 1){
|
||||
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" prices");
|
||||
}
|
||||
}else{
|
||||
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" price");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// No Needs For Auto Selected
|
||||
// if(account_types.length > 0){
|
||||
// var item_rows=get_item_rows();
|
||||
// if(item_rows.length > 0){
|
||||
// for(var k=0; k < item_rows.length; k++){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(item_rows[k].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// alert("No Items!");
|
||||
// }
|
||||
// }
|
||||
|
||||
sub_total = parseFloat(origin_sub_total) - parseFloat(total_discount);
|
||||
totalAmount = sub_total
|
||||
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
|
||||
}
|
||||
|
||||
// For Percentage Pay
|
||||
if(type == 1){
|
||||
if(amount > 100 ){
|
||||
swal({
|
||||
title:"Oops!",
|
||||
text:'Percentage Value over 100!',
|
||||
type: "error",
|
||||
confirmButtonText: 'OK',
|
||||
confirmButtonColor:"red"
|
||||
});
|
||||
}
|
||||
else{
|
||||
// Check sale items exists
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
// if(account_types.length > 0){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(sale_items[i].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + dis_amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
dis_amount = -Math.round(sale_items[i].price * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
|
||||
total_discount = total_discount + dis_amount;
|
||||
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
}else{
|
||||
total_discount = total_discount - dis_amount;
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}
|
||||
// }
|
||||
}
|
||||
sub_total = parseFloat(origin_sub_total) + parseFloat(total_discount);
|
||||
totalAmount = sub_total
|
||||
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
|
||||
}
|
||||
}
|
||||
// No Needs For Auto Selected
|
||||
// Check account types exists
|
||||
// if(account_types.length > 0){
|
||||
// var item_rows=get_item_rows();
|
||||
// console.log(account_types);
|
||||
// if(item_rows.length > 0){
|
||||
// for(var k=0; k < item_rows.length; k++){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(item_rows[k].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
|
||||
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + dis_amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// alert("No Items!");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}else{
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function item_row_template(type, item, discount_amount, amount){
|
||||
var dis_str = "-discount";
|
||||
if(type == 1){
|
||||
dis_str = dis_str + "(" + amount + "%)"
|
||||
}
|
||||
var discount_item_row = "<tr class='item-row new-discount' id='" + item.id + "'>" +
|
||||
"<td style='width: 60%; text-align: left;'>" +
|
||||
"<span id='item_account_type' class='hidden'>" +
|
||||
item.account_id +
|
||||
"</span>" +
|
||||
"<span id='item-name-price'>" +
|
||||
item.name + dis_str +
|
||||
"</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-qty'>1</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-total-price'>" +
|
||||
discount_amount +
|
||||
"</span>" +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
return discount_item_row;
|
||||
}
|
||||
|
||||
</script>
|
||||
39
app/views/foodcourt/orders/app_order_by_booking.html.erb
Normal file
39
app/views/foodcourt/orders/app_order_by_booking.html.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
|
||||
<div id="oqs_loading_wrapper" style="display:none;">
|
||||
<div id="oqs_loading"></div>
|
||||
</div>
|
||||
<div class="row m-t--20">
|
||||
<div class="col-md-9 col-lg-9 col-sm-12 m-t-10">
|
||||
</div>
|
||||
<div class="col-md-3 col-lg-3 col-sm-12 m-t-10">
|
||||
<div class="card-header" style="padding: 0.12rem 0.25rem">
|
||||
<div class="row ">
|
||||
<div class="col-md-9 col-lg-9 col-sm-9 ">
|
||||
<strong id="order-title" class="font-14 p-l-10">ORDER DETAILS </strong>
|
||||
<strong class="font-14 p-l-10">Booking Id : </strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-text" id="order-detail-slimscroll" data-height="140">
|
||||
<table class="table table-striped summary-items" id="order-items-table" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-qty">QTY</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="font-13 order_item_list" >
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
|
||||
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
|
||||
<button type="button" class="btn btn-primary action-btn create col-md-11" id="done_order" disabled="disabled" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">done</i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
17
app/views/foodcourt/orders/app_orders.html.erb
Normal file
17
app/views/foodcourt/orders/app_orders.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
|
||||
<div id="oqs_loading_wrapper" style="display:none;">
|
||||
<div id="oqs_loading"></div>
|
||||
</div>
|
||||
<div class="row m-t--20">
|
||||
<div class="col-md-9 col-lg-9 col-sm-12 m-t-10">
|
||||
</div>
|
||||
<div class="col-md-3 col-lg-3 col-sm-12 m-t-10">
|
||||
<div class="card-header" style="padding: 0.12rem 0.25rem">
|
||||
<div class="card-block">
|
||||
<div class="card-text" id="order-detail-slimscroll" data-height="140">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
391
app/views/foodcourt/orders/show.html.erb
Executable file
391
app/views/foodcourt/orders/show.html.erb
Executable file
@@ -0,0 +1,391 @@
|
||||
|
||||
<div class="container-fluid"><div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs tab-col-teal" role="tablist" id="mytab">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link " data-toggle="tab" href="#completed" role="tab"><%= t :competed %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link " data-toggle="tab" href="#tables" role="tab"><%= t :tables %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab"><%= t :rooms %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#orders" role="tab"><%= t :orders %></a>
|
||||
</li>
|
||||
<li class="nav-item credit_items">
|
||||
<a class="nav-link" data-toggle="tab" href="#credits" role="tab"><%= t :credits %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Nav tabs - End -->
|
||||
<div id="custom-slimscroll">
|
||||
<div class="tab-content">
|
||||
<!--- Panel 0 - Completed Orders -->
|
||||
<div class="tab-pane " id="completed" role="tabpanel" style="">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @complete.each do |sale| %>
|
||||
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 1 - Table Orders -->
|
||||
<div class="tab-pane " id="tables" role="tabpanel" style="">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
|
||||
<div style="font-size:12px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="card tables green text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= table.id %> hide"> new</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 2 - Room Orders -->
|
||||
<div class="tab-pane" id="rooms" role="tabpanel" style="">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @rooms.each do |room| %>
|
||||
<% if room.status == 'occupied' %>
|
||||
<% if room.get_booking.nil? %>
|
||||
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %> <br>
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %>"> billed</span>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %> <br>
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %>"> new</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="card rooms green text-white table_<%= room.id %>" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %> <br>
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %> hide">
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 3 - Orders -->
|
||||
<div class="tab-pane active" id="orders" role="tabpanel" style="">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @orders.each do |order| %>
|
||||
<div class="card orders <%=(order.status=="new") ? 'blue' : 'red'%> text-white" data-id = "<%= order.order_id %>">
|
||||
<div class="card-block">
|
||||
<%
|
||||
order_status = ""
|
||||
sale_order = SaleOrder.find_by_order_id(order)
|
||||
if sale_order
|
||||
unless sale_order.sale_id.nil?
|
||||
sale = Sale.find(sale_order.sale_id)
|
||||
order_status = sale.sale_status
|
||||
if order_status == 'new'
|
||||
order_status = order.status
|
||||
end
|
||||
end
|
||||
else
|
||||
order_status = order.status
|
||||
end
|
||||
%>
|
||||
<%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Credit Item Lists-->
|
||||
<div class="tab-pane dining" id="credits" role="tabpanel">
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData('cashier');">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');" >
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
<option value="<%= cus[0] %>"><%= cus[1] %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix m-t-20 m-l-10">
|
||||
<table class="table table-responsive tbl_credit_lists">
|
||||
<thead>
|
||||
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||
</thead>
|
||||
<tbody class="tbd_credit_lists"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- tabs - End -->
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">ORDERS DETAILS </strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Order No: <span id="receipt_no"> <%= @order.order_id %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
Date: <span id="receipt_date"><%= @order.created_at.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-title row customer_detail hide">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Customer : <span id="customer_name"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="order-detail-slimscroll" data-height="<%= @status_sale=="sale" ? 200 : 160%>">
|
||||
<div class="card-text" style="">
|
||||
<table class="table table-striped" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</th>
|
||||
<th class="item-attr">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
sub_total = 0
|
||||
@order.order_items.each do |sale_item|
|
||||
sub_total = sub_total + sale_item.price
|
||||
%>
|
||||
<% unless sale_item.price <= 0 %>
|
||||
<tr>
|
||||
<td class='item-name'>
|
||||
<%= sale_item.item_name %>
|
||||
<% if !sale_item.set_menu_items.nil?
|
||||
sale_item.set_menu_items.each do |item_instance| %>
|
||||
<br><span class="font-13"><%= item_instance %></span>
|
||||
<% end
|
||||
end %>
|
||||
</td>
|
||||
<td class='item-attr'><%= sale_item.qty %></td>
|
||||
<td class='item-attr'><%= sale_item.price %></td>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer ">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
|
||||
<td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td>
|
||||
</tr>
|
||||
<tr class="rebate_amount"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 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 %>
|
||||
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
<td>{customer_name}</td>
|
||||
<td>{credit_amount}</td>
|
||||
</tr>
|
||||
</script>
|
||||
<!-- script data for credit lists -->
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
getCreditSales("","","cashier"); //credit sales script data binding
|
||||
$(".tables").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/table/' + dining_id;
|
||||
})
|
||||
$(".sales").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/sale/' + sale_id;
|
||||
})
|
||||
$(".rooms").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/room/' + dining_id;
|
||||
})
|
||||
$(".orders").on('click',function(){
|
||||
var order_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/order/' + order_id;
|
||||
})
|
||||
});
|
||||
$('#pay').on('click',function() {
|
||||
var sale_id = $('#sale_id').val();
|
||||
var url = '/foodcourt/sale/'+ sale_id + "/rounding_adj" ;
|
||||
alert(url)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/foodcourt/sale/'+ sale_id + "/rounding_adj",
|
||||
success:function(result){
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id + "/payment";
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/foodcourt/';
|
||||
})
|
||||
$('#move').on('click',function(){
|
||||
|
||||
});
|
||||
|
||||
//order_split
|
||||
$('#by_order').on('click',function () {
|
||||
swal({
|
||||
title: "Alert",
|
||||
text: "Are you sure, you want to Split?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Yes, split it!",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if(isConfirm){
|
||||
orderSplitBillProcess();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* function for order items split bill process */
|
||||
function orderSplitBillProcess(){
|
||||
var booking = JSON.parse('<%= @booking.to_json.html_safe %>');
|
||||
var orders = JSON.parse('<%= @orders.to_json.html_safe %>');
|
||||
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 || '';
|
||||
var booking_id = "";
|
||||
if(orders.length == 1){
|
||||
booking_id = booking[0].booking_id;
|
||||
}
|
||||
var cashier_type = "cashier";
|
||||
|
||||
var ajax_url = "/foodcourt/split_bills";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
dataType: 'JSON',
|
||||
data: {'cashier_type':cashier_type,'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(arr_order)},
|
||||
success: function (result) {
|
||||
if (!result.status) {
|
||||
swal("Information!", result.error_message);
|
||||
}
|
||||
else{
|
||||
if (dining_id == 0) {
|
||||
window.location.href = '/foodcourt';
|
||||
}else{
|
||||
if(type=='Table'){
|
||||
window.location.href = '/foodcourt/table/' + dining_id;
|
||||
}else{
|
||||
window.location.href = '/foodcourt/room/' + dining_id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
406
app/views/foodcourt/other_charges/index.html.erb
Executable file
406
app/views/foodcourt/other_charges/index.html.erb
Executable file
@@ -0,0 +1,406 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<!-- Order Details -->
|
||||
<div class="card" >
|
||||
<!-- <div class="card-header">
|
||||
<div><strong id="order-title">ORDER DETAILS</strong></div>
|
||||
</div> -->
|
||||
<div class="card-block">
|
||||
<div class="row card-title">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
|
||||
<p>Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
|
||||
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Date: <span id="receipt_date"> <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="order-detail-slimscroll" data-height="160">
|
||||
<div class="card-text dining">
|
||||
<table class="table table-default" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</th>
|
||||
<th class="item-attr">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% sub_total = 0 %>
|
||||
<% @sale_data.sale_items.each do |sale_item| %>
|
||||
<%
|
||||
sub_total += sale_item.qty*sale_item.unit_price
|
||||
unless sale_item.price == 0
|
||||
%>
|
||||
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
|
||||
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-qty"><%=sale_item.qty%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @sale_data.discount_type == 'member_discount'%>
|
||||
<td class="charges-name"><strong>Member Discount:</strong></td>
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
<td class="item-attr">(<strong id="order-discount"><%=@sale_data.total_discount rescue 0%></strong>)</td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%=@sale_data.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%=@sale_data.grand_total rescue 0%></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5">
|
||||
<!-- Discount Amount -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">Other Charges Control</strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<div class="form-horizontal">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<div class="bottom-5">
|
||||
<input type="number" id="other-charges-amount" name="other-charges-amount" class="form-control" placeholder="Amount" onkeypress="return isNumberKey(event);", onkeyup="otherCharges(this.value);" />
|
||||
<br><span id="other-charges-amountErr" style="color:red;"></span>
|
||||
</div>
|
||||
<div class="bottom-5">
|
||||
<textarea id="reasons" name="reasons" rows="2" class="form-control" placeholder="Reasons"></textarea>
|
||||
</div>
|
||||
<div class="bottom-5">
|
||||
<input type="checkbox" id="is_taxable" name="is_taxable" />
|
||||
<lable for="is_taxable">Is Taxable</lable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
|
||||
<div class="p-l-20">
|
||||
<div class="row bottom">
|
||||
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
|
||||
<div class="fluid cashier_number" data-value="3000" data-type="add">3000</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="5000" data-type="add">5000</div>
|
||||
</div>
|
||||
<div class="col-md-9 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
<div class="col-md-9 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="15000" data-type="add">15000</div>
|
||||
</div>
|
||||
<div class="col-md-9 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="20000" data-type="add">20000</div>
|
||||
</div>
|
||||
<div class="col-md-9 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number"></div>
|
||||
<div class="col-md-3 left cashier_number red" data-type="del">DEL</div>
|
||||
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 m-l--15">
|
||||
<div class="form-group">
|
||||
<button id="add_charges" class="btn bg-info fluid action-btn">Add</button>
|
||||
<button id="remove-item" class="btn bg-danger fluid action-btn">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Action Panel -->
|
||||
<div>
|
||||
<%if !@table.nil?%>
|
||||
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/foodcourt/<%=@table.type.downcase%>/<%=@table.id%>'"><i class="material-icons">reply</i> Back </button>
|
||||
<%else%>
|
||||
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/foodcourt/sale/<%=@sale_data.sale_id%>/<%=@cashier_type%>/payment'"><i class="material-icons">reply</i> Back </button>
|
||||
<%end%>
|
||||
<button id="charge_other" class="btn bg-primary btn-block action-btn">Enter</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
function otherCharges(val){
|
||||
var aa = parseInt(val);
|
||||
if(isNaN(aa)) $("#other-charges-amount").val("");
|
||||
}
|
||||
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
|
||||
$(document).ready(function(){
|
||||
setHeaderBreadCrumb(_OTHER_CHARGES_);
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
|
||||
$(".cashier_number").on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value=0;
|
||||
original_value = $('#other-charges-amount').val();
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0.0"){
|
||||
$('#other-charges-amount').val(input_value);
|
||||
}
|
||||
else{
|
||||
$('#other-charges-amount').val(original_value + '' + input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value);
|
||||
$('#other-charges-amount').val(amount);
|
||||
break;
|
||||
|
||||
case 'del' :
|
||||
var discount_text=$('#other-charges-amount').val();
|
||||
$('#other-charges-amount').val(discount_text.substr(0,discount_text.length-1));
|
||||
break;
|
||||
|
||||
case 'clr':
|
||||
$('#other-charges-amount').val("0.0");
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Select discount-item
|
||||
$('#order-items-table tbody').on('click', '.other-item-row',function(){
|
||||
if($(this).hasClass('selected-item') == true){
|
||||
$(this).removeClass('selected-item');
|
||||
}
|
||||
else {
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
});
|
||||
|
||||
// Remove selected discount items
|
||||
$("#remove-item").on('click', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
$('.other-item-row.selected-item').each(function(i){
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var charge_amount = $(this).children('td').find("#item-total-price").text();
|
||||
|
||||
// Update sub total
|
||||
$('#order-sub-total').text(parseFloat(sub_total) - parseFloat(charge_amount));
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
|
||||
// Calculate Net Discount for Payment
|
||||
$("#add_charges").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var charge_amount = $("#other-charges-amount").val();
|
||||
var reasons = $("#reasons").val();
|
||||
var is_taxable = 0
|
||||
if ($("#is_taxable:checked").length > 0) {
|
||||
is_taxable = 1
|
||||
}
|
||||
$("#other-charges-amountErr").html("");
|
||||
if(charge_amount != ""){
|
||||
$("#other-charges-amount").val("");
|
||||
$("#reasons").val("");
|
||||
// Update sub total
|
||||
$('#order-sub-total').text(parseFloat(sub_total) + parseFloat(charge_amount));
|
||||
|
||||
var item_row = item_row_template(sale_id, charge_amount, reasons, is_taxable);
|
||||
$("#order-items-table tbody").append(item_row);
|
||||
}
|
||||
else{
|
||||
$("#other-charges-amountErr").html("can't be blank");
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate Other Charges for Payment
|
||||
$("#charge_other").on('click', function(e){
|
||||
e.preventDefault();
|
||||
if($('#charge_other').is(":visible")) {
|
||||
$('#charge_other').prop("disabled",true);
|
||||
}
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var other_charges_items = JSON.stringify(get_other_item_rows());
|
||||
var ajax_url = "/foodcourt/" + sale_id + "/other_charges";
|
||||
|
||||
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'other_charges_items': other_charges_items };
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
success:function(result){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Success",
|
||||
type:"success"
|
||||
}, function () {
|
||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/foodcourt/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/foodcourt/room/" + result.table_id
|
||||
}
|
||||
}s
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* Remove Selection */
|
||||
function selection_remove(){
|
||||
$(".item-row").removeClass("selected-item");
|
||||
$(".discount_item_row").removeClass("selected-item");
|
||||
$(".accounts-type").removeClass("selected-account");
|
||||
}
|
||||
|
||||
/* Get discount Item rows */
|
||||
function get_other_item_rows(){
|
||||
var sale_items = [];
|
||||
$('.other-item-row').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id');
|
||||
sale_item.name = $(this).find('#item-name-price').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text()
|
||||
sale_item.is_taxable = $(this).find('#item_taxable').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
function item_row_template(sale_id, charge_amount, reasons, is_taxable){
|
||||
var item_row = "<tr class='other-item-row' id='SLI-000000000000'>" +
|
||||
"<td style='width: 60%; text-align: left;'>" +
|
||||
"<span id='item_account_type' class='hidden'>" +
|
||||
0 +
|
||||
"</span>" +
|
||||
"<span id='item-name-price'>" +
|
||||
reasons +
|
||||
"</span>" +
|
||||
"<span id='item_taxable' class='hidden'>" + is_taxable + "</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-qty'>1</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-total-price'>" +
|
||||
charge_amount +
|
||||
"</span>" +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
return item_row;
|
||||
}
|
||||
|
||||
function isNumberKey(evt) {
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
2
app/views/foodcourt/paymal/create.json.jbuilder
Normal file
2
app/views/foodcourt/paymal/create.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.set! :status, @out[0]
|
||||
json.set! :message, @out[1]
|
||||
404
app/views/foodcourt/paymal/index.html.erb
Normal file
404
app/views/foodcourt/paymal/index.html.erb
Normal file
@@ -0,0 +1,404 @@
|
||||
<div class="container-fluid">
|
||||
<!-- <div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%=foodcourt_root_path %>"><%= t :home %></a></li>
|
||||
<li class="breadcrumb-item"><a href="/foodcourt/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.details.redeem") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back',:default => t("views.btn.back")),'/foodcourt/sale/'+@sale_id+'/payment/others_payment'%>
|
||||
</span>
|
||||
</ol>
|
||||
</div> -->
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
|
||||
<div class="rebate-form">
|
||||
<input type="hidden" name="receipt_no" id="receipt_no" value="<%= @receipt_no%>">
|
||||
<p class="hidden" name="sale_id" id="sale_id"><%=@sale_id %></p>
|
||||
<p class="hidden" name="membership_id" id="membership_id" ><%=@membership_id %></p>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">You can pay up to </label>
|
||||
<%@payment_prices = @payment_prices +@rounding_adj%>
|
||||
<input type="text" name="" id="paymentamt" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @payment_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% if @payparcount > 0 %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">Recent Payment Amount </label>
|
||||
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @payparcount %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">Available Balance </label>
|
||||
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@membership_rebate_balance%>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">Payment Balance</label>
|
||||
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <% if @payparcount > 0 %>
|
||||
<p class="">Last time rebate amount is <%= @payparcount %></p>
|
||||
<% end %>
|
||||
<p class="">You can rebate upto <span style="color:red;" id="food_prices"><%= @payment_prices %></span></p> -->
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="m-t-10 p-l-20">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-1 col-sm-1">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number green border-left" data-type="nett">Nett</div>
|
||||
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
|
||||
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
|
||||
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
|
||||
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="pay purple left" id="paymal_payment">Pay</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn bg-default m-t-10 btn-lg btn-block" onclick="window.location.href = '/foodcourt/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sxModal">
|
||||
<div id="sxModal-Content"><h3>Card Tap</h3></div>
|
||||
<div class="m-r-20" align="right">
|
||||
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- customer light box -->
|
||||
<div class="modal fade" id="is_paymemberModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-md" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title" id="is_paymemberModalLabel">Are you Member?</h1>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
|
||||
<input type="hidden" name="qr_code" id="qr_code" />
|
||||
<div class="row text-center m-t-20">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
||||
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_member">Card Member</button>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
||||
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_qr_code">QR Code</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$(document).ready(function() {
|
||||
setHeaderBreadCrumb(_PAYMAL_);
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||
else {
|
||||
$('#paymentamt').attr("value",parseFloat("<%= @payment_prices %>") - parseFloat(localStorage.getItem("cash")));
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#used_amount').text();
|
||||
|
||||
var input_value = $(this).attr("data-value");
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
if (original_value == "0.0"){
|
||||
$('#used_amount').text(input_value);
|
||||
}else{
|
||||
$('#used_amount').append(input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value) + parseInt(original_value);
|
||||
$('#used_amount').html(amount);
|
||||
|
||||
break;
|
||||
case 'clr':
|
||||
$('#used_amount').html("0.0");
|
||||
break;
|
||||
case 'del' :
|
||||
var cash=$('#used_amount').text();
|
||||
$('#used_amount').text(cash.substr(0,cash.length-1));
|
||||
break;
|
||||
case 'nett':
|
||||
var remain_amount = $('#paymentamt').val();
|
||||
$('#used_amount').text(remain_amount);
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$("#paymal_payment").on('click',function(){
|
||||
valid_amount = $("#valid_amount").val();
|
||||
sale_id = $("#valid_amount").attr('data-value');
|
||||
membership_id = $("#valid_amount").attr('data-member-value');
|
||||
payment_amount = parseFloat($("#used_amount").text());
|
||||
if(payment_amount > 0){
|
||||
if((membership_id!=undefined) && (membership_id!="") && (membership_id > 0)){
|
||||
if(payment_amount<=0 ){
|
||||
swal ( "Oops" , "Please type valid amount!" , "warning" );
|
||||
}else if(valid_amount< payment_amount){
|
||||
swal ( "Oops" , "Insufficient Amount!" , "warning" );
|
||||
}else{
|
||||
if(payment_amount <= "<%= @payment_prices %>"){
|
||||
$(this).off("click");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=foodcourt_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:"",account_no:0},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.message,
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id + "/"+cashier_type+"/payment"
|
||||
});
|
||||
|
||||
}else{
|
||||
swal ( "Information" , result.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
}else {
|
||||
swal ( "Oops" , "Payment Amount is over!" , "warning" );
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$("#is_paymemberModal").show();
|
||||
$("#is_paymemberModal").modal({show : true, backdrop: false, keyboard : false});
|
||||
}
|
||||
}else{
|
||||
swal ( "Oops" , "Amount should be greater than 0!" , "warning" );
|
||||
}
|
||||
});
|
||||
|
||||
// Read Card Reader
|
||||
$(".btn_member").on('click', function(){
|
||||
var cardNo = "";
|
||||
var sale_id = $("#sale_id").text() || 0;
|
||||
var receipt_no = $("#receipt_no").val() || "";
|
||||
|
||||
var customer_mamber_card_no = 0;
|
||||
var payment_amount = parseFloat($("#used_amount").text());
|
||||
|
||||
$("#is_paymemberModal").hide();
|
||||
$("#sxModal").show();
|
||||
setTimeout(function(){
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
||||
if (customer_mamber_card_no == 0) {
|
||||
customer_mamber_card_no = $("#membership_id").text() || 0;
|
||||
}
|
||||
if(sale_id != 0 && customer_mamber_card_no !=0){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/"+sale_id+"/send_account" ,
|
||||
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.status == true) {
|
||||
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
|
||||
$("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=foodcourt_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.message,
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
||||
});
|
||||
|
||||
}else{
|
||||
swal ( "Opps",result.message ,"warning" );
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: data.message.toString(),
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/PAYMAL";
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal("Opp","Please Check Member","warning")
|
||||
}
|
||||
},100);
|
||||
});
|
||||
|
||||
// Read NFC card no from java
|
||||
function getCardNo(){
|
||||
code2lab.readNFC();
|
||||
}
|
||||
|
||||
// get CardNo from Java
|
||||
function setCardNo(cardNo){
|
||||
if(cardNo.length == 16){
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
}
|
||||
}
|
||||
|
||||
// QR Code Reader
|
||||
$(".btn_qr_code").on('click', function(e){
|
||||
$("#is_paymemberModal").hide();
|
||||
var code = "";
|
||||
var sale_id = $("#sale_id").text() || 0;
|
||||
var receipt_no = $("#receipt_no").val() || "";
|
||||
var payment_amount = parseFloat($("#used_amount").text());
|
||||
setTimeout(function(){
|
||||
code=getQRCode();
|
||||
if(sale_id != 0 && code != ""){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/"+sale_id+"/send_account" ,
|
||||
data: { account_no : code, amount : payment_amount, receipt_no : receipt_no},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.status == true) {
|
||||
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
|
||||
$("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=foodcourt_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.message,
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
||||
});
|
||||
|
||||
}else{
|
||||
swal ( "Opps",result.message ,"warning" );
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: data.message.toString(),
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/PAYMAL";
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},100);
|
||||
});
|
||||
|
||||
// Read qrcode from java
|
||||
function getQRCode(){
|
||||
return code2lab.readQRCode();
|
||||
$("#qr_code").val(code);
|
||||
}
|
||||
|
||||
$("#sxModal .btn_cancel").on('click',function(){
|
||||
$("#sxModal").hide();
|
||||
});
|
||||
</script>
|
||||
2
app/views/foodcourt/payments/create.json.jbuilder
Executable file
2
app/views/foodcourt/payments/create.json.jbuilder
Executable file
@@ -0,0 +1,2 @@
|
||||
json.status true
|
||||
|
||||
1788
app/views/foodcourt/payments/show.html.erb
Executable file
1788
app/views/foodcourt/payments/show.html.erb
Executable file
File diff suppressed because it is too large
Load Diff
2
app/views/foodcourt/paypar_payments/create.json.jbuilder
Executable file
2
app/views/foodcourt/paypar_payments/create.json.jbuilder
Executable file
@@ -0,0 +1,2 @@
|
||||
json.set! :status, @out[0]
|
||||
json.set! :message, @out[1]
|
||||
21
app/views/foodcourt/paypar_payments/index.html.erb
Executable file
21
app/views/foodcourt/paypar_payments/index.html.erb
Executable file
@@ -0,0 +1,21 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-5 col-md-5 col-sm-3">
|
||||
<div class="card">
|
||||
<% if @membership_id!=0 %>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 long purple " id="redim">Redim Amount</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 m-t-10">
|
||||
<button type="button" class="btn bg-default m- btn-block" onclick="window.location.href = '/foodcourt/sale/<%= @sale_id %>/<%= @cashier_type %>/payment';"> Back </button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
setHeaderBreadCrumb(_PAYPAR_PAYMENT_);
|
||||
});
|
||||
</script>
|
||||
7
app/views/foodcourt/request_bills/print.json.jbuilder
Executable file
7
app/views/foodcourt/request_bills/print.json.jbuilder
Executable file
@@ -0,0 +1,7 @@
|
||||
if @status == true
|
||||
#show invoice number and stuff
|
||||
json.status @status
|
||||
else
|
||||
json.status @status
|
||||
json.error_message @error_message
|
||||
end
|
||||
149
app/views/foodcourt/reservation/index.html.erb
Normal file
149
app/views/foodcourt/reservation/index.html.erb
Normal file
@@ -0,0 +1,149 @@
|
||||
<%= stylesheet_link_tag 'reservation', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'reservation', 'data-turbolinks-track': 'reload' %>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
|
||||
<div class="card" id="make-reservation-slimscroll" data-height="-50">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title text-center bg-faded"><%= t :make_reservation %></h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="wizard">
|
||||
<div class="wizard-inner">
|
||||
<div class="active-line"></div>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="nav-item">
|
||||
<div class="connecting-line border-right"></div>
|
||||
<a href="#reservation" class="nav-link active" data-toggle="tab" aria-controls="reservation" role="tab" title="Reservation">
|
||||
<span class="round-tab">
|
||||
1
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation" class="nav-item disabled">
|
||||
<div class="connecting-line"></div>
|
||||
<a href="#personal_detail" class="nav-link disable" data-toggle="tab" aria-controls="personal_detail" role="tab" title="Personal Detail">
|
||||
<span class="round-tab">
|
||||
2
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div> <!-- .end.wizard-inner -->
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" role="tabpanel" id="reservation">
|
||||
<div class="form-row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label class="font-12 radio-inline">
|
||||
<input type="radio" name="reservation_type" checked class="radio-col-indigo reservation_type" value="0"><%= t("views.right_panel.detail.dine_in") %>
|
||||
</label>
|
||||
<label class="font-12 radio-inline">
|
||||
<input type="radio" name="reservation_type" class="radio-col-indigo reservation_type" value="1"><%= t :room %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dining_type">
|
||||
<div class="form-row clearfix">
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<input class="form-control check_in_date datepicker" name="check_in_date" id="check_in_date" type="text" placeholder="Check-in Date">
|
||||
</div>
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<input class="form-control check_out_date datepicker" name="check_out_date" id="check_out_date" type="text" placeholder="Check Out Date">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row clearfix">
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<input class="form-control check_in_time timepicker" name="check_in_time" id="check_in_time" type="text" placeholder="Check-in Time">
|
||||
</div>
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<input class="form-control check_out_time timepicker" name="check_out_time" id="check_out_time" type="text" placeholder="Check Out Time">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="room_type">
|
||||
<div class="form-row clearfix">
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<input class="form-control check_in_date datepicker" name="check_in_date" id="check_in_date" type="text" placeholder="Check-in Date">
|
||||
</div>
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<input class="form-control check_out_date datepicker" name="check_out_date" id="check_out_date" type="text" placeholder="Check Out Date">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row clearfix">
|
||||
<div class="form-group col-sm-12 col-md-12 col-lg-12">
|
||||
<label for="room_count" class="control-label">ROOMS</label>
|
||||
<input type="number" class="form-control number_limit" name="room_count" id="room_count" data-type="room" value="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row clearfix">
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<label for="adult_count" class="control-label">ADULT</label>
|
||||
<input type="number" class="form-control number_limit" name="adult_count" id="adult_count" data-type="adult" value="1">
|
||||
</div>
|
||||
<div class="form-group col-sm-6 col-md-6 col-lg-6">
|
||||
<label for="child_count" class="control-label">CHILD</label>
|
||||
<input type="number" class="form-control number_limit" name="child_count" id="child_count" data-type="child">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="form-group col-sm-12 col-md-12 col-lg-12">
|
||||
<button class="btn bg-blue btn-lg waves-effect">CHECK AVAILABLE</button>
|
||||
<button class="btn bg-blue btn-lg waves-effect next-step">NEXT</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- .end.tab-panel .reservation -->
|
||||
|
||||
<div class="tab-pane" role="tabpanel" id="personal_detail">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-12 col-md-12 col-lg-12">
|
||||
<input class="form-control" name="name" id="name" type="text" placeholder="NAME">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-12 col-md-12 col-lg-12">
|
||||
<input class="form-control" name="contact_no" id="contact_no" type="number" placeholder="PHONE NUMBER">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-12 col-md-12 col-lg-12">
|
||||
<input class="form-control" name="address" id="address" type="text" placeholder="ADDRESS">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-12 col-md-12 col-lg-12">
|
||||
<label for="reservation_note" class="control-label">RESERVATION NOTE</label>
|
||||
<textarea rows="3" id="reservation_note" name="reservation_note" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="form-group col-sm-12 col-md-12 col-lg-12">
|
||||
<button class="btn bg-blue btn-lg prev-step">PREV</button>
|
||||
<button class="btn bg-blue btn-lg">SUBMIT</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- .end.tab-content .personal_detail -->
|
||||
</div> <!-- .end.wizard -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
|
||||
<div class="card font-13">
|
||||
<div class="row clearfix">
|
||||
<div class="col-xs-7 col-sm-7 col-md-7 col-lg-7" id="process-reservation-slimscroll" data-height="-80">
|
||||
|
||||
</div>
|
||||
<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5" id="reservation-info-slimscroll" data-height="-80">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/foodcourt/sale_edit/apply_void.json.jbuilder
Executable file
1
app/views/foodcourt/sale_edit/apply_void.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
1
app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder
Executable file
1
app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
427
app/views/foodcourt/sale_edit/edit.html.erb
Executable file
427
app/views/foodcourt/sale_edit/edit.html.erb
Executable file
@@ -0,0 +1,427 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-11 col-md-11 col-sm-11">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">INVOICE DETAILS </strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p class="m-l-10"> Receipt No: <span id="receipt_no">
|
||||
<%= @saleobj.receipt_no rescue '' %>
|
||||
</span></p>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p class="m-r-10">Date:
|
||||
<span id="receipt_date"><%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-title row customer_detail hide">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p>Customer : <span id="customer_name"></span></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="card-text dining">
|
||||
<table class="table " id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="2%">#</th>
|
||||
<th class="" width="20%">Items</th>
|
||||
<th style="" width="5%">QTY
|
||||
</th>
|
||||
<th class="" width="10%">Price
|
||||
</th>
|
||||
<!-- <th class='' width="17%"> Total </th> -->
|
||||
<th class='' width="20%"> Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
count = 0
|
||||
sub_total = 0
|
||||
@saleobj.sale_items.each do |sale_item|
|
||||
count += 1
|
||||
sub_total = sub_total + sale_item.price
|
||||
%>
|
||||
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
|
||||
<%
|
||||
# Can't check for discount
|
||||
unless sale_item.price == 0
|
||||
%>
|
||||
<tr>
|
||||
<td class="p-1" width="2%"><%= count %></td>
|
||||
<td class="p-2" width="20%">
|
||||
<%= sale_item.product_name %>
|
||||
</td>
|
||||
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != '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 " 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" onkeypress="return isNumberKey(event);"/>
|
||||
<span id="<%= sale_item.id %>_priceErr" style="color:red;"></span>
|
||||
</td>
|
||||
<!-- <td class='' width="17%">
|
||||
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
|
||||
</td> -->
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
|
||||
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
|
||||
|
||||
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
|
||||
</td>
|
||||
|
||||
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class='' width="10%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<!-- <td class='' width="17%">
|
||||
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
|
||||
</td> -->
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect cancel'>Cancel
|
||||
Void/Update
|
||||
</button>
|
||||
</td>
|
||||
<% else %>
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class="p-1" width="10%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="p-1" width="50%"><strong>Sub Total:</strong></td>
|
||||
<td><strong id="order-sub-total"><%= sub_total %></strong></td>
|
||||
</tr>
|
||||
<tr class="rebate_amount"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="col-md-3">
|
||||
<div class="card p-l-15 p-r-15">
|
||||
<div class="card-block">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left green" data-type="nett">Nett</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left red" data-type="del">Del</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left orange" data-type="clr">Clr</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
|
||||
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="editModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="editModalLabel">Please Enter Remark</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
|
||||
</div>
|
||||
<div class="modal-footer ">
|
||||
<div class="row p-r-20">
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect" id="action">VOID</button>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
var access_code = localStorage.getItem("access_code");
|
||||
// Bill Request
|
||||
$(document).ready(function () {
|
||||
|
||||
setHeaderBreadCrumb(_SALE_EDIT_);
|
||||
$('.editModal').on('click', function () {
|
||||
$("#action").attr('data-type', $(this).attr('data-type'));
|
||||
$("#action").attr('data-id', $(this).attr('data-id'));
|
||||
$("#action").text($(this).attr('data-type'))
|
||||
})
|
||||
|
||||
$(".update").on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var qty = $('#' + sale_item_id + "_qty").val();
|
||||
var price = $('#' + sale_item_id + "_price").val();
|
||||
var qty_status = true;
|
||||
var price_status = true;
|
||||
if((qty > 0) && (price > 0)){
|
||||
qty_status = true;
|
||||
price_status = true;
|
||||
$('#' + sale_item_id + "_qtyErr").html("");
|
||||
$('#' + sale_item_id + "_priceErr").html("");
|
||||
}else if((qty > 0) && (price <= 0 || price == '')){
|
||||
price_status = false;
|
||||
$('#' + sale_item_id + "_qtyErr").html("");
|
||||
if(price == ''){
|
||||
$('#' + sale_item_id + "_priceErr").html("can't be blank");
|
||||
}else{
|
||||
$('#' + sale_item_id + "_price").val("");
|
||||
$('#' + sale_item_id + "_priceErr").html("Price must be greater than 0");
|
||||
}
|
||||
}else if((qty <= 0 || qty == '') && (price > 0)){
|
||||
qty_status = false;
|
||||
if(qty == ''){
|
||||
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
|
||||
}else{
|
||||
$('#' + sale_item_id + "_qty").val("");
|
||||
$('#' + sale_item_id + "_qtyErr").html("Quantity must be greater than 0");
|
||||
}
|
||||
|
||||
$('#' + sale_item_id + "_priceErr").html("");
|
||||
}else{
|
||||
qty_status = false;
|
||||
price_status = false;
|
||||
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
|
||||
$('#' + sale_item_id + "_priceErr").html("can't be blank");
|
||||
}
|
||||
|
||||
if(qty_status && price_status){
|
||||
var ajax_url = "/foodcourt/item_edit";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price+ "&access_code=" + access_code + "&type=" + cashier_type,
|
||||
success: function (result) {
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Qty and Price was successfully Updated",
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/*$('.void').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var remark = $("#remark").val();
|
||||
var ajax_url = "/foodcourt/item_void";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('.foc').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/foodcourt/item_foc";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})*/
|
||||
|
||||
$('#action').on('click', function () {
|
||||
var access_code = localStorage.getItem("access_code");
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var type = $(this).attr('data-type');
|
||||
var remark = $("#remark").val();
|
||||
if (type=='foc') {
|
||||
var ajax_url = "/foodcourt/item_foc";
|
||||
}else{
|
||||
var ajax_url = "/foodcourt/item_void";
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark+ "&access_code=" + access_code + "&type=" + cashier_type,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('.cancel').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/foodcourt/item_void_cancel";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + '&access_code=' + access_code + "&type=" + cashier_type,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
$('#back').on('click', function () {
|
||||
var table_id = '<%= @table_id %>'
|
||||
var sale_id = "<%= @saleobj.sale_id %>"
|
||||
if (cashier_type=="quick_service" || cashier_type == "food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
window.location.href = '/foodcourt/table/' + table_id;
|
||||
}
|
||||
})
|
||||
|
||||
$('#cancel_all_void').on('click', function () {
|
||||
var sale_id = "<%= @saleobj.sale_id %>"
|
||||
var ajax_url = "/foodcourt/cancel_all_void";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_id=' + sale_id +'&type='+cashier_type,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('#apply').on('click', function () {
|
||||
var sale_id = "<%= @saleobj.sale_id %>"
|
||||
var ajax_url = "/foodcourt/apply_void";
|
||||
var table_id = '<%= @table_id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_id=' + sale_id+'&type='+cashier_type,
|
||||
success: function (result) {
|
||||
if (cashier_type=="quick_service" || cashier_type=="food_court") {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id+'/'+cashier_type+'/payment/';
|
||||
}else{
|
||||
window.location.href = '/foodcourt/table/' + table_id;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$( "input" ).focusin(function() {
|
||||
$('.addfocus').removeClass('addfocus');
|
||||
$( this ).addClass('addfocus');
|
||||
});
|
||||
|
||||
$(".cashier_number").on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
|
||||
var original_value='';
|
||||
original_value = $('.addfocus').val();
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0.0"){
|
||||
$('.addfocus').val(input_value);
|
||||
}
|
||||
else{
|
||||
$('.addfocus').val(original_value + '' + input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value);
|
||||
$('.addfocus').val(amount);
|
||||
break;
|
||||
|
||||
case 'del' :
|
||||
var discount_text=$('.addfocus').val();
|
||||
$('.addfocus').val(discount_text.substr(0,discount_text.length-1));
|
||||
break;
|
||||
|
||||
case 'clr':
|
||||
$('.addfocus').val("");
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
function checkPrice(obj_value,sale_item_id) {
|
||||
|
||||
}
|
||||
</script>
|
||||
1
app/views/foodcourt/sale_edit/item_void.json.jbuilder
Executable file
1
app/views/foodcourt/sale_edit/item_void.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
1
app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder
Executable file
1
app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
1
app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder
Executable file
1
app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
565
app/views/foodcourt/sales/show.html.erb
Executable file
565
app/views/foodcourt/sales/show.html.erb
Executable file
@@ -0,0 +1,565 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs tab-col-teal" role="tablist" id="mytab">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Completed</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link " data-toggle="tab" href="#tables" role="tab">Tables</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a>
|
||||
</li>
|
||||
<li class="nav-item credit_items">
|
||||
<a class="nav-link" data-toggle="tab" href="#credits" role="tab"><%= t :credit %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
|
||||
<!-- Nav tabs - End -->
|
||||
<div id="custom-slimscroll">
|
||||
<div class="tab-content">
|
||||
<!--- Panel 0 - Completed Orders -->
|
||||
<div class="tab-pane active" id="completed" role="tabpanel" style="max-height:600px; overflow:auto">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @complete.each do |sale| %>
|
||||
<div class="card sales bg-red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 1 - Table Orders -->
|
||||
<div class="tab-pane " id="tables" role="tabpanel" style="">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
<!-- <% if !@order_items_count.nil? %>
|
||||
<% if @order_items_count.key?(table.id) %>
|
||||
(Orders : <%= @order_items_count[table.id] %>)
|
||||
<% end %>
|
||||
<% end %> -->
|
||||
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
|
||||
<div style="font-size:12px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
<!-- <% if !@order_items_count.nil? %>
|
||||
<% if @order_items_count.key?(table.id) %>
|
||||
(Orders : <%= @order_items_count[table.id] %>)
|
||||
<% end %>
|
||||
<% end %> -->
|
||||
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="card tables green text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= table.id %> hide"> new</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 2 - Room Orders -->
|
||||
<div class="tab-pane" id="rooms" role="tabpanel" style="">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @rooms.each do |room| %>
|
||||
<% if room.status == 'occupied' %>
|
||||
<% if room.get_booking.nil? %>
|
||||
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %> <br>
|
||||
<%= room.zone.name %>
|
||||
<!-- <% if !@order_items_count.nil? %>
|
||||
<% if @order_items_count.key?(room.id) %>
|
||||
(Orders : <%= @order_items_count[room.id] %>)
|
||||
<% end %>
|
||||
<% end %> -->
|
||||
<span class="float-right font-12 new_text_<%= room.id %>"> billed</span>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %><br>
|
||||
<%= room.zone.name %>
|
||||
<!-- <% if !@order_items_count.nil? %>
|
||||
<% if @order_items_count.key?(room.id) %>
|
||||
(Orders : <%= @order_items_count[room.id] %>)
|
||||
<% end %>
|
||||
<% end %> -->
|
||||
<span class="float-right font-12 new_text_<%= room.id %>"> new</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="card rooms green text-white table_<%= room.id %>" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %><br>
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %> hide">
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 3 - Orders -->
|
||||
<div class="tab-pane" id="orders" role="tabpanel" style="">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @orders.each do |order| %>
|
||||
<div class="card orders <%=(order.status=="new") ? 'blue' : 'red'%> text-white" data-id="<%= order.order_id %>">
|
||||
<div class="card-block">
|
||||
<%
|
||||
order_status = ""
|
||||
sale_order = SaleOrder.find_by_order_id(order)
|
||||
if sale_order
|
||||
unless sale_order.sale_id.nil?
|
||||
sale = Sale.find(sale_order.sale_id)
|
||||
order_status = sale.sale_status
|
||||
if order_status == 'new'
|
||||
order_status = order.status
|
||||
end
|
||||
end
|
||||
else
|
||||
order_status = order.status
|
||||
end
|
||||
%>
|
||||
<%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Credit Item Lists-->
|
||||
<div class="tab-pane dining" id="credits" role="tabpanel">
|
||||
<div class="card-block">
|
||||
<div class="row m-t-10 m-l-10 clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<input type="text" name="filter" id="filter" style="height: 32px;" placeholder="Receipt No." class="form-control" onchange="getCreditData('cashier');">
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('cashier');" >
|
||||
<option value="">-- Select Customer --</option>
|
||||
<% if !@customers.empty? %>
|
||||
<% @customers.each do |cus| %>
|
||||
<option value="<%= cus[0] %>"><%= cus[1] %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix m-t-20 m-l-10">
|
||||
<table class="table table-responsive tbl_credit_lists">
|
||||
<thead>
|
||||
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||
</thead>
|
||||
<tbody class="tbd_credit_lists"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- tabs - End -->
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">INVOICE DETAILS </strong>| Table <%= @dining.name rescue "" %></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Receipt No: <span id="receipt_no">
|
||||
<%= @sale.receipt_no rescue '' %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-title row customer_detail p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Customer : <%= @sale.customer.name rescue "-" %>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="order-detail-slimscroll" data-height="160">
|
||||
<div class="card-text" style="">
|
||||
<table class="table table-striped" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</th>
|
||||
<th class="item-attr">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
sub_total = 0
|
||||
@sale.sale_items.each do |sale_item|
|
||||
sub_total = sub_total + sale_item.price
|
||||
%>
|
||||
<input type="hidden" id="sale_id" value="<%= @sale.sale_id %>">
|
||||
<% #unless sale_item.price <= 0 %>
|
||||
<tr>
|
||||
<td class='item-name'><%= sale_item.product_name %></td>
|
||||
<td class='item-attr'><%= sale_item.qty %></td>
|
||||
<td class='item-attr'><%= sale_item.price %></td>
|
||||
</tr>
|
||||
<%
|
||||
|
||||
#end
|
||||
end
|
||||
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @sale.discount_type == 'member_discount'%>
|
||||
<td class="charges-name"><strong>Member Discount:</strong></td>
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= @sale.grand_total rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr class="rebate_amount"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<% if @sale.sale_status != 'void' && @sale.sale_status != 'waste' && @sale.sale_status != 'spoile' %>
|
||||
<% if current_login_employee.role == "cashier" %>
|
||||
<% if @sale.payment_status != 'foc' %>
|
||||
<a class="btn btn-block bg-danger waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||
<% end %>
|
||||
<a class="btn btn-block bg-blue waves-effect access_modal" data-toggle="modal" data-type="reprint"> Re.Print</a>
|
||||
<% else %>
|
||||
<% if @sale.payment_status != 'foc' %>
|
||||
<button type="button" id="void" class="btn bg-danger btn-block">VOID</button>
|
||||
<% end %>
|
||||
<button type="button" id="reprint" class="btn bg-blue btn-block">Re.Print</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
|
||||
</div>
|
||||
<div class="modal-footer ">
|
||||
<div class="row p-r-20">
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link bg-red waves-effect " id="void" active="true">VOID</button>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="AccessCodeModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-sm" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="AccessCodeModalLabel">Enter Access Code</h4>
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="padding: 0px 25px 15px 25px !important">
|
||||
<input type="password" id="access_code" class="access_code form-control col-md-12 ">
|
||||
<div class="row bottom p-l-15 p-r-15 m-t-10">
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="3" data-type="num">3</div>
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="4" data-type="num">4</div>
|
||||
</div>
|
||||
<div class="row bottom p-l-15 p-r-15">
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="6" data-type="num">6</div>
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="8" data-type="num">8</div>
|
||||
</div>
|
||||
<div class="row bottom p-l-15 p-r-15">
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="9" data-type="num">9</div>
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 access_number border-top border-left orange" data-type="clr">Clr</div>
|
||||
<div class="col-md-3 access_number ok border-top border-left blue" data-type="ok" data-action="">OK</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
|
||||
</div>
|
||||
<div class="modal-footer ">
|
||||
<div class="row p-r-20">
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect " id="void" active="true">VOID</button>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- script data for credit lists -->
|
||||
<script type="text/html" id="html_credit_items">
|
||||
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
||||
<td>{receipt_date}</td>
|
||||
<td>{receipt_no}</td>
|
||||
<td>{cashier_name}</td>
|
||||
<td>{customer_name}</td>
|
||||
<td>{credit_amount}</td>
|
||||
</tr>
|
||||
</script>
|
||||
<!-- script data for credit lists -->
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
getCreditSales("","","cashier"); //credit sales script data binding
|
||||
|
||||
$(".tables").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/table/' + dining_id;
|
||||
})
|
||||
$(".sales").on('click',function(){
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/sale/' + sale_id;
|
||||
})
|
||||
$(".rooms").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/room/' + dining_id;
|
||||
})
|
||||
$(".orders").on('click',function(){
|
||||
var order_id = $(this).attr("data-id");
|
||||
window.location.href = '/foodcourt/order/' + order_id;
|
||||
})
|
||||
});
|
||||
|
||||
$('#reprint').on('click', function () {
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = '/foodcourt/'+ sale_id + "/reprint";
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
success: function (result) {
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
if(typeof code2lab != 'undefined'){
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#pay').on('click',function() {
|
||||
var sale_id = $('#sale_id').val();
|
||||
window.location.href = '/foodcourt/sale/'+ sale_id + "/payment";
|
||||
});
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/foodcourt/';
|
||||
})
|
||||
|
||||
// $('#void').on('click',function () {
|
||||
// var sure = confirm("Are you sure want to Void");
|
||||
// if (sure == true) {
|
||||
// // var sale_id = $('#sale_id').val();
|
||||
// // var ajax_url = "/foodcourt/sale/" + sale_id + '/void';
|
||||
// // $.ajax({
|
||||
// // type: 'POST',
|
||||
// // url: ajax_url,
|
||||
// // success: function () {
|
||||
// // window.location.href = '/foodcourt/';
|
||||
// // }
|
||||
// // });
|
||||
// }
|
||||
// });
|
||||
|
||||
$(document).on('click', '.access_modal', function(event){
|
||||
type = $(this).data("type");
|
||||
$(".ok").attr("data-action",type);
|
||||
$('#AccessCodeModal').modal('show');
|
||||
});
|
||||
$('#void').on('click', function () {
|
||||
var access_code = localStorage.getItem("access_code");
|
||||
swal({
|
||||
title: "Alert",
|
||||
text: "Are you sure want to Void?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Yes, void it!",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/foodcourt/sale/" + sale_id +'/'+'cashier'+ '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
data: {'access_code':access_code},
|
||||
success: function () {
|
||||
window.location.href = '/foodcourt/sale/'+sale_id;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function check_emp_access_code(access_code,type) {
|
||||
var url = "/foodcourt/check_emp_access_code/" + access_code ;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: url,
|
||||
data: {},
|
||||
success: function (result) {
|
||||
console.log(result)
|
||||
if (result.status == true) {
|
||||
createAccessCode(code);
|
||||
if (type == "edit") {
|
||||
var dining_id = $('#dining').text();
|
||||
var sale_id = $('#sale_id').text();
|
||||
if (dining_id) {
|
||||
window.location.href = '/foodcourt/table/' + dining_id + "/sale/" + sale_id + "/"+cashier_type+"/edit";
|
||||
}else{
|
||||
window.location.href = "/foodcourt/table/sale/" + sale_id + "/"+cashier_type+"/edit";
|
||||
}
|
||||
}else if(type == "void"){
|
||||
$('#AccessCodeModal').modal('hide');
|
||||
$('#voidModal').modal('show');
|
||||
// overall_void();
|
||||
}else if(type == "waste") {
|
||||
// $('#AccessCodeModal').modal('hide');
|
||||
// $('#focModal').modal('show');
|
||||
waste_and_spoilage("waste")
|
||||
}else if(type == "waste") {
|
||||
// $('#AccessCodeModal').modal('hide');
|
||||
// $('#focModal').modal('show');
|
||||
waste_and_spoilage("waste")
|
||||
}else if(type == "reprint") {
|
||||
$('#AccessCodeModal').modal('hide');
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/foodcourt/"+ sale_id + "/reprint";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
success: function (result) {
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
if(typeof code2lab != 'undefined'){
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}else if(type == "foc"){
|
||||
$('#AccessCodeModal').modal('hide');
|
||||
$('#focModal').modal('show');
|
||||
// overall_foc();
|
||||
}
|
||||
}else{
|
||||
swal("Opps",result.message,"warning")
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
67
app/views/foodcourt/second_display/_second_display.html.erb
Normal file
67
app/views/foodcourt/second_display/_second_display.html.erb
Normal file
@@ -0,0 +1,67 @@
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<div class="card-text" >
|
||||
<div id="order-detail-slimscroll" data-height="160">
|
||||
<table class="table table-striped second_display_items" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>#</th>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-">QTY</th>
|
||||
<th class="item-">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="item-attr"><strong id="s_sub_total">0.00</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Discount Amount:</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="item-attr"><strong id="s_total_discount">0.00</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax Amount:</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="item-attr"><strong id="s_tatal_tax">0.00</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand:</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="item-attr"><strong id="s_grand_total">0.00</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div id="wowslider-container" style="max-width: 100%;">
|
||||
<div class="ws_images full_screen">
|
||||
<% @display_images.each do |p| %>
|
||||
<%= image_tag "#{p.image}", :alt => "rss feed"%>
|
||||
<% break %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
20
app/views/foodcourt/second_display/_slider.html.erb
Normal file
20
app/views/foodcourt/second_display/_slider.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<%= stylesheet_link_tag 'wow_style', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'wowslider', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'wow_script', 'data-turbolinks-track': 'reload' %>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div id="wowslider-container" style="max-width: 100%;">
|
||||
<div class="ws_images full_screen">
|
||||
<ul>
|
||||
<% @display_images.each do |p| %>
|
||||
<li>
|
||||
<%= image_tag "#{p.image}", :alt => "rss feed"%>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ws_bullets"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
20
app/views/foodcourt/second_display/index.html.erb
Normal file
20
app/views/foodcourt/second_display/index.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<div class="container-fluid" style="margin-top:-65px;">
|
||||
<button type="button" class="hidden" id="s_reload">Reload</button>
|
||||
<div class="slider" id="second_display_slider">
|
||||
<%= render 'slider' %>
|
||||
</div>
|
||||
|
||||
<div class="item hidden" id="second_display_items">
|
||||
<%= render 'second_display' %>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
//html font-size for second display till 35px!
|
||||
// document.getElementsByTagName( "html" )[0].style[ "font-size" ] = "35px";
|
||||
|
||||
$('#s_reload').on('click', function () {
|
||||
window.location.href = '/foodcourt/second_display';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
1
app/views/foodcourt/shifts/create.json.jbuilder
Executable file
1
app/views/foodcourt/shifts/create.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
1
app/views/foodcourt/shifts/edit.html.erb
Executable file
1
app/views/foodcourt/shifts/edit.html.erb
Executable file
@@ -0,0 +1 @@
|
||||
<h1> Close Cashier </h1>
|
||||
2
app/views/foodcourt/shifts/index.html.erb
Executable file
2
app/views/foodcourt/shifts/index.html.erb
Executable file
@@ -0,0 +1,2 @@
|
||||
<h1>Origami::Shifts#index</h1>
|
||||
<p>Find me in app/views/origami/shifts/index.html.erb</p>
|
||||
126
app/views/foodcourt/shifts/new.html.erb
Executable file
126
app/views/foodcourt/shifts/new.html.erb
Executable file
@@ -0,0 +1,126 @@
|
||||
<div class="container-fluid">
|
||||
<h1>Open Cashier</h1>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<th>Cashier Terminal</th>
|
||||
<th>
|
||||
<select class="form-control show-tick" id='cashier_terminal'>
|
||||
<% @terminal.each do |ter| %>
|
||||
<option value="<%= ter.id %>" ><%= ter.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
<% @float.each do |float| %>
|
||||
<tr>
|
||||
<th><%= float.name %></th>
|
||||
<th><input class='float-value form-control' type='text' data-value ="<%= float.value %>" value='0' id='<%= float.value %>'></input></th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<th><div id='total'></div></th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class='col-md-8'>
|
||||
<div class="row p-l-30">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="1" data-type="num">1</div>
|
||||
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
|
||||
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="4" data-type="num">4</div>
|
||||
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
|
||||
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="7" data-type="num">7</div>
|
||||
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
|
||||
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="0" data-type="num">0</div>
|
||||
<div class=" cashier_number left" data-value="." data-type="num">.</div>
|
||||
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number orange " data-type="clr">Clr</div>
|
||||
<div class=" cashier_number left" data-type='ent' >Calculate</div>
|
||||
<div class=" cashier_number purple left" id="open_cashier">Open Cashier</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
var float_value = ""
|
||||
var total = 0
|
||||
|
||||
$(document).on('focusout', '.float-value', function(event){
|
||||
float_value = $(this).attr("data-value");
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
if(event.handled !== true) {
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
var original = $('#'+float_value).val();
|
||||
if (original == "0"){
|
||||
$('#'+float_value).val(input_value);
|
||||
}else{
|
||||
$('#'+float_value).val(original + input_value);
|
||||
}
|
||||
break;
|
||||
case 'clr':
|
||||
$('#'+float_value).val("0");
|
||||
break;
|
||||
case 'ent':
|
||||
var sum = 0
|
||||
<%
|
||||
sum = 0
|
||||
@float.each do |float|
|
||||
%>
|
||||
var float = "<%= float.value %>"
|
||||
console.log(float)
|
||||
var cal = $('#'+ float).val() * float
|
||||
sum += cal;
|
||||
<%
|
||||
end
|
||||
%>
|
||||
total = sum
|
||||
$('#total').text(total)
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('#open_cashier').on('click touchstart', function(event){
|
||||
$(this).off("click touchstart touchend");
|
||||
var cashier_terminal = $('#cashier_terminal').val();
|
||||
var amount = $('#total').text()||0;
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= foodcourt_shifts_path %>",
|
||||
data: "opening_balance=" + amount + "&cashier_terminal="+ cashier_terminal,
|
||||
success:function(result){
|
||||
if(result){
|
||||
window.location.href = "<%= foodcourt_food_court_path%>";
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
201
app/views/foodcourt/shifts/sale_summary.html.erb
Executable file
201
app/views/foodcourt/shifts/sale_summary.html.erb
Executable file
@@ -0,0 +1,201 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-10 col-md-10 col-sm-10">
|
||||
<h3 style="text-align: center;">Sales Summary Quick View </h3>
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Cashier </th>
|
||||
<th>Cashier Terminal </th>
|
||||
<th>Opening Date </th>
|
||||
<th>Opening float </th>
|
||||
<th>Received Amount </th>
|
||||
<th>Cast In </th>
|
||||
<th>Cast Out </th>
|
||||
<th>Total Receipt </th>
|
||||
<th>Dining Count </th>
|
||||
<th>Takeaway Count </th>
|
||||
<th>Total Void</th>
|
||||
</tr>
|
||||
<tr style="border-bottom:2px solid #000">
|
||||
<td><%= @shift.employee.name%></td>
|
||||
<td><%=@shift.cashier_terminal.name%></td>
|
||||
<td><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %>
|
||||
</td>
|
||||
<td><%=@shift.opening_balance %></td>
|
||||
<td><%=@shift.closing_balance %></td>
|
||||
<td><%=@shift.cash_in %></td>
|
||||
<td><%=@shift.cash_out %></td>
|
||||
<th><%= @shift.total_receipt %></th>
|
||||
<th><%= @shift.dining_count %></th>
|
||||
<th><%= @shift.takeaway_count %></th>
|
||||
<th>(<%= @shift.total_void.round(2) %>)</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<table width="100%">
|
||||
<% @total_amount_by_account.each do |amount| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;"> Total <%= amount.account_name %> Amount</td>
|
||||
<td><%= amount.total_price.round(2) %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Net Sales</th>
|
||||
<th><%=@shift.nett_sales %></th>
|
||||
</tr>
|
||||
|
||||
<% @total_discount_by_account.each do |amount| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;"> Total <%= amount.account_name %> Discount</td>
|
||||
<td><%= amount.total_price.round(2) %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
|
||||
<% if !@total_member_discount[0].member_discount.nil?
|
||||
@member_discount = @total_member_discount[0].member_discount rescue 0.0
|
||||
@overall = @shift.total_discounts - @member_discount
|
||||
%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Member Discount</th>
|
||||
<th><%= @member_discount %></th>
|
||||
</tr>
|
||||
<%else @overall = @shift.total_discounts %>
|
||||
|
||||
<%end%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Overall Discount</th>
|
||||
<th><%= @overall %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Discount</th>
|
||||
<th><%= @shift.total_discounts %></th>
|
||||
</tr>
|
||||
|
||||
<% @sale_taxes.each do |tax| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;"> <%= tax.tax_name %> </td>
|
||||
<td><%= tax.st_amount.round(2) %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Tax </th>
|
||||
<th><%=@shift.total_taxes %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Rounding Adj </th>
|
||||
<th><%= @shift.total_rounding.round(2) %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Grand Total </th>
|
||||
<th><%= @shift.grand_total.round(2) %></th>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td colspan="6">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Cash Payment </th>
|
||||
<th><%=@shift.cash_sales %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Credit Payment </th>
|
||||
<th><%=@shift.credit_sales %></th>
|
||||
</tr>
|
||||
<% @total_amount = 0
|
||||
|
||||
@other_payment.each do |other| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Other Payment Detail </th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">MPU Payment </td>
|
||||
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">VISA Payment </td>
|
||||
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">JCB Payment </td>
|
||||
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">Master Payment </td>
|
||||
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">Reedem Payment </td>
|
||||
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;"><strong>FOC </strong></td>
|
||||
<td><%=other.foc_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<%end%>
|
||||
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Total Other Payment </th>
|
||||
<th><%=@shift.other_sales %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;">Total Payment </th>
|
||||
<th><%= @total_amount+@shift.cash_sales+@shift.credit_sales %></th>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<br><br><br>
|
||||
<button id="close_cashier" type="button" class="btn btn-block btn-primary btn-lg"> Close Cashier
|
||||
</button>
|
||||
<button id="back" type="button" class="btn btn-block btn-primary btn-lg"><i class="fa fa-home fa-lg"></i> Back
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#close_cashier').on('click',function(){
|
||||
window.location.href = '/foodcourt/shift/close';
|
||||
})
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/foodcourt';
|
||||
})
|
||||
})
|
||||
</script>
|
||||
282
app/views/foodcourt/shifts/show.html.erb
Executable file
282
app/views/foodcourt/shifts/show.html.erb
Executable file
@@ -0,0 +1,282 @@
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
|
||||
<div class='row clearfix'>
|
||||
<div class='col-md-10'>
|
||||
<h1><%= t :close_cashier %></h1>
|
||||
<br>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td><%= t :shift_started_at %></td>
|
||||
<td><%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t :cashier_name %></td>
|
||||
<td><%= @shift.employee.name rescue ''%></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<hr>
|
||||
<div class='row clearfix '>
|
||||
<div class='col-md-5'>
|
||||
<span style='font-size:20px;'><b><%= t :closing_balance %></b></span>
|
||||
</div>
|
||||
<div class='col-md-6'>
|
||||
<span style='font-size:20px;'><b><input type='number' class="form-control" id='closing_balance_amount' value='' onkeypress="return isNumberKey(event);" onkeyup="closeCashier(this.value);"></b></span>
|
||||
</div>
|
||||
</div><br>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
|
||||
<button type="button" class="btn bg-blue btn-block green close_cashier"> <%= t("views.btn.close_cashier") %> </button>
|
||||
<% if @bank_integration == '1' && @cashier_type!="ordering" %>
|
||||
<button type="button" class="btn bg-blue btn-block green" id="card_settlement"> <%= t("views.btn.card_settle") %> </button>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="cardSettleModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="cardSettleModal">Select Device: </h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<select class="form-control show-tick sel_com_port" id="sel_com_port" >
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer p-r-30">
|
||||
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect" id="card_settle">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
// $(document).ready(function(){
|
||||
// var val = $('#sale_items').val()
|
||||
// if (val == 1) {
|
||||
// $('#sale_items').prop( "checked", true );
|
||||
// }
|
||||
// })
|
||||
|
||||
function closeCashier(val){
|
||||
var aa = parseInt(val);
|
||||
if(isNaN(aa)) $("#closing_balance_amount").val("");
|
||||
}
|
||||
|
||||
function isNumberKey(evt) {
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function greaterThanOne(val){
|
||||
if(parseInt(val)==0) $("#closing_balance_amount").val(1);
|
||||
}
|
||||
|
||||
var cashier_type = '<%= @cashier_type %>';
|
||||
$('.close_cashier').on('click',function(){
|
||||
var amount = $('#closing_balance_amount').val();
|
||||
var shift_id = "<%= @shift.id rescue ""%>"
|
||||
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= foodcourt_close_shift_path %>",
|
||||
data: "closing_balance="+ amount + "&shift_id="+ shift_id ,
|
||||
success:function(result){
|
||||
console.log(result)
|
||||
window.location.href = '/';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = "<%= foodcourt_food_court_path%>";
|
||||
});
|
||||
|
||||
/** start CB Card Settle process **/
|
||||
$("#card_settlement").on('click', function(){
|
||||
if(typeof code2lab != 'undefined'){
|
||||
$('#cardSettleModal').modal({ keyboard: false, backdrop: false });
|
||||
code2lab.getCommPorts();
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: 'Settlement can not print out in browser!',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/shift/'+cashier_type+'/close';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//CB Bank payment settlement ECR integration
|
||||
function setCommPorts(comPortLists) {
|
||||
// alert(comPortLists);
|
||||
$('#sel_com_port').html("");
|
||||
var jsonPortLists = $.parseJSON(comPortLists);
|
||||
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){
|
||||
$.each(jsonPortLists,function(key,value){
|
||||
$('#sel_com_port').append("<option value='"+value+"'>"+value+"</option>");
|
||||
});
|
||||
}
|
||||
else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: 'Payment can not pay in browser!',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/shift/'+cashier_type+'/close';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$("#card_settle").on('click', function () {
|
||||
$("#loading_wrapper").show();
|
||||
$('#cardSettleModal').modal('hide');
|
||||
reqCBBankMPUSettlement();
|
||||
});
|
||||
|
||||
//add req data to card_settle_trans table
|
||||
function reqCardSettleTrans(cmd_type,payment_type,com_port) {
|
||||
var jobj = {"cmd_type" : cmd_type, "payment_type" : payment_type};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/bank_integration/settle_trans",
|
||||
data: {type:"request", data: jobj},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.status == "success"){
|
||||
resCardSettleTrans(data.card_settle_trans_id,cmd_type,payment_type,com_port);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//add res data to card_settle_trans table
|
||||
function resCardSettleTrans(card_settle_trans_id,cmd_type,payment_type,com_port) {
|
||||
var resMsg = "";
|
||||
if($("#loading_wrapper").is(':visible')){
|
||||
resMsg = code2lab.reqBankPayment(cmd_type, payment_type, 1, "", com_port);
|
||||
}
|
||||
|
||||
if(resMsg.includes("STATUS")){
|
||||
var jobj = $.parseJSON(resMsg);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/foodcourt/bank_integration/settle_trans",
|
||||
data: {type:"response", card_settle_trans_id: card_settle_trans_id, data: jobj},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == "success"){
|
||||
if(payment_type == "MPU"){
|
||||
reqCBBankVMJSettlement();
|
||||
}
|
||||
else if(payment_type == "VMJ"){
|
||||
reqCBBankJCBSettlement();
|
||||
}
|
||||
else if(payment_type == "JCB"){
|
||||
reqCBBankCUPSettlement();
|
||||
}
|
||||
else if(payment_type == "CUP"){
|
||||
$("#loading_wrapper").hide();
|
||||
swal({
|
||||
title: 'Information!',
|
||||
text: 'Settlement is successfully.',
|
||||
type: 'success',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/foodcourt/shift/'+cashier_type+'/close';
|
||||
});
|
||||
// reqCBBankAlipaySettlement();
|
||||
}
|
||||
// else if(payment_type == "Alipay"){
|
||||
// reqCBBankIPPSettlement();
|
||||
// $('#loading').hide();
|
||||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
$("#loading_wrapper").hide();
|
||||
swal ( "Oops" , resMsg.toString() , "error" );
|
||||
}
|
||||
}
|
||||
|
||||
//settle for MPU / MPU-UPI
|
||||
function reqCBBankMPUSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "MPU";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for VMJ (VISA, MASTER)
|
||||
function reqCBBankVMJSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "VMJ"; //VISA,Master and JCB
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for JCB
|
||||
function reqCBBankJCBSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "JCB";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for International Union Pay (CUP)
|
||||
function reqCBBankCUPSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "CUP";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for Alipay
|
||||
function reqCBBankAlipaySettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "Alipay";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for insert/direct swipe (now does not using this state - future one)
|
||||
function reqCBBankIPPSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "IPP";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
/** end CB Card Settle process **/
|
||||
</script>
|
||||
1
app/views/foodcourt/shifts/update_shift.json.jbuilder
Executable file
1
app/views/foodcourt/shifts/update_shift.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
534
app/views/foodcourt/surveys/_form.html.erb
Executable file
534
app/views/foodcourt/surveys/_form.html.erb
Executable file
@@ -0,0 +1,534 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
|
||||
<div class="card">
|
||||
<%= simple_form_for(@survey, :url => foodcourt_create_surveys_path) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
<div class="form-inputs p-l-10">
|
||||
<% if !@survey_data.nil? %>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyChild(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyAdult(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :male , input_html: { value: @survey_data.male, class: 'col-md-10', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyMale(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :female , input_html: { value: @survey_data.female, class: 'col-md-10', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyFemale(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= f.input :total_customer, input_html: { value:@survey_data.total_customer , :readonly => true, class: 'col-md-11'} %>
|
||||
<%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-11', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyLocal(this.value);" }%>
|
||||
<!--<fieldset style="border: 1px solid #BDBDBD;padding: 20px; width: 92%;margin: 20px 0 20px 0;"> -->
|
||||
<!-- <legend style="font-size: 1.2em !important;font-weight: bold !important;text-align: left !important;border:none;width:100px;">Foreigner</legend> -->
|
||||
<fieldset style="border: 1px solid #BDBDBD;padding: 20px; width: 92%;margin: 20px 0 20px 0;">
|
||||
<legend style="font-size: 1.2em !important;font-weight: bold !important;text-align: left !important;border:none;width:100px;">Foreigner</legend>
|
||||
<div class="row clearfix foreignerDiv">
|
||||
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Foreigner</label>
|
||||
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
|
||||
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
|
||||
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
|
||||
<option value="<%= ct.value %>">
|
||||
<%= ct.name %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Number</label>
|
||||
<input type="number" name="survey[foreigner][]" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
|
||||
<br>
|
||||
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden" id="newTemplate" >
|
||||
</div>
|
||||
</fieldset>
|
||||
<% else %>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :child , input_html: { class: 'col-md-10' ,min:'1', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyChild(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :adult , input_html: { class: 'col-md-10' ,min:'1', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyAdult(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :male , input_html: { min:'1',class: 'col-md-10' , :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyMale(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<%= f.input :female , input_html: { min:'1',class: 'col-md-10' , :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyFemale(this.value);" }%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= f.input :total_customer, input_html: { :readonly => true,min:'1', class: 'col-md-11'} %>
|
||||
<%= f.input :local , input_html: { min:'1',class: 'col-md-11', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyLocal(this.value);" }%>
|
||||
|
||||
<fieldset style="border: 1px solid #BDBDBD;padding: 20px; width: 92%;margin: 20px 0 20px 0;">
|
||||
<legend style="font-size: 1.2em !important;font-weight: bold !important;text-align: left !important;border:none;width:100px;">Foreigner</legend>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Foreigner</label>
|
||||
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
|
||||
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
|
||||
<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>
|
||||
<option value="<%= ct.value %>">
|
||||
<%= ct.name %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Number</label>
|
||||
<input type="number" name="survey[foreigner][]" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
|
||||
<br>
|
||||
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden" id="newTemplate" >
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
<%if !@dining_facility.nil? %>
|
||||
<input type="hidden" name="table_id" id="table_id" value="<%= @dining_facility.id %>">
|
||||
<input type="hidden" name="table_type" id="table_type" value="<%= @table_type %>">
|
||||
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %>
|
||||
<%else%>
|
||||
<input type="hidden" name="table_id" id="table_id" value="0">
|
||||
<input type="hidden" name="table_type" id="table_type" value="0">
|
||||
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => 0 } %>
|
||||
<%end%>
|
||||
<input type="hidden" name="sale_id" value="<%=@id%>">
|
||||
<input type="hidden" name="cashier_type" value="<%=@cashier_type%>">
|
||||
|
||||
<% if !@survey_data.nil? %>
|
||||
<input type="hidden" name="survey_id" value=<%= @survey_data.id %> />
|
||||
<% else %>
|
||||
<input type="hidden" name="survey_id" />
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= f.input :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %>
|
||||
<%= f.input :receipt_no, :as => :hidden, :input_html => { :value => @receipt_no} %>
|
||||
<%= f.input :total_amount, :as => :hidden, :input_html => { :value => @grand_total } %>
|
||||
</div>
|
||||
<div class="form-actions form-inputs p-l-10">
|
||||
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<div class="p-l-70 m-b-10 m-t-10">
|
||||
<div class="row bottom">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-12 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-12 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-12 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-3 left cashier_number" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-12 m-l--5">
|
||||
<div class="row m-l--5">
|
||||
<div class="col-md-3 left cashier_number"></div>
|
||||
<div class="col-md-3 left cashier_number red" data-type="del">DEL</div>
|
||||
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3 hidden">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.detail.title") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.title_txt") %> <br>
|
||||
2) <%= t("views.right_panel.detail.account_type") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.account_type_txt") %> <br>
|
||||
3) <%= t("views.right_panel.detail.discount") %> - <%= t("views.right_panel.detail.checkbox") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.discount_txt") %> <br>
|
||||
4) <%= t("views.right_panel.detail.point") %> - <%= t("views.right_panel.detail.checkbox") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.point_txt") %> <br>
|
||||
5) <%= t("views.right_panel.detail.bonus") %> - <%= t("views.right_panel.detail.checkbox") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.bonus_txt") %> <br>
|
||||
6) <%= t("views.right_panel.detail.rebate") %> - <%= t("views.right_panel.detail.checkbox") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.rebate_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function isNumberKey(evt) {
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function surveyChild(val){
|
||||
var aa = parseInt(val);
|
||||
if(isNaN(aa)) $("#survey_child").val("");
|
||||
}
|
||||
function surveyAdult(val){
|
||||
var aa = parseInt(val);
|
||||
if(isNaN(aa)) $("#survey_adult").val("");
|
||||
}
|
||||
function surveyMale(val){
|
||||
var aa = parseInt(val);
|
||||
if(isNaN(aa)) $("#survey_male").val("");
|
||||
}
|
||||
function surveyFemale(val){
|
||||
var aa = parseInt(val);
|
||||
if(isNaN(aa)) $("#survey_female").val("");
|
||||
}
|
||||
function surveyLocal(val){
|
||||
var aa = parseInt(val);
|
||||
if(isNaN(aa)) $("#survey_local").val("");
|
||||
}
|
||||
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$(document).ready(function(){
|
||||
/* check webview loaded*/
|
||||
var webview = <%= @webview %>;
|
||||
showHideNavbar(webview);
|
||||
|
||||
$('.foreignerDiv').removeClass("hidden");
|
||||
setHeaderBreadCrumb(_SURVEY_);
|
||||
<% if !@survey_data.nil? %>
|
||||
addSurveyForeignerLists(<%= @survey_data.foreigner.to_json.html_safe %>);
|
||||
<% end %>
|
||||
//click add button for new row
|
||||
$('#addForeigner').on('click',function(){
|
||||
$('#newTemplate').removeClass('hidden');
|
||||
|
||||
var text_box = '<div id="newRow" class="row clearfix">'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+' <select class="form-control col-md-12 selectpicker show-tick" '
|
||||
+' name="survey[foreigner][]" style="height: " >'
|
||||
+'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>'
|
||||
+'<option value="<%= ct.value %>">'
|
||||
+'<%= ct.name %></option>'
|
||||
+'<%end %>'
|
||||
+'</select>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+'<input type="number" name="survey[foreigner][]" class="form-control">'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">'
|
||||
+'<button type="button" class="btn btn-danger" id="removeRow">Remove</button>'
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
$('#newTemplate').append(text_box);
|
||||
});
|
||||
|
||||
//click add button for new row
|
||||
$('#newTemplate').on('click','#addForeigner',function(){
|
||||
$('#newTemplate').removeClass('hidden');
|
||||
|
||||
var text_box = '<div id="newRow" class="row clearfix">'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+' <select class="form-control col-md-12 selectpicker show-tick" '
|
||||
+' name="survey[foreigner][]" style="height: " >'
|
||||
+'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>'
|
||||
+'<option value="<%= ct.value %>">'
|
||||
+'<%= ct.name %></option>'
|
||||
+'<%end %>'
|
||||
+'</select>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+'<input type="number" name="survey[foreigner][]" class="form-control">'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">'
|
||||
+'<button type="button" class="btn btn-danger" id="removeRow">Remove</button>'
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
$('#newTemplate').append(text_box);
|
||||
});
|
||||
|
||||
//click remove buttom
|
||||
$('#newTemplate').on('click','#removeRow', function(){
|
||||
$(this).parent().parent().remove()
|
||||
});
|
||||
|
||||
$( "input" ).focusin(function() {
|
||||
$('.addfocus').removeClass('addfocus');
|
||||
$( this ).addClass('addfocus');
|
||||
});
|
||||
|
||||
$(".cashier_number").on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
|
||||
var original_value='';
|
||||
original_value = $('.addfocus').val();
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0.0"){
|
||||
var value = $('.addfocus').val(input_value);
|
||||
if ($("#survey_child").hasClass('addfocus')){
|
||||
var child = $("#survey_child").val()+value;
|
||||
var adult = $("#survey_adult").val() || 0;
|
||||
var result = parseInt(child) + parseInt(adult);
|
||||
$("#survey_total_customer").val(result);
|
||||
}
|
||||
if ($("#survey_adult").hasClass('addfocus')){
|
||||
var adult = $("#survey_adult").val()+value;
|
||||
var child = $("#survey_child").val() || 0;
|
||||
var result = parseInt(child) + parseInt(adult);
|
||||
$("#survey_total_customer").val(result);
|
||||
}
|
||||
}
|
||||
else{
|
||||
var value = $('.addfocus').val(original_value + '' + input_value);
|
||||
if ($("#survey_child").hasClass('addfocus')){
|
||||
var child = $("#survey_child").val()+value;
|
||||
var adult = $("#survey_adult").val() || 0;
|
||||
var result = parseInt(child) + parseInt(adult);
|
||||
$("#survey_total_customer").val(result);
|
||||
}
|
||||
if ($("#survey_adult").hasClass('addfocus')){
|
||||
var adult = $("#survey_adult").val()+value;
|
||||
var child = $("#survey_child").val() || 0;
|
||||
var result = parseInt(child) + parseInt(adult);
|
||||
$("#survey_total_customer").val(result);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value);
|
||||
$('.addfocus').val(amount);
|
||||
break;
|
||||
|
||||
case 'del' :
|
||||
var discount_text=$('.addfocus').val();
|
||||
$('.addfocus').val(discount_text.substr(0,discount_text.length-1));
|
||||
break;
|
||||
|
||||
case 'clr':
|
||||
$('.addfocus').val("");
|
||||
if($("#survey_child").hasClass('addfocus')){
|
||||
$("#survey_child").val("");
|
||||
var adult = $("#survey_adult").val() || 0;
|
||||
var result = parseInt(adult);
|
||||
$("#survey_total_customer").val(result);
|
||||
}else if($("#survey_adult").hasClass('addfocus')){
|
||||
$("#survey_adult").val("");
|
||||
var child = $("#survey_child").val() || 0;
|
||||
var result = parseInt(child);
|
||||
$("#survey_total_customer").val(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
// click back button for redirect
|
||||
$('#back').on('click',function(){
|
||||
var table_type = $('#table_type').val();
|
||||
var table_id = $('#table_id').val();
|
||||
|
||||
if (cashier_type == "quick_service" || cashier_type == "food_court") {
|
||||
window.location.href = '/foodcourt/sale/<%= @id %>/<%= @cashier_type %>/payment/';
|
||||
}else{
|
||||
if(table_type == "Table"){
|
||||
window.location.href = "/foodcourt/table/" + table_id;
|
||||
}
|
||||
else {
|
||||
window.location.href = "/foodcourt/room/" + table_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function addSurveyForeignerLists(foreigner_lists){
|
||||
if((foreigner_lists != undefined) && (foreigner_lists != null) && (foreigner_lists != "")){
|
||||
$('.foreignerDiv').remove();
|
||||
$('#newTemplate').removeClass('hidden');
|
||||
foreigner_lists = foreigner_lists.substring(1, (foreigner_lists.length - 1)).replace(new RegExp('"', "g"),'').split(",");
|
||||
var arr_foreigner = {};
|
||||
$.each(foreigner_lists,function(key,value){
|
||||
if(!value.match(/^[0-9]+$/)){
|
||||
arr_foreigner[value] = 0;
|
||||
}else{
|
||||
$.each(arr_foreigner,function(k,val){
|
||||
if(arr_foreigner[k] == 0){
|
||||
arr_foreigner[k] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// console.log(foreigner_lists);
|
||||
// console.log(arr_foreigner);
|
||||
$.each(arr_foreigner, function(key,value){
|
||||
if(Object.keys(arr_foreigner)[0] == key){
|
||||
var fgn_template = '<div id="newRow" class="row clearfix">'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+' <select class="form-control col-md-12 selectpicker show-tick" '
|
||||
+' name="survey[foreigner][]" style="height: " >'
|
||||
+'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>'
|
||||
// if (key.toString() == '<%= ct.value.to_s %>')
|
||||
// var selected = "selected";
|
||||
// else
|
||||
// var selected = "";
|
||||
+'<option value="<%= ct.value %>">'
|
||||
+'<%= ct.name %></option>'
|
||||
+'<%end %>'
|
||||
+'</select>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+'<input type="number" name="survey[foreigner][]" class="form-control" value="'+value+'">'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">'
|
||||
+'<button type="button" class="btn btn-success" id="addForeigner">Add</button>'
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
}else{
|
||||
var fgn_template = '<div id="newRow" class="row clearfix">'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+' <select class="form-control col-md-12 selectpicker show-tick" '
|
||||
+' name="survey[foreigner][]" style="height: " >'
|
||||
+'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>'
|
||||
// if (key.toString() == '<%= ct.value.to_s %>')
|
||||
// var selected = "selected";
|
||||
// else
|
||||
// var selected = "";
|
||||
+'<option value="<%= ct.value %>">'
|
||||
+'<%= ct.name %></option>'
|
||||
+'<%end %>'
|
||||
+'</select>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">'
|
||||
+'<div class="form-group p-l-10 p-r-10">'
|
||||
+'<input type="number" name="survey[foreigner][]" class="form-control" value="'+value+'">'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">'
|
||||
+'<button type="button" class="btn btn-danger" id="removeRow">Remove</button>'
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
}
|
||||
|
||||
$('#newTemplate').append(fgn_template);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function total_customer(){
|
||||
var child = $("#survey_child").val() || 0;
|
||||
var adult = $("#survey_adult").val() || 0;
|
||||
var result = parseInt(child) + parseInt(adult);
|
||||
$("#survey_total_customer").val(result);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
2
app/views/foodcourt/surveys/_survey.json.jbuilder
Executable file
2
app/views/foodcourt/surveys/_survey.json.jbuilder
Executable file
@@ -0,0 +1,2 @@
|
||||
json.extract! settings_account, :id, :title, :account_type, :created_at, :updated_at
|
||||
json.url settings_account_url(settings_account, format: :json)
|
||||
12
app/views/foodcourt/surveys/edit.html.erb
Executable file
12
app/views/foodcourt/surveys/edit.html.erb
Executable file
@@ -0,0 +1,12 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item"><a href="<%= settings_accounts_path %>"><%= t("views.right_panel.detail.account") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.btn.edit") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), settings_accounts_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<%= render 'form', settings_account: @settings_account %>
|
||||
91
app/views/foodcourt/surveys/index.html.erb
Executable file
91
app/views/foodcourt/surveys/index.html.erb
Executable file
@@ -0,0 +1,91 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= foodcourt_root_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.account") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), foodcourt_root_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.title") %></th>
|
||||
<th><%= t("views.right_panel.detail.account_type") %></th>
|
||||
<th><%= t("views.right_panel.detail.discount") %></th>
|
||||
<th><%= t("views.right_panel.detail.point") %></th>
|
||||
<th><%= t("views.right_panel.detail.bonus") %></th>
|
||||
<th><%= t("views.right_panel.detail.rebate") %></th>
|
||||
<th><%= t("views.right_panel.detail.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @settings_accounts.each do |account| %>
|
||||
<tr>
|
||||
<td><%= account.title %></td>
|
||||
<td><%= account.account_type == 1 ? "Expense" : "Income"%></td>
|
||||
<td><%= account.discount %></td>
|
||||
<td><%= account.point %></td>
|
||||
<td><%= account.bonus %></td>
|
||||
<td><%= account.rebate %></td>
|
||||
<td>
|
||||
<%= link_to t("views.btn.show"), settings_account_path(account),:class => 'btn btn-info btn-sm waves-effect' %>
|
||||
<%= link_to t("views.btn.edit"), edit_settings_account_path(account),:class => 'btn btn-primary btn-sm waves-effect' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.detail.title") %> - <%= t("views.right_panel.detail.title_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
2) <%= t("views.right_panel.detail.account_type") %> - <%= t("views.right_panel.detail.account_type_txt") %> <br>
|
||||
3) <%= t("views.right_panel.detail.discount") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.discount_txt") %> <br>
|
||||
4) <%= t("views.right_panel.detail.point") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.point_txt") %> <br>
|
||||
5) <%= t("views.right_panel.detail.bonus") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.bonus_txt") %> <br>
|
||||
6) <%= t("views.right_panel.detail.rebate") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.rebate_txt") %> <br>
|
||||
7) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.new") %> - <%= t("views.right_panel.detail.new_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.show") %> - <%= t("views.right_panel.detail.show_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.dashboard_txt") %> <br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#back').on('click',function(){
|
||||
table_type = '<%=@table_type%>';
|
||||
table = '<%=@dining_facility.id%>';
|
||||
if(table_type == "Table"){
|
||||
window.location.href = "/foodcourt/table/" + table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/foodcourt/room/" + table_id
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
1
app/views/foodcourt/surveys/index.json.jbuilder
Executable file
1
app/views/foodcourt/surveys/index.json.jbuilder
Executable file
@@ -0,0 +1 @@
|
||||
json.array! @settings_accounts, partial: 'settings_accounts/settings_account', as: :settings_account
|
||||
3
app/views/foodcourt/surveys/new.html.erb
Executable file
3
app/views/foodcourt/surveys/new.html.erb
Executable file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
<%= render 'form', survey: @survey %>
|
||||
84
app/views/foodcourt/surveys/show.html.erb
Executable file
84
app/views/foodcourt/surveys/show.html.erb
Executable file
@@ -0,0 +1,84 @@
|
||||
<!-- -->
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item"><a href="<%= settings_accounts_path %>"><%= t("views.right_panel.detail.account") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t :details %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), settings_accounts_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Account</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.title") %></th>
|
||||
<th><%= t("views.right_panel.detail.account_type") %></th>
|
||||
<!-- <th>Can get Discount</th> -->
|
||||
<th><%= t("views.right_panel.detail.can_get_points") %></th>
|
||||
<!-- <th>Can get Bonus</th> -->
|
||||
<th><%= t("views.right_panel.detail.can_rebate") %></th>
|
||||
<th><%= t("views.right_panel.detail.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><%= @settings_account.title %></td>
|
||||
<td><%= @settings_account.account_type %></td>
|
||||
<!-- <td><%= @settings_account.discount %></td> -->
|
||||
<td><%= @settings_account.point %></td>
|
||||
<!-- <td><%= @settings_account.bonus %></td> -->
|
||||
<td><%= @settings_account.rebate %></td>
|
||||
|
||||
<td><%= link_to t("views.btn.edit"), edit_settings_account_path(@settings_account),:class => 'btn btn-primary btn-sm waves-effect' %>
|
||||
<button class="delete btn btn-danger btn-sm waves-effect" data-ref="<%= settings_account_path(@settings_account)%>" data-method="delete">
|
||||
<%= t("views.btn.delete") %>
|
||||
</button>
|
||||
|
||||
<span class="hidden" id="delete_text">
|
||||
<h6>Are you sure you want to delete this row ?</h6>
|
||||
<h6>This action can't be undo. </h6>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.detail.title") %> - <%= t("views.right_panel.detail.title_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
2) <%= t("views.right_panel.detail.account_type") %> - <%= t("views.right_panel.detail.account_type_txt") %> <br>
|
||||
3) <%= t("views.right_panel.detail.can_get_points") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.point_txt") %> <br>
|
||||
4) <%= t("views.right_panel.detail.can_rebate") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.rebate_txt") %> <br>
|
||||
5) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt2") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.delete") %> - <%= t("views.right_panel.detail.delete_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.account_txt") %> <br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user