diff --git a/Gemfile.lock b/Gemfile.lock index e4b905ea..5c0f8a10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,7 +122,6 @@ GEM nokogiri (1.8.0) mini_portile2 (~> 2.2.0) pdf-core (0.7.0) - pg (0.21.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -261,7 +260,6 @@ DEPENDENCIES kaminari (~> 1.0.1) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) diff --git a/app/assets/images/profile-1.png b/app/assets/images/profile-1.png new file mode 100644 index 00000000..bc020542 Binary files /dev/null and b/app/assets/images/profile-1.png differ diff --git a/app/assets/images/profile-2.png b/app/assets/images/profile-2.png new file mode 100644 index 00000000..b56112e2 Binary files /dev/null and b/app/assets/images/profile-2.png differ diff --git a/app/assets/images/profile-3.png b/app/assets/images/profile-3.png new file mode 100644 index 00000000..f2f65cc6 Binary files /dev/null and b/app/assets/images/profile-3.png differ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d0a8ca9e..f923858a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,7 +29,9 @@ class ApplicationController < ActionController::Base end def current_login_employee - @employee = Employee.find_by_token_session(session[:session_token]) + if (!session[:session_token].nil?) + @employee = Employee.find_by_token_session(session[:session_token]) + end end private diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 29e9082a..d290c25a 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,10 +1,30 @@ class HomeController < ApplicationController - skip_before_action :authenticate, only: [:index, :create, :destroy] + skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy] def index + @employees = Employee.all.order("name asc") @login_form = LoginForm.new() end + def show + @login_form = LoginForm.new() + @login_form.emp_id = params[:emp_id] + end + + def update + @login_form = LoginForm.new() + @login_form.emp_id = params[:emp_id] + @login_form.password = params[:login_form][:password] + @employee = Employee.login(@login_form.emp_id, @login_form.password) + + if @employee != nil + session[:session_token] = @employee.token_session + redirect_to origami_root_path + else + render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!" + end + end + def create @login_form = LoginForm.new() @login_form.emp_id = params[:login_form][:emp_id] @@ -21,9 +41,9 @@ class HomeController < ApplicationController else render :index end - else + else redirect_to origami_root_path, :notice => "Username and Password dosn't match!" - end + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..96956958 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,11 @@ module ApplicationHelper + + def flash_class(level) + case level + when :notice then "alert alert-info fade-in" + when :success then "alert alert-success fade-in" + when :error then "alert alert-error fade-in" + when :alert then "alert alert-error fade-in" + end +end end diff --git a/app/models/employee.rb b/app/models/employee.rb index 98b8380b..69eb3fae 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -13,9 +13,9 @@ class Employee < ApplicationRecord def self.login(emp_id, password) user = Employee.find_by_emp_id(emp_id) if (user) - user.authenticate(password) + #user.authenticate(password) - if (user) + if (user.authenticate(password)) user.generate_token user.session_expiry = DateTime.now.utc + 30.minutes user.session_last_login = DateTime.now.utc diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 35eb6481..87bf3f50 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,7 +1,7 @@ - + +
+
+
+ + <% @employees.each do |employee| %> + +
+
+
+

+ <%= employee.name %> +

+
+ (<%= employee.emp_id%>) +
+ +
+
+ <% end %> +
+
+ + diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb new file mode 100644 index 00000000..84b6f199 --- /dev/null +++ b/app/views/home/show.html.erb @@ -0,0 +1,68 @@ + + +
+
+ <%= simple_form_for(@login_form, url: emp_login_update_path, method: "PATCH") do |f| %> +
+
+
+ <%= f.input :emp_id,as: :hidden, label: "Access PIN", required: false, class: "form-control" %> + + <%= f.input :password, label: "Access PIN", required: false, class: "form-control" %> +
+
+
+ + + + + + + + + + + + + +
+ + +
+ + <% end %> +
+
+ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1d4991e6..a4c62ce3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -17,12 +17,11 @@ <%= render 'layouts/header' %>
- <% flash.each do |type, message| %> -
- - <%= message %> -
- <% end %> + <% flash.each do |key, value| %> +
+ <%= value %> +
+ <% end %> <%= yield %>
diff --git a/config/routes.rb b/config/routes.rb index c93beb92..efb9ca5d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,9 +2,6 @@ require 'sidekiq/web' Rails.application.routes.draw do - namespace :settings do - resources :membership_actions - end root 'home#index' mount Sidekiq::Web => '/kiq' @@ -16,6 +13,9 @@ Rails.application.routes.draw do post 'install' => 'install#create' #--------- Login/Authentication ------------# + get 'emp_login/:emp_id' => 'home#show' , as: :emp_login + patch "emp_login/:emp_id" => 'home#update', as: :emp_login_update + post 'login' => 'home#create' delete 'logout' => 'home#destroy' get 'dashboard' => 'home#dashboard' @@ -196,6 +196,8 @@ Rails.application.routes.draw do resources :payment_method_settings #membership_settings resources :membership_settings + resources :membership_actions + #zones resources :zones do #tables @@ -205,6 +207,7 @@ Rails.application.routes.draw do end end + #--------- Transactions Sections ------------# namespace :transactions do resources :sales