diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 28ba5c2b..12eeccd2 100644 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -34,7 +34,7 @@ class BaseReportController < ActionController::Base to = params[:to] day_ref = Time.now.utc.getlocal - if params[:report_type] == "daily_sale" + if params[:report_type] == "daily_sale" || params[:report_type] == "sale_item" if from != "" && to != "" @@ -86,9 +86,7 @@ class BaseReportController < ActionController::Base else # end daily sale report if period_type.to_i == 1 - if params[:from] && params[:to] - - if params[:from] != "" && params[:to] !="" + if params[:from] != "" && params[:to] !="" f_date = DateTime.parse(params[:from]) t_date = DateTime.parse(params[:to]) @@ -99,8 +97,7 @@ class BaseReportController < ActionController::Base else from = day_ref.beginning_of_day.utc to = day_ref.end_of_day.utc - end - end + end else case period.to_i when PERIOD["today"] diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index f8a80cb8..2f5b25d2 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -82,7 +82,8 @@ class Crm::CustomersController < BaseCrmController card_no = customer_params[:card_no] member_group_id = params[:member_group_id] - if !member_group_id.nil? + if member_group_id.present? + puts "aaaaaaaaa" membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") merchant_uid = memberaction.merchant_account_id.to_s @@ -101,6 +102,7 @@ class Crm::CustomersController < BaseCrmController }, :timeout => 10 ) + rescue Net::OpenTimeout response = { status: false } @@ -110,9 +112,7 @@ class Crm::CustomersController < BaseCrmController rescue SocketError response = { status: false} end - if response["status"] == true - customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) @@ -125,11 +125,17 @@ class Crm::CustomersController < BaseCrmController else # @crm_customers.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '} else - format.html { redirect_to crm_customers_path, notice: response["message"] } + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } end end + else + if params[:sale_id] + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '} + else + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } + end end else @@ -183,6 +189,8 @@ end }, :timeout => 10 ) + puts "hhhhhhhhh" + puts response.to_json rescue Net::OpenTimeout response = { status: false } @@ -200,7 +208,7 @@ end format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'} else - format.html { redirect_to crm_customers_path, notice: response["message"] } + format.html { redirect_to crm_customers_path, notice: response["error"] } end else diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 8303780f..de4be3c3 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -20,6 +20,7 @@ class Transactions::OrdersController < ApplicationController format.json { render json: @orders } end end + def show @order = Order.find(params[:id]) diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 66c20ff2..140a8cc0 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -20,9 +20,7 @@ class ShiftSale < ApplicationRecord #if current_user #find open shift where is open today and is not closed and login by current cashier today_date = DateTime.now.strftime("%Y-%m-%d") - shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take - return shift #end end diff --git a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb index 7f95b6b9..c57c8be9 100644 --- a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb +++ b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb @@ -116,24 +116,6 @@ <% end %> - - - \ No newline at end of file