Merge branch 'foodcourt' of gitlab.com:code2lab/SXRestaurant into HEAD
This commit is contained in:
@@ -100,7 +100,7 @@ class HomeController < ApplicationController
|
|||||||
@sales = Sale.receipt_date_between(@from, @to).completed
|
@sales = Sale.receipt_date_between(@from, @to).completed
|
||||||
|
|
||||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
if shift = ShiftSale.current_open_shift(current_user)
|
||||||
@orders = @orders.where(shift_sale_id: shift.id)
|
@orders = @orders.where(shift_sale_id: shift.id)
|
||||||
@sales = @sales.where(shift_sale_id: shift.id)
|
@sales = @sales.where(shift_sale_id: shift.id)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
#card_balance amount for Paymal payment
|
#card_balance amount for Paymal payment
|
||||||
card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
if find_close_cashier_print[0][1].to_i > 0
|
if find_close_cashier_print[0][1].to_i > 0
|
||||||
|
|
||||||
|
|
||||||
printer.print_close_cashier(print_settings,cashier_terminal,current_shop, @sale_items, @total_other_charges_info, current_shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
printer.print_close_cashier(print_settings,cashier_terminal, @shift, @sale_items, @total_other_charges_info, current_shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Settings::EmployeesController < ApplicationController
|
class Settings::EmployeesController < ApplicationController
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
before_action :set_employee, only: [:show, :edit, :update, :destroy]
|
before_action :set_employee, only: [:show, :edit, :update, :destroy, :change_auth_token]
|
||||||
|
|
||||||
|
|
||||||
# GET /employees
|
# GET /employees
|
||||||
@@ -38,6 +38,13 @@ class Settings::EmployeesController < ApplicationController
|
|||||||
format.html { render :new }
|
format.html { render :new }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def change_app_token
|
||||||
|
@employee.app_token = @employee.generate_app_token #SecureRandom.hex(10)
|
||||||
|
@employee.save
|
||||||
|
flash[:notice] = 'Auth Token was successfully updated.'
|
||||||
|
redirect_to settings_employee_url(@employee)
|
||||||
end
|
end
|
||||||
|
|
||||||
# PATCH/PUT /employees/1
|
# PATCH/PUT /employees/1
|
||||||
@@ -71,6 +78,6 @@ class Settings::EmployeesController < ApplicationController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def employee_params
|
def employee_params
|
||||||
params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path)
|
params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path, :app_id, :app_token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Employee < ApplicationRecord
|
class Employee < ApplicationRecord
|
||||||
has_secure_password
|
has_secure_password
|
||||||
|
# has_secure_token :auth_token
|
||||||
has_many :commissioners
|
has_many :commissioners
|
||||||
has_many :shit_sales
|
has_many :shit_sales
|
||||||
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale"
|
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale"
|
||||||
@@ -11,6 +12,7 @@ class Employee < ApplicationRecord
|
|||||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||||
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
||||||
|
|
||||||
|
before_create :generate_app_id, :generate_app_token , if: Proc.new { self.role == "application" }
|
||||||
# Employee Image Uploader
|
# Employee Image Uploader
|
||||||
mount_uploader :image_path, EmployeeImageUploader
|
mount_uploader :image_path, EmployeeImageUploader
|
||||||
|
|
||||||
@@ -89,4 +91,18 @@ class Employee < ApplicationRecord
|
|||||||
|
|
||||||
return expiry_time
|
return expiry_time
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_app_id
|
||||||
|
# return if self.role != 'application'
|
||||||
|
self.app_id = SecureRandom.urlsafe_base64(nil, false)
|
||||||
|
rescue ActiveRecord::RecordNotUnique
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_app_token
|
||||||
|
# return if self.role != 'application'
|
||||||
|
self.app_token = SecureRandom.hex(10)
|
||||||
|
rescue ActiveRecord::RecordNotUnique
|
||||||
|
retry
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1498,7 +1498,7 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
if shift = ShiftSale.current_open_shift(current_user)
|
||||||
query = query.where("shift_sale_id='#{shift.id}'")
|
query = query.where("shift_sale_id='#{shift.id}'")
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1525,7 +1525,7 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
if shift = ShiftSale.current_open_shift(current_user)
|
||||||
query = query.where("shift_sale_id='#{shift.id}'")
|
query = query.where("shift_sale_id='#{shift.id}'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -347,7 +347,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% if isMobile.include? "Mobile" %>
|
<% if isMobile.to_s.include? "Mobile" %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 ">
|
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 ">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|||||||
@@ -19,8 +19,14 @@
|
|||||||
<a href="javascript:void(0);" class="bars"></a>
|
<a href="javascript:void(0);" class="bars"></a>
|
||||||
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "account" %>
|
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "account" %>
|
||||||
<a class="navbar-brand mbl_view" href="<%=dashboard_path%>" style="margin-left: 20px;">
|
<a class="navbar-brand mbl_view" href="<%=dashboard_path%>" style="margin-left: 20px;">
|
||||||
<% elsif current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
|
<% elsif current_login_employee.role == "supervisor" %>
|
||||||
<a class="navbar-brand mbl_view" href="<%=origami_dashboard_path%>" style="margin-left: 20px;">
|
<a class="navbar-brand mbl_view" href="<%=origami_dashboard_path%>" style="margin-left: 20px;">
|
||||||
|
<% elsif current_login_employee.role == "cashier" || current_login_employee.role == "waiter"%>
|
||||||
|
<%if ShiftSale.current_open_shift(current_login_employee) %>
|
||||||
|
<a class="navbar-brand mbl_view" href="<%=origami_dashboard_path%>" style="margin-left: 20px;">
|
||||||
|
<%else%>
|
||||||
|
<a class="navbar-brand mbl_view" href="" style="margin-left: 20px;">
|
||||||
|
<%end%>
|
||||||
<%else%>
|
<%else%>
|
||||||
<a class="navbar-brand mbl_view" href="" style="margin-left: 20px;">
|
<a class="navbar-brand mbl_view" href="" style="margin-left: 20px;">
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -54,12 +54,24 @@
|
|||||||
<th><%= t("views.right_panel.detail.employee_photo") %></th>
|
<th><%= t("views.right_panel.detail.employee_photo") %></th>
|
||||||
<td><%= image_tag @employee.image_path, :size => '200x200'%></td>
|
<td><%= image_tag @employee.image_path, :size => '200x200'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% if @employee.role == 'application' %>
|
||||||
|
<tr>
|
||||||
|
<th><%= t("views.right_panel.detail.employee_app_id") %></th>
|
||||||
|
<td><%= @employee.app_id %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><%= t("views.right_panel.detail.employee_app_token") %></th>
|
||||||
|
<td><%= @employee.app_token %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to t("views.btn.edit"), edit_settings_employee_path(@employee),:class => 'btn btn-primary btn-lg waves-effect' %>
|
<%= link_to t("views.btn.edit"), edit_settings_employee_path(@employee),:class => 'btn btn-primary btn-lg waves-effect' %>
|
||||||
|
<% if @employee.role == 'application' %>
|
||||||
|
<%= link_to t("views.btn.change_app_token"), settings_change_app_token_url(id: @employee.id), class: 'btn btn-primary btn-lg waves-effect' %>
|
||||||
|
<% end %>
|
||||||
<%if @employee.role != "administrator"%>
|
<%if @employee.role != "administrator"%>
|
||||||
|
|
||||||
<button class="delete btn btn-danger btn-sm waves-effect" data-ref="<%=settings_employee_path(@employee)%>" data-method="delete">
|
<button class="delete btn btn-danger btn-sm waves-effect" data-ref="<%=settings_employee_path(@employee)%>" data-method="delete">
|
||||||
<%= t("views.btn.delete") %>
|
<%= t("views.btn.delete") %>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ en:
|
|||||||
del: "DEL"
|
del: "DEL"
|
||||||
clr: "CLR"
|
clr: "CLR"
|
||||||
assign: "ASSIGN"
|
assign: "ASSIGN"
|
||||||
|
change_app_token: "Change App Token"
|
||||||
|
|
||||||
print_order_summary: "Print Order Summary"
|
print_order_summary: "Print Order Summary"
|
||||||
memeber_card: "Member Card"
|
memeber_card: "Member Card"
|
||||||
@@ -678,6 +679,8 @@ en:
|
|||||||
edit_btn_txt: "to edit "
|
edit_btn_txt: "to edit "
|
||||||
delete_btn_txt: "to delete "
|
delete_btn_txt: "to delete "
|
||||||
update_btn_txt: "to update "
|
update_btn_txt: "to update "
|
||||||
|
employee_app_id: "App ID"
|
||||||
|
employee_app_token: "App Token"
|
||||||
|
|
||||||
helpers:
|
helpers:
|
||||||
page_entries_info:
|
page_entries_info:
|
||||||
|
|||||||
@@ -432,7 +432,9 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
resources :display_images
|
resources :display_images
|
||||||
end
|
end
|
||||||
#employees
|
#employees
|
||||||
resources :employees
|
resources :employees
|
||||||
|
get '/:id/change_app_token' => 'employees#change_app_token', as: 'change_app_token'
|
||||||
|
|
||||||
#menu
|
#menu
|
||||||
resources :menus do
|
resources :menus do
|
||||||
collection do
|
collection do
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class AddAppIdAndAuthTokenToEmployees < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
add_column :employees, :app_id, :string, unique: true
|
||||||
|
add_column :employees, :auth_token, :string, unique: true
|
||||||
|
|
||||||
|
add_index :employees, :app_id
|
||||||
|
add_index :employees, :auth_token
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class ChangeColumnAuthTokenToAppToken < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
rename_column :employees, :auth_token, :app_token
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user