update login To show dashboard screen with available features based on user type

This commit is contained in:
Aung Myo
2017-07-24 17:42:34 +06:30
parent 8db4a8cc05
commit a7cbea5dbb
7 changed files with 158 additions and 156 deletions

View File

@@ -30,134 +30,3 @@ function export_to(path)
var form_params = $("#frm_report").serialize();
window.location = path+"?"+ form_params;
}
/*
* ToDo Move to here from pages
*
*
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');
$("#from").val("<%=params[:from]%>");
$("#to").val("<%=params[:to]%>");
$("#sel_period").val(<%=params[:period]%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var to = $('#to').val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
// console.log(check_arr.length)
if(check_arr.length == 1){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
*/

View File

@@ -1,13 +1,13 @@
class Crm::HomeController < BaseCrmController
def index
@booking = Booking.all
@customer = Customer.all
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
# redirect_to crm_customers_path
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
@booking = Booking.all
@customer = Customer.all
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
redirect_to crm_customers_path
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
end

View File

@@ -42,9 +42,12 @@ class HomeController < ApplicationController
elsif @employee.role == "manager"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
elsif @employee.role == "accountant"
elsif @employee.role == "supervisour"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
redirect_to origami_root_path
elsif @employee.role == "account"
session[:session_token] = @employee.token_session
redirect_to reports_dailysale_index_path
else
render :index
end
@@ -96,12 +99,15 @@ class HomeController < ApplicationController
redirect_to new_origami_shift_path
end
elsif employee.role == "manager"
redirect_to oqs_root_path
redirect_to dashboard_path
elsif employee.role == "waiter"
redirect_to oqs_root_path
elsif employee.role == "crm"
redirect_to crm_root_path
elsif @employee.role == "supervisour"
redirect_to origami_root_path
elsif @employee.role == "account"
redirect_to reports_dailysale_index_path
end
end
end

View File

@@ -104,7 +104,7 @@ class Ability
can :manage, DiningQueue
elsif user.role == "accountant"
elsif user.role == "account"
can :index, :dailysale
can :index, :saleitem
@@ -113,11 +113,19 @@ class Ability
elsif user.role == "supervisour"
can :index, :dailysale
can :index, :saleitem
can :index, :receipt_no
can :index, :shiftsale
can :edit, :sale_edit
can :item_void, :sale_edit
can :item_edit, :sale_edit
can :item_void_cancel, :sale_edit
can :cancel_all_void, :sale_edit
can :apply_void, :sale_edit
can :overall_void, :void
can :first_bill, :payment
can :create, :payment
can :show, :payment
can :reprint, :payment
can :rounding_adj, :payment
end
end

View File

@@ -6,7 +6,7 @@ class OrderItemPdf < Prawn::Document
self.page_height = 1450
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 35
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
@@ -80,7 +80,7 @@ class OrderItemPdf < Prawn::Document
text "#{order_item.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
bounding_box([self.item_width-4,y_position], :width => self.qty_width) do
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end

View File

@@ -68,8 +68,8 @@ class OrderSummaryPdf < Prawn::Document
text "Item", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width-2,y_position], :width => self.qty_width, :height => self.item_height) do
text "Qty", :size => self.item_font_size,:align => :left
bounding_box([self.item_width-4,y_position], :width => self.qty_width, :height => self.item_height) do
text "Qty", :size => self.item_font_size,:align => :right
end
stroke_horizontal_rule
@@ -96,8 +96,8 @@ class OrderSummaryPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
bounding_box([self.item_width-4,y_position], :width => self.qty_width) do
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :right
end
bounding_box([0,y_position], :width => self.item_width) do

View File

@@ -24,8 +24,8 @@
</div>
</div> -->
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="card-deck">
<div class="col-md-8 col-lg-8">
<div class="card-columns">
<% @employees.each do |employee| %>
@@ -43,11 +43,111 @@
</div>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<div class="col-md-4 col-lg-4" >
<div class="card" style="max-height:550px; overflow:auto;padding: 15px">
<!-- <p><strong>Note:</strong> The <strong>data-parent</strong> attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.</p> -->
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#admin">Administrator <span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="admin" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="">
<li class="">All Accept</li>
</ul>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#manager">Manager <span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="manager" class="panel-collapse collapse">
<div class="panel-body">
<ul class="">
<li class="">All Accept except Membership and Payment Settings</li>
</ul>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#supervisor">Supervisor <span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="supervisor" class="panel-collapse collapse">
<div class="panel-body">
<ul class="">
<li class="">Void</li>
<li class="">FOC</li>
<li class="">Edit</li>
<li class="">Credit </li>
<li class="">and Payment </li>
</ul>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#cashier">Cashier <span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="cashier" class="panel-collapse collapse">
<div class="panel-body">
<ul class="">
<li class="">Orgami Panel except Edit and Void</li>
<li class="">Sale and Order </li>
<li class="">and Queue in CRM</li>
</ul>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#accountant">Accountant <span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="accountant" class="panel-collapse collapse">
<div class="panel-body">
<ul class="">
<li class="">Daily Sale Report</li>
<li class="">Sale Item Report</li>
<li class="">Receipt No Report</li>
<li class="">ShiftSale Report</li>
</ul>
</div>
</div>
</div>
</div> <!-- end accordion id -->
</div>
</div> <!-- end col-md-4 -->
</div>
<style type="text/css">
.panel-body {
padding: 5px !important;
}
.card-columns {
column-count: 5;
}
.panel-title .glyphicon {
float: right;
}
</style>
<script type="text/javascript">
$(document).on('turbolinks:load', function() {
$(".empBtn").click(function(event){
@@ -57,5 +157,24 @@ $(document).on('turbolinks:load', function() {
$(item).submit();
});
// Add minus icon for collapse element which is open by default
$(".collapse.in").each(function(){
$(this).siblings(".panel-heading").find(".glyphicon").addClass("glyphicon-minus").removeClass("glyphicon-plus");
});
// Toggle plus minus icon on show hide of collapse element
$(".collapse").on('show.bs.collapse', function(){
$(this).parent().find(".glyphicon").removeClass("glyphicon-plus").addClass("glyphicon-minus");
}).on('hide.bs.collapse', function(){
$(this).parent().find(".glyphicon").removeClass("glyphicon-minus").addClass("glyphicon-plus");
});
});
</script>