fix conflit

This commit is contained in:
Zin Lin Phyo
2017-08-28 18:22:32 +06:30
26 changed files with 644 additions and 253 deletions

View File

@@ -4,8 +4,25 @@ class Api::Restaurant::MenuController < Api::ApiController
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menus = Menu.all
# @current_menu = Menu.current_menu
param_checksum = params[:checksum]
# checksum = File.readlines("public/checksums/menu_json.txt").pop.chomp
all_menu = Menu.all
# to hash
menu_array = []
all_menu.each do |m|
menu_array.push(m.to_json(:include => {:menu_categories => { :include => { :menu_items => { :include => [:menu_item_sets, :menu_item_instances => {:include => :menu_instance_item_sets}]} } }}))
end
#export Checksum file generate by md5
menu_checksum = Digest::MD5.hexdigest(menu_array.to_json)
if menu_checksum != param_checksum
response.headers['CHECKSUM'] = menu_checksum
@menus = all_menu
end
# @current_menu = Menu.current_menu
end
#Description

View File

@@ -6,13 +6,33 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers.json
def index
filter = params[:filter]
type = params[:type]
if filter.nil?
@crm_customers = Customer.all
else
@crm_customers = Customer.search(filter)
# search account no from paypar
if !@crm_customers.present? && type == "card"
response = Customer.search_paypar_account_no(filter)
if response["status"] == true
@crm_customers = Customer.new
@crm_customers.name = response["customer_data"]["name"]
@crm_customers.contact_no = response["customer_data"]["phone"]
@crm_customers.email = response["customer_data"]["email"]
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
@crm_customers.nrc_no = response["customer_data"]["NRC"]
@crm_customers.address = response["customer_data"]["address"]
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
@crm_customers.paypar_account_no = filter
@crm_customers.membership_id = response["customer_data"]["id"]
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
@crm_customers.customer_type = "Dinein"
@crm_customers.tax_profiles = ["1", "2"]
@crm_customers.save
@crm_customers = Customer.search(filter)
end
end
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
@count_customer = Customer.count_customer

View File

@@ -9,13 +9,40 @@ class Origami::CustomersController < BaseOrigamiController
end
def get_customer
filter = params[:filter]
type = params[:type]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
@crm_customers = Customer.search(filter)
# search account no from paypar
if !@crm_customers.present? && type == "card"
response = Customer.search_paypar_account_no(filter)
if response["status"] == true
@crm_customers = Customer.new
@crm_customers.name = response["customer_data"]["name"]
@crm_customers.contact_no = response["customer_data"]["phone"]
@crm_customers.email = response["customer_data"]["email"]
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
@crm_customers.nrc_no = response["customer_data"]["NRC"]
@crm_customers.address = response["customer_data"]["address"]
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
@crm_customers.paypar_account_no = filter
@crm_customers.membership_id = response["customer_data"]["id"]
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
@crm_customers.customer_type = "Dinein"
@crm_customers.tax_profiles = ["1", "2"]
@crm_customers.save
@crm_customers = Customer.search(filter)
else
@crm_customers = [{"customer_id": response["status"],"message": response["message"] }]
end
end
end
render :json => @crm_customers.to_json
end

View File

@@ -8,9 +8,10 @@ class Origami::InJutiesController < BaseOrigamiController
end
def index_in_juty
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
@juty_in= InJuty.where("dinning_id=?",params[:table_id])
@table = DiningFacility.find(params[:table_id])
@in_juty = InJuty.new
@juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10)
end
# GET /in_juties/1
@@ -31,6 +32,9 @@ class Origami::InJutiesController < BaseOrigamiController
def edit_in_juty
@in_juty = InJuty.find(params[:id])
@table = DiningFacility.find(params[:table_id])
@commissioner = @in_juty.commissioner
render json: {in_juty: @in_juty, commissioner: @commissioner}
end
def assign_in_juty
@@ -89,12 +93,19 @@ class Origami::InJutiesController < BaseOrigamiController
end
def update_for_in_juty
@in_juty.dinning_id = params[:dining_id]
@in_juty.commissioner_ids = params[:commissioner_ids]
@in_juty.in_time = params[:in_time]
@in_juty.out_time = params[:out_time]
@in_juty.save
def update_for_in_juty
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
@in_juty.in_time = in_juty_params[:in_time]
@in_juty.out_time = in_juty_params[:out_time]
respond_to do |format|
if @in_juty.save
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# DELETE /in_juties/1
@@ -125,6 +136,6 @@ class Origami::InJutiesController < BaseOrigamiController
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time)
params.require(:in_juty).permit(:id,:dinning_id,:commissioner_ids,:in_time,:out_time)
end
end

View File

@@ -79,7 +79,7 @@ class Settings::SimpleMenuItemsController < ApplicationController
respond_to do |format|
if @settings_menu_item.save
menu_item = MenuItem.find(@settings_menu_item.id)
menu_item.update_attributes(item_options: params[:simple_menu_item][:item_options])
menu_item.update_attributes(item_attributes: params[:simple_menu_item][:item_attributes], item_options: params[:simple_menu_item][:item_options])
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item }

View File

@@ -91,46 +91,54 @@ class Customer < ApplicationRecord
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
@customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL")
@customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL")
@customers.each do |customer|
begin
response = HTTParty.post(url,
:body =>
{ name: customer.name,phone: customer.contact_no,
email: customer.email,dob: customer.date_of_birth,
address: customer.address,nrc:customer.nrc_no,
card_no:customer.card_no,member_group_id: customer.membership_type,
merchant_uid:merchant_uid,auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
})
rescue Net::OpenTimeout
response = { status: false, message: "Server Time out" }
rescue OpenURI::HTTPError
response = { status: false, message: "Can't connect server"}
member_params = { name: customer.name,phone: customer.contact_no,
email: customer.email,dob: customer.date_of_birth,
address: customer.address,nrc:customer.nrc_no,
card_no:customer.card_no,member_group_id: customer.membership_type,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
rescue SocketError
response = { status: false, message: "Can't connect server"}
end
# Check for paypar account exists
# if paypar_account_no != nil || paypar_account_no != ''
if paypar_account_no.present?
member_params = { name: customer.name,phone: customer.contact_no,
email: customer.email,dob: customer.date_of_birth,
address: customer.address,nrc:customer.nrc_no,
paypar_account_no: customer.paypar_account_no,
card_no:customer.card_no,member_group_id: customer.membership_type,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
end
if response["status"] == true
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
end
begin
response = HTTParty.post(url,
:body => member_params,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
})
rescue Net::OpenTimeout
response = { status: false, message: "Server Time out" }
rescue OpenURI::HTTPError
response = { status: false, message: "Can't connect server"}
rescue SocketError
response = { status: false, message: "Can't connect server"}
end
if response["status"] == true
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
end
end
end
def self.update_rebate
sales = Sale.where("rebate_status = 'false'")
sales.each do |sale|
if sale.customer.membership_id
response = self.rebat(Sale.find(sale.sale_id))
puts response.to_json
response = self.rebat(Sale.find(sale.sale_id))
if response["status"] == true
status = sale.update_attributes(rebate_status: "true")
end
@@ -188,12 +196,44 @@ class Customer < ApplicationRecord
response = { "status": false, "message": "Can't connect server"}
end
return response
puts response.to_json
return response
end
end
end
def self.search_paypar_account_no(account_no)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("search_paypar_account_no")
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
response = HTTParty.get(url,
:body => { paypar_account_no:account_no,
merchant_uid:merchant_uid,
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
},
:timeout => 10
)
rescue HTTParty::Error
response = {status: false, message: "Server Error"}
rescue Net::OpenTimeout
response = { status: false , message: "Server Time out"}
rescue OpenURI::HTTPError
response = { status: false, message: "Can't connect server"}
rescue SocketError
response = { status: false, message: "Can't connect server"}
end
return response
end
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])

View File

@@ -1,6 +1,6 @@
class MenuItemAttribute < ApplicationRecord
validates_presence_of :attribute_type, :name, :value
def self.collection
MenuItemAttribute.select("name, value").map { |e| [e.name, e.value] }
MenuItemAttribute.select("name").map { |e| [e.name, e.name] }
end
end

View File

@@ -90,7 +90,7 @@ class Order < ApplicationRecord
# self.employee_name)
# end
OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
OrderItem.processs_item(menu_item[:item_code], item[:item_instance_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
self.employee_name)

View File

@@ -20,11 +20,12 @@ class OrderItem < ApplicationRecord
# option_values : [],
# sub_order_items : [],
# }
def self.processs_item (item_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
def self.processs_item (item_code, instance_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
orderitem = OrderItem.create do |oitem|
oitem.order_id = order_id
oitem.item_code = item_code
oitem.item_instance_code = instance_code
oitem.item_name = menu_name
oitem.alt_name = alt_name
oitem.account_id = account_id

View File

@@ -69,7 +69,7 @@ class Promotion < ApplicationRecord
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, sale_id)
elsif promo.promo_type == Promotion::PROMO_TYPE4
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, sale_id)
give_promotion_discount(same,promo_product,promo.min_qty, orderitem, sale_id)
end
end
@@ -138,8 +138,8 @@ class Promotion < ApplicationRecord
sale_item.remark = type
sale_item.qty = foc_qty * (-1)
sale_item.unit_price = item_price * (-1)
sale_item.taxable_price = item_price * (-1)
sale_item.unit_price = item_price # * (-1)
sale_item.taxable_price = item_price # * (-1)
sale_item.price = foc_qty * item_price * (-1)
sale_item.is_taxable = false
@@ -170,8 +170,8 @@ class Promotion < ApplicationRecord
if same
foc_qty = orderitem[1].to_i / foc_min_qty
item = OrderItem.find_by_item_code(orderitem[0])
price = item.price - promo_product.net_price
item = OrderItem.find_by_item_code(orderitem[0]) # need to specify with menu item instance
price = item.price.to_i - promo_product.net_price.to_i
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
else
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
@@ -187,13 +187,15 @@ class Promotion < ApplicationRecord
if same
foc_qty = orderitem[1].to_i / foc_min_qty
item = OrderItem.find_by_item_code(orderitem[0])
total = orderitem[1].to_i * item.price
# total = orderitem[1].to_i * item.price
total = item.price
price = calculate_discount(total, promo_product.percentage)
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
else
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
item = OrderItem.find_by_item_code(promo_product.item_code)
total = item.price * foc_qty
# total = item.price * foc_qty
total = item.price
price = calculate_discount(total, promo_product.percentage)
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
end

View File

@@ -324,7 +324,6 @@ class SalePayment < ApplicationRecord
update_shift
end
end
end
# update for cashier shift

View File

@@ -17,5 +17,4 @@ if (menu.menu_categories)
end
end
end
end

View File

@@ -1,44 +1,82 @@
# Format for attributes json
attr_format = []
param_count = item.item_attributes.count
# Format for attributes json
item.item_attributes.each do|attr_id|
menu_attr = MenuItemAttribute.find(attr_id)
if attr_format.count == 0
attr_format.push({ type: menu_attr.attribute_type, value: [] })
end
attr_format.each do |af|
if menu_attr.attribute_type == af[:type]
af[:value].push(menu_attr.value)
else
new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
attr_format.push(new_attr)
# Format for attributes json
if item.item_attributes.count > 0
item.item_attributes.each do|attr_id|
menu_attr = MenuItemAttribute.find(attr_id)
if attr_format.count == 0
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
next
end
break if attr_format.count > param_count
end
param_count -= 1
attr_format.each do |af|
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
if menu_attr.attribute_type == af[:type]
af[:values].push(menu_attr.name)
end
else
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
attr_format.push(new_attr)
break
end
end
end
end
# Format for option json
opt_format = []
# Format for attributes json
if item.item_options.count > 0
item.item_options.each do|opt|
menu_opt = MenuItemOption.find(opt)
if opt_format.count == 0
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
next
end
opt_format.each do |of|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
if menu_opt.option_type == of[:type]
of[:values].push(menu_opt.name)
end
else
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
opt_format.push(new_opt)
break
end
end
end
end
#Menu Item Information
json.id item.id
json.item_code item.item_code
json.code item.item_code
json.name item.name
json.alt_name item.alt_name
json.image item.image_path.url
json.description item.description
json.Information item.information
json.information item.information
json.type item.type
json.account_id item.account_id
json.min_qty item.min_qty
json.is_available item.is_available
json.is_sub_item item.is_sub_item
json.unit item.unit
json.item_sets item.item_sets
# Item Sets of Menu Item
json.item_sets item.item_sets do |its|
json.id its.id
json.name its.name
json.alt_name its.alt_name
json.min_selectable_qty its.min_selectable_qty
json.max_selectable_qty its.max_selectable_qty
json.instances its.menu_item_instances do |i|
json.id i.id
end
end
json.attributes attr_format
json.options item.item_options
json.options opt_format
# json.min_selectable_item item.min_selectable_item
# json.max_selectable_item item.max_selectable_item
@@ -52,6 +90,7 @@ json.options item.item_options
# json.item_attributes = item_instance.item_attributes
json.instances item.menu_item_instances do |is|
json.id is.id
json.code is.item_instance_code
json.name is.item_instance_name
json.price is.price
@@ -59,8 +98,8 @@ json.options item.item_options
json.is_default is.is_default
json.is_on_promotion is.is_on_promotion
json.promotion_price is.promotion_price
json.item_attributes is.item_attributes
json.item_sets is.item_sets
json.values is.item_attributes
# json.item_sets is.item_sets
end
#Child Menu items

View File

@@ -1,4 +1,4 @@
json.array! @menus do |menu|
menu_json = json.array! @menus do |menu|
json.id menu.id
json.name menu.name
json.valid_days menu.valid_days
@@ -12,3 +12,4 @@ json.array! @menus do |menu|
# end
# end
end

View File

@@ -169,6 +169,7 @@
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
$("#search").val(cardNo);
$("#type").val("card");
}
}
</script>

View File

@@ -25,6 +25,7 @@
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
<div class="input-append col-md-7 form-group pull-left">
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control input-xs col-md-9">
<input type="hidden" name="type" id="type" value="">
<button type="submit" class="btn btn-primary btn-md">Search</button>
<!-- <a href="modal-window" data-toggle= "modal" data-target="#modal-window" class="btn btn-primary btn-md" id="card_read" >Read Card</a> -->

View File

@@ -49,48 +49,6 @@
</div>
</div>
</div>
<!-- Large modal -->
<button class="btn btn-primary" data-toggle="modal" data-target=".sx_item_detailModal">Large modal</button>
<div class="modal fade sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: #54A5AF;">
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">&times;</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-5">
<%= image_tag "logo.png" ,width: '', height: '', :style => '' %>
<br><br>
<div class="form-group">
<h4 class="col-md-12">Quantity</h4>
<input type="number" name="qty" class="form-control col-md-12 input-number" id="modal-qty" value="" min="1" max="100">
</div>
<div class="form-group row">
<h4 class="col-md-6">Total</h4>
<h4 class="col-md-6" id="total_price"> 2500 Ks</h4>
</div>
</div>
<div class="col-md-7">
<h4>Options</h4>
<h4>Attributes</h4>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
<button type="button" class="btn btn-success" data-dismiss="modal" id="save_order">Add Order</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true">
@@ -130,6 +88,51 @@
</div>
</div>
<!-- Large modal -->
<div class="modal fade sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: #54A5AF;">
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">&times;</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-5">
<%= image_tag "logo.png" ,width: '', height: '', :style => '' %>
<br><br>
<div class="form-group">
<h4 class="col-md-12">Quantity</h4>
<input type="number" name="qty" class="form-control col-md-12 input-number change_qty" id="change_qty" value="" min="1" max="100">
</div>
<div class="form-group row">
<h4 class="col-md-6">Total</h4>
<h4 class="col-md-6" id="total_price"></h4>
<p class="hidden" id="unit_price"></p>
</div>
</div>
<div class="col-md-7 item-detail">
<div class="hide attr-alert alert-danger" role="alert">
<strong>Oh !</strong>Have not attribute for this item Please select another attribute .
</div>
<div class="attributes-list">
</div>
<div class="option-list">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
<button type="button" class="btn btn-success add_to_order" data-dismiss="modal" id="add_to_order">Add to Order</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
@@ -141,6 +144,13 @@ $(function(){
show_menu_item_list(url);
});
//End menu category Click
$(".change_qty").change(function(){
qty = $(this).val();
price = $("#unit_price").text();
$("#total_price").text(qty*price);
});
//show menu item list when click menu category
function show_menu_item_list(url_item){
@@ -154,43 +164,36 @@ $(function(){
data: {},
dataType: "json",
success: function(data) {
console.log(data);
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
console.log(data);
for(var field in menu_items) {
var code = menu_items[field].instances[0].code
var name = menu_items[field].instances[0].name
var price = parseFloat(menu_items[field].instances[0].price).toFixed(2);
var is_available = menu_items[field].instances[0].is_available
var is_on_promotion = menu_items[field].instances[0].is_on_promotion
var item_attributes = menu_items[field].instances[0].item_attributes
var promotion_price = menu_items[field].instances[0].promotion_price
instances = menu_items[field].instances ;
$(instances).each(function(i){
if (instances[i].is_default === true) {
code = instances[i].code;
name = instances[i].name;
price = parseFloat(instances[i].price).toFixed(2);
is_available = instances[i].is_available ;
is_on_promotion = instances[i].is_on_promotion;
item_attributes = instances[i].values;
promotion_price = instances[i].promotion_price;
code = instances[i].code;
}
});
row = '<div class="card">'
row = '<div class="card">'
+'<div class="card-head" style="line-height:14px;">'
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
+'<div class="col-md-3 add_icon"'
+'data-id="'+ menu_items[field].name +'"'
+'data-item-code="'+ menu_items[field].item_code +'"'
+'data-name="'+ menu_items[field].name +'"'
+'data-price="'+ price +'"'
+'data-available="'+ is_available +'"'
+'data-promotion="'+ is_on_promotion +'"'
+'data-attributes="'+ item_attributes +'"'
+'data-instance-code="'+ code +'"'
+'data-instance="'+ name +'"'
+'data-promotion-price="'+ promotion_price +'"'
+'>'
+"<div class='col-md-3 add_icon' data-item-code='"+ menu_items[field].code +"' data-name='"+ menu_items[field].name +"' data-price = '"+ price +"' data-instance-code = '"+ code +"' data-instance = '"+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"+ JSON.stringify(item_attributes) +"'>"
+'<i class="fa fa-plus "'
+ 'style="margin-top:4px;">'
+'</i></div>'
+'</div>'
+'<div class="menu_item_box" data-toggle="modal" data-target=".sx_item_detailModal">'
+"<div class='menu_item_box' data-instance = '"+JSON.stringify(menu_items[field].instances)+"' data-id = '"+JSON.stringify(menu_items[field].attributes)+"' data-item = '"+JSON.stringify(item_attributes)+"' data-toggle='modal' data-target='.sx_item_detailModal'>"
+'<div class="card-block">'
+'<%= image_tag "logo.png" ,width: '75', height: '75', :style => '' %>'
+'</div>'
@@ -206,7 +209,115 @@ $(function(){
});
//end Ajax
}
//end show detail function
//end show list function
//click item row for add order
$(document).on('click', '.menu_item_box', function(event){
$('.attributes-list').empty();
$('.attr-alert').addClass('hide');
data = $(this).parent().children().children('.add_icon');
attributes = $(this).data('id');
selected_item = $(this).data('item');
instances = $(this).data('instance');
for(var field in attributes) {
value = attributes[field]["values"];
type = attributes[field]["type"]
row = "<h4>"+attributes[field]["type"]+"</h4>"
$(value).each(function(i){
status ="";
if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){
status = "selected-option";
}
row +="<button id='selected-option' data-instances='"+JSON.stringify(instances)+"' data-type='"+type+"' data-value='"+value[i]+"' class='btn btn-default attribute_btn "+ status +" "+ type +" '>"+value[i]+"</button>";
});
$(".attributes-list").append(row);
}
$('#change_qty').val(1);
$('#title_name').text(data.attr('data-name'));
$('#item_code').text(data.attr('data-item-code'));
$('#total_price').text(data.attr('data-price'));
$('#unit_price').text(data.attr('data-price'));
});
// click select option icon for add
$(document).on('click', '.attribute_btn', function(event){
value = $(this).data('value');
type = $(this).data('type');
instances = $(this).data('instances');
console.log(instances);
if ($(".attribute_btn").attr("data-type")==type){
$('.'+type).removeClass("selected-option");
}
$(this).addClass('selected-option');
selected_item = $('.selected-option').text();
qty = $('#change_qty').val();
total_price = 0;
for(var field in instances) {
item_attr = instances[field].values;
if(parseInt(jQuery.inArray(selected_item, item_attr))!== -1){
unit_price = instances[field].price
total_price = qty * unit_price
$('#instance_name').text(instances[field].name);
$('#instance_code').text(instances[field].code);
$('#promotion_price').text(instances[field].promotion_price);
$('#total_price').text(total_price);
$('#unit_price').text(unit_price);
}
}
if (total_price == 0) {
$('.attr-alert').removeClass('hide');
$('#total_price').text(total_price);
}else{
$('.attr-alert').addClass('hide');
$('#total_price').text(total_price);
}
}); //End selecct attribute buttom
// click add order
$(document).on('click', '.add_to_order', function(event){
total_price = $('#total_price').text();
unit_price = $('#unit_price').text();
qty = $('#change_qty').val();
var item_row = $('.selected-option');
var arr = [];
var attribute_arr = [];
$(item_row).each(function(i){
value = $(item_row[i]).attr('data-value');
arr = {value};
});
console.log(arr);
if(total_price > 0){
$('.add_to_order').attr('data-item-code',$('#item_code').text());
$('.add_to_order').attr('data-name',$('#title_name').text());
$('.add_to_order').attr('data-price',unit_price);
$('.add_to_order').attr('data-instance-code',$('#instance_code').text());
$('.add_to_order').attr('data-instance',$('#instance_name').text());
$('.add_to_order').attr('data-promotion-price',$('#promotion_price').text());
$('.add_to_order').attr('data-attributes',$('#instance_name').text());
var item_data = $(this);
show_item_detail(item_data);
calculate_sub_total();
}else{
$.alert({
title: 'Alert!',
content: 'Please select another item',
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}
}); //End Add Icon Click
// click plus icon for add
$(document).on('click', '.add_icon', function(event){
@@ -219,9 +330,9 @@ $(function(){
qty = 1;
append = 0;
price = parseFloat(data.attr('data-price')).toFixed(2);
instance_code = data.attr('data-instance');
instance_name = data.attr('data-instance');
if (instance_code == "undefined"){
if (instance_name == "undefined"){
instance = '';
}else{
instance = "("+data.attr('data-instance')+")";
@@ -231,11 +342,13 @@ $(function(){
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
if ($(item_row[i]).attr('data-code') == data.attr('data-item-code')) {
item_code = $(item_row[i]).attr('data-code');
instance_code = $(item_row[i]).attr('data-instance-code');
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')) {
qty = parseInt($(item_row[i]).children('#item_qty').text()) +1;
$(item_row[i]).children('#item_qty').text(qty);
parseFloat($(item_row[i]).children('#item_price').text(price*qty)).toFixed(2);
append = 1;
}else{
qty = 1;
@@ -243,9 +356,9 @@ $(function(){
});
if (append===0) {
row ="<tr class='item_box' data-price ='"+price+ "'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"+instance+ "'data-code='"+data.attr('data-item-code')+"'>"
row ="<tr class='item_box' data-price ='"+price+ "'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"+instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='"+data.attr('data-instance-code')+"' data-attributes='"+data.attr('data-attributes')+"'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance + '</td>'
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(price).toFixed(2)
@@ -253,7 +366,6 @@ $(function(){
+'</tr>';
$(".summary-items tbody").append(row);
}
}
//click item row for update qty
@@ -265,14 +377,6 @@ $(function(){
$('#modal-qty').val(qty);
});
//click item row for update qty
$(document).on('click', '.menu_item_box', function(event){
data = $(this).parent().children().children('.add_icon');
$('#title_name').text(data.attr('data-name'));
console.log(data);
});
//click remove buttom in modal box
$('#sx_itemModal').on('click','#remove', function(){
$('.summary-items tr').filter(function(){
@@ -321,7 +425,6 @@ $(function(){
function summary_items_filter(){
$('.summary-items tr').filter(function(){
if ($(this).attr('data-active') == 'true'){
qty = $('#modal-qty').val();
price = parseFloat($(this).attr('data-price'));
@@ -406,6 +509,17 @@ $(function(){
padding-top: 100px;
}
.selected-option {
color: #fff !important;
background-color: green !important;
}
.attribute_btn {
white-space: normal !important;
height: 60px;
width: 90px;
margin-bottom: 5px;
margin-right: 5px;
}
</style>

View File

@@ -22,6 +22,7 @@
<%= form_tag path, :id => "filter_form", :method => :get do %>
<div class="input-append col-md-7 form-group pull-left">
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
<input type="hidden" name="type" id="type" value="">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
</div>
<% end %>
@@ -258,12 +259,23 @@
$.ajax({
type: "POST",
url: "get_customer" ,
data: { filter : customer_mamber_card_no },
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
customer_id = data[0].customer_id;
customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id);
success: function(data) {
if (data[0].customer_id == false) {
$.alert({
title: 'Alert!',
content: data[0].message,
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id);
}
}
});
}
@@ -282,6 +294,7 @@
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
$("#search").val(cardNo);
$("#type").val("card")
}
}

View File

@@ -1,9 +1,12 @@
<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :method => :post do |f| %>
<%= simple_form_for @in_juty,:url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-inputs">
<%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
<label>Dining Name:</label>
<%= @table.name %>
<br/>
@@ -12,14 +15,14 @@
<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=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
<%= f.text_field :in_time, :value=>'',:class=>"form-control datepicker"%><br/>
<label>Out time</label>
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
<%= f.text_field :out_time, :value=>'',:class=>"form-control datepicker"%>
</div><br>
<div class="form-group">
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update' %>
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
</div>
@@ -30,11 +33,18 @@
$(function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
format : 'yyyy-mm-dd',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
});
$('#reset').click(function() {
// window.location.href = '/origami/assign_in_juty/'+ table_id;
location.reload();
return false;
});
</script>

View File

@@ -2,8 +2,7 @@
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :dinning_id %>
<%= f.input :commissioner_ids %>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
<%= f.input :in_time %>
<%= f.input :out_time %>
</div>

View File

@@ -4,6 +4,7 @@
<table class="table table-striped">
<thead>
<tr>
<th>Select</th>
<th>Dining Facility Name</th>
<th>Commissioner Ids</th>
<th>In time</th>
@@ -21,13 +22,12 @@
<td><%= in_juty.commissioner.name rescue '-' %></td>
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Back', origami_path(in_juty.dining_facility.id) %></td>
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty.dining_facility.id,in_juty) %></td>
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id,in_juty),method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @juties_in %>
</div>
<div class="col-md-4">
@@ -35,40 +35,45 @@
</div>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
</div>
<script type="text/javascript">
$(document).on('click',".injuty_tr",function(){
debugger;
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true );
var in_juty_id = $(this).attr('data-ref');
var table_id = "<%= @table.id %>";
var url = "/origami/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
var url = "/origami/assign_in_juty/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
// Selected for Taxes
$('#in_juty_commissioner_ids').val(data.commissioner.name);
$('#in_juty_in_time').val(data.in_time);
$('#in_juty_out_time').val(data.out_time);
$('#in_juty_id').val(data.in_juty.id);
$('#in_juty_commissioner_ids').val(data.commissioner.id);
$('#in_juty_in_time').val(data.in_juty.in_time.split('T')[0]);
$('#in_juty_out_time').val(data.in_juty.out_time.split('T')[0]);
$('#update').removeAttr('disabled');
$('#update').removeAttr('disabled').val('');
$('#update').attr('value', 'Update');
$('#create').attr('disabled','disabled');
$("#new_in_juty").attr('class', 'simple_form new_in_juty');
var id = customer_id;
$("#new_customer").attr('id', id);
$("#new_in_juty").attr('class', 'simple_form edit_in_juty');
var id = "edit_in_juty_" + in_juty_id;
$("#new_in_juty").attr('id', id);
$(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_in_juty").attr('id', id);
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
}
});
@@ -76,4 +81,9 @@ $(document).on('click',".injuty_tr",function(){
// }
})
$('#back').on('click', function () {
window.location.href = '/origami/table/'+ "<%= @table.id %>";
})
</script>