merge with august spring

This commit is contained in:
Yan
2017-08-28 18:33:49 +06:30
50 changed files with 1677 additions and 976 deletions

View File

@@ -64,6 +64,7 @@
<orderEntry type="library" scope="PROVIDED" name="httparty (v0.15.5, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.8.6, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jbuilder (v2.7.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-datatables-rails (v3.4.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-datetimepicker-rails (v2.4.1.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-rails (v4.3.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-ui-rails (v6.0.1, rbenv: 2.3.3) [gem]" level="application" />

1323
.idea/workspace.xml generated

File diff suppressed because it is too large Load Diff

View File

@@ -53,6 +53,7 @@ gem 'to_xls-rails'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-datatables-rails', '~> 3.4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

View File

@@ -89,6 +89,11 @@ GEM
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-datatables-rails (3.4.0)
actionpack (>= 3.1)
jquery-rails
railties (>= 3.1)
sass-rails
jquery-datetimepicker-rails (2.4.1.0)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
@@ -266,6 +271,7 @@ DEPENDENCIES
font-awesome-rails
httparty (~> 0.15.5)
jbuilder (~> 2.5)
jquery-datatables-rails (~> 3.4.0)
jquery-datetimepicker-rails
jquery-rails
jquery-ui-rails

View File

@@ -21,6 +21,7 @@
//= require jquery-ui
//= require bootstrap-datepicker
//= require jquery.datetimepicker
//= require dataTables/jquery.dataTables
$(document).on('turbolinks:load', function() {
$('.datepicker').datepicker({

View File

@@ -5,6 +5,7 @@
@import "jquery-ui";
@import "bootstrap-datepicker3";
@import "jquery.datetimepicker";
@import "dataTables/jquery.dataTables";
/* Show it is fixed to the top */
// body {

View File

@@ -60,4 +60,31 @@ ul.dropdown-menu li a{
.padding-10 {
padding: 10px;
}
}
/* Colors */
.purple {
background-color:#7a62d3;
}
.orange{
background-color:#FF7F50;
}
.red {
background-color:#ff0000;
}
.green{
background-color: #009900;
}
.orange{
background-color: #FF8C00;
}
.blue{
background-color: blue;
}
/* End Colors */

View File

@@ -1,75 +0,0 @@
class Origami::CommissionersController < BaseOrigamiController
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
# GET /commissioners
# GET /commissioners.json
def index
@commissioners = Commissioner.all.order("id asc")
end
# GET /commissioners/1
# GET /commissioners/1.json
def show
end
# GET /commissioners/new
def new
@commissioner = Commissioner.new
@employee = Employee.all.order('name asc')
end
# GET /commissioners/1/edit
def edit
end
# POST /commissioners
# POST /commissioners.json
def create
@commissioner = Commissioner.new(commissioner_params)
@commissioner.created_by = current_user.id
respond_to do |format|
if @commissioner.save
format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully created.' }
format.json { render :show, status: :created, location: @commissioner }
else
format.html { render :new }
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /commissioners/1
# PATCH/PUT /commissioners/1.json
def update
respond_to do |format|
if @commissioner.update(commissioner_params)
format.html { redirect_to origami_commissioner_path(@commissioner) , notice: 'Commissioner was successfully updated.' }
format.json { render :show, status: :ok, location: @commissioner }
else
format.html { render :edit }
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
end
end
end
# DELETE /commissioners/1
# DELETE /commissioners/1.json
def destroy
@commissioner.destroy
respond_to do |format|
format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commissioner
@commissioner = Commissioner.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def commissioner_params
params.require(:commissioner).permit(:name,:emp_id,:created_by,:commission_type, :is_active)
end
end

View File

@@ -8,9 +8,10 @@ class Origami::InJutiesController < BaseOrigamiController
end
def index_in_juty
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
@juty_in= InJuty.where("dinning_id=?",params[:table_id])
@table = DiningFacility.find(params[:table_id])
@in_juty = InJuty.new
@juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10)
end
# GET /in_juties/1
@@ -31,6 +32,9 @@ class Origami::InJutiesController < BaseOrigamiController
def edit_in_juty
@in_juty = InJuty.find(params[:id])
@table = DiningFacility.find(params[:table_id])
@commissioner = @in_juty.commissioner
render json: {in_juty: @in_juty, commissioner: @commissioner}
end
def assign_in_juty
@@ -89,12 +93,19 @@ class Origami::InJutiesController < BaseOrigamiController
end
def update_for_in_juty
@in_juty.dinning_id = params[:dining_id]
@in_juty.commissioner_ids = params[:commissioner_ids]
@in_juty.in_time = params[:in_time]
@in_juty.out_time = params[:out_time]
@in_juty.save
def update_for_in_juty
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
@in_juty.in_time = in_juty_params[:in_time]
@in_juty.out_time = in_juty_params[:out_time]
respond_to do |format|
if @in_juty.save
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# DELETE /in_juties/1
@@ -125,6 +136,6 @@ class Origami::InJutiesController < BaseOrigamiController
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time)
params.require(:in_juty).permit(:id,:dinning_id,:commissioner_ids,:in_time,:out_time)
end
end

View File

@@ -62,15 +62,16 @@ class Origami::ProductCommissionsController < ApplicationController
end
def set_commissioner_to_sale_item
# byebug
deselect = false
sale_item_id = params[:sale_item_id]
commissioner_id = params[:commissioner_id]
@sale_item = SaleItem.find(sale_item_id)
@menu_item = MenuItem.find_by_item_code(@sale_item.product_code)
@commission = Commission.where('product_id = ? AND is_active = ?', @menu_item.id, true).take
@commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.id, true).take
@commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take
@product_commission = ProductCommission.where('sale_item_id = ?', @sale_item.id).take
# byebug
if !@product_commission.nil?
if @product_commission.commissioner_id == @commissioner.id
@product_commission.destroy
@@ -81,7 +82,8 @@ class Origami::ProductCommissionsController < ApplicationController
end
else
@product_commission = ProductCommission.new
@product_commission.product_id = @menu_item.id
@product_commission.product_code = @menu_item.id
@product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type
unless @commission.nil?
@product_commission.commission_id = @commission.id
if @commission.commission_type == 'Percentage'

View File

@@ -0,0 +1,50 @@
class Reports::CommissionController < BaseReportController
# authorize_resource :class => false
def index
from, to = get_date_range_from_params
@shift = ''
if params[:shift_name].to_i != 0
@shift = ShiftSale.find(params[:shift_name])
end
@sale_data = Sale.get_by_shiftsales(from,to,@shift)
@from = from
@to = to
if @shift.present?
@shift_from = @shift.shift_started_at.nil? ? '-' : @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = @shift
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -0,0 +1,93 @@
class Settings::CommissionersController < ApplicationController
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
# GET /commissioners
# GET /commissioners.json
def index
@commissioners = Commissioner.all.order("id asc")
end
# GET /commissioners/1
# GET /commissioners/1.json
def show
end
# GET /commissioners/new
def new
@commissioner = Commissioner.new
@employee = Employee.all.order('name asc')
end
# GET /commissioners/1/edit
def edit
end
# POST /commissioners
# POST /commissioners.json
def create
@commissioner = Commissioner.new(commissioner_params)
@commissioner.created_by = current_user.id
unless @commissioner.joined_date.nil?
@commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d')
end
unless @commissioner.resigned_date.nil?
@commissioner.resigned_date = @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d')
end
respond_to do |format|
if @commissioner.save
format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully created.'}
format.json {render :show, status: :created, location: @commissioner}
else
format.html {render :new}
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
end
end
end
# PATCH/PUT /commissioners/1
# PATCH/PUT /commissioners/1.json
def update
respond_to do |format|
if @commissioner.update(commissioner_params)
format.html {redirect_to settings_commissioner_path(@commissioner), notice: 'Commissioner was successfully updated.'}
format.json {render :show, status: :ok, location: @commissioner}
else
format.html {render :edit}
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
end
end
end
# DELETE /commissioners/1
# DELETE /commissioners/1.json
def destroy
@commissioner.destroy
respond_to do |format|
format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully destroyed.'}
format.json {head :no_content}
end
end
def get_transaction_by_commissioner
commissioner_id = params[:commissioner_id]
@transactions = []
@product_commissions = ProductCommission.where(commissioner_id: commissioner_id).order('updated_at desc')
@product_commissions.each_with_index do |p, i|
@transactions[i] = []
@transactions[i] << p
@transactions[i] << p.commission.menu_item.name
end
render json: @transactions
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commissioner
@commissioner = Commissioner.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def commissioner_params
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active)
end
end

View File

@@ -1,4 +1,4 @@
class Origami::CommissionsController < BaseOrigamiController
class Settings::CommissionsController < ApplicationController
before_action :set_commission, only: [:show, :edit, :update, :destroy]
# GET /commissions
@@ -27,10 +27,11 @@ class Origami::CommissionsController < BaseOrigamiController
# POST /commissions.json
def create
@commission = Commission.new(commission_params)
@commission.product_type = 'menu_item'
respond_to do |format|
if @commission.save
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully created.'}
format.html {redirect_to settings_commissions_path, notice: 'Commission was successfully created.'}
format.json {render :show, status: :created, location: @commission}
else
format.html {render :new}
@@ -44,7 +45,7 @@ class Origami::CommissionsController < BaseOrigamiController
def update
respond_to do |format|
if @commission.update(commission_params)
format.html {redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.'}
format.html {redirect_to settings_commission_path(@commission), notice: 'Commission was successfully updated.'}
format.json {render :show, status: :ok, location: @commission}
else
format.html {render :edit}
@@ -58,7 +59,7 @@ class Origami::CommissionsController < BaseOrigamiController
def destroy
@commission.destroy
respond_to do |format|
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.'}
format.html {redirect_to settings_commissions_path, notice: 'Commission was successfully destroyed.'}
format.json {head :no_content}
end
end
@@ -96,6 +97,6 @@ class Origami::CommissionsController < BaseOrigamiController
# Never trust parameters from the scary internet, only allow the white list through.
def commission_params
params.require(:commission).permit(:product_id, :amount, :commission_type, :is_active)
params.require(:commission).permit(:product_type, :product_code, :amount, :commission_type, :is_active)
end
end

View File

@@ -1,5 +1,16 @@
class Commission < ApplicationRecord
belongs_to :menu_item, foreign_key: 'product_id'
self.primary_key = 'commission_id'
# primary key - need to be unique
before_create :generate_custom_id
belongs_to :menu_item, foreign_key: 'product_code'
has_many :commissioners
has_many :product_commissions
private
def generate_custom_id
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
end
end

View File

@@ -1,6 +1,6 @@
class Commissioner < ApplicationRecord
belongs_to :employee, foreign_key: 'emp_id'
belongs_to :commission, foreign_key: 'commission_type'
belongs_to :commission, foreign_key: 'commission_id'
has_many :in_juties
has_many :product_commissions
scope :active, -> { where(is_active: true) }

View File

@@ -5,7 +5,5 @@ class ProductCommission < ApplicationRecord
belongs_to :sale_item, foreign_key: 'sale_item_id'
belongs_to :sale, foreign_key: 'sale_id'
def self.check_product_commission(sale_item_id)
end
end

View File

@@ -69,7 +69,7 @@ class Promotion < ApplicationRecord
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, sale_id)
elsif promo.promo_type == Promotion::PROMO_TYPE4
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, sale_id)
give_promotion_discount(same,promo_product,promo.min_qty, orderitem, sale_id)
end
end
@@ -138,8 +138,8 @@ class Promotion < ApplicationRecord
sale_item.remark = type
sale_item.qty = foc_qty * (-1)
sale_item.unit_price = item_price * (-1)
sale_item.taxable_price = item_price * (-1)
sale_item.unit_price = item_price # * (-1)
sale_item.taxable_price = item_price # * (-1)
sale_item.price = foc_qty * item_price * (-1)
sale_item.is_taxable = false
@@ -170,8 +170,8 @@ class Promotion < ApplicationRecord
if same
foc_qty = orderitem[1].to_i / foc_min_qty
item = OrderItem.find_by_item_code(orderitem[0])
price = item.price - promo_product.net_price
item = OrderItem.find_by_item_code(orderitem[0]) # need to specify with menu item instance
price = item.price.to_i - promo_product.net_price.to_i
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
else
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
@@ -187,13 +187,15 @@ class Promotion < ApplicationRecord
if same
foc_qty = orderitem[1].to_i / foc_min_qty
item = OrderItem.find_by_item_code(orderitem[0])
total = orderitem[1].to_i * item.price
# total = orderitem[1].to_i * item.price
total = item.price
price = calculate_discount(total, promo_product.percentage)
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
else
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
item = OrderItem.find_by_item_code(promo_product.item_code)
total = item.price * foc_qty
# total = item.price * foc_qty
total = item.price
price = calculate_discount(total, promo_product.percentage)
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
end

View File

@@ -28,8 +28,8 @@
<li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %></li>
<li><%= link_to "Commissions", origami_commissions_path , :tabindex =>"-1" %></li>
<li><%= link_to "Commissioners", origami_commissioners_path , :tabindex =>"-1" %></li>
<li><%= link_to "Commissions", settings_commissions_path , :tabindex =>"-1" %></li>
<li><%= link_to "Commissioners", settings_commissioners_path , :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
@@ -55,6 +55,7 @@
<li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Credit Sale Report", reports_credit_payment_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Void Sale Report", reports_void_sale_index_path, :tabindex =>"-1" %></li>
<!--<li><% link_to "Commission Report", reports_commission_index_path, :tabindex =>"-1" %></li>-->
</ul>
</li>
<li class="navbar-nav mr-auto">

View File

@@ -1,21 +0,0 @@
<div class="col-md-3">
<%= simple_form_for([:origami, @commissioner]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
<%= f.label :emp_id %>
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %><br/>
<%= f.label :commission_type %>
<%= f.select :commission_type, Commission.all.map{ |l| [l.menu_item.name, l.id] } %>
<br/>
<label><%= f.check_box :is_active %> Active </label>
</div><br/>
<div class="form-actions">
<%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-info' %>
</div>
<% end %>
</div>

View File

@@ -1,47 +0,0 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
<span style="float: right">
</span>
</ul>
</div>
<div class="card">
<div class="card-block">
<h4 class="card-title">Commissioner</h4>
<table class="table">
<tbody>
<tr>
<td style="width:20%">Name</td>
<td><%= @commissioner.name %></td>
</tr>
<tr>
<td style="width:20%">Employee Name</td>
<td>
<%= @commissioner.employee.name rescue '-' %>
</td>
</tr>
<tr>
<td style="width:20%">Commission Type</td>
<td><%= @commissioner.commission.menu_item.name rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Active</td>
<td><%= @commissioner.is_active %></td>
</tr>
<tr>
<td style="width:20%">Created By</td>
<td><%= Employee.find(@commissioner.created_by).name %></td>
</tr>
</tbody>
</table>
<%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_origami_commissioner_path(@commissioner), class: 'btn btn-info' %>
<%= link_to 'Destroy', origami_commissioner_path(@commissioner), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
</div>
</div>
</div>

View File

@@ -1,9 +1,12 @@
<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :method => :post do |f| %>
<%= simple_form_for @in_juty,:url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-inputs">
<%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
<label>Dining Name:</label>
<%= @table.name %>
<br/>
@@ -12,14 +15,14 @@
<label>Commissioner Name:</label>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
<label>In time</label>
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
<%= f.text_field :in_time, :value=>'',:class=>"form-control datepicker"%><br/>
<label>Out time</label>
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
<%= f.text_field :out_time, :value=>'',:class=>"form-control datepicker"%>
</div><br>
<div class="form-group">
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update' %>
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
</div>
@@ -30,11 +33,18 @@
$(function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
format : 'yyyy-mm-dd',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
});
$('#reset').click(function() {
// window.location.href = '/origami/assign_in_juty/'+ table_id;
location.reload();
return false;
});
</script>

View File

@@ -2,8 +2,7 @@
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :dinning_id %>
<%= f.input :commissioner_ids %>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
<%= f.input :in_time %>
<%= f.input :out_time %>
</div>

View File

@@ -4,6 +4,7 @@
<table class="table table-striped">
<thead>
<tr>
<th>Select</th>
<th>Dining Facility Name</th>
<th>Commissioner Ids</th>
<th>In time</th>
@@ -21,13 +22,12 @@
<td><%= in_juty.commissioner.name rescue '-' %></td>
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Back', origami_path(in_juty.dining_facility.id) %></td>
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty.dining_facility.id,in_juty) %></td>
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id,in_juty),method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @juties_in %>
</div>
<div class="col-md-4">
@@ -35,40 +35,45 @@
</div>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
</div>
<script type="text/javascript">
$(document).on('click',".injuty_tr",function(){
debugger;
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true );
var in_juty_id = $(this).attr('data-ref');
var table_id = "<%= @table.id %>";
var url = "/origami/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
var url = "/origami/assign_in_juty/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
// Selected for Taxes
$('#in_juty_commissioner_ids').val(data.commissioner.name);
$('#in_juty_in_time').val(data.in_time);
$('#in_juty_out_time').val(data.out_time);
$('#in_juty_id').val(data.in_juty.id);
$('#in_juty_commissioner_ids').val(data.commissioner.id);
$('#in_juty_in_time').val(data.in_juty.in_time.split('T')[0]);
$('#in_juty_out_time').val(data.in_juty.out_time.split('T')[0]);
$('#update').removeAttr('disabled');
$('#update').removeAttr('disabled').val('');
$('#update').attr('value', 'Update');
$('#create').attr('disabled','disabled');
$("#new_in_juty").attr('class', 'simple_form new_in_juty');
var id = customer_id;
$("#new_customer").attr('id', id);
$("#new_in_juty").attr('class', 'simple_form edit_in_juty');
var id = "edit_in_juty_" + in_juty_id;
$("#new_in_juty").attr('id', id);
$(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_in_juty").attr('id', id);
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
}
});
@@ -76,4 +81,9 @@ $(document).on('click',".injuty_tr",function(){
// }
})
$('#back').on('click', function () {
window.location.href = '/origami/table/'+ "<%= @table.id %>";
})
</script>

View File

@@ -0,0 +1,119 @@
<div class="row">
<div class="col-md-12">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="form-group col-md-2">
<label>Select Period</label>
<select name="period" id="sel_period" class="form-control">
<option value="0">Today</option>
<option value="1">Yesterday</option>
<option value="2">This week</option>
<option value="3">Last week</option>
<option value="4">Last 7 days</option>
<option value="5">This month</option>
<option value="6">Last month</option>
<option value="7">Last 30 days</option>
<option value="8">This year</option>
<option value="9">Last year</option>
</select>
</div>
<div class="form-group col-md-3">
<!-- <label class="">Select Shift Period</label> -->
<label class="">From</label>
<input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date">
</div>
<div class="form-group col-md-3">
<label class="">To</label>
<input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date">
</div>
<div class="form-group col-md-2">
<label class="">All Shift</label>
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="form-group col-md-2 margin-top-20">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<script type="text/javascript">
$(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
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")%> -<%= @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") %>'
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$("#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();
}
}
});
</script>

View File

@@ -0,0 +1,211 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Commission Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'commission_report_filter',
:locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_commission_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_commission_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<!-- <div class="span11">
<div id="report_container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</div> -->
<div class="card row">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
- To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
</th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th>Cashier Station</th>
<th>Cashier Name</th>
<th>Shift Name</th>
<!-- <th>Void Amount</th> -->
<th>Cash Payment</th>
<!-- <th>Credit Charges</th> -->
<th>Credit Payment</th>
<!-- <th>FOC Payment</th> -->
<th>Other Payment</th>
<!-- <th>Grand Total
<br/>Rounding Adj</th> -->
<!-- <th>Rounding Adj</th> -->
<th>Grand Total</th>
</tr>
</thead>
<tbody>
<% void = 0%>
<% cash = 0%>
<% credit = 0%>
<% accept_credit = 0%>
<% foc = 0%>
<% card = 0%>
<% total = 0%>
<% rounding_adj = 0%>
<% g_total = 0 %>
<% @sale_data.each do |result|%>
<tr>
<td>
<%= result.cashier_terminal.name rescue '-'%>
</td>
<td>
<%= result.employee.name rescue '-'%>
</td>
<td><%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.rounding_adj.to_f.to_d rescue '-'%></td> -->
<% grand_total = result.grand_total.to_f %>
<!-- <td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td> -->
</tr>
<% cash += result.cash_sales.to_f %>
<% credit += result.credit_sales.to_f %>
<% card += result.other_sales.to_f %>
<% total += result.grand_total.to_f %>
<% g_total += grand_total.to_f %>
<% end %>
<tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
<td><b><%= sprintf("%.2f",cash) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",credit) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(function(){
var check_arr = [];
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
show_shift_name(period,period_type,from,to,'shift_item');
}
$('#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){
show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
shift.empty();
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
str = '<option value="0">--- All Shift ---</option>';
$(data.message).each(function(index){
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
var shift_id = data.message[index].shift_id ;
if(param_shift != ''){
if(shift_id == param_shift){
selected = 'selected = "selected"';
}
else{
selected = '';
}
}else{
selected = '';
}
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
shift.append(str);
});
}
});
</script>

View File

@@ -0,0 +1,100 @@
<div class="container margin-top-20">
<!-- <div class="span11">
<div id="report_container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</div> -->
<div class="card row">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
- To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
</th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th>Cashier Station</th>
<th>Cashier Name</th>
<th>Shift Name</th>
<!-- <th>Void Amount</th> -->
<th>Cash Payment</th>
<!-- <th>Credit Charges</th> -->
<th>Credit Payment</th>
<!-- <th>FOC Payment</th> -->
<th>Other Payment</th>
<!-- <th>Grand Total
<br/>Rounding Adj</th> -->
<!-- <th>Rounding Adj</th> -->
<th>Grand Total</th>
</tr>
</thead>
<tbody>
<% void = 0%>
<% cash = 0%>
<% credit = 0%>
<% accept_credit = 0%>
<% foc = 0%>
<% card = 0%>
<% total = 0%>
<% rounding_adj = 0%>
<% g_total = 0 %>
<% @sale_data.each do |result|%>
<tr>
<td>
<%= result.cashier_terminal.name rescue '-'%>
</td>
<td>
<%= result.employee.name rescue '-'%>
</td>
<td><%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.rounding_adj.to_f.to_d rescue '-'%></td> -->
<% grand_total = result.grand_total.to_f %>
<!-- <td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td> -->
</tr>
<% cash += result.cash_sales.to_f %>
<% credit += result.credit_sales.to_f %>
<% card += result.other_sales.to_f %>
<% total += result.grand_total.to_f %>
<% g_total += grand_total.to_f %>
<% end %>
<tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
<td><b><%= sprintf("%.2f",cash) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",credit) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -0,0 +1,42 @@
<div class="col-md-3">
<%= simple_form_for([:settings, @commissioner]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
<%= f.label :emp_id, 'Employee' %>
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %>
<br/>
<%= f.label :commission_id, 'Commission' %><br/>
<%= f.select :commission_id, Commission.all.map {|l| [l.menu_item.name, l.id]}, {prompt: 'Select a Product'}, {class: 'form-control'} %>
<br/>
<%= f.label :joined_date %><br/>
<%= f.text_field :joined_date, {class: 'form-control', id: 'joined_date', readonly: true} %><br/>
<%= f.label :resigned_date %><br/>
<%= f.text_field :resigned_date, {class: 'form-control', id: 'resigned_date', readonly: true} %><br/>
<label><%= f.check_box :is_active %> Active </label>
</div>
<br/>
<div class="form-actions">
<%= link_to 'Back', settings_commissioners_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-info' %>
</div>
<% end %>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#joined_date').datepicker({
format: 'yyyy-mm-dd',
autoclose: true
});
$('#resigned_date').datepicker({
format: 'yyyy-mm-dd',
autoclose: true
});
});
</script>

View File

@@ -1,8 +1,8 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
<li><a href="<%= settings_commissioners_path %>">Home</a></li>
<li><a href="<%= settings_commissioners_path %>">Commissioners</a></li>
<li>Edit</li>
</ul>
</div>

View File

@@ -1,9 +1,9 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= settings_commissioners_path %>">Home</a></li>
<li>Commissioner</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commissioner_path, :class => 'btn btn-primary btn-sm' %>
<%= link_to t('.new', :default => t("helpers.links.new")), new_settings_commissioner_path, :class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
@@ -16,8 +16,10 @@
<th>Name</th>
<th>Employee Name</th>
<th>Commission type</th>
<th>Joined Date</th>
<th>Resigned Date</th>
<th>Active</th>
<th colspan="3"></th>
<th colspan="4"></th>
</tr>
</thead>
@@ -29,10 +31,12 @@
<%= commissioner.employee.name rescue '-' %>
</td>
<td><%= commissioner.commission.menu_item.name rescue '-' %></td>
<td><%= commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
<td><%= commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
<td><%= commissioner.is_active %></td>
<td><%= link_to 'Show', origami_commissioner_path(commissioner) %></td>
<td><%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %></td>
<td><%= link_to 'Destroy', origami_commissioner_path(commissioner), method: :delete, data: {confirm: 'Are you sure?'} %></td>
<td><%= link_to 'Show', settings_commissioner_path(commissioner) %></td>
<td><%= link_to 'Edit', edit_settings_commissioner_path(commissioner) %></td>
<td><%= link_to 'Destroy', settings_commissioner_path(commissioner), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>

View File

@@ -1,8 +1,8 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
<li><a href="<%= settings_commissioners_path %>">Home</a></li>
<li><a href="<%= settings_commissioners_path %>">Commissioners</a></li>
<li>New</li>
</ul>
</div>

View File

@@ -0,0 +1,132 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= settings_commissioner_path %>">Home</a></li>
<li><a href="<%= settings_commissioner_path %>">Commissioners</a></li>
<span style="float: right">
</span>
</ul>
</div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#info" role="tab">Info</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#transaction" id="transaction_tab" role="tab">Transaction</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content">
<!--- Panel 0 - Info -->
<div class="tab-pane active" id="info" role="tabpanel" style="max-height:670px; overflow:auto">
<div class="card">
<div class="card-block">
<table class="table">
<tbody>
<tr>
<td style="width:20%">Name</td>
<td><%= @commissioner.name %></td>
</tr>
<tr>
<td style="width:20%">Employee Name</td>
<td><%= @commissioner.employee.name rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Commission Type</td>
<td><%= @commissioner.commission.menu_item.name rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Joined Date</td>
<td><%= @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Resigned Date</td>
<td><%= @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Active</td>
<td><%= @commissioner.is_active %></td>
</tr>
<tr>
<td style="width:20%">Created By</td>
<td><%= Employee.find(@commissioner.created_by).name %></td>
</tr>
</tbody>
</table>
<%= link_to 'Back', settings_commissioners_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_settings_commissioner_path(@commissioner), class: 'btn btn-info' %>
<%= link_to 'Destroy', settings_commissioner_path(@commissioner), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
</div>
</div>
</div>
<!--- Panel 1 - Transaction -->
<div class="tab-pane" id="transaction" role="tabpanel" style="max-height:670px; overflow:auto">
<div class="card">
<div class="card-block">
<table class="table" id="myTable">
<thead>
<tr>
<th><%= 'Product Type' %></th>
<th><%= 'Product Name' %></th>
<th><%= 'Qty' %></th>
<th><%= 'Price' %></th>
<th><%= 'Amount' %></th>
<th><%= 'Date' %></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<br/>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#transaction_tab").click(function () {
get_transaction();
});
function get_transaction() {
var commissioner_id = <%= @commissioner.id %>
paramlist = 'commissioner_id=' + commissioner_id ;
$.ajax({
type: 'GET',
url: '<%= settings_get_transaction_by_commissioner_path() %>',
data: paramlist,
success: function (data) {
// $('#myTable').DataTable().destroy();
$('#myTable tbody > tr').remove();
$.each(data, function (i, item) {
tr = "<tr>" + "<td>" + data[i][0].product_type + "</td>" + "<td>" + data[i][1] + "</td>" + "<td>" + data[i][0].qty + "</td>" + "<td>" + data[i][0].price + "</td>" + "<td>" + data[i][0].amount + "</td>" + "<td>" + new Date(data[i][0].updated_at).toISOString().split('T')[0] + "</td>" + "</tr>";
$('#myTable tbody').append(tr);
});
// $('#myTable').DataTable({
// data: data,
// columns: [
// {data: 'product_type'},
// {data: 'product_code'},
// {data: 'commission_id'},
// {data: 'qty'},
// {data: 'price'},
// {data: 'amount'}
// ],
// "order": [[0, "desc"]]
// });
}
});
}
});
</script>

View File

@@ -1,17 +1,17 @@
<div class="col-md-3">
<%= simple_form_for([:origami,@commission]) do |f| %>
<%= simple_form_for([:settings,@commission]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.label :product_id %>
<%= f.collection_select :product_id, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<%= f.input :amount %>
<%= f.label :product_code, 'Product' %>
<%= f.collection_select :product_code, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
<%= f.input :amount %>
<label><%= f.check_box :is_active %> Active </label>
</div><br>
<div class="form-actions">
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
<%= link_to 'Back', settings_commissions_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-info' %>
</div>
<% end %>

View File

@@ -1,8 +1,8 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
<li><a href="<%= settings_commissions_path %>">Home</a></li>
<li><a href="<%= settings_commissions_path %>">Commissions</a></li>
<li>Edit</li>
</ul>
</div>

View File

@@ -1,9 +1,9 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= settings_commissions_path %>">Home</a></li>
<li>Commissions</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path, :class => 'btn btn-primary btn-sm' %>
<%= link_to t('.new', :default => t("helpers.links.new")), new_settings_commission_path, :class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
@@ -14,8 +14,8 @@
<thead>
<tr>
<th>Product Name</th>
<th>Commission Type</th>
<th>Amount</th>
<th>Commission type</th>
<th>Active</th>
<th colspan="3"></th>
</tr>
@@ -25,12 +25,12 @@
<% @commissions.each do |commission| %>
<tr>
<td><%= commission.menu_item.name rescue '-' %></td>
<td><%= commission.amount rescue '-' %></td>
<td><%= commission.commission_type rescue '-' %></td>
<td><%= commission.amount rescue '-' %></td>
<td><%= commission.is_active rescue '-' %></td>
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %></td>
<td><%= link_to 'Show', settings_commissions_path(commission) %></td>
<td><%= link_to 'Edit', edit_settings_commission_path(commission) %></td>
<td><%= link_to 'Destroy', settings_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>

View File

@@ -1,8 +1,8 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
<li><a href="<%= settings_commissions_path %>">Home</a></li>
<li><a href="<%= settings_commissions_path %>">Commissions</a></li>
<li>New</li>
</ul>
</div>

View File

@@ -2,8 +2,8 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
<li><a href="<%= settings_commissions_path %>">Home</a></li>
<li><a href="<%= settings_commissions_path %>">Commissions</a></li>
<span style="float: right">
</span>
@@ -32,9 +32,9 @@
</tr>
</tbody>
</table>
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_origami_commission_path(@commission), class: 'btn btn-info' %>
<%= link_to 'Destroy', origami_commission_path(@commission), method: :delete, class: 'btn btn-danger', data: {confirm: 'Are you sure?'} %>
<%= link_to 'Back', settings_commissions_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_settings_commission_path(@commission), class: 'btn btn-info' %>
<%= link_to 'Destroy', settings_commissions_path(@commission), method: :delete, class: 'btn btn-danger', data: {confirm: 'Are you sure?'} %>
</div>
</div>

View File

@@ -11,10 +11,10 @@ Rails.application.routes.draw do
#--------- SmartSales Installation ------------#
get 'install' => 'install#index'
post 'install' => 'install#create'
post 'install' => 'install#create'
#--------- Login/Authentication ------------#
get 'auth/:emp_id' => 'home#show' , as: :emp_login
get 'auth/:emp_id' => 'home#show', as: :emp_login
patch "auth/:emp_id" => 'home#update', as: :emp_login_update
post 'login' => 'home#create'
@@ -23,14 +23,14 @@ Rails.application.routes.draw do
#--------- API Routes ------------#
namespace :api, :defaults => { :format => 'json' } do
namespace :api, :defaults => {:format => 'json'} do
#Session Login and Logout
post 'authenticate' => "authenticate#create"
post 'authenticate' => "authenticate#create"
delete 'authenticate' => "authenticate#destroy"
namespace :restaurant do
get 'zones' => "zones#index"
resources :menu, only:[:index, :show]
resources :menu, only: [:index, :show]
resources :menu_categories, only: [:index, :show]
resources :menu_items, only: [:index, :show]
resources :menu_item_attributes, only: [:index]
@@ -57,10 +57,10 @@ Rails.application.routes.draw do
get "customers/get_order/:id" => "customers#get_customer_order"
#Generating Invoice and making payments - output render @sale
resources :invoices, only: [:index, :show, :create, :update, :destroy ] do
resources :sale_items, only:[:create, :update, :destroy]
resources :invoices, only: [:index, :show, :create, :update, :destroy] do
resources :sale_items, only: [:create, :update, :destroy]
resources :discounts, only: [:create, :update, :destroy]
resources :memberships, only:[:create]
resources :memberships, only: [:create]
post "payment/:payment_method" => "payment#create"
put "payment/:id" => "payment#update"
resources :receipt, only: [:create, :show] #generate receipt, show receipt
@@ -72,8 +72,8 @@ Rails.application.routes.draw do
#--------- Cashier ------------#
namespace :origami do
resources :cash_ins, only:[:new, :create]
resources :cash_outs, only:[:new, :create]
resources :cash_ins, only: [:new, :create]
resources :cash_outs, only: [:new, :create]
root "home#index"
get "table/:dining_id" => "home#show" do #origami/:booking_id will show
# resources :discounts, only: [:index,:new, :create ] #add discount type
@@ -87,17 +87,13 @@ Rails.application.routes.draw do
post 'item_void_cancel' => "sale_edit#item_void_cancel"
post 'cancel_all_void' => 'sale_edit#cancel_all_void'
post 'apply_void' => 'sale_edit#apply_void'
# commissions
get '/table/:table_id/sale/:sale_id/load_commissioners' => 'commissions#load_commissioners', as: 'load_commissioners'
post 'select_sale_item' => 'commissions#select_sale_item'
# product_commission
post 'select_commissioner' => 'product_commissions#set_commissioner_to_sale_item'
# in_juties
get '/table/:table_id/assign_in_juty' => 'in_juties#assign_in_juty', as: 'assign_in_juty'
post 'assign_in_juty' => 'in_juties#create_for_in_juty', as: 'create_for_in_juty'
get 'assign_in_juty/:table_id' => 'in_juties#index_in_juty', as: 'index_in_juty'
get 'table/:table_id/in_juty/:id/edit' => 'in_juties#edit_in_juty' ,as: 'edit_in_juty'
put '/edit_in_juty/:id' => 'in_juties#update_for_in_juty', as: 'update_for_in_juty'
post 'assign_in_juty/:table_id' => 'in_juties#create_for_in_juty'
get 'assign_in_juty/table/:table_id/in_juty/:id/edit' => 'in_juties#edit_in_juty' ,as: 'edit_in_juty'
patch 'edit_in_juty/:id' => 'in_juties#update_for_in_juty', as: 'update_for_in_juty'
delete 'table/:table_id/destroy_in_juty/:id' => 'in_juties#destroy_in_juty', as: 'destroy_in_juty'
get 'table/:dining_id/movetable' => "movetable#move_dining"
@@ -122,8 +118,8 @@ Rails.application.routes.draw do
# Discount for Member
post "/:id/member_discount" => "discounts#member_discount"
get "/:id/request_bills" => "request_bills#print",:as => "request_bill"
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
get "/:id/request_bills" => "request_bills#print", :as => "request_bill"
get '/:sale_id/reprint' => 'payments#reprint', :defaults => {:format => 'json'}
#---------Shift ---------------#
resources :shifts, only: [:index, :new, :create, :edit]
@@ -141,11 +137,11 @@ Rails.application.routes.draw do
#payment - Outing payments - Cash only [ *Misc expeness tracking]
#--------- Payment ------------#
post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj',:as => "calculate_rouding_adjs"
get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' }
post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj', :as => "calculate_rouding_adjs"
get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => {:format => 'json'}
get 'sale/:sale_id/payment' => 'payments#show'
post 'payment/foc' => 'payments#foc', :defaults => { :format => 'json' }
post 'payment/foc' => 'payments#foc', :defaults => {:format => 'json'}
post 'payment/cash' => 'payments#create'
post 'payment/mpu' => "mpu#create"
post 'payment/jcb' => "jcb#create"
@@ -168,16 +164,16 @@ Rails.application.routes.draw do
post 'sale/:sale_id/void' => 'void#overall_void'
#---------Multiple Invoices --------------#
get 'table/:table_id/table_invoices' => "table_invoices#index" , :as => "table_invoice_index"
get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show" , :as => "table_invoice_show"
get 'room/:room_id/room_invoices' => "room_invoices#index" , :as => "room_invoice_index"
get 'room/:room_id/room_invoice/:invoice_id' => "room_invoices#show" , :as => "room_invoice_show"
get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index"
get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show", :as => "table_invoice_show"
get 'room/:room_id/room_invoices' => "room_invoices#index", :as => "room_invoice_index"
get 'room/:room_id/room_invoice/:invoice_id' => "room_invoices#show", :as => "room_invoice_show"
#---------Add Customer --------------#
#resources :customers
get '/:sale_id/customers', to: "customers#add_customer"
get '/:customer_id/get_customer' => 'home#get_customer',:as => "show_customer_details"
post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer" # update customer id in sale table
get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details"
post '/:sale_id/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table
post '/:sale_id/get_customer' => "customers#get_customer"
@@ -186,27 +182,28 @@ Rails.application.routes.draw do
resources :commissions
resources :commissioners
resources :in_juties
end
#--------- Waiter/Ordering Station ------------#
namespace :oishi do
#zones
#tables
#orders
#zones
#tables
#orders
end
#--------- Customer Relationship Management ------------#
namespace :crm do
root "home#index"
resources :customers
resources :dining_queues
post "update_booking" , to: "bookings#update_booking", as: "update_booking"#assign and cancel
get '/print/:id', to: "home#print_order"#print order for crm
root "home#index"
resources :customers
resources :dining_queues
post "update_booking", to: "bookings#update_booking", as: "update_booking" #assign and cancel
get '/print/:id', to: "home#print_order" #print order for crm
get "/dining_queues/:id/assign" =>"dining_queues#assign", :as => "assign"
post "/dining_queues/assign_table" =>"dining_queues#assign_table", :as => "assign_table"
post "/dining_queues/cancel_queue" =>"dining_queues#cancel_queue", :as => "cancel_queue"
get "/dining_queues/:id/assign" => "dining_queues#assign", :as => "assign"
post "/dining_queues/assign_table" => "dining_queues#assign_table", :as => "assign_table"
post "/dining_queues/cancel_queue" => "dining_queues#cancel_queue", :as => "cancel_queue"
end
@@ -225,7 +222,7 @@ Rails.application.routes.draw do
get 'print/print/:id', to: "print#print"
get 'print/print_order_summary/:id', to: "print#print_order_summary"
get "/get_items/:id" =>"home#get_items_by_oqs", :as => "get_order_items_by_oqs"
get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs"
#dashboard
#
end
@@ -237,7 +234,7 @@ Rails.application.routes.draw do
#menu
resources :menus do
#menu_categories
resources :menu_categories, only: [:new, :create, :edit,:delete]
resources :menu_categories, only: [:new, :create, :edit, :delete]
end
resources :item_sets
@@ -301,16 +298,28 @@ Rails.application.routes.draw do
resources :promotion_products
end
# commission
resources :commissions
resources :commissioners
get '/get_transactions_by_commissioner' => 'commissioners#get_transaction_by_commissioner', as:'get_transaction_by_commissioner'
end
# commissions
get 'origami/table/:table_id/sale/:sale_id/load_commissioners' => 'settings/commissions#load_commissioners', as: 'load_commissioners'
post 'origami/select_sale_item' => 'settings/commissions#select_sale_item', as: 'select_sale_item'
# product_commission
post 'origami/select_commissioner' => 'origami/product_commissions#set_commissioner_to_sale_item', as: 'select_commissioner'
#--------- Transactions Sections ------------#
namespace :transactions do
resources :sales
resources :orders
resources :credit_notes
get "/sales/:sale_id/manual_complete_sale" =>"manual_sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" =>"manual_sales#void", :as => "void"
get "/sales/:sale_id/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" => "manual_sales#void", :as => "void"
post "sales/:sale_id/manual_void_sale", to: "manual_sales#manual_void_sale", :as => "manual_void_sale"
end
@@ -322,6 +331,7 @@ Rails.application.routes.draw do
resources :shiftsale, :only => [:index, :show]
resources :credit_payment, :only => [:index, :show]
resources :void_sale, :only => [:index, :show]
resources :commission, :only => [:index, :show]
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
end

View File

@@ -1,12 +0,0 @@
class CreateCommissioners < ActiveRecord::Migration[5.1]
def change
create_table :commissioners do |t|
t.string :name, :null => false
t.string :emp_id
t.string :created_by
t.string :commission_type
t.boolean :is_active
t.timestamps
end
end
end

View File

@@ -1,11 +0,0 @@
class CreateCommissions < ActiveRecord::Migration[5.1]
def change
create_table :commissions do |t|
t.integer :product_id, null: false
t.integer :amount
t.string :commission_type
t.boolean :is_active
t.timestamps
end
end
end

View File

@@ -1,16 +0,0 @@
class CreateProductCommissions < ActiveRecord::Migration[5.1]
# rake db:migrate:down VERSION=20170823034141
def change
create_table :product_commissions do |t|
t.string :product_id
t.integer :commission_id
t.integer :commissioner_id
t.decimal :qty, :precision => 10, :scale => 2, :default => 0.00
t.string :sale_id
t.string :sale_item_id
t.decimal :price, :precision => 10, :scale => 2, :default => 0.00
t.decimal :amount, :precision => 10, :scale => 2, :default => 0.00
t.timestamps
end
end
end

View File

@@ -0,0 +1,17 @@
class CreateProductCommissions < ActiveRecord::Migration[5.1]
# rake db:migrate:down VERSION=20170825034141
def change
create_table :product_commissions do |t|
t.string :product_type
t.string :product_code
t.string :commission_id
t.integer :commissioner_id
t.decimal :qty, precision: 10, scale: 2, default: 0.00
t.string :sale_id
t.string :sale_item_id
t.decimal :price, precision: 10, scale: 2, default: 0.00
t.decimal :amount, precision: 10, scale: 2, default: 0.00
t.timestamps
end
end
end

View File

@@ -0,0 +1,15 @@
class CreateCommissioners < ActiveRecord::Migration[5.1]
# rake db:migrate:down VERSION=20170825090115
def change
create_table :commissioners do |t|
t.string :name
t.string :emp_id
t.string :created_by
t.string :commission_id
t.datetime :joined_date
t.datetime :resigned_date
t.boolean :is_active, default: true
t.timestamps
end
end
end

View File

@@ -0,0 +1,15 @@
class CreateCommissions < ActiveRecord::Migration[5.1]
# rake db:migrate:down VERSION=20170825093252
def change
create_table :commissions, id: false do |t|
t.string :commission_id, limit: 16, primary_key: true # custom primary key
t.string :product_type
t.string :product_code
t.string :commission_type
t.integer :amount
t.boolean :is_active, default: true
t.timestamps
end
end
end