From 23be4771fd53301486478491e13434938d8158e3 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 8 Mar 2018 14:57:45 +0630 Subject: [PATCH] add function for member card and qr code in payment --- app/controllers/crm/customers_controller.rb | 10 +- .../origami/customers_controller.rb | 1 + app/models/sale.rb | 6 +- app/views/crm/customers/index.html.erb | 9 +- app/views/origami/customers/index.html.erb | 87 +++++++--- app/views/origami/home/show.html.erb | 4 +- app/views/origami/payments/show.html.erb | 156 +++++++++++++++--- app/views/origami/rooms/show.html.erb | 3 +- config/routes.rb | 4 +- 9 files changed, 213 insertions(+), 67 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 12944632..83a437a2 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -167,7 +167,7 @@ class Crm::CustomersController < BaseCrmController status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' } else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} end @@ -186,21 +186,21 @@ class Crm::CustomersController < BaseCrmController if response["message"] == "Account has not exist." customer.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer cannot created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]} else format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] } end end if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]} else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response["message"] } end end else if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. noted'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created. noted'} else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } end @@ -209,7 +209,7 @@ class Crm::CustomersController < BaseCrmController if params[:sale_id] flash[:errors] = @crm_customers.errors - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page]} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } else flash[:errors] = @crm_customers.errors diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index db89b1d0..f8036a2a 100755 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -50,6 +50,7 @@ class Origami::CustomersController < BaseOrigamiController @sale_id = params[:sale_id] @cashier_type = params[:type] + @page = params[:page] if(@sale_id[0,3] == "SAL") @booking = Booking.find_by_sale_id(@sale_id) diff --git a/app/models/sale.rb b/app/models/sale.rb index 8252d343..591d460b 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -556,12 +556,8 @@ class Sale < ApplicationRecord prefix = DateTime.now().utc #self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s if !shop_details.nil? - if !shop_details.client_code.nil? && shop_details.shop_code.nil? - self.receipt_no = shop_details.client_code + "-" + prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s - elsif shop_details.client_code.nil? && !shop_details.shop_code.nil? + if !shop_details.shop_code.nil? self.receipt_no = shop_details.shop_code + "-" + prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s - elsif !shop_details.client_code.nil? && !shop_details.shop_code.nil? - self.receipt_no = shop_details.client_code + "-" + shop_details.shop_code + "-" + prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s else self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s end diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index d05af387..372c05e9 100755 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -23,10 +23,10 @@ - + - - + + <% end %> @@ -145,7 +145,8 @@ $(function() { $("#qr_code").on('click', function(e){ var code = ""; setTimeout(function(){ - var hi=getQRCode(); + code=getQRCode(); + setQRCode(code); },100); }); diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index eebaabbf..e144d848 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -34,12 +34,14 @@ -
- -
+ + + + + <% end %> @@ -114,6 +116,8 @@ + + <%if !@dining_facility.nil?%> @@ -262,7 +266,8 @@ \ No newline at end of file diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 7291581c..3826df57 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -486,6 +486,7 @@