diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 4a7e3d50..87b74809 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -11,6 +11,7 @@ // about supported directives. // //= require jquery +//= require tether //= require bootstrap //= require jquery_ujs //= require turbolinks @@ -20,13 +21,13 @@ $(document).ready(function(){ // auto refresh every 60 seconds - setTimeout(function(){ - window.location.reload(1); - }, 60000); + // setTimeout(function(){ + // window.location.reload(1); + // }, 60000); // For selected order return var order_status = ""; - order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); + order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); // Enable/Disable Button control_button(order_status); @@ -220,7 +221,7 @@ $(document).ready(function(){ if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ var balance = data["response_data"]["data"][i]["balance"]; if (data["response_data"]["status"]==true) { - $('.rebate_amount').removeClass('hide'); + $('.rebate_amount').removeClass('hide'); row = '' + data["response_data"]["data"][i]["accountable_type"] +'' +'' + balance + ''; @@ -290,8 +291,8 @@ $(document).ready(function(){ }); /* Button Control by Status */ -function control_button(order_status){ - if(order_status=="billed"){ +function control_button(order_status){ + if(order_status=="billed"){ $("#customer").prop('disabled', false); $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', false); diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index b89e7c63..29e9082a 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -10,15 +10,20 @@ class HomeController < ApplicationController @login_form.emp_id = params[:login_form][:emp_id] @login_form.password = params[:login_form][:password] @employee = Employee.login(@login_form.emp_id, @login_form.password) - if @employee.role == "administrator" - session[:session_token] = @employee.token_session - redirect_to dashboard_path - elsif @employee.role == "cashier" - session[:session_token] = @employee.token_session - redirect_to origami_root_path - else - render :index - end + + if @employee != nil + if @employee.role == "administrator" + session[:session_token] = @employee.token_session + redirect_to dashboard_path + elsif @employee.role == "cashier" + session[:session_token] = @employee.token_session + redirect_to origami_root_path + else + render :index + end + else + redirect_to origami_root_path, :notice => "Username and Password dosn't match!" + end end diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 2d3a819e..35cefe6f 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -13,7 +13,7 @@ class Transactions::OrdersController < ApplicationController end end - @orders = Kaminari.paginate_array(orders).page(params[:page]).per(2) + @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) respond_to do |format| format.html # index.html.erb format.json { render json: @orders } diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index c8ecb725..b1c28e98 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -10,12 +10,18 @@ class Transactions::SalesController < ApplicationController today = Date.today if receipt_no.nil? - @sales = Sale.order("sale_id") - #@products = Product.order("name").page(params[:page]).per(5) + sales = Sale.order("sale_id desc") else - @sales = Sale.search(receipt_no) - end - @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + order = Sale.search(receipt_no) + if order.count > 0 + sales = order + else + sales = Sale.order("sale_id desc") + + end + end + @sales = Kaminari.paginate_array(sales).page(params[:page]).per(50) + respond_to do |format| format.html # index.html.erb format.json { render json: @sales } diff --git a/app/models/sale.rb b/app/models/sale.rb index 67953c14..dee4c2f7 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -57,10 +57,9 @@ class Sale < ApplicationRecord self.tax_type = "exclusive" # set cashier by current login - # TODO: requested_by is string , can't cast to id. error occur. please fix - # self.cashier_id = requested_by.id - self.cashier_name = requested_by - self.requested_by = requested_by + self.cashier_id = requested_by.id + self.cashier_name = requested_by.name + self.requested_by = requested_by.name self.requested_at = DateTime.now.utc diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index ce88a421..35eb6481 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,25 +1,25 @@ -
-
- <%= simple_form_for(@login_form, url: login_path, method: "POST") do |f| %> -
-

Login

-
-
- <%= f.input :emp_id, required: false, autofocus: true, class: "form-control" %> -
-
- <%= f.input :password, required: false, class: "form-control" %> -
- +
+
+ <%= simple_form_for(@login_form, url: login_path, method: "POST") do |f| %> +
+

Login

+
+
+ <%= f.input :emp_id, required: false, autofocus: true, class: "form-control" %>
- + +
+ +
+ + <% end %>
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 44624a43..1d4991e6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,7 +18,7 @@ <%= render 'layouts/header' %>
<% flash.each do |type, message| %> -
+
<%= message %>
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 230e8a5a..dab6615d 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -237,6 +237,7 @@ +
diff --git a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb new file mode 100644 index 00000000..1b4082f5 --- /dev/null +++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb @@ -0,0 +1,211 @@ +
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ +
+
+ <% end %> + + + +
+
+ <% if defined? promotions %> + <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %> + <% end %> + + <% if defined? menu_types %> + <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %> + <% end %> + + <% if defined? payments %> + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> + <% end %> + + <% if defined? shift_name %> + + <% end %> + + <% if defined? cashiers %> + <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> + <% end %> + + <% if defined? singer %> + <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %> + <% end %> + + <% if defined? bsm %> + <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %> + <% end %> + + <% if defined? guest_role %> + <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %> + <% end %> + + <% if defined? list_by_payment_type %> + <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %> + <% end %> + + <% if defined? products %> + <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %> + <% end %> + + <% if defined? items %> + <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %> + <% end %> +
+
+ + + + <% end %> +
+
+ + + + \ No newline at end of file diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb index a50bf56b..ee82eb8b 100644 --- a/app/views/transactions/sales/index.html.erb +++ b/app/views/transactions/sales/index.html.erb @@ -57,7 +57,7 @@
- + <%= paginate @sales %>
diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 26fcc62f..56887410 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -171,13 +171,7 @@ -