merge with august sprint for commission
This commit is contained in:
@@ -22,6 +22,12 @@
|
||||
//= require bootstrap-datepicker
|
||||
//= require jquery.datetimepicker
|
||||
//= require dataTables/jquery.dataTables
|
||||
//= require moment
|
||||
//= require daterangepicker
|
||||
//= require select2
|
||||
//= require bootstrap-datetimepicker
|
||||
//= require pickers
|
||||
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.datepicker').datepicker({
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//= require cable
|
||||
//= require jquery-ui
|
||||
//= require bootstrap-datepicker
|
||||
//= require jquery.datetimepicker
|
||||
|
||||
$(document).ready(function(){
|
||||
// auto refresh every 60 seconds
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
@import "bootstrap-datepicker3";
|
||||
@import "jquery.datetimepicker";
|
||||
@import "dataTables/jquery.dataTables";
|
||||
@import "daterangepicker-bs3";
|
||||
@import "select2";
|
||||
@import "bootstrap-datetimepicker";
|
||||
|
||||
/* Show it is fixed to the top */
|
||||
// body {
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
@import "jquery-ui";
|
||||
@import "bootstrap-datepicker3";
|
||||
|
||||
@import "jquery.datetimepicker";
|
||||
|
||||
/* Show it is fixed to the top */
|
||||
// body {
|
||||
// min-height: 75rem;
|
||||
|
||||
@@ -2,21 +2,14 @@ class Reports::CommissionController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
|
||||
def index
|
||||
from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
|
||||
to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
|
||||
commissioner = params[:commissioner].to_i
|
||||
@commissioner = Commissioner.active.all
|
||||
|
||||
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
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
||||
66
app/inputs/date_picker_input.rb
Normal file
66
app/inputs/date_picker_input.rb
Normal file
@@ -0,0 +1,66 @@
|
||||
class DatePickerInput < SimpleForm::Inputs::StringInput
|
||||
def input(wrapper_options)
|
||||
set_html_options
|
||||
set_value_html_option
|
||||
|
||||
template.content_tag :div, class: 'input-group date datetimepicker' do
|
||||
input = super(wrapper_options) # leave StringInput do the real rendering
|
||||
input + input_button
|
||||
end
|
||||
end
|
||||
|
||||
def input_html_classes
|
||||
super.push '' # 'form-control'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def input_button
|
||||
template.content_tag :span, class: 'input-group-btn' do
|
||||
template.content_tag :button, class: 'btn btn-default', type: 'button' do
|
||||
template.content_tag :span, '', class: 'fa fa-calendar'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_html_options
|
||||
input_html_options[:type] = 'text'
|
||||
input_html_options[:data] ||= {}
|
||||
input_html_options[:data].merge!(date_options: date_options)
|
||||
end
|
||||
|
||||
def set_value_html_option
|
||||
return unless value.present?
|
||||
input_html_options[:value] ||= I18n.localize(value, format: display_pattern)
|
||||
end
|
||||
|
||||
def value
|
||||
object.send(attribute_name) if object.respond_to? attribute_name
|
||||
end
|
||||
|
||||
def display_pattern
|
||||
I18n.t('datepicker.dformat', default: '%d/%m/%Y')
|
||||
end
|
||||
|
||||
def picker_pattern
|
||||
I18n.t('datepicker.pformat', default: 'DD/MM/YYYY')
|
||||
end
|
||||
|
||||
def date_view_header_format
|
||||
I18n.t('dayViewHeaderFormat', default: 'MMMM YYYY')
|
||||
end
|
||||
|
||||
def date_options_base
|
||||
{
|
||||
locale: I18n.locale.to_s,
|
||||
format: picker_pattern,
|
||||
dayViewHeaderFormat: date_view_header_format
|
||||
}
|
||||
end
|
||||
|
||||
def date_options
|
||||
custom_options = input_html_options[:data][:date_options] || {}
|
||||
date_options_base.merge!(custom_options)
|
||||
end
|
||||
|
||||
end
|
||||
13
app/inputs/datetime_picker_input.rb
Normal file
13
app/inputs/datetime_picker_input.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class DatetimePickerInput < DatePickerInput
|
||||
private
|
||||
|
||||
def display_pattern
|
||||
I18n.t('datepicker.dformat', default: '%d/%m/%Y') + ' ' +
|
||||
I18n.t('timepicker.dformat', default: '%R')
|
||||
end
|
||||
|
||||
def picker_pattern
|
||||
I18n.t('datepicker.pformat', default: 'DD/MM/YYYY') + ' ' +
|
||||
I18n.t('timepicker.pformat', default: 'HH:mm')
|
||||
end
|
||||
end
|
||||
15
app/inputs/time_picker_input.rb
Normal file
15
app/inputs/time_picker_input.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class TimePickerInput < DatePickerInput
|
||||
private
|
||||
|
||||
def display_pattern
|
||||
I18n.t('timepicker.dformat', default: '%R')
|
||||
end
|
||||
|
||||
def picker_pattern
|
||||
I18n.t('timepicker.pformat', default: 'HH:mm')
|
||||
end
|
||||
|
||||
def date_options
|
||||
date_options_base
|
||||
end
|
||||
end
|
||||
@@ -9,7 +9,6 @@ class Commission < ApplicationRecord
|
||||
has_many :product_commissions
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
|
||||
end
|
||||
|
||||
@@ -5,5 +5,14 @@ class ProductCommission < ApplicationRecord
|
||||
belongs_to :sale_item, foreign_key: 'sale_item_id'
|
||||
belongs_to :sale, foreign_key: 'sale_id'
|
||||
|
||||
|
||||
def self.get_transaction(from, to, commissioner)
|
||||
transaction = self.all
|
||||
if !from.nil? && !to.nil?
|
||||
transaction = transaction.where('updated_at between ? and ?', from, to)
|
||||
end
|
||||
if commissioner != 0
|
||||
transaction = transaction.where(commissioner_id: commissioner)
|
||||
end
|
||||
return transaction
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
|
||||
promoList = Promotion.where("(Date_Format(promo_start_date, 'YYYY-MM-DD') <=? AND Date_Format(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
promoList = Promotion.where("(date_format(promo_start_date, 'YYYY-MM-DD') <=? AND date_format(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
return promoList
|
||||
end
|
||||
|
||||
|
||||
@@ -55,7 +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>-->
|
||||
<li><%= link_to "Commission Report", reports_commission_index_path, :tabindex =>"-1" %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="navbar-nav mr-auto">
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
<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=>'',:class=>"form-control datepicker"%><br/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>'',:class=>"form-control datepicker"%>
|
||||
|
||||
<%= f.input :in_time, :placeholder => "From Date" , :class => "form-control", :as => :datetime_picker%>
|
||||
|
||||
<%= f.input :out_time, :placeholder => "From Date" , :class => "form-control", :as => :datetime_picker%>
|
||||
</div><br>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -31,20 +31,16 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
$('.datepicker').datepicker({
|
||||
format : 'yyyy-mm-dd',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
$('#reset').click(function() {
|
||||
$(document).ready(function(){
|
||||
// $('#in_juty_in_time').datetimepicker();
|
||||
// $('#in_juty_out_time').datetimepicker();
|
||||
$('#reset').click(function() {
|
||||
|
||||
// window.location.href = '/origami/assign_in_juty/'+ table_id;
|
||||
location.reload();
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -1,36 +1,20 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
|
||||
<%= 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">
|
||||
<label class="">Select Date Range</label>
|
||||
<input class="form-control" name="daterange" id="daterange" type="text" placeholder="Date Range" readonly="true">
|
||||
</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" >
|
||||
<label class="">Commissioner</label>
|
||||
<select class="form-control" name="commissioner" id="commissioner">
|
||||
<option value=""></option>
|
||||
<% @commissioner.each do |c| %>
|
||||
<option value="<%= c.id %>"><%= c.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20">
|
||||
@@ -44,76 +28,42 @@
|
||||
</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;
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#commissioner').select2({
|
||||
placeholder: 'Select Commissioner'
|
||||
});
|
||||
|
||||
var item = $('#item').val();
|
||||
var payment_type = $('#payment_type');
|
||||
|
||||
if(item == 'order'){
|
||||
$('#cashier').hide();
|
||||
$('#waiter').show();
|
||||
if(payment_type){
|
||||
$('#payment_type').hide();
|
||||
$('input[name="daterange"]').daterangepicker({
|
||||
autoUpdateInput: false,
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
},
|
||||
locale: {
|
||||
format: 'YYYY-MM-DD'
|
||||
}
|
||||
}
|
||||
else if(item == 'sale'){
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
}
|
||||
else{
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
$("#item").val('sale');
|
||||
}
|
||||
},
|
||||
function(start, end, label) {
|
||||
$('input[name="daterange"]').val(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').on('apply.daterangepicker', function (ev, picker) {
|
||||
$('input[name="daterange"]').val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
|
||||
|
||||
from_date = picker.startDate.format('YYYY-MM-DD 00:00:00');
|
||||
to_date = picker.endDate.format('YYYY-MM-DD 23:59:59');
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').on('cancel.daterangepicker', function (ev, picker) {
|
||||
$('input[name="daterange"]').val('');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//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>
|
||||
</script>
|
||||
|
||||
@@ -6,112 +6,66 @@
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<%= render :partial=>'commission_report_filter',
|
||||
:locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_commission_index_path} %>
|
||||
<hr />
|
||||
<%= 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>
|
||||
<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>
|
||||
<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>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Date</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 %>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
|
||||
<% @sale_data.each do |result|%>
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= result.cashier_terminal.name rescue '-'%>
|
||||
<%= result.commissioner.name rescue '-' %>
|
||||
</td>
|
||||
<td>
|
||||
<%= result.employee.name rescue '-'%>
|
||||
<%= result.commission.menu_item.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> -->
|
||||
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
|
||||
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") 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 %>
|
||||
|
||||
<% total_qty += result.qty.to_f %>
|
||||
<% total_price += result.price.to_f %>
|
||||
<% total_amount += result.amount.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>
|
||||
<td colspan="2"></td>
|
||||
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -119,91 +73,7 @@
|
||||
</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);
|
||||
});
|
||||
}
|
||||
$(function () {
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,100 +1,52 @@
|
||||
<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>
|
||||
<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>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Date</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 %>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
|
||||
<% @sale_data.each do |result|%>
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= result.cashier_terminal.name rescue '-'%>
|
||||
<%= result.commissioner.name rescue '-' %>
|
||||
</td>
|
||||
<td>
|
||||
<%= result.employee.name rescue '-'%>
|
||||
<%= result.commission.menu_item.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> -->
|
||||
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
|
||||
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") 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 %>
|
||||
|
||||
<% total_qty += result.qty.to_f %>
|
||||
<% total_price += result.price.to_f %>
|
||||
<% total_amount += result.amount.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>
|
||||
<td colspan="2"></td>
|
||||
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user