diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index eaf3bab7..2f1cba36 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -30,49 +30,48 @@ class Origami::HomeController < BaseOrigamiController @status_order = "" @status_sale = "" - @sale_array = Array.new @shop = shop_detail @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - @order_items = Array.new - @dining.current_bookings.each do |booking| - if @obj_sale || @booking.blank? - @booking = booking - end + @sale_array = @dining.current_sales + if (booking = @dining.current_checkin_booking) + @booking = booking + @order_items = booking.order_items + @obj_order = booking.orders.first + end - if booking.sale_id - @sale_array.push(booking.sale) + if (booking = @dining.current_checkout_booking) + @booking = booking + @obj_sale = booking.sale + @sale_taxes = @obj_sale.sale_taxes + @status_sale = 'sale' + end - if @obj_sale.blank? - @obj_sale = booking.sale - @sale_taxes = @obj_sale.sale_taxes - @status_sale = 'sale' - end - else - @order_items += booking.order_items - @obj_order = booking.orders.first - end - - if @obj_sale || @customer.blank? - if obj = @obj_sale || @obj_order - @customer = obj.customer - @date = obj.created_at - end - end - - if @obj_sale - @status_order = 'sale' - else - @status_order = 'order' - end - - if (@obj_sale || @account_arr.blank?) && @customer - @account_arr = TaxProfile.find_by(id: @customer.tax_profiles) + if @obj_sale || @customer.blank? + if obj = @obj_sale || @obj_order + @customer = obj.customer + @date = obj.created_at end end + if @obj_sale + @status_order = 'sale' + else + @status_order = 'order' + end + + if (@obj_sale || @account_arr.blank?) && @customer + @account_arr = TaxProfile.find_by(id: @customer.tax_profiles) + end + + # @dining.current_bookings.each do |booking| + # if @obj_sale || @booking.blank? + # @booking = booking + # end + # end + #for bank integration @checkout_time = Lookup.collection_of('checkout_time') @checkout_alert_time = Lookup.collection_of('checkout_alert_time') diff --git a/app/models/booking.rb b/app/models/booking.rb index 276ef53e..760a3350 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -58,9 +58,9 @@ class Booking < ApplicationRecord end end - scope :active, -> {where("booking_status != 'moved'")} - scope :today, -> {where("created_at >= #{Time.now.utc}")} - scope :assign, -> { where(booking_status: 'assign')} + scope :active, -> { where('booking_status != ?', 'moved') } + scope :today, -> { where('created_at >= ?', Time.now) } + scope :assign, -> { where(booking_status: 'assign') } def self.sync_booking_records(bookings) if !bookings.nil? diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index 7971ba72..b5bbc39c 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -57,7 +57,7 @@
<%= f.input :name, :class => "form-control name", :required => true %> <% flash.each do |test, msg| %> - <% + <% str="[\"#{msg['name']}\"]" str.gsub!('["', '') str.gsub!('"]', '') %> @@ -94,7 +94,7 @@
-
+
@@ -107,12 +107,12 @@ <% if f.object.image_path? %>

<%= f.object.name %>

<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %> - <% else %> + <% else %> <%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %> - <% end %> + <% end %>
<%= f.file_field :image_path, :class => "img-thumbnail" %> - +
@@ -160,7 +160,7 @@ <%end %> - +
@@ -185,7 +185,7 @@
-
+
@@ -201,7 +201,7 @@ <%end %> - +
@@ -212,7 +212,7 @@ -
+
@@ -259,7 +259,7 @@ console.log(paypar_account_no); // Read Card Reader - $("#paypar_account_no").on('focus', function(e){ + $("#paypar_account_no").on('focus', function(e){ if($(this).val() == ''){ $("#sxModal").show(); getCardNo(); @@ -280,13 +280,13 @@ // get CardNo from Java function setCardNo(cardNo){ - $("#sxModal").hide(); 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"); + $("#filter_form").submit(); }else{ if($.inArray(cardNo, paypar_account_no) !== -1){ swal({ @@ -307,9 +307,10 @@ } } } + $("#sxModal").hide(); } $("#sxModal .btn_cancel").on('click',function(){ $("#sxModal").hide(); }); - \ No newline at end of file + diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index a5462b1d..a639631d 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -161,22 +161,13 @@ $(document).ready(function () { $("#oqs_loading_wrapper").show(); localStorage.setItem("member_card",false); - /*$('.datepicker').datepicker({ - format : 'dd-mm-yyyy', - autoclose: true - }); - $('.datepicker').attr('ReadOnly','true'); - $('.datepicker').css('cursor','pointer');*/ - // Read Card Reader $("#member_acc_no").on('click', function(e){ localStorage.setItem("member_card",true); - var cardNo = ""; $("#sxModal").show(); getCardNo(); }); - // QR Code Reader $("#qr_code").on('click', function(e){ var code = ""; @@ -236,88 +227,85 @@ /*customer UI tab btn*/ $(document).on('click',".customer_tr",function(){ - // if(this.checked){ - $(this).closest('tr').find('.checkbox_check').prop( "checked", true ); - //$( "#checkbox_check" ).prop( "checked", true ); - var sale_id = $("#sale_id").val() || 0; - var customer_id = $(this).attr('data-ref'); + // if(this.checked){ + $(this).closest('tr').find('.checkbox_check').prop( "checked", true ); + //$( "#checkbox_check" ).prop( "checked", true ); + var sale_id = $("#sale_id").val() || 0; + var customer_id = $(this).attr('data-ref'); - if(sale_id != 0){ - // var url = "/"+customer_id; - update_sale(customer_id,sale_id); - }else{ + if(sale_id != 0){ + // var url = "/"+customer_id; + update_sale(customer_id,sale_id); + }else{ - var url = "customers/" + customer_id + "/edit"; - } + var url = "customers/" + customer_id + "/edit"; + } - $("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'}); + $("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'}); - $.ajax({ - type: "GET", - url: url, - data: {}, - dataType: "json", - success: function(data) { - // Selected for Taxes - 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").css({'color':'#fff','background':'#215d9c'}); - }); + $.ajax({ + type: "GET", + url: url, + data: {}, + dataType: "json", + success: function(data) { + // Selected for Taxes + 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").css({'color':'#fff','background':'#215d9c'}); + }); - $('#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_salutation').val(data.salutation); - $('#customer_nrc_no').val(data.nrc_no); - $('#customer_card_no').val(data.card_no); - $('#customer_type').val(data.customer_type); - $('#paypar_account_no').val(data.paypar_account_no); - $('#customer_address').val(data.address); - $('#customer_date_of_birth').val(data.date_of_birth); - if(data.image_path.url!=undefined && data.image_path.url!=null){ - $('.menu-item-img .img-thumbnail').attr('src',data.image_path.url); - } - $('#customer_membership_type').val(data.membership_type); - $('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected'); - if (data.gender == 'Male') { - $('.male').prop( "checked", true ) - }else{ - $('.female').prop( "checked", true ) - } + $('#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_salutation').val(data.salutation); + $('#customer_nrc_no').val(data.nrc_no); + $('#customer_card_no').val(data.card_no); + $('#customer_type').val(data.customer_type); + $('#paypar_account_no').val(data.paypar_account_no); + $('#customer_address').val(data.address); + $('#customer_date_of_birth').val(data.date_of_birth); + if(data.image_path.url!=undefined && data.image_path.url!=null){ + $('.menu-item-img .img-thumbnail').attr('src',data.image_path.url); + } + $('#customer_membership_type').val(data.membership_type); + $('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected'); + 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 ) - } + 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 ) + } - $('.membership_authentication_code').val(data.membership_authentication_code); + $('.membership_authentication_code').val(data.membership_authentication_code); - $('#update_customer').removeAttr('disabled').val(''); - $('#update_customer').attr('value', 'Update'); - $('#submit_customer').attr('disabled','disabled'); + $('#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; - $("#new_customer").attr('id', id); + $("#new_customer").attr('class', 'simple_form edit_customer'); + var id = "edit_customer_"+customer_id; + $("#new_customer").attr('id', id); - $(".edit_customer").attr('id', id); - $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); - $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); - $(".patch_method").html(''); - //$(".edit_customer").attr('method', 'PATCH'); - } - }); - // }else{ - - // } + $(".edit_customer").attr('id', id); + $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); + $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); + $(".patch_method").html(''); + //$(".edit_customer").attr('method', 'PATCH'); + } + }); }) function update_sale(customer_id,sale_id) { diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index fb804f5b..9144a260 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -82,7 +82,7 @@ - <% if crm_customer.customer_id != "" && crm_customer.customer_id != "" %> + <% if crm_customer.customer_id != "" && crm_customer.customer_id != "" %> <%= @i += 1 %> <%else%> - @@ -354,12 +354,12 @@ - + -
+

Card Tap

- +
@@ -368,6 +368,8 @@ var page = "<%= @page %>"; var paypar_account_no = []; $(function() { + setHeaderBreadCrumb(_CUSTOMERS_); + paypar_account_no = JSON.parse('<%= @paypar_accountno.to_json.html_safe %>', function (key, value) { var type; if (value && typeof value === 'object') { @@ -378,7 +380,7 @@ } return value; }); - console.log(paypar_account_no); + /* check webview loaded*/ var webview = <%= @webview %>; showHideNavbar(webview); @@ -400,47 +402,11 @@ } }); - $(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(); getCardNo(); - customer_mamber_card_no = $("#search").val(); - - if(sale_id != 0 && customer_mamber_card_no != 0){ - $.ajax({ - type: "POST", - url: "/origami/"+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); - } - - } - }); - } }); /*new customer UI func:*/ @@ -449,7 +415,6 @@ //Wizard $('a[data-toggle="tab"]').on('show.bs.tab', function (e) { - var $target = $(e.target); if ($target.parent().hasClass('disabled')) { @@ -463,6 +428,7 @@ 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'); @@ -474,29 +440,30 @@ /*customer UI tab btn*/ function nextTab(elem) { - $(elem).parent().next().find('a[data-toggle="tab"]').click(); + $(elem).parent().next().find('a[data-toggle="tab"]').click(); } function prevTab(elem) { - $(elem).parent().prev().find('a[data-toggle="tab"]').click(); + $(elem).parent().prev().find('a[data-toggle="tab"]').click(); } /*customer UI tab btn*/ // Read NFC card no from java function getCardNo(){ - code2lab.readNFC(); + if (typeof code2lab != 'undefined') { + code2lab.readNFC(); + } } // get CardNo from Java function setCardNo(cardNo){ - $("#sxModal").hide(); 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"); - $("#filter_form").submit(); + get_customer(); }else{ if($.inArray(cardNo, paypar_account_no) !== -1){ swal({ @@ -517,47 +484,76 @@ } } } + $("#sxModal").hide(); + } + + function get_customer() { + var cardNo = ""; + var customer_id = ''; + var customer_name = ''; + var sale_id = $("#sale_id").val() || 0; + var customer_mamber_card_no = $("#search").val(); + + if(sale_id != 0 && customer_mamber_card_no != 0){ + $('#loading_wrapper').show(); + $.ajax({ + type: "POST", + url: "/origami/"+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"); + }else{ + customer_id = data[0].customer_id; + customer_name = data[0].name; + update_sale(customer_id, customer_name,sale_id); + } + $('#loading_wrapper').hide(); + } + }); + } } // 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; + 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); + setTimeout(function(){ + code=getQRCode(); + setQRCode(code); + }, 100); - customer_mamber_card_no = $("#search").val(); + customer_mamber_card_no = $("#search").val(); - if(sale_id != 0 && customer_mamber_card_no != 0){ - $.ajax({ - type: "POST", - url: "/origami/"+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); - } + if(sale_id != 0 && customer_mamber_card_no != 0){ + $.ajax({ + type: "POST", + url: "/origami/"+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 @@ -572,81 +568,75 @@ } $(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{ + $(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(); - var url = "customers/"+customer_id; - } + if(sale_id != 0){ + 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"); - }); + // 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); + $('#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.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 ) - } + 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'); + $('#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(''); - //$(".edit_customer").attr('method', 'PATCH'); - } - }); - // }else{ - - // } - }) + $("#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(''); + //$(".edit_customer").attr('method', 'PATCH'); + } + }); + }) function update_sale(customer_id, customer_name, sale_id) { var customer=""; diff --git a/app/views/origami/dinga/index.html.erb b/app/views/origami/dinga/index.html.erb index fbefb5be..6c04a15b 100644 --- a/app/views/origami/dinga/index.html.erb +++ b/app/views/origami/dinga/index.html.erb @@ -106,19 +106,14 @@
-
-

Card Tap

-
- -
-
-
-

Card Tap

-
- -
-
+ +
+

Card Tap

+
+ +
+
@@ -145,10 +140,10 @@ - +