diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 7e91163f..a75779c3 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -389,13 +389,20 @@ function setHeaderBreadCrumb(params){ } //show hide nav bar for webview -function showHideNavbar(webview,page){ - // if(webview){ - $("nav.navbar").hide(); - // if(page=="index"){ - // $(".btn-lists").hide(); - // } - // }else{ - // $("nav.navbar").show(); - // } +function showHideNavbar(webview,page=""){ + if(webview){ + $("nav.navbar").addClass("hidden"); + $("section").addClass("section-margin"); + $(".page-loader-wrapper").addClass("hidden"); + if(page!=""){ + $("#back").hide(); + } + }else{ + $("nav.navbar").removeClass("hidden"); + $("section").removeClass("section-margin"); + $(".page-loader-wrapper").removeClass("hidden"); + if(page!=""){ + $("#back").show(); + } + } } diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 792eb4bd..601b8f89 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -435,5 +435,5 @@ iframe { /* section class for webview */ .section-margin { - + margin-top: -50px; } \ No newline at end of file diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index 45b9434d..ddcdc9e2 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -7,7 +7,8 @@ class BaseOrigamiController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception - helper_method :shop_detail + helper_method :shop_detail, :current_token + rescue_from CanCan::AccessDenied do |exception| flash[:warning] = exception.message # redirect_to origami_root_path @@ -37,30 +38,13 @@ class BaseOrigamiController < ActionController::Base #check webview def check_mobile status = false - if request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i + authenticate_with_http_token do |token, options| + session[:session_token] = token + end + + if session[:session_token] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i status = true end return status end - - # protected - # # Authenticate the user with token based authentication - # def authenticate - # authenticate_token || render_unauthorized - # end - - # def authenticate_token - # authenticate_with_http_token do |token, options| - # Rails.logger.debug "token - " + token.to_s - # @user = Employee.authenticate_by_token(token) - # if @user - # return true - # end - # end - # end - - # def render_unauthorized(realm = "Application") - # request.headers["WWW-Authenticate"] = %(Token realm="#{realm.gsub(/"/, "")}") - # render json: 'Bad credentials', status: :unauthorized - # end end diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 0e905724..4abab9c8 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -2,13 +2,23 @@ class Origami::AddordersController < BaseOrigamiController # before_action :set_dining, only: [:detail] def index - @tables = Table.all.active.order('zone_id asc').group("zone_id") - @rooms = Room.all.active.order('zone_id asc').group("zone_id") - @all_table = Table.all.active.order('status desc') - @all_room = Room.all.active.order('status desc') + @webview = false + if check_mobile + @webview = true + end + + @tables = Table.all.active.order('zone_id asc').group("zone_id") + @rooms = Room.all.active.order('zone_id asc').group("zone_id") + @all_table = Table.all.active.order('status desc') + @all_room = Room.all.active.order('status desc') end def detail + @webview = false + if check_mobile + @webview = true + end + today = DateTime.now day = Date.today.wday @menus = Menu.all diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index c3a3d3b9..70e5260f 100755 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -9,7 +9,6 @@ class Origami::CustomersController < BaseOrigamiController end def get_customer - filter = params[:filter] type = params[:type] @@ -47,7 +46,11 @@ class Origami::CustomersController < BaseOrigamiController end def add_customer - + @webview = false + if check_mobile + @webview = true + end + @sale_id = params[:sale_id] @cashier_type = params[:type] @page = params[:page] diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 6add4a12..0d3899bd 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -3,6 +3,11 @@ class Origami::DiscountsController < BaseOrigamiController #discount page show from origami index with selected order def index + @webview = false + if check_mobile + @webview = true + end + sale_id = params[:id] @cashier_type = params[:type] if Sale.exists?(sale_id) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 2d19c9c5..427d2a86 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -5,10 +5,8 @@ class Origami::HomeController < BaseOrigamiController def index @webview = false if check_mobile - puts "request data" @webview = true end - puts @webview == false @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') @@ -21,6 +19,11 @@ class Origami::HomeController < BaseOrigamiController # origami table detail def show + @webview = false + if check_mobile + @webview = true + end + @tables = Table.all.active.order('status desc') @rooms = Room.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')) diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 3181d470..2a600294 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -1,5 +1,10 @@ class Origami::OrdersController < BaseOrigamiController def show + @webview = false + if check_mobile + @webview = true + end + @tables = Table.all.active.order('status desc') @rooms = Room.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')) diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index def94a1f..28ab2c06 100755 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -2,6 +2,11 @@ class Origami::OtherChargesController < BaseOrigamiController 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) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 5c0cd454..505d747c 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -5,9 +5,18 @@ class Origami::RoomsController < BaseOrigamiController @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') # @shift = ShiftSale.current_open_shift(current_user.id) + @webview = false + if check_mobile + @webview = true + end end def show + @webview = false + if check_mobile + @webview = true + end + @tables = Table.all.active.order('status desc') @rooms = Room.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')) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index e18828fc..8cd68d9c 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -2,6 +2,11 @@ class Origami::SplitBillController < BaseOrigamiController authorize_resource :class => false def index + @webview = false + if check_mobile + @webview = true + end + dining_id = params[:dining_id] @cashier_type = params[:type] @table = DiningFacility.find(dining_id) diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index b30ff1b0..663fa805 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -1,6 +1,10 @@ class Origami::SurveysController < BaseOrigamiController def new - + @webview = false + if check_mobile + @webview = true + end + @survey = Survey.new @id = params[:id] @cashier_type = params[:type] diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 93569170..6681a7f2 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -591,5 +591,12 @@ //end Ajax } //end show list function + + /* check webview loaded*/ + var webview = ''; + <%if @webview %> + var webview = <%= @webview %>; + showHideNavbar(webview); + <% end %> }); \ No newline at end of file diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 181319b9..59badabe 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -274,6 +274,9 @@ var cashier_type = "<%= @cashier_type %>"; var page = "<%= @page %>"; $(function() { + /* check webview loaded*/ + var webview = <%= @webview %>; + showHideNavbar(webview); /*$('.datepicker').datepicker({ setDate: '12-12-1999', format : 'dd-mm-yyyy', diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index fc05b630..59341bcb 100755 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -257,6 +257,9 @@ var cashier_type = "<%= @cashier_type %>"; $(document).ready(function(){ setHeaderBreadCrumb(_DISCOUNTS_); + /* check webview loaded*/ + var webview = <%= @webview %>; + showHideNavbar(webview); $('#back').on('click',function(){ var id = $("#table_id").text(); diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 5c0a51cd..38f0cc79 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,7 +1,7 @@