Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into doemal_ordering

This commit is contained in:
EikhantMon
2018-06-01 17:14:12 +06:30
8 changed files with 99 additions and 30 deletions

View File

@@ -185,6 +185,26 @@ $(document).ready(function() {
} }
}); });
$(".order").fileinput({
previewFileType: "mp3",
allowedFileExtensions: ["mp3"],
browseClass: "btn btn-success",
browseLabel: "Pick Audio",
browseIcon: "<i class=\"fa fa-image\"></i> ",
removeClass: "btn btn-danger",
removeLabel: "Delete",
removeIcon: "<i class=\"fa fa-trash\"></i> ",
showUpload: false,
// uploadClass: "btn btn-info",
// uploadLabel: "Upload",
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
previewTemplates: {
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
'</div>\n',
}
});
// first input focus for all form // first input focus for all form
$('form:first *input[data-behaviour!=datepicker]:input[type!=hidden]:first').focus(); $('form:first *input[data-behaviour!=datepicker]:input[type!=hidden]:first').focus();

View File

@@ -5,14 +5,10 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
ORDER_RESERVATION = "order_and_reservation" ORDER_RESERVATION = "order_and_reservation"
def check_customer def check_customer
customer_id = 0 customer_id = nil
status = false status = false
if !params[:name] if !params[:name] || !params[:email] || !params[:contact_no] || !params[:membership_id]
render :json => { :status => false, :message => "name is required!" } render :json => { :status => false, :message => "name, email, contact_no and membership_id are required!" }
elsif !params[:email]
render :json => { :status => false, :message => "email is required!" }
elsif !params[:membership_id]
render :json => { :status => false, :message => "membership_id is required!" }
else else
status = true status = true
end end
@@ -25,9 +21,13 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
customer = OrderReservation.addCustomer(params) customer = OrderReservation.addCustomer(params)
customer_id = customer.id customer_id = customer.id
end end
if !customer_id.nil?
render :json => { :status => false, :message => "email and customer are already existed!" }
else
render :json => { :status => true, :data => { :customer_id => customer_id} } render :json => { :status => true, :data => { :customer_id => customer_id} }
end end
end end
end
def create def create
status = false status = false

View File

@@ -17,8 +17,8 @@ class Api::SurveyController < Api::ApiController
dining_facility = DiningFacility.find(params[:id]) dining_facility = DiningFacility.find(params[:id])
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
puts params.to_json
if params[:survey][:id] if params[:survey][:id]>0
survey = Survey.find(params[:survey][:id]) survey = Survey.find(params[:survey][:id])
else else
survey = Survey.new survey = Survey.new

View File

@@ -47,15 +47,28 @@ class Settings::ShopsController < ApplicationController
# PATCH/PUT /settings/shops/1 # PATCH/PUT /settings/shops/1
# PATCH/PUT /settings/shops/1.json # PATCH/PUT /settings/shops/1.json
def update def update
respond_to do |format| respond_to do |format|
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|
if File.extname(a.original_filename) == ".mp3"
delete_path = Rails.root.join("public/#{@settings_shop.display_images.find_by_name("order_audio").image}")
if File.exists?(delete_path)
File.delete(delete_path)
end
save_path = Rails.root.join("public/#{Shop.find(1).shop_code}_#{a.original_filename}")
File.open(save_path, 'wb') do |f|
f.write a.read
end
audio_name = "#{Shop.find(1).shop_code}_#{a.original_filename}"
@settings_shop.display_images.where(:name => "order_audio").destroy_all
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name)
else
@aa = Base64.encode64(a.read) @aa = Base64.encode64(a.read)
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => "data:image/jpeg;base64,"+@aa) @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => "data:image/jpeg;base64,"+@aa)
end 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.' }
format.json { render :index, status: :ok, location: @settings_shop } format.json { render :index, status: :ok, location: @settings_shop }
else else
@@ -85,6 +98,6 @@ class Settings::ShopsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def shop_params def shop_params
params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info, display_images_attributes: [:id, :shop_id, :image]) params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info, display_images_attributes: [:id, :shop_id, :name, :image])
end end
end end

View File

@@ -154,7 +154,8 @@ class Promotion < ApplicationRecord
promotion_qty = foc_qty promotion_qty = foc_qty
end end
# item = OrderItem.find_by_item_instance_code(promo_product) # item = OrderItem.find_by_item_instance_code(promo_product)
item = OrderItem.where("item_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first item = OrderItem.where("item_instance_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
source = Order.find(item.order_id).source source = Order.find(item.order_id).source
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source) update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
end end
@@ -211,8 +212,12 @@ class Promotion < ApplicationRecord
source = Order.find(item.order_id).source source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source) update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
else else
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code)# need to check for qty order_qty = find_second_item_qty(sale_id, promo_product.item_code)# need to check for qty
foc_qty = orderitem[1].to_i / foc_min_qty foc_qty = orderitem[1].to_i / foc_min_qty
if foc_qty > order_qty
foc_qty = order_qty
end
# item = OrderItem.find_by_item_instance_code(promo_product.item_code) # item = OrderItem.find_by_item_instance_code(promo_product.item_code)
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
price = item.price - promo_product.net_price price = item.price - promo_product.net_price
@@ -233,11 +238,13 @@ class Promotion < ApplicationRecord
source = Order.find(item.order_id).source source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source) update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
else else
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check order_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check
foc_qty = orderitem[1].to_i / foc_min_qty foc_qty = orderitem[1].to_i / foc_min_qty
# give total qty is 1 # give total qty is 1
#foc_qty = (foc_qty - foc_qty) + 1 #foc_qty = (foc_qty - foc_qty) + 1
if foc_qty > order_qty
foc_qty = order_qty
end
# item = OrderItem.find_by_item_instance_code(promo_product.item_code) # item = OrderItem.find_by_item_instance_code(promo_product.item_code)
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
# total = item.price * foc_qty # total = item.price * foc_qty

View File

@@ -468,7 +468,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="mr-2 m-t-5 btn-lg btn-block bg-red waves-effect print_receipt"> Print <button type="button" class="mr-2 m-t-5 btn-lg btn-block bg-red waves-effect print_receipt" id="print_receipt"> Print
</button> </button>
<button type="button" class="btn-lg btn-block bg-blue waves-effect btn_pdf_close" data-dismiss="modal"> <button type="button" class="btn-lg btn-block bg-blue waves-effect btn_pdf_close" data-dismiss="modal">
CLOSE CLOSE
@@ -1045,15 +1045,12 @@ var pdf_view = '<%=@pdf_view%>';
//print pdf function //print pdf function
// $(".print_receipt").on('click',function(){ // $(".print_receipt").on('click',function(){
$(document).on('touchstart click', '.print_receipt', function(event){ $("#print_receipt").on('click touchstart', function(event){
$(this).off("click touchstart touchend");
print_receipt(); print_receipt();
}); });
function print_receipt() { function print_receipt() {
if($('.print_receipt').is(":visible")) {
$('.print_receipt').prop("disabled",true);
}
if($('#pay').is(":visible")) { if($('#pay').is(":visible")) {
$('#pay').prop("disabled",true); $('#pay').prop("disabled",true);
} }

View File

@@ -47,9 +47,11 @@
<div class="form-group"> <div class="form-group">
<div class="menu-item-img"> <div class="menu-item-img">
<%= f.fields_for :display_images do |p| %> <%= f.fields_for :display_images do |p| %>
<% if p.object.name.nil? %>
<%= image_tag "#{p.object.image}", :class => "img-thumbnail second-display", :size => "150x185"%> <%= image_tag "#{p.object.image}", :class => "img-thumbnail second-display", :size => "150x185"%>
<%= link_to '<i class="material-icons">delete</i>'.html_safe, settings_shop_display_image_path(p.object), method: :delete %> <%= link_to '<i class="material-icons">delete</i>'.html_safe, settings_shop_display_image_path(p.object), method: :delete %>
<% end %> <% end %>
<% end %>
</div> </div>
</div> </div>
</div> </div>
@@ -57,6 +59,24 @@
<%= f.file_field :image, :multiple => true, name: "display_images[image][]" %> <%= f.file_field :image, :multiple => true, name: "display_images[image][]" %>
</div> </div>
<div class="card">
<div class="card-block">
<label class="card-title">Audio File</label>
<div class="panel padding-10">
<div class="form-group">
<div class="menu-item-img">
<%= f.fields_for :display_images do |p| %>
<% if !p.object.name.nil? %>
<%= "#{p.object.image}"%>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
<%= f.file_field :image, :multiple => false, name: "display_images[image][]", accept: 'audio/mp3', :class => "order" %>
</div>
<div class="form-actions p-l-15"> <div class="form-actions p-l-15">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div> </div>

View File

@@ -103,8 +103,20 @@
<td style="width:20%">Shop Images</td> <td style="width:20%">Shop Images</td>
<td> <td>
<% @display_images.each do |p| %> <% @display_images.each do |p| %>
<% if p.name.nil? %>
<%= image_tag "#{p.image}", :class => "img-thumbnail second-display", :size => "155x185"%> <%= image_tag "#{p.image}", :class => "img-thumbnail second-display", :size => "155x185"%>
<% end %> <% end %>
<% end %>
</td>
</tr>
<tr>
<td style="width:20%">Order Audio</td>
<td>
<% @display_images.each do |p| %>
<% if !p.name.nil? %>
<%= image_tag "#{p.image}", :class => "img-thumbnail second-display", :size => "155x185"%>
<% end %>
<% end %>
</td> </td>
</tr> </tr>
<tr> <tr>