diff --git a/app/controllers/api/phone_verification/verifications_controller.rb b/app/controllers/api/phone_verification/verifications_controller.rb new file mode 100644 index 00000000..077c4944 --- /dev/null +++ b/app/controllers/api/phone_verification/verifications_controller.rb @@ -0,0 +1,27 @@ +class Api::VerificationsController < ActionController::API + + def request_code + + phone_number = params[:phone_number] + + #TODO - user generate + + if @user.pin.nil? + @user.pin = rand(1000..9999) + @user.contact_no = phone_number + @user.pin_send_at = Time.now + @user.save + VerifyNumber.send_message(@user.contact_no, @user.pin) + #sent message + else + @user.contact_no = phone_number + @user.save + VerifyNumber.send_message(@user.contact_no, @user.pin) + #sent message + end + end + + def verify_code + end + +end \ No newline at end of file diff --git a/app/controllers/api/shops_controller.rb b/app/controllers/api/shops_controller.rb index e1c758fc..279af3f2 100644 --- a/app/controllers/api/shops_controller.rb +++ b/app/controllers/api/shops_controller.rb @@ -1,7 +1,9 @@ class Api::ShopsController < Api::ApiController + skip_before_action :authenticate + def index - + @shops = Shop.select('id,logo,name,shop_code,address,phone_no,cloud_url,cloud_token').all end end \ No newline at end of file diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 49b4ff5d..15072c2e 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,9 +1,9 @@ class HomeController < ApplicationController # layout "application", except: [:index, :show] # skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy] - + include PrecisionHelper before_action :check_user, only: :dashboard - + # Special check for only dashboard def check_user if current_user.nil? @@ -90,9 +90,7 @@ class HomeController < ApplicationController def dashboard @from, @to, @from_time, @to_time = get_date_range_from_params - @shop = Shop.first - today = DateTime.now.strftime('%Y-%m-%d') if !@from.nil? && !@to.nil? if !@from_time.nil? && @to_time.nil? @@ -115,12 +113,7 @@ class HomeController < ApplicationController @top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top").sum('i.qty') @bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom").sum('i.qty') @hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total) - # .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p') - # .sum(:grand_total) - logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><' - logger.debug @hourly_sales.to_json employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time) - # .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)") @employee_sales = [] if !employee_sales.nil? employee_sales.each do |emp| @@ -154,7 +147,6 @@ class HomeController < ApplicationController end @summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time) @total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time) - # @total_other_customer = Sale.total_other_customer(today,current_user) @total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time) @total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time) @@ -172,7 +164,7 @@ class HomeController < ApplicationController @total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time) # get printer info - @print_settings = PrintSetting.get_precision_delimiter() + # @print_settings = get_precision_delimiter end def destroy diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 25ea8390..a4028323 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -2,7 +2,6 @@ class Origami::DashboardController < BaseOrigamiController def index @shop = Shop.first - today = DateTime.now.strftime('%Y-%m-%d') @display_type = Lookup.find_by_lookup_type("display_type") diff --git a/app/helpers/precision_helper.rb b/app/helpers/precision_helper.rb new file mode 100644 index 00000000..ada80673 --- /dev/null +++ b/app/helpers/precision_helper.rb @@ -0,0 +1,27 @@ +#PrecisionHelper +module PrecisionHelper + + def get_precision_delimiter + value_set = nil + + setting = PrintSetting.find_by_unique_code("CloseCashierPdf") + if setting.nil? + star_setting = PrintSetting.find_by_unique_code("CloseCashierStarPdf") + if star_setting.nil? + value_set = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf") + else + value_set = star_setting + end + else + value_set = setting + end + + if !value_set.nil? + @precision_value = value_set.precision.to_i > 0 ? value_set.precision : 0 + @delimiter_value = value_set.delimiter ? "," : "" + end + + return @precision_value, @delimiter_value + end + +end diff --git a/app/models/sale.rb b/app/models/sale.rb index 98457d0e..d0995a26 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1589,9 +1589,10 @@ end end end end - end + end else if current_user.nil? + puts "Run employee " total = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) else if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' @@ -1602,7 +1603,7 @@ end total = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id) end end - end + end end end diff --git a/app/views/api/shops/index.json.jbuilder b/app/views/api/shops/index.json.jbuilder new file mode 100644 index 00000000..4836e68a --- /dev/null +++ b/app/views/api/shops/index.json.jbuilder @@ -0,0 +1,7 @@ +if @shops + json.status true + json.data @shops +else + json.status false + json.message "Record Not Found" +end \ No newline at end of file diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 0f9890d7..d8a5a9c8 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -3,18 +3,6 @@
| <% @sale_data.each do |data| %> <% pay_mth = payment.payment_method %> - <%= number_with_precision(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_with_precision(data[""+pay_mth+""], precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(0, precision: @precision.to_i ,delimiter: @delimiter) %> <% end %> | @@ -253,7 +241,7 @@|
| <%= t("views.right_panel.detail.other_payment") %> : | - <%= number_with_precision(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_with_precision(total_card["card"], precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(0, precision: @precision.to_i ,delimiter: @delimiter) %> |