Merge branch 'r-1902001-01' of gitlab.com:code2lab/SXRestaurant into r-1902001-01

This commit is contained in:
Zoey
2019-06-03 09:23:50 +06:30
9 changed files with 346 additions and 72 deletions

View File

@@ -82,6 +82,14 @@ For ReceiptBillA5Pdf
For ReceiptBillAltName options
1) settings/lookups => { type:print_settings, name:ReceiptBillAltName, value:1 }
For CloseCashierPrint with Star Printer
1) settings/print_settings
a) Unique Code => CloseCashierStarPdf
For Sale Items Summary Include at CloseCashierPrint
1) settings/print_settings
a) Check => Shift Sale Items
For Bank Integration setting
1) rake db:migrate for card_sale_trans, card_settle_trans
2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 }

View File

@@ -1,7 +1,7 @@
class Reports::SaleitemController < BaseReportController
authorize_resource :class => false
def index
@account = Account.all
from, to = get_date_range_from_params
@@ -13,7 +13,7 @@ class Reports::SaleitemController < BaseReportController
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
if to.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
@@ -43,7 +43,7 @@ class Reports::SaleitemController < BaseReportController
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@@ -80,7 +80,7 @@ class Reports::SaleitemController < BaseReportController
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
@@ -98,7 +98,7 @@ class Reports::SaleitemController < BaseReportController
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
if to.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
@@ -122,9 +122,19 @@ class Reports::SaleitemController < BaseReportController
# get printer info
print_settings = PrintSetting.find_by_unique_code('CloseCashierPdf') # SaleItemsPdf
printer = Printer::CashierStationPrinter.new(print_settings)
print_settings_star = PrintSetting.find_by_unique_code('CloseCashierStarPdf')
if print_settings.nil?
if !print_settings_star.nil?
printer = Printer::CashierStationPrinter.new(print_settings_star)
printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data)
end
else
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data)
end
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data)
respond_to do |format|
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
@@ -144,31 +154,31 @@ class Reports::SaleitemController < BaseReportController
when PERIOD["this_week"]
period_name = "This Week"
when PERIOD["last_week"]
period_name = "Last Week"
when PERIOD["last_7"]
period_name = "Last 7 days"
when PERIOD["this_month"]
period_name = "This Month"
when PERIOD["last_month"]
period_name = "Last Month"
when PERIOD["last_30"]
period_name = "Last 30 Days"
when PERIOD["this_year"]
period_name = "This Year"
when PERIOD["last_year"]
period_name = "Last Year"
end
end
return period_name
end
end

View File

@@ -5,9 +5,14 @@ class PrintSetting < ApplicationRecord
def self.get_precision_delimiter
setting = PrintSetting.find_by_unique_code("CloseCashierPdf")
if setting.nil?
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
star_setting = PrintSetting.find_by_unique_code("CloseCashierStarPdf")
if star_setting.nil?
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
else
return star_setting
end
end
return setting
end
end

View File

@@ -37,7 +37,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# pdf.render_file filename
# self.print(filename, cashier_terminal.printer_name)
# end
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
if !sale_items.blank? or !sale_items.nil?
@@ -84,7 +84,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items)
filename = "tmp/reports_sale_items.pdf"
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
if print_settings.unique_code == "CloseCashierPdf"
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
puts 'Printing!!!!'
end
if print_settings.unique_code == "CloseCashierStarPdf"
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
puts 'PrintingStar!!!!'
end
pdf.render_file filename

View File

@@ -2534,6 +2534,15 @@ end
end
end
def self.get_shift_sale_items(sh_id)
query = Sale.select("sales.shift_sale_id as shift_sale_id, i.account_id as account_id, acc.title as account_name, i.item_instance_code as item_code, i.menu_category_name, i.menu_category_code as menu_category_id, i.product_name as product_name, i.unit_price, i.price as price, i.qty as qty, SUM(i.qty) as total_item, SUM(i.qty * i.unit_price) as grand_total, i.status as status_type, i.remark as remark")
.joins("JOIN sale_items i on i.sale_id = sales.sale_id")
.joins("JOIN accounts acc on acc.id = i.account_id")
.where("sales.shift_sale_id=?", sh_id)
.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc")
end
def self.pending_sale(type)
query = Sale.all
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")

View File

@@ -11,9 +11,9 @@ class MoveTableStarPdf < Prawn::Document
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
self.label_width=90
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -85,7 +85,7 @@ class MoveTableStarPdf < Prawn::Document
move_down 5
order_items.each do|odi|
# check for item not to show
# check for item not to show
# if odi.price != 0
y_position = cursor
@@ -103,15 +103,15 @@ class MoveTableStarPdf < Prawn::Document
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
if !(odi.alt_name).empty?
move_down 4
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
end
end
end

View File

@@ -151,7 +151,7 @@ class SaleItemsPdf < Prawn::Document
sale_items.each do |item|
if !arr.include?(item['menu_category_id'])
unless total_qty == 0 and sub_total == 0
total_details('Sub Total', total_qty, sub_total)
end
@@ -193,7 +193,7 @@ class SaleItemsPdf < Prawn::Document
text_box "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
if item['total_item'].to_i > 0
total_qty += item['total_item'].to_i
total_items += item['total_item'].to_i
@@ -209,7 +209,7 @@ class SaleItemsPdf < Prawn::Document
move_down 5
total_details('Total Amount', total_items, total_amount)
move_down 10
end
end
end
def total_details(col_name, total_qty, sub_total)
@@ -230,4 +230,4 @@ class SaleItemsPdf < Prawn::Document
}
end
end
end

View File

@@ -0,0 +1,233 @@
class SaleItemsStarPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, acc_cate_count, menu_cate_count, total_by_acc)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
self.item_font_size = printer_settings.item_font_size.to_i
self.margin = 5
self.price_width = 60
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
@label_name_width = 50
@label_item_width = self.page_width-@label_name_width
self.label_width = 100
self.text_width = (self.page_width - 80) - self.price_width / 3
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
#check delimiter
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header( shop_details)
stroke_horizontal_rule
sale_details(period, type, account, from_date, to_date, shift)
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
end
def header (shop_details)
move_down 7
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down 5
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down 5
stroke_horizontal_rule
end
def sale_details(period, type, account, from_date, to_date, shift)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Period : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{period}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Type : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{type}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Account : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{account}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "From Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{ from_date.utc.getlocal.strftime("%d-%m-%Y")}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "To Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{ to_date.utc.getlocal.strftime("%d-%m-%Y")}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Shift : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width) do
text "#{shift}" , :size => self.item_font_size,:align => :left
end
move_down 10
end
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
self.item_width = 73
self.price_width = 35
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = 32
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = 64
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "Sale Items Summary", :size => self.header_font_size, :align => :center
end
total_items = 0
total_amount = 0
total_qty = 0
sub_total = 0
arr = Array.new
unless sale_items.nil?
sale_items.each do |item|
if !arr.include?(item['menu_category_id'])
unless total_qty == 0 and sub_total == 0
total_details('Sub Total', total_qty, sub_total)
end
total_qty = 0
sub_total = 0
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
end
# write_stroke_dash
# dash(1, :space => 1, :phase => 1)
# stroke_horizontal_rule
# move_down 2
y_position = cursor
pad_top(15) {
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :left, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 2
stroke_horizontal_rule
end
move_down 3
y_position = cursor
pad_top(15) {
bounding_box([0,y_position], :width =>self.item_width) do
text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
end
text_box "#{item['unit_price'].to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
if item['total_item'].to_i > 0
total_qty += item['total_item'].to_i
total_items += item['total_item'].to_i
end
sub_total += item['grand_total'].to_i
total_amount += item['grand_total'].to_i
arr.push(item['menu_category_id'])
end
# stroke_horizontal_rule
total_details('Sub Total', total_qty, sub_total)
move_down 5
total_details('Total Amount', total_items, total_amount)
move_down 10
end
end
def total_details(col_name, total_qty, sub_total)
self.item_width = 73
self.price_width = 35
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = 32
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = 64
move_down 5
stroke_horizontal_rule
y_position = cursor
pad_top(15) {
text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "#{total_qty.to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
end
end

View File

@@ -21,7 +21,7 @@
<div class="margin-top-20">
<div class="card">
<div class="table-responsive">
<div class="table-responsive">
<table class="table table-striped" id="items_table" border="0">
<thead>
<tr>
@@ -29,9 +29,9 @@
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<% end %>
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
@@ -43,9 +43,11 @@
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<th><%= t("views.right_panel.detail.revenue") %></th>
</tr>
</tr>
</thead>
<tbody>
<% puts 'testing!!!!!!' %>
<% puts @print_settings.precision.to_i %>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
@@ -57,9 +59,9 @@
else
delimiter = ""
end
%>
%>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% cate_arr = Array.new %>
<% p_qty = 0 %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
@@ -81,7 +83,7 @@
<% @sale_data.each do |sale| %>
<% row_count += 1 %>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
@@ -95,15 +97,15 @@
total_qty += sale.total_item*(-1)
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
@@ -113,7 +115,7 @@
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
<% grand_total += total %>
<% grand_total += total %>
<% end %>
<% end %>
</td>
@@ -122,7 +124,7 @@
<% end %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
@@ -135,7 +137,7 @@
<%else%>
<td><%= sale.total_item*(-1) rescue '-' %></td>
<% end %>
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
@@ -143,7 +145,7 @@
<% @menu_cate_count.each do |key,value| %>
<% if sale.account_id == key %>
<% count = count + 1 %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC") && sale.status_type != "promotion"
@@ -156,7 +158,7 @@
<% if sale.status_type == "promotion" && @type == "promotion"
sub_qty += sale.total_item*(-1)
end %>
<% if count == value %>
<% if count == value %>
<tr>
<td colspan="3">&nbsp;</td>
<td><b>Total <%= sale.account_name %> Qty </b> </td>
@@ -174,7 +176,7 @@
<% end %>
<!--Product Sale -->
<% if @product.present?%>
<tr>
<td><b>Product</b></td>
<td colspan="4">&nbsp;</td>
@@ -196,9 +198,9 @@
<td> <%= number_with_precision(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% product_sub_total += product.grand_total %>
<!-- end sub total -->
<!-- end sub total -->
<% end %>
<tr>
<td colspan="3">&nbsp;</td>
@@ -213,7 +215,7 @@
<!--Other Charges -->
<% if @type == "other" || @other_charges.present?%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
@@ -234,9 +236,9 @@
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<!-- end sub total -->
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
@@ -250,11 +252,11 @@
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
<td><span><%= total_qty%></span></td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<% end %>
<% if @type == "other"%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
@@ -275,9 +277,9 @@
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<!-- end sub total -->
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
@@ -287,7 +289,7 @@
<%end%>
</tbody>
</table>
</div>
</div>
</div>
@@ -302,13 +304,13 @@
if(search){
if(parseInt(search) == 0){
search_by_period();
search_by_period();
}
else{
search_by_date();
search_by_date();
}
}else{
search_by_period();
search_by_period();
}
$('#sel_period').change(function(){
@@ -321,8 +323,8 @@
var from = "";
var to = "";
show_shift_name(period,period_type,from,to,'shift_item');
}
show_shift_name(period,period_type,from,to,'shift_item');
}
// OK button is clicked
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
@@ -338,13 +340,13 @@
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to)
search_by_date();
});
});
function search_by_date(){
from = $("#from").val();
to = $("#to").val();
var period = 0;
var period_type = 1;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
@@ -353,7 +355,7 @@
console.log(check_arr.length)
if(check_arr.length == 1){
show_shift_name(period,period_type,from,to,'shift_item');
show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
@@ -372,14 +374,14 @@
var selected = '';
var str = '';
var param_shift = '<%= params[:shift_name]%>';
url = '<%= reports_get_shift_by_sale_item_path %>';
console.log(url)
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
console.log(data)
str = '<option value="0">--- All Shift ---</option>';
$(data.message).each(function(index){
$(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;
@@ -390,18 +392,18 @@
selected = 'selected = "selected"';
}
else{
selected = '';
}
selected = '';
}
}
else{
selected = '';
}
selected = '';
}
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
})
shift.append(str);
});
}
@@ -432,4 +434,4 @@
});
// }
}
</script>
</script>