merge with report

This commit is contained in:
Aung Myo
2017-06-13 15:07:29 +06:30
4 changed files with 314 additions and 187 deletions

View File

@@ -1,156 +1,121 @@
<%= form_tag report_path, :method => :get, :id=>"frm_report" do %>
<div class="row">
<div class="col-md-12"></div>
<div class="span3">
<% if defined? product_account %>
<%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account])%>
<% end %>
<% if defined? shift_product_account %>
<%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account]), :prompt => 'All Group'%>
<% end %>
</div>
<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-2">
<label>Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="0">All Sale Type</option>
<option value="1">Revenue Only</option>
<option value="2">Discount Only</option>
<option value="3">Void Only</option>
<option value="4">Taxes Only</option>
<option value="5">Other Amount Only</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 margin-top-20">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<!-- <div class="row">
<% if defined? show_monthly %>
<div class="span3" style="margin-bottom:10px;">
<input type="hidden" id="report_type" name="report_type" value="0">
<div class="btn-group" data-toggle="buttons-radio">
<button id="btn_report_type_1" onclick="$('#report_type').val(1)" type="button" class="btn btn-inverse">Monthly</button>
<button id="btn_report_type_2" onclick="$('#report_type').val(2)" type="button" class="btn btn-inverse">Yearly</button>
</div>
</div>
<% end %>
</div> -->
<div class="span3">
<% if period_type != false %>
<label class="radio inline top-valign">
<input type="radio" id="rd_period_type_0" name="period_type" value="0" checked></input>
</label>
<select name="period" id="sel_period">
<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>
<% end %>
<div class="row">
<div class="form-group">
<% if defined? promotions %>
<%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %>
<% end %>
<% if defined? menu_types %>
<%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %>
<% end %>
<% if defined? payments %>
<%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>
<% end %>
<% if defined? shift_name %>
<!-- Temporary no needs
<select name="shift_name" id="shift_name"></select>
-->
<% end %>
<% if defined? cashiers %>
<%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %>
<% end %>
<% if defined? singer %>
<%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %>
<% end %>
<% if defined? bsm %>
<%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %>
<% end %>
<% if defined? guest_role %>
<%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %>
<% end %>
<% if defined? list_by_payment_type %> <!-- for report detail by credit and foc -->
<%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %>
<% end %>
<% if defined? products %>
<%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %>
<% end %>
<% if defined? items %>
<%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %>
<% end %>
</div>
</div>
<!-- <div class="row">
<div class="col-md-12">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div> -->
<% end %>
</div>
<div class="span3">
<div class="btn-group">
<a href="javascript:export_to('<%=report_path%>.xls')" class = "btn" >Export to Excel</a>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<!-- <ul class="dropdown-menu">
<li>
<a href="javascript:export_to('<%=report_path%>.pdf')" class = "btn" >Export to Pdf</a>
</li>
</ul>
-->
</div>
<br>
<br>
</div>
<!-- <div class="span3">
<% url = url_for(:format => 'xls')%>
<div class="btn-group">
<div id="default_excel">
<a href="javascript:export_to('<%=report_path%>.xls')" class = "btn" >Export to Excel</a>
</div>
<div id="custom_excel" data-url="<%= url %>">
<a href="#" class="btn">Export to Excel</a>
</div>
</div>
<br>
<br>
</div> -->
</div>
<div class="row">
<div class="span3">
<% if defined? show_sale_type %>
<select name="sale_type" id="sel_sale_type">
<option value="0">All Sale Type</option>
<option value="1">Revenue Only</option>
<option value="2">Discount Only</option>
<option value="3">Void Only</option>
<option value="4">Taxes Only</option>
<option value="5">Other Amount Only</option>
</select>
<% end %>
<% if defined? promotions %>
<%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]) %>
<% end %>
<% if defined? menu_types %>
<%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]) %>
<% end %>
<% if defined? payments %>
<%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]) %>
<% end %>
<% if defined? shift_name %>
<select name="shift_name" id="shift_name">
</select>
<% end %>
<% if defined? cashiers %>
<%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations" %>
<% end %>
<% if defined? singer %>
<%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List" %>
<% end %>
<% if defined? bsm %>
<%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List" %>
<% end %>
<% if defined? guest_role %>
<%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List" %>
<% end %>
<% if defined? list_by_payment_type %> <!-- for report detail by credit and foc -->
<%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]) %>
<% end %>
<% if defined? products %>
<%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products" %>
<% end %>
<% if defined? items %>
<%= select_tag "item", options_for_select(@items, :selected => params[:item_type]) %>
<% end %>
</div>
<div class="span3">
<label class="radio inline top-valign">
<input type="radio" id="rd_period_type_1" name="period_type" value="1">
<div class="input-prepend margin-left-3">
<span class="add-on">From</span>
<input data-behaviour='datepicker' class="span2" name="from" id="from" type="text" placeholder="From date">
</div>
</label>
<div class="input-prepend margin-left-23">
<span class="add-on">To&nbsp&nbsp&nbsp&nbsp</span>
<input data-behaviour='datepicker' class="span2" name="to" id="to" type="text" placeholder="To date">
</div>
</div>
<% if defined? show_monthly %>
<div class="span3" style="margin-bottom:10px;">
<input type="hidden" id="report_type" name="report_type" value="0">
<div class="btn-group" data-toggle="buttons-radio">
<!-- <button id="btn_report_type_0" onclick="$('#report_type').val(0)" type="button" class="btn btn-inverse active">Daily</button> -->
<button id="btn_report_type_1" onclick="$('#report_type').val(1)" type="button" class="btn btn-inverse">Monthly</button>
<button id="btn_report_type_2" onclick="$('#report_type').val(2)" type="button" class="btn btn-inverse">Yearly</button>
</div>
</div>
<% end %>
<div class="span3">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<!--
<div class = "row">
@@ -167,7 +132,6 @@
</div>
</div>
-->
<% end %>
<script type="text/javascript">
$(function(){

View File

@@ -2,49 +2,63 @@
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Receipt List Report</li>
<span style="float: center">
<%= render :partial=>'shift_sale_report_filter',:locals=>{ :period_type => true,
:shift_name => true, :report_path => reports_receipt_no_index_path} %>
</span>
</ul>
</div>
<div class="card">
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<th style='text-align:center;'>CT</th>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tbody>
<% total_sales = 0 %>
<% net_sales = 0 %>
<% @sale_data.each do |sale| %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=sale.cashier_id rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_tax.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_receipt_no_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<div class="card row">
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<th style='text-align:center;'>CT</th>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tbody>
<% total_sales = 0 %>
<% net_sales = 0 %>
<% @sale_data.each do |sale| %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=sale.cashier_id rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_tax.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<%= paginate @sale_data %>
<script>
$(function(){
var check_arr = [];