Add multiple photo upload

This commit is contained in:
San Wai Lwin
2018-03-19 18:35:59 +06:30
36 changed files with 391 additions and 93 deletions

View File

@@ -41,6 +41,7 @@ gem 'rack-cors'
# image upload # image upload
gem 'carrierwave', '~> 1.0' gem 'carrierwave', '~> 1.0'
gem 'mini_magick' gem 'mini_magick'
gem 'jquery-fileupload-rails'
#Report and Printing gems #Report and Printing gems
gem 'cups' gem 'cups'

View File

@@ -107,6 +107,10 @@ GEM
jbuilder (2.7.0) jbuilder (2.7.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
multi_json (>= 1.2) multi_json (>= 1.2)
jquery-fileupload-rails (0.4.7)
actionpack (>= 3.1)
railties (>= 3.1)
sass (>= 3.2)
jquery-rails (4.3.1) jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
@@ -304,6 +308,7 @@ DEPENDENCIES
font-awesome-rails (~> 4.7, >= 4.7.0.2) font-awesome-rails (~> 4.7, >= 4.7.0.2)
httparty (~> 0.15.5) httparty (~> 0.15.5)
jbuilder (~> 2.5) jbuilder (~> 2.5)
jquery-fileupload-rails
jquery-rails jquery-rails
jquery-ui-rails jquery-ui-rails
kaminari (~> 1.0.1) kaminari (~> 1.0.1)

View File

@@ -180,7 +180,7 @@ $(function() {
image_path = "image/logo.png"; image_path = "image/logo.png";
} }
} }
console.log(menu_items[field].options)
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">' row = '<div class="card custom-card testimonial-card animated fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">' +'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
@@ -202,7 +202,7 @@ $(function() {
+ price +"' data-instance-code = '"+ code +"' data-instance = '" + price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '" + name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '" + JSON.stringify(item_attributes) +"' data-options = '"
+ options +"' data-image='"+image_path+"' data-toggle='" + JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='"
+data_modal+"' data-target='."+data_target+"' data-item-sets = '" +data_modal+"' data-target='."+data_target+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '" +JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
+JSON.stringify(menu_items[field].instances)+"'>" +JSON.stringify(menu_items[field].instances)+"'>"
@@ -237,7 +237,7 @@ $(function() {
//instances = $(this).data('instance'); //instances = $(this).data('instance');
item_sets = $(this).data('item-sets'); item_sets = $(this).data('item-sets');
instances = $(this).data('instances'); instances = $(this).data('instances');
// item_sets = $(data).attr('data-item-sets'); item_options = $(this).data('options');
for(var field in item_sets) { for(var field in item_sets) {
@@ -283,10 +283,20 @@ $(function() {
}); });
} }
for(var j in item_options) {
value = item_options[j]["values"];
type = item_options[j]["type"];
row = "<h4>"+type+"</h4>"
$(value).each(function(i){
row +="<button class='btn btn- waves-effect option_btn "+ type +"' data-type='"
+type+"' data-value='"+value[i]+"' data-group='set_menu_default'>"+value[i]+"</button>";
});
$(".options-list").append(row);
}
$('.set-item').attr('data-code',instances[0]['code']); $('.set-item').attr('data-code',instances[0]['code']);
$('.set-item').attr('data-name',instances[0]['name']); $('.set-item').attr('data-name',instances[0]['name']);
$('.set-item').attr('data-price',instances[0]['price']); $('.set-item').attr('data-price',instances[0]['price']);
$('.set-item').attr('data-options','[]'); // $('.set-item').attr('data-options','[]');
$('.set-item').attr('data-parent',true); $('.set-item').attr('data-parent',true);
$('#set_change_qty').val(1); $('#set_change_qty').val(1);
@@ -371,32 +381,28 @@ $(function() {
customer_display_view(item,"set_add"); customer_display_view(item,"set_add");
attribute_arr = [] attribute_arr = []
option_arr = []
var rowCount = $('.summary-items tbody tr').length+1; var rowCount = $('.summary-items tbody tr').length+1;
option_arr = []
code = $('.set-item').attr('data-code'); code = $('.set-item').attr('data-code');
name = $('.set-item').attr('data-name'); name = $('.set-item').attr('data-name');
price = $('.set-item').attr('data-price'); price = $('.set-item').attr('data-price');
option = $('.set-item').attr('data-options'); option = $('.set-item').attr('data-options');
parent = $('.set-item').attr('data-parent'); parent = $('.set-item').attr('data-parent');
total = qty * price ; total = qty * price ;
option_arr.push(option);
row ="<tr class='item_box' data-price ='" row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='" +price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='" +name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='" +code+"' data-attributes='"
+attribute_arr+"' data-options ='" +attribute_arr+"' data-options ='"
+option_arr+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>" +option+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>' +'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>' +'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'-' + option +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>' +'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">' +'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2) + parseFloat(total).toFixed(2)
+'</td>' +'</td>'
+'</tr>'; +'</tr>';
$(".summary-items tbody").append(row); $(".summary-items tbody").append(row);
var rowCount = $('.summary-items tbody tr').length+1; var rowCount = $('.summary-items tbody tr').length+1;
$(items).each(function(i){ $(items).each(function(i){
code = $(items[i]).attr('data-code'); code = $(items[i]).attr('data-code');
@@ -406,15 +412,14 @@ $(function() {
sub_item = $(items[i]).attr('data-sub-item'); sub_item = $(items[i]).attr('data-sub-item');
option = $(items[i]).attr('data-options'); option = $(items[i]).attr('data-options');
total = qty * price ; total = qty * price ;
option_arr.push(option);
row ="<tr class='item_box' data-price ='" row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='" +price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='" +name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='" +code+"' data-attributes='"
+attribute_arr+"' data-options ='" +attribute_arr+"' data-options ='"
+option_arr+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>" +option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>' +'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>' +'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'-' + option +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>' +'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">' +'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2) + parseFloat(total).toFixed(2)
@@ -626,8 +631,6 @@ $(function() {
if(group == "set_menu"){ if(group == "set_menu"){
code = $(this).data('code');
value = $(this).data('value');
instance = $(".selected-instance"); instance = $(".selected-instance");
$(instance).each(function(i){ $(instance).each(function(i){
@@ -639,6 +642,12 @@ $(function() {
}); });
} }
if(group == "set_menu_default"){
option_arr = get_selected_attributes('selected-option');
$('.set-item').attr('data-options',JSON.stringify(option_arr));
$('.set_default_option').text(option_arr);
}
}); //End selecct attribute buttom }); //End selecct attribute buttom
// click add order // click add order

View File

@@ -28,11 +28,12 @@
//= require raphael/raphael.min //= require raphael/raphael.min
//= require Chart.bundle //= require Chart.bundle
//= require chartkick //= require chartkick
//= require fileinput.min //= require fileinput.min.js
//= require settings/processing_items //= require settings/processing_items
//= require BSBMaterial/admin.js //= require BSBMaterial/admin.js
//= require BSBMaterial/demo.js //= require BSBMaterial/demo.js
//= require custom.js //= require custom.js
//= require jquery-fileupload/basic
$(document).ready(function() { $(document).ready(function() {
$('.count-to').countTo(); $('.count-to').countTo();

View File

@@ -0,0 +1,6 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
jQuery ->
$('#new_display_image').fileupload
dataType: "script"

View File

@@ -74,16 +74,6 @@ class Origami::HomeController < BaseOrigamiController
@date = order.created_at @date = order.created_at
@booking= booking @booking= booking
order.order_items.each do |item| order.order_items.each do |item|
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
item.price = item.price.to_f + instance_item["price"].to_f
end
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item) @order_items.push(item)
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) # assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil? # if !assigned_order_items.nil?

View File

@@ -104,6 +104,8 @@ class Origami::PaymentsController < BaseOrigamiController
end end
end end
#end rounding adjustment #end rounding adjustment
puts "sale"
puts saleObj.to_json
sale_payment = SalePayment.new sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "cash") sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
@@ -158,6 +160,20 @@ class Origami::PaymentsController < BaseOrigamiController
end end
end end
#orders print out
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id)
end
end
#for card sale data #for card sale data
card_data = Array.new card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
@@ -181,19 +197,6 @@ class Origami::PaymentsController < BaseOrigamiController
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id)
end
end
end end
end end
end end

View File

@@ -68,16 +68,6 @@ class Origami::RoomsController < BaseOrigamiController
@date = order.created_at @date = order.created_at
@booking = booking @booking = booking
order.order_items.each do |item| order.order_items.each do |item|
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
item.price = item.price.to_f + instance_item["price"].to_f
end
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item) @order_items.push(item)
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) # assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil? # if !assigned_order_items.nil?

View File

@@ -3,6 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController
end end
def show def show
@type = params[:type]
@shift = ShiftSale.current_open_shift(current_user.id) @shift = ShiftSale.current_open_shift(current_user.id)
#for bank integration #for bank integration
bank_integration = Lookup.collection_of('bank_integration') bank_integration = Lookup.collection_of('bank_integration')

View File

@@ -6,6 +6,10 @@ class Settings::MenusController < ApplicationController
# GET /settings/menus.json # GET /settings/menus.json
def index def index
@settings_menus = Menu.all.page(params[:page]).per(10) @settings_menus = Menu.all.page(params[:page]).per(10)
respond_to do |format|
format.html
format.csv { send_data Menu.to_csv }
end
end end
# GET /settings/menus/1 # GET /settings/menus/1

View File

@@ -51,7 +51,11 @@ class Settings::ShopsController < ApplicationController
if @settings_shop.update(shop_params) if @settings_shop.update(shop_params)
if params[:display_images].present? if params[:display_images].present?
params[:display_images]['image'].each do |a| params[:display_images]['image'].each do |a|
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a)
aa = a.read
base64_encoded = Base64.encode64(aa)
byebug
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => base64_encoded)
end end
end end
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully updated.' } format.html { redirect_to settings_shops_url, notice: 'Shop was successfully updated.' }

View File

@@ -31,4 +31,29 @@ class Menu < ApplicationRecord
menu.destroy menu.destroy
return false return false
end end
def self.to_csv
m_attributes = %w{id name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
CSV.generate(headers: true) do |csv|
csv << m_attributes
menu = Menu.all
menu.each do |user|
puts user
csv << m_attributes.map{ |attr| user.send(attr)}
end
end
# mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
# CSV.generate(headers: true) do |csv|
# csv << m_attributes
# csv << mc_attributes
# MenuCategory.all.each do |user|
# puts user
# csv << mc_attributes.map{ |attr| user.send(attr)}
# end
# end
end
end end

View File

@@ -152,7 +152,7 @@ class Order < ApplicationRecord
item[:sub_items].each do |si| item[:sub_items].each do |si|
# Retrive instance's Price # Retrive instance's Price
set_item = MenuItem.search_by_item_code(si[:item_instance_code]) set_item = MenuItem.search_by_item_code(si[:item_instance_code])
set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity], "price"=>set_item[:price]}) set_order_items.push({"item_instance_code"=>si[:item_instance_code], "item_instance_name"=>set_item[:name], "quantity"=>si[:quantity], "price"=>set_item[:price], "options"=>si[:options]})
end end
end end
set_order_items = set_order_items.to_json set_order_items = set_order_items.to_json

View File

@@ -6,4 +6,8 @@ class Shop < ApplicationRecord
has_many :display_images has_many :display_images
accepts_nested_attributes_for :display_images accepts_nested_attributes_for :display_images
def file_data=(input_data)
self.data = input_data.read
end
end end

View File

@@ -37,7 +37,7 @@ class OrderItemPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf" # font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf" #font "public/fonts/Chinese.ttf"
if order_item.dining.to_i > 0 if !order_item.dining.nil?
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20

2
app/pdf/order_item_slim_pdf.rb Normal file → Executable file
View File

@@ -37,7 +37,7 @@ class OrderItemSlimPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf" # font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf" #font "public/fonts/Chinese.ttf"
if order_item_slim.dining.to_i > 0 if !order_item_slim.dining.nil?
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20

2
app/pdf/order_set_item_pdf.rb Normal file → Executable file
View File

@@ -37,7 +37,7 @@ class OrderSetItemPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf" # font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf" #font "public/fonts/Chinese.ttf"
if order_set_item.dining.to_i > 0 if !order_set_item.dining.nil?
text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20

View File

@@ -36,7 +36,8 @@ class OrderSummaryPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf" # font "public/fonts/padauk.ttf"
if order[0].dining.to_i > 0
if !order[0].dining.nil?
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20

2
app/pdf/order_summary_set_pdf.rb Normal file → Executable file
View File

@@ -36,7 +36,7 @@ class OrderSummarySetPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf" # font "public/fonts/padauk.ttf"
if order[0].dining.to_i > 0 if !order[0].dining.nil?
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20

2
app/pdf/order_summary_slim_pdf.rb Normal file → Executable file
View File

@@ -36,7 +36,7 @@ class OrderSummarySlimPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf" # font "public/fonts/padauk.ttf"
if order[0].dining.to_i > 0 if !order[0].dining.nil?
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20

View File

@@ -46,9 +46,12 @@ if (@booking)
child_spent += (item.price * item.qty) child_spent += (item.price * item.qty)
end end
# End YGN BBQ # End YGN BBQ
json.order_items_id item.order_items_id
json.order_id item.order_id
json.item_code item.item_code json.item_code item.item_code
json.item_instance_code item.item_instance_code json.item_instance_code item.item_instance_code
json.item_name item.item_name json.item_name item.item_name
json.set_menu_items item.set_menu_items
json.price item.price json.price item.price
json.qty item.qty json.qty item.qty
json.options item.options json.options item.options

View File

@@ -193,6 +193,8 @@
<button type="button" data-href="<%=origami_second_display_index_path%>" target="_blank" id="second_view" class="btn action-btn bg-blue waves-effect second_view hidden" style="height: 45px">Customer View</button> <button type="button" data-href="<%=origami_second_display_index_path%>" target="_blank" id="second_view" class="btn action-btn bg-blue waves-effect second_view hidden" style="height: 45px">Customer View</button>
<script> <script>
$(".cashier_view").on('click', function() { $(".cashier_view").on('click', function() {
window.location.href = '/origami'; window.location.href = '/origami';
}); });

View File

@@ -241,7 +241,7 @@ $('#cash_out').on('click',function(){
$('#close_cashier').on('click',function(e){ $('#close_cashier').on('click',function(e){
e.preventDefault(); // Prevent the href from redirecting directly e.preventDefault(); // Prevent the href from redirecting directly
var linkURL = '/origami/shift/close'; var linkURL = '/origami/shift/cashier/close';
warnBeforeRedirect(linkURL); warnBeforeRedirect(linkURL);
}) })

View File

@@ -292,9 +292,26 @@
<td><%= count %></td> <td><%= count %></td>
<td class='item-name'> <td class='item-name'>
<%= order_item.item_name %> <%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
<%= option %>
</span>
<% end %>
<% end %>
<% if !order_item.set_menu_items.nil? <% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %> JSON.parse(order_item.set_menu_items).each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span> <br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && !item_instance["options"].empty? %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13">
<%= set_item_option %>
</span>
<% end %>
<% end %>
</span>
<% end <% end
end %> end %>
</td> </td>
@@ -371,9 +388,26 @@
<td><%= count %> <td><%= count %>
<td class='item-name'> <td class='item-name'>
<%= order_item.item_name %> <%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
<%= option %>
</span>
<% end %>
<% end %>
<% if !order_item.set_menu_items.nil? <% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %> JSON.parse(order_item.set_menu_items).each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span> <br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13">
<%= set_item_option %>
</span>
<% end %>
<% end %>
</span>
<% end <% end
end %> end %>
</td> </td>

22
app/views/origami/pending_order/index.html.erb Normal file → Executable file
View File

@@ -34,7 +34,9 @@
<i class="material-icons">reply</i> <i class="material-icons">reply</i>
<%= t("views.btn.back") %> <%= t("views.btn.back") %>
</button> </button>
<% if current_user.role != "waiter" %>
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<% end %>
</div> </div>
</div> </div>
</div> </div>
@@ -51,4 +53,22 @@
$('#back').on('click', function () { $('#back').on('click', function () {
window.location.href = '/origami/quick_service'; window.location.href = '/origami/quick_service';
}) })
$('#close_cashier').on('click',function(e){
e.preventDefault(); // Prevent the href from redirecting directly
var linkURL = '/origami/shift/quick_service/close';
warnBeforeRedirect(linkURL);
});
function warnBeforeRedirect(linkURL) {
swal({
title: "Alert!",
text: "Are you sure you want to close cashier?",
type: "warning",
showCancelButton: true
}, function() {
// Redirect the user
window.location.href = linkURL;
});
}
</script> </script>

25
app/views/origami/pending_order/show.html.erb Normal file → Executable file
View File

@@ -1,7 +1,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<!-- Column One --> <!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-5 col-md-5 col-sm-5">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<strong id="order-title"> PENDING ORDER </strong> <strong id="order-title"> PENDING ORDER </strong>
@@ -148,7 +148,7 @@
</div> </div>
</div> </div>
<!-- Column Three --> <!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-2 col-md-2 col-sm-2">
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button> <button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
<% if current_user.role != "waiter" || @status != "sale"%> <% if current_user.role != "waiter" || @status != "sale"%>
<button type="button" id="addorder" class="btn bg-blue btn-block">Add Order</button> <button type="button" id="addorder" class="btn bg-blue btn-block">Add Order</button>
@@ -167,6 +167,9 @@
<% if @status != "sale"%> <% if @status != "sale"%>
<button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button> <button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button>
<%end%> <%end%>
<% if current_user.role != "waiter" %>
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<% end %>
</div> </div>
</div> </div>
</div> </div>
@@ -269,5 +272,23 @@ $(document).ready(function(){
} }
return false; return false;
}); });
$('#close_cashier').on('click',function(e){
e.preventDefault(); // Prevent the href from redirecting directly
var linkURL = '/origami/shift/quick_service/close';
warnBeforeRedirect(linkURL);
});
function warnBeforeRedirect(linkURL) {
swal({
title: "Alert!",
text: "Are you sure you want to close cashier?",
type: "warning",
showCancelButton: true
}, function() {
// Redirect the user
window.location.href = linkURL;
});
}
}); });
</script> </script>

View File

@@ -277,9 +277,26 @@
<td><%= count %></td> <td><%= count %></td>
<td class='item-name'> <td class='item-name'>
<%= order_item.item_name %> <%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
<%= option %>
</span>
<% end %>
<% end %>
<% if !order_item.set_menu_items.nil? <% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %> JSON.parse(order_item.set_menu_items).each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span> <br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13">
<%= set_item_option %>
</span>
<% end %>
<% end %>
</span>
<% end <% end
end %> end %>
</td> </td>
@@ -345,9 +362,26 @@
<td><%= count %> <td><%= count %>
<td class='item-name'> <td class='item-name'>
<%= order_item.item_name %> <%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
<%= option %>
</span>
<% end %>
<% end %>
<% if !order_item.set_menu_items.nil? <% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %> JSON.parse(order_item.set_menu_items).each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span> <br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13">
<%= set_item_option %>
</span>
<% end %>
<% end %>
</span>
<% end <% end
end %> end %>
</td> </td>

View File

@@ -58,6 +58,7 @@
</div> </div>
</div> </div>
<script> <script>
var type = '<%= @type %>';
$('#close_cashier').on('click',function(){ $('#close_cashier').on('click',function(){
var amount = $('#closing_balance_amount').val(); var amount = $('#closing_balance_amount').val();
var shift_id = "<%= @shift.id rescue ""%>" var shift_id = "<%= @shift.id rescue ""%>"
@@ -72,7 +73,11 @@
}); });
$('#back').on('click',function(){ $('#back').on('click',function(){
if(type!='quick_service'){
window.location.href = '/origami'; window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}); });
/** start CB Card Settle process **/ /** start CB Card Settle process **/
@@ -90,7 +95,7 @@
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/shift/close'; window.location.href = '/origami/shift/'+type+'/close';
}); });
} }
}); });
@@ -115,7 +120,7 @@
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/shift/close'; window.location.href = '/origami/shift/'+type+'/close';
}); });
} }
} }

2
app/views/reports/product_sale/index.html.erb Normal file → Executable file
View File

@@ -1,7 +1,7 @@
<div class="page-header"> <div class="page-header">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li> <li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.sale_item_report") %></li> <li class="breadcrumb-item active"><%= t("views.right_panel.detail.product_sale_report") %></li>
<span class="float-right"> <span class="float-right">
<%= link_to 'Back', dashboard_path %> <%= link_to 'Back', dashboard_path %>
</span> </span>

View File

@@ -47,9 +47,8 @@
<%= f.fields_for :display_images do |p| %> <%= f.fields_for :display_images do |p| %>
<div class="field"> <div class="field">
<%= p.label :image %><br>
<%= image_tag p.object.image, :class => "img-thumbnail" %> <%= image_tag p.object.image, :class => "img-thumbnail" %>
<%= p.file_field :image, :multiple => true, name: "display_images[image][]" %>
<%= link_to "Destroy", settings_shop_display_image_path(p.object), method: :delete %> <%= link_to "Destroy", settings_shop_display_image_path(p.object), method: :delete %>
</div> </div>
<% end %> <% end %>
@@ -57,7 +56,7 @@
</div> </div>
</div> </div>
</div> </div>
<%= f.file_field :image, :multiple => true, name: "display_images[image][]" %>
<!-- <%= f.fields_for :display_images do |p| %> <!-- <%= f.fields_for :display_images do |p| %>
<div class="field"> <div class="field">
<%= p.label :image %><br> <%= p.label :image %><br>

View File

@@ -0,0 +1,5 @@
<% if @display_image.new_record? %>
alert("Failed to upload display_image: <%= j @display_image.errors.full_messages.join(', ').html_safe %>");
<% else %>
$("#display_images").append("<%= j render(@display_image) %>");
<% end %>

View File

@@ -1,5 +1,6 @@
require_relative 'boot' require_relative 'boot'
require 'csv'
require 'rails/all' require 'rails/all'
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems

View File

@@ -449,6 +449,7 @@ en:
gateway_url: "Gateway url" gateway_url: "Gateway url"
additional_parameter: "Additional parameter" additional_parameter: "Additional parameter"
lookup: "Lookup" lookup: "Lookup"
product_sale_report: "Product Sale"
code_txt: "code " code_txt: "code "
charge_txt: "charge" charge_txt: "charge"

View File

@@ -444,6 +444,7 @@ mm:
additional_parameter: "ထပ်ဖြည့်အကြောင်းအရာ" additional_parameter: "ထပ်ဖြည့်အကြောင်းအရာ"
survey: "ခြုံငုံလေ့လာခြင်း" survey: "ခြုံငုံလေ့လာခြင်း"
lookup: "သတ်မှတ်ချက်များ" lookup: "သတ်မှတ်ချက်များ"
product_sale_report: "Product Sale"
code_txt: "ကုတ်ဒ် " code_txt: "ကုတ်ဒ် "
charge_txt: "ကောက်ခံသည်" charge_txt: "ကောက်ခံသည်"

View File

@@ -152,7 +152,7 @@ scope "(:locale)", locale: /en|mm/ do
#---------Shift ---------------# #---------Shift ---------------#
resources :shifts, only: [:index, :new, :create, :edit] resources :shifts, only: [:index, :new, :create, :edit]
post 'close_shift' => 'shifts#update_shift' post 'close_shift' => 'shifts#update_shift'
get 'shift/close' => 'shifts#show' get 'shift/:type/close' => 'shifts#show'
get 'shift/sale_summary' => 'shifts#sale_summary' get 'shift/sale_summary' => 'shifts#sale_summary'
#shift - index (open/close shift landing page) #shift - index (open/close shift landing page)
#shift - show (sales summary display) #shift - show (sales summary display)

128
data/recent_users.json Normal file
View File

@@ -0,0 +1,128 @@
[
{
"id": 1,
"name": "Administrator",
"role": "administrator",
"emp_id": "999",
"password_digest": "$2a$10$mfWmxBvOHt3NbWrLGOF/POTpnxF7QEtnW99qW818dkrQqVLtjQdrS",
"token_session": null,
"session_expiry": null,
"session_last_login": "2018-03-14 09:41:25 +0630",
"created_by": "SYSTEM DEFAULT",
"created_at": "2017-11-08 09:44:30 +0630",
"updated_at": "2018-03-14 16:02:09 +0630",
"image_path": {"url":null}
},
{
"id": 2,
"name": "Waiter",
"role": "waiter",
"emp_id": "111",
"password_digest": "$2a$10$PjBemEA2yKOcoGAyXjz81OqglrASIF8RTYHVe0vqp3FQ0T4/PzJJG",
"token_session": "662e797ad508ab6c43b1",
"session_expiry": "2018-02-21 01:45:11 +0630",
"session_last_login": "2018-02-20 13:45:11 +0630",
"created_by": "SYSTEM DEFAULT",
"created_at": "2017-11-08 09:44:30 +0630",
"updated_at": "2018-02-20 13:59:17 +0630",
"image_path": {"url":null}
},
{
"id": 3,
"name": "Waiter 2",
"role": "waiter",
"emp_id": "222",
"password_digest": "$2a$10$gXh/Tpbr8EyJSaxsbJYVh.K7Fr4bT0A1i2mWuuZm/FHQ4D/wV1E8e",
"token_session": "61868be9530b753ada84",
"session_expiry": "2018-03-14 05:41:12 +0630",
"session_last_login": "2018-03-13 17:11:12 +0630",
"created_by": "SYSTEM DEFAULT",
"created_at": "2017-11-08 09:44:30 +0630",
"updated_at": "2018-03-13 17:32:47 +0630",
"image_path": {"url":null}
},
{
"id": 4,
"name": "Cashier",
"role": "cashier",
"emp_id": "333",
"password_digest": "$2a$10$fHo.9wOn.yr.2Ke6iuCfou6DjpyHXwQSmZQ.43O7W4SnlmzuoIEF2",
"token_session": "693f6e98bb90b6af9978",
"session_expiry": "2018-03-15 12:36:28 +0630",
"session_last_login": "2018-03-14 16:36:28 +0630",
"created_by": "SYSTEM DEFAULT",
"created_at": "2017-11-08 09:44:30 +0630",
"updated_at": "2018-03-14 17:05:14 +0630",
"image_path": {"url":null}
},
{
"id": 5,
"name": "manager",
"role": "manager",
"emp_id": "888",
"password_digest": "$2a$10$EaU/Sxfsb8Q3kBIAyxSEJ.ZpRC9vxSdVAFvF0WXUvWiAqHyqGggoe",
"token_session": null,
"session_expiry": null,
"session_last_login": "2018-01-16 13:37:05 +0630",
"created_by": null,
"created_at": "2017-11-30 10:03:11 +0630",
"updated_at": "2018-01-16 13:48:02 +0630",
"image_path": {"url":null}
},
{
"id": 6,
"name": "Account",
"role": "account",
"emp_id": "777",
"password_digest": "$2a$10$bJmgIxHefkvxpxJQLQPcpurTJrp8.BwP/kirJRYb1v1thrU3TDzkC",
"token_session": null,
"session_expiry": null,
"session_last_login": "2018-01-16 10:37:22 +0630",
"created_by": null,
"created_at": "2018-01-16 10:23:09 +0630",
"updated_at": "2018-01-16 10:49:24 +0630",
"image_path": {"url":null}
},
{
"id": 7,
"name": "Supervisor",
"role": "supervisor",
"emp_id": "666",
"password_digest": "$2a$10$/WQirOw5nu6kKDiITTVa7.IGeVyxH5JmLp3/Astu/5DlOAoMLn4Ne",
"token_session": null,
"session_expiry": null,
"session_last_login": "2018-01-16 14:28:40 +0630",
"created_by": null,
"created_at": "2018-01-16 10:23:32 +0630",
"updated_at": "2018-01-16 15:32:33 +0630",
"image_path": {"url":null}
},
{
"id": 8,
"name": "123",
"role": "waiter",
"emp_id": "123",
"password_digest": "$2a$10$v8JBsc31XkLRNZ/QhfYBg.wbVT7CyVvk83U..0PsGiz61w0Atl/WW",
"token_session": "4fc9a18a5df511e507fc",
"session_expiry": "2018-02-01 20:08:35 +0630",
"session_last_login": "2018-02-01 14:08:35 +0630",
"created_by": null,
"created_at": "2018-02-01 14:07:16 +0630",
"updated_at": "2018-02-01 17:45:10 +0630",
"image_path": {"url":null}
},
{
"id": 9,
"name": "Cashier 2",
"role": "cashier",
"emp_id": "444",
"password_digest": "$2a$10$5n34O09xmrIHbgvX.uhr9uAaUR8etjaqiicaXr017VWm/qDkjKVue",
"token_session": "0477edce9cf259f280c1",
"session_expiry": "2018-02-20 19:07:50 +0630",
"session_last_login": "2018-02-20 11:37:50 +0630",
"created_by": null,
"created_at": "2018-02-14 17:10:12 +0630",
"updated_at": "2018-02-20 13:37:46 +0630",
"image_path": {"url":null}
}
]