Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into addorder
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
//= require settings/processing_items
|
||||
//= require jquery-ui
|
||||
//= require bootstrap-datepicker
|
||||
//= require jquery.datetimepicker
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.datepicker').datepicker({
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
@import "theme";
|
||||
@import "jquery-ui";
|
||||
@import "bootstrap-datepicker3";
|
||||
|
||||
@import "jquery.datetimepicker";
|
||||
|
||||
/* Show it is fixed to the top */
|
||||
// body {
|
||||
@@ -76,5 +76,3 @@ select.form-control {
|
||||
}
|
||||
|
||||
/*--- Reset --- */
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class Api::BillController < Api::ApiController
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
||||
end
|
||||
Promotion.promo_activate(@sale)
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@ class Origami::CommissionersController < BaseOrigamiController
|
||||
# GET /commissioners
|
||||
# GET /commissioners.json
|
||||
def index
|
||||
@commissioners = Commissioner.all
|
||||
@commissioners = Commissioner.all.order("id asc")
|
||||
end
|
||||
|
||||
# GET /commissioners/1
|
||||
|
||||
@@ -15,10 +15,12 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
# GET /commissions/new
|
||||
def new
|
||||
@commission = Commission.new
|
||||
@products = MenuItem.all
|
||||
end
|
||||
|
||||
# GET /commissions/1/edit
|
||||
def edit
|
||||
@products = MenuItem.all
|
||||
end
|
||||
|
||||
# POST /commissions
|
||||
@@ -28,11 +30,11 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
|
||||
respond_to do |format|
|
||||
if @commission.save
|
||||
format.html { redirect_to origami_commissions_path , notice: 'Commission was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @commission }
|
||||
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully created.'}
|
||||
format.json {render :show, status: :created, location: @commission}
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @commission.errors, status: :unprocessable_entity }
|
||||
format.html {render :new}
|
||||
format.json {render json: @commission.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -42,11 +44,11 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @commission.update(commission_params)
|
||||
format.html { redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @commission }
|
||||
format.html {redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.'}
|
||||
format.json {render :show, status: :ok, location: @commission}
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @commission.errors, status: :unprocessable_entity }
|
||||
format.html {render :edit}
|
||||
format.json {render json: @commission.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -56,19 +58,34 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
def destroy
|
||||
@commission.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.'}
|
||||
format.json {head :no_content}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commission
|
||||
@commission = Commission.find(params[:id])
|
||||
end
|
||||
def load_commissioners
|
||||
sale_id = params[:sale_id]
|
||||
@table_id = params[:table_id]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commission_params
|
||||
params.require(:commission).permit(:product_id,:amount,:commission_type, :is_active)
|
||||
end
|
||||
@commissioners = []
|
||||
end
|
||||
|
||||
def select_sale_item
|
||||
# byebug
|
||||
sale_item_id = params[:sale_item_id]
|
||||
@sale_item = SaleItem.find_by_sale_item_id(sale_item_id)
|
||||
@commissioners = Commissioner.active.all
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commission
|
||||
@commission = Commission.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commission_params
|
||||
params.require(:commission).permit(:product_id, :amount, :commission_type, :is_active)
|
||||
end
|
||||
end
|
||||
|
||||
74
app/controllers/origami/in_juties_controller.rb
Normal file
74
app/controllers/origami/in_juties_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Origami::InJutiesController < BaseOrigamiController
|
||||
before_action :set_in_juty, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /in_juties
|
||||
# GET /in_juties.json
|
||||
def index
|
||||
@in_juties = InJuty.all
|
||||
end
|
||||
|
||||
# GET /in_juties/1
|
||||
# GET /in_juties/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /in_juties/new
|
||||
def new
|
||||
@in_juty = InJuty.new
|
||||
end
|
||||
|
||||
# GET /in_juties/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /in_juties
|
||||
# POST /in_juties.json
|
||||
def create
|
||||
@in_juty = InJuty.new(in_juty_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @in_juty.save
|
||||
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @in_juty }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /in_juties/1
|
||||
# PATCH/PUT /in_juties/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @in_juty.update(in_juty_params)
|
||||
format.html { redirect_to origami_in_juty_path(@in_juty), 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
|
||||
# DELETE /in_juties/1.json
|
||||
def destroy
|
||||
@in_juty.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_in_juty
|
||||
@in_juty = InJuty.find(params[:id])
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
end
|
||||
@@ -28,8 +28,14 @@ class Settings::PromotionsController < ApplicationController
|
||||
def create
|
||||
@promotion = Promotion.new(promotion_params)
|
||||
@promotion.created_by = current_login_employee.id
|
||||
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
respond_to do |format|
|
||||
if @promotion.save
|
||||
promo_pros = @promotion.promotion_products
|
||||
promo_pros.each do |promo_pro|
|
||||
promo_pro.save
|
||||
end
|
||||
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @promotion }
|
||||
else
|
||||
@@ -44,6 +50,13 @@ class Settings::PromotionsController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @promotion.update(promotion_params)
|
||||
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
@promotion.save
|
||||
promo_pros = @promotion.promotion_products
|
||||
promo_pros.each do |promo_pro|
|
||||
promo_pro.save
|
||||
end
|
||||
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @promotion }
|
||||
else
|
||||
|
||||
2
app/helpers/origami/in_juties_helper.rb
Normal file
2
app/helpers/origami/in_juties_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Origami::InJutiesHelper
|
||||
end
|
||||
@@ -1,2 +1,4 @@
|
||||
class Commission < ApplicationRecord
|
||||
belongs_to :menu_item, foreign_key: 'product_id'
|
||||
has_many :commissioners
|
||||
end
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
class Commissioner < ApplicationRecord
|
||||
has_many :employees
|
||||
belongs_to :employee, foreign_key: 'emp_id'
|
||||
belongs_to :commission, foreign_key: 'commission_type'
|
||||
has_many :in_juties
|
||||
scope :active, -> { where(is_active: true) }
|
||||
end
|
||||
|
||||
@@ -91,41 +91,50 @@ 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
|
||||
|
||||
@@ -3,19 +3,22 @@ class DiningCharge < ApplicationRecord
|
||||
belongs_to :room
|
||||
|
||||
def self.amount_calculate(dining_charges_obj, checkin , checkout)
|
||||
|
||||
# note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block
|
||||
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
|
||||
price = 0
|
||||
minutes = DiningCharge.time_diff(checkout, checkin)
|
||||
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.strftime('%H:%M'))
|
||||
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.localtime.strftime('%H:%M'))
|
||||
dining_minutes = minutes - free_time # stayminutes - free minutes
|
||||
charge_type = dining_charges_obj.charge_type
|
||||
if charge_type == 'hr'
|
||||
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
||||
elsif charge_type == 'day'
|
||||
price = charges(dining_charges_obj, dining_minutes, 'day')
|
||||
if dining_minutes <= 0
|
||||
price = 0
|
||||
else
|
||||
charge_type = dining_charges_obj.charge_type
|
||||
if charge_type == 'hr'
|
||||
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
||||
elsif charge_type == 'day'
|
||||
price = charges(dining_charges_obj, dining_minutes, 'day')
|
||||
end
|
||||
end
|
||||
|
||||
return price
|
||||
else
|
||||
puts "<<<<<<<< NO"
|
||||
@@ -25,14 +28,15 @@ class DiningCharge < ApplicationRecord
|
||||
|
||||
def self.charges(chargesObj, dining_minutes, type)
|
||||
solid_price = 0
|
||||
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.strftime('%H:%M'))
|
||||
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.localtime.strftime('%H:%M'))
|
||||
|
||||
result = dining_minutes / block
|
||||
if result.to_i < 1
|
||||
return chargesObj.unit_price
|
||||
elsif result.to_i >= 1
|
||||
solid_price = result * chargesObj.unit_price
|
||||
remain_value = dining_minutes % block
|
||||
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.strftime('%H:%M'))
|
||||
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.localtime.strftime('%H:%M'))
|
||||
roundingblock = remain_value / rounding_block
|
||||
if roundingblock.to_i < 1
|
||||
return DiningCharge.check_rounding(chargesObj, solid_price)
|
||||
@@ -48,7 +52,7 @@ class DiningCharge < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_rounding(chargesObj)
|
||||
def self.check_rounding(chargesObj,solid_price)
|
||||
if chargesObj.time_rounding == "down"
|
||||
return solid_price
|
||||
else
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class DiningFacility < ApplicationRecord
|
||||
belongs_to :zone
|
||||
has_many :dining_charges
|
||||
has_many :in_juties
|
||||
|
||||
TABLE_TYPE = "Table"
|
||||
ROOM_TYPE = "Room"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class Employee < ApplicationRecord
|
||||
has_secure_password
|
||||
belongs_to :commissioner
|
||||
has_many :commissioners
|
||||
has_many :shit_sales
|
||||
|
||||
validates_presence_of :name, :role
|
||||
validates_presence_of :password, :on => [:create]
|
||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
|
||||
4
app/models/in_juty.rb
Normal file
4
app/models/in_juty.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class InJuty < ApplicationRecord
|
||||
belongs_to :dining_facility, foreign_key: 'dinning_id'
|
||||
belongs_to :commissioner, foreign_key: 'commissioner_ids'
|
||||
end
|
||||
@@ -3,6 +3,8 @@ class MenuItem < ApplicationRecord
|
||||
|
||||
belongs_to :menu_category, :optional => true
|
||||
has_many :menu_item_instances
|
||||
has_many :commissions
|
||||
|
||||
# belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
# has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
belongs_to :account
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Product < ApplicationRecord
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
# Product Image Uploader
|
||||
mount_uploader :image_path, ProductImageUploader
|
||||
end
|
||||
|
||||
@@ -6,7 +6,204 @@ class Promotion < ApplicationRecord
|
||||
accepts_nested_attributes_for :promotion_products , :allow_destroy => true
|
||||
|
||||
PROMO_TYPE1 = "Quantity"
|
||||
PROMO_TYPE2 = "Net_off"
|
||||
PROMO_TYPE3 = "Net_price"
|
||||
PROMO_TYPE2 = "Net_off" # 3000 => - 500 => 2500 [total]
|
||||
PROMO_TYPE3 = "Net_price" # 1800 => 1000 => 1000
|
||||
PROMO_TYPE4 = "Percentage"
|
||||
|
||||
def self.promo_activate(saleObj)
|
||||
current_day = Time.now.strftime("%Y-%m-%d")
|
||||
current_time = Time.now.strftime('%H:%M:%S')
|
||||
day = Date.today.wday
|
||||
promoList = is_between_promo_datetime(current_day,current_time)
|
||||
puts "promoList - " + promoList.size.to_s
|
||||
if promoList.size > 0
|
||||
itemList = combine_item(saleObj)
|
||||
is_promo_day(promoList,day, itemList, saleObj.sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
|
||||
promoList = Promotion.where("(TO_CHAR(promo_start_date, 'YYYY-MM-DD') <=? AND TO_CHAR(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
return promoList
|
||||
end
|
||||
|
||||
def self.combine_item(saleObj)
|
||||
itemList = saleObj.sale_items.group(:product_code).sum(:qty)
|
||||
end
|
||||
|
||||
def self.is_promo_day(promoList, day, orderitemList, sale_id)
|
||||
puts "Today date - " + day.to_s
|
||||
promoList.each do |promo|
|
||||
dayresult = promo.promo_day.include?(day.to_s)
|
||||
if dayresult
|
||||
orderitemList.each do |item|
|
||||
find_promo_item(promo, item, sale_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_promo_item(promo, orderitem, sale_id)
|
||||
if promo.original_product.to_s == orderitem[0].to_s
|
||||
if promo.min_qty.to_i > orderitem[1].to_i
|
||||
return false
|
||||
else
|
||||
check_promo_type(promo,orderitem, sale_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_promo_type(promo, orderitem, sale_id)
|
||||
same, promo_product = check_giveaway_product(promo, orderitem[0])
|
||||
if promo.promo_type == Promotion::PROMO_TYPE1
|
||||
if same
|
||||
give_promotion_same_product(orderitem[1], promo.min_qty, promo_product.min_qty, orderitem, sale_id)
|
||||
else
|
||||
give_promotion_second_product(orderitem[1], promo.min_qty, promo_product.item_code, orderitem, sale_id)
|
||||
end
|
||||
|
||||
elsif promo.promo_type == Promotion::PROMO_TYPE2
|
||||
give_promotion_nett_off(same,promo_product,promo.min_qty, orderitem, sale_id)
|
||||
|
||||
elsif promo.promo_type == Promotion::PROMO_TYPE3
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_giveaway_product(promo, orderitem)
|
||||
promo.promotion_products.each do |promo_product|
|
||||
if promo_product.item_code == orderitem
|
||||
return true, promo_product
|
||||
else
|
||||
return false, promo_product
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, sale_id)
|
||||
puts " Order qty: " + qty.to_s + " / promoqty: " + promoqty.to_s + " / giveaway: " + foc_min_qty.to_s
|
||||
multiple = qty.to_i / promoqty.to_i # loop count
|
||||
charge_qty = 0
|
||||
foc_qty = 0
|
||||
if multiple > 0
|
||||
multiple.times.each do |key|
|
||||
if qty > promoqty
|
||||
charge_qty += promoqty
|
||||
different = qty - promoqty
|
||||
qty = different
|
||||
if different == 0
|
||||
foc_qty += foc_min_qty
|
||||
else
|
||||
foc_qty += foc_min_qty
|
||||
qty = qty - foc_min_qty
|
||||
end
|
||||
else
|
||||
charge_qty += qty
|
||||
end
|
||||
end
|
||||
if multiple == foc_qty
|
||||
charge_qty += qty
|
||||
end
|
||||
else
|
||||
charge_qty += qty
|
||||
end
|
||||
item = OrderItem.find_by_item_code(orderitem[0])
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion", item.price)
|
||||
|
||||
puts "Charged - " + charge_qty.to_s
|
||||
puts "FOC - " + foc_qty.to_s
|
||||
end
|
||||
# AA - 10 # 3 # BB # orderList, #S34345
|
||||
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id)
|
||||
puts "..... orderitem_count: " + orderitem_count.to_s + " / foc_min_qty: " + foc_min_qty.to_s + " /promo_product: " + promo_product + " orderitem: " + orderitem.to_s
|
||||
promotion_qty = orderitem_count.to_i / foc_min_qty.to_i # get foc item qty
|
||||
item = OrderItem.find_by_item_code(promo_product)
|
||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price)
|
||||
end
|
||||
|
||||
def self.update_existing_item(foc_qty, item, sale_id, type, item_price)
|
||||
|
||||
sale_item = SaleItem.new
|
||||
sale_item.product_code = item.item_code
|
||||
sale_item.product_name = item.item_name + "(promotion)"
|
||||
sale_item.product_alt_name = item.alt_name
|
||||
sale_item.account_id = item.account_id
|
||||
sale_item.remark = type
|
||||
sale_item.qty = foc_qty * (-1)
|
||||
|
||||
sale_item.unit_price = item_price * (-1)
|
||||
sale_item.taxable_price = item_price
|
||||
sale_item.price = foc_qty * item_price * (-1)
|
||||
|
||||
sale_item.is_taxable = item.taxable
|
||||
sale_item.sale_id = sale_id
|
||||
|
||||
sale_item.save
|
||||
end
|
||||
|
||||
|
||||
def self.give_promotion_nett_off(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
|
||||
if same
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
item = OrderItem.find_by_item_code(orderitem[0])
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off)
|
||||
else
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
item = OrderItem.find_by_item_code(promo_product.item_code)
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off)
|
||||
end
|
||||
end
|
||||
|
||||
def self.give_promotion_nett_price(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
|
||||
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
|
||||
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)
|
||||
item = OrderItem.find_by_item_code(promo_product.item_code)
|
||||
price = item.price - promo_product.net_price
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
|
||||
end
|
||||
end
|
||||
|
||||
def self.give_promotion_discount(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
|
||||
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
|
||||
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
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_second_item_qty(sale_id, promo_item)
|
||||
saleObj = Sale.find_by_sale_id(sale_id)
|
||||
itemList = combine_item(saleObj)
|
||||
itemList.each do |item|
|
||||
if item[0] == promo_item
|
||||
return item[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.calculate_discount(total, discount)
|
||||
self (total.to_i * discount.to_i) / 100
|
||||
end
|
||||
end
|
||||
|
||||
@@ -298,8 +298,8 @@ class Sale < ApplicationRecord
|
||||
customer = Customer.find(sale.customer_id)
|
||||
# #Creat new tax records
|
||||
tax_profiles.each do |tax|
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax.to_i == tax.id
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax.to_i == tax.id
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
@@ -311,7 +311,7 @@ class Sale < ApplicationRecord
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
@@ -319,7 +319,7 @@ class Sale < ApplicationRecord
|
||||
# total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
sale_tax.save
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -338,13 +338,13 @@ class Sale < ApplicationRecord
|
||||
total_tax_amount = 0
|
||||
#tax_profile - list by order_by
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
|
||||
customer = Customer.find(self.customer_id)
|
||||
|
||||
customer = Customer.find(self.customer_id)
|
||||
puts customer
|
||||
#Create new tax records
|
||||
tax_profiles.each do |tax|
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax.to_i == tax.id
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax.to_i == tax.id
|
||||
sale_tax = SaleTax.new(:sale => self)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
@@ -356,16 +356,16 @@ class Sale < ApplicationRecord
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
|
||||
|
||||
#new taxable amount is standard rule for step by step
|
||||
# total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
sale_tax.save
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -596,7 +596,7 @@ def self.get_item_query()
|
||||
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
|
||||
@@ -1,116 +1,4 @@
|
||||
class Shop < ApplicationRecord
|
||||
|
||||
def promo_activate
|
||||
current_day = Time.now.strftime("%Y-%d-%m")
|
||||
current_time = Time.now.strftime('%H:%M')
|
||||
day = Date.today.wday
|
||||
promoList = is_between_promo_datetime(current_day,current_time)
|
||||
if promoList.size > 0
|
||||
itemList = combine_item(saleObj)
|
||||
is_promo_day(promoList,day, itemList)
|
||||
end
|
||||
end
|
||||
|
||||
def is_between_promo_datetime(current_day,current_time)
|
||||
promoList = Promotion.where('( promo_start_date < ? AND promo_end_date > ?) AND (promo_start_time < ? AND promo_end_time > ?)', current_day, current_day, current_time, current_time)
|
||||
return promoList
|
||||
end
|
||||
|
||||
def combine_item(saleObj)
|
||||
itemList = saleObj.sale_items.group(:product_code).sum(:qty)
|
||||
end
|
||||
|
||||
def is_promo_day(promoList, day, orderitemList)
|
||||
promoList.each do |promo|
|
||||
dayresult = promo.promo_day.include?(day)
|
||||
if dayresult
|
||||
orderitemList.each do |item|
|
||||
find_promo_item(promo, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def find_promo_item(promo, orderitem)
|
||||
if promo.prouduct_item == orderitem
|
||||
if promo.minmum_qty < orderitem.qty
|
||||
return false
|
||||
else
|
||||
same, promo_item_code = check_giveaway_product(promo, orderitem)
|
||||
if same
|
||||
give_promotion_same_product
|
||||
else
|
||||
find_promo_item_in_orderlist
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_giveaway_product(promo, orderitem)
|
||||
promo.promotion_products.each do |promo_product|
|
||||
if promo_product.item_code == orderitem.item_code
|
||||
return true, promo_product.item_code
|
||||
else
|
||||
return false, promo_product.item_code
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.give_promotion_same_product(qty, promoqty, foc_min_qty)
|
||||
multiple = qty / promoqty # loop count
|
||||
charge_qty = 0
|
||||
foc_qty = 0
|
||||
if multiple > 0
|
||||
multiple.times.each do |key|
|
||||
if qty >= promoqty
|
||||
charge_qty += promoqty
|
||||
different = qty - promoqty
|
||||
qty = different
|
||||
if different == 0
|
||||
Shop.add_promotion_item
|
||||
foc_qty += foc_min_qty
|
||||
else
|
||||
foc_qty += foc_min_qty
|
||||
qty = qty - foc_min_qty
|
||||
end
|
||||
else
|
||||
if multiple == foc_qty
|
||||
charge_qty += qty
|
||||
else
|
||||
charge_qty += qty
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
charge_qty = qty
|
||||
end
|
||||
puts "Charged - " + charge_qty.to_s
|
||||
puts "FOC - " + foc_qty.to_s
|
||||
end
|
||||
|
||||
def find_promo_item_in_orderlist(promo_item_code, orderitemList)
|
||||
orderitemList.each do |item|
|
||||
if item.item_code == promo_item_code
|
||||
give_promotion_second_product(item)
|
||||
else
|
||||
add_promotion_second_item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def give_promotion_second_product(item, foc_min_qty)
|
||||
if item.qty > foc_min_qty
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def self.add_promotion_item
|
||||
|
||||
end
|
||||
|
||||
def self.add_promotion_second_item
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ class OrderItemPdf < 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
|
||||
def initialize(print_settings,order_item, print_status, options, alt_name)
|
||||
self.page_width = printer_settings.page_width
|
||||
self.page_height = printer_settings.page_height
|
||||
self.page_width = print_settings.page_width
|
||||
self.page_height = print_settings.page_height
|
||||
self.margin = 0
|
||||
self.price_width = 40 # No Need for item
|
||||
self.qty_width = 40
|
||||
|
||||
@@ -2,8 +2,8 @@ class OrderSummaryPdf < 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
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name)
|
||||
self.page_width = printer_settings.page_width
|
||||
self.page_height = printer_settings.page_height
|
||||
self.page_width = print_settings.page_width
|
||||
self.page_height = print_settings.page_height
|
||||
self.margin = 0
|
||||
self.price_width = 40 # No Need for item
|
||||
self.qty_width = 40
|
||||
|
||||
@@ -17,5 +17,4 @@ if (menu.menu_categories)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,44 +1,78 @@
|
||||
# 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: [] })
|
||||
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
||||
next
|
||||
end
|
||||
|
||||
attr_format.each do |af|
|
||||
if menu_attr.attribute_type == af[:type]
|
||||
af[:value].push(menu_attr.value)
|
||||
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, value: [ menu_attr.value ] }
|
||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
||||
attr_format.push(new_attr)
|
||||
end
|
||||
|
||||
break if attr_format.count > param_count
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
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
|
||||
|
||||
param_count -= 1
|
||||
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
|
||||
|
||||
#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 +86,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 +94,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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
16
app/views/origami/commissioners/_commissioners_form.html.erb
Normal file
16
app/views/origami/commissioners/_commissioners_form.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">COMMISSIONERS </strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem; min-height:600px; max-height:600px; overflow-x:scroll;">
|
||||
<% @commissioners.each do |commissioner| %>
|
||||
<div class="card tables green text-white" data-id="<%= commissioner.id %>">
|
||||
<div class="card-block">
|
||||
<%= commissioner.name %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5,10 +5,13 @@
|
||||
<div class="form-inputs">
|
||||
<%= f.input :name %>
|
||||
<%= f.label :emp_id %>
|
||||
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :emp_id, :name, {prompt: "Select an Employee"}, {class: "form-control"} %><br/>
|
||||
<%= f.input :commission_type %>
|
||||
<label><%= f.check_box :is_active %> Active </label>
|
||||
</div>
|
||||
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %><br/>
|
||||
<%= f.label :commission_type %>
|
||||
<%= f.select :commission_type, Commission.all.map{ |l| [l.menu_item.name, l.id] } %>
|
||||
<br/>
|
||||
<label><%= f.check_box :is_active %> Active </label>
|
||||
</div><br/>
|
||||
|
||||
|
||||
<div class="form-actions">
|
||||
<%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li>Commissioner</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commissioner_path ,:class => 'btn btn-primary btn-sm' %>
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li>Commissioner</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commissioner_path, :class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
@@ -23,22 +23,18 @@
|
||||
|
||||
<tbody>
|
||||
<% @commissioners.each do |commissioner| %>
|
||||
<tr>
|
||||
<td><%= commissioner.name %></td>
|
||||
<td>
|
||||
<% if Employee.exists? %>
|
||||
<% employee = Employee.where('emp_id=?',commissioner.emp_id) %>
|
||||
<%= employee[0].name %>
|
||||
<% end %>
|
||||
|
||||
</td>
|
||||
<td><%= commissioner.commission_type %></td>
|
||||
<td><%= commissioner.is_active %></td>
|
||||
<td><%= link_to 'Show', origami_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Destroy', origami_commissioner_path(commissioner), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= commissioner.name %></td>
|
||||
<td>
|
||||
<%= commissioner.employee.name rescue '-' %>
|
||||
</td>
|
||||
<td><%= commissioner.commission.menu_item.name rescue '-' %></td>
|
||||
<td><%= commissioner.is_active %></td>
|
||||
<td><%= link_to 'Show', origami_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Destroy', origami_commissioner_path(commissioner), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -21,16 +21,12 @@
|
||||
<tr>
|
||||
<td style="width:20%">Employee Name</td>
|
||||
<td>
|
||||
<% if Employee.exists? %>
|
||||
<% employee = Employee.where('emp_id=?', @commissioner.emp_id) %>
|
||||
<%= employee[0].name %>
|
||||
<% end %>
|
||||
|
||||
<%= @commissioner.employee.name rescue '-' %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Commission Type</td>
|
||||
<td><%= @commissioner.commission_type %></td>
|
||||
<td><%= @commissioner.commission.menu_item.name rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Active</td>
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.label :product_id %>
|
||||
<%= f.collection_select :product_id, Product.all.order('name asc'), :id, :name, {prompt: "Select a Product"}, {class: "form-control"} %><br/>
|
||||
<%= f.collection_select :product_id, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
|
||||
<%= f.input :amount %>
|
||||
<%= f.input :commission_type, :collection => [:percentage, :net_amount] %>
|
||||
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
|
||||
<label><%= f.check_box :is_active %> Active </label>
|
||||
</div>
|
||||
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
|
||||
<%= f.button :submit, class: 'btn btn-info' %>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li>Commissions</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path ,:class => 'btn btn-primary btn-sm' %>
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li>Commissions</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path, :class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
@@ -23,22 +23,16 @@
|
||||
|
||||
<tbody>
|
||||
<% @commissions.each do |commission| %>
|
||||
<tr>
|
||||
<td>
|
||||
<% if Product.exists? %>
|
||||
<% product = Product.find(commission.product_id) %>
|
||||
<%= product.name %>
|
||||
<% end %>
|
||||
|
||||
</td>
|
||||
<td><%= commission.amount %></td>
|
||||
<td><%= commission.commission_type %></td>
|
||||
<td><%= commission.is_active %></td>
|
||||
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= commission.menu_item.name rescue '-' %></td>
|
||||
<td><%= commission.amount rescue '-' %></td>
|
||||
<td><%= commission.commission_type rescue '-' %></td>
|
||||
<td><%= commission.is_active rescue '-' %></td>
|
||||
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
217
app/views/origami/commissions/load_commissioners.html.erb
Normal file
217
app/views/origami/commissions/load_commissioners.html.erb
Normal file
@@ -0,0 +1,217 @@
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5" style="height: 100%">
|
||||
<%= render 'origami/commissioners/commissioners_form', commissioners: @commissioners %>
|
||||
</div>
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">INVOICE DETAILS </strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p> Receipt No: <span id="receipt_no">
|
||||
<%= @saleobj.receipt_no rescue '' %>
|
||||
</span></p>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Date:
|
||||
<span id="receipt_date"><%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-title row customer_detail hide">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p>Customer : <span id="customer_name"></span></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="card-text" style="min-height:500px; max-height:500px; overflow-x:scroll">
|
||||
<table class="table " id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="4%">#</th>
|
||||
<th class="" width="60%">Items</th>
|
||||
<th style="" width="20%">QTY
|
||||
</td>
|
||||
<th class="" width="30%">Price
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
count = 0
|
||||
sub_total = 0
|
||||
@saleobj.sale_items.each do |sale_item|
|
||||
count += 1
|
||||
sub_total = sub_total + sale_item.price
|
||||
%>
|
||||
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
|
||||
<%
|
||||
# Can't check for discount
|
||||
unless sale_item.price == 0
|
||||
%>
|
||||
<tr id="sale_item" data-sale-item="<%= sale_item.sale_item_id %>">
|
||||
<td width="4%"><%= count %></td>
|
||||
<td class='' width="60%">
|
||||
<%= sale_item.product_name %>
|
||||
</td>
|
||||
<td class='' width="20%">
|
||||
<%= sale_item.qty %>
|
||||
</td>
|
||||
<td class='' width="20%">
|
||||
<%= sale_item.unit_price %>
|
||||
</td>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
|
||||
</tr>
|
||||
<tr class="rebate_amount"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='apply'>Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Bill Request
|
||||
$(document).ready(function () {
|
||||
|
||||
$(".update").on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var qty = $('#' + sale_item_id + "_qty").val();
|
||||
var price = $('#' + sale_item_id + "_price").val();
|
||||
console.log(qty + "|" + price)
|
||||
var ajax_url = "/origami/item_edit";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
|
||||
success: function (result) {
|
||||
$.confirm({
|
||||
title: 'Alert!',
|
||||
content: 'Qty and Price was successfully Updated',
|
||||
buttons: {
|
||||
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green btn-lg',
|
||||
action: function () {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.void').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/origami/item_void";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('.foc').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/origami/item_foc";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('.cancel').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/origami/item_void_cancel";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
$('#back').on('click', function () {
|
||||
var table_id = '<%= @table_id %>'
|
||||
window.location.href = '/origami/table/' + table_id;
|
||||
})
|
||||
|
||||
$('#cancel_all_void').on('click', function () {
|
||||
var sale_id = "<%= @saleobj.sale_id %>"
|
||||
var ajax_url = "/origami/cancel_all_void";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_id=' + sale_id,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('#apply').on('click', function () {
|
||||
var sale_id = "<%= @saleobj.sale_id %>"
|
||||
var ajax_url = "/origami/apply_void";
|
||||
var table_id = '<%= @table_id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_id=' + sale_id,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/table/' + table_id;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('#sale_item').on('click', function () {
|
||||
var sale_item_id = this.getAttribute('data-sale-item');
|
||||
var ajax_url = "/origami/select_sale_item";
|
||||
var table_id = '<%= @table_id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
// window.location.href = '/origami/table/' + table_id;
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
@@ -16,12 +16,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:20%">Product Name</td>
|
||||
<td>
|
||||
<% if Product.exists? %>
|
||||
<% product = Product.find(@commission.product_id) %>
|
||||
<%= product.name %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= @commission.menu_item.name rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Amount</td>
|
||||
|
||||
@@ -108,17 +108,15 @@
|
||||
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
|
||||
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
|
||||
<!-- Temporary Disabled -->
|
||||
<%if current_login_employee.role == "cashier" && @shop.quick_sale_summary == true%>
|
||||
<button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Summary</button>
|
||||
<%end%>
|
||||
|
||||
<button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button>
|
||||
|
||||
|
||||
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
|
||||
<button id="back" type="button" class="btn btn-block btn-primary"><i class="fa fa-home fa-lg"></i> Back
|
||||
|
||||
|
||||
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
|
||||
<button id="back" type="button" class="btn btn-block btn-primary"><i class="fa fa-home fa-lg"></i> Back
|
||||
</button>
|
||||
<%end%>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
@@ -572,6 +572,12 @@
|
||||
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/edit";
|
||||
});
|
||||
|
||||
$('#commissions').on('click', function () {
|
||||
var dining_id = "<%= @dining.id %>"
|
||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/load_commissioners";
|
||||
});
|
||||
|
||||
$('#void').on('click', function () {
|
||||
var sure = confirm("Are you sure want to Void");
|
||||
if (sure == true) {
|
||||
|
||||
33
app/views/origami/in_juties/_form.html.erb
Normal file
33
app/views/origami/in_juties/_form.html.erb
Normal file
@@ -0,0 +1,33 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.label :dinning_id %>
|
||||
<%= f.collection_select :dinning_id, DiningFacility.all, :id, :name, {prompt: 'Select Dining Facilities'}, {class: 'form-control'} %><br/>
|
||||
<%= f.label :commissioner_ids %>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><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/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %>
|
||||
<%= f.button :submit, class: 'btn btn-info' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
$('.datepicker').datepicker({
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
</script>
|
||||
2
app/views/origami/in_juties/_in_juty.json.jbuilder
Normal file
2
app/views/origami/in_juties/_in_juty.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! in_juty, :id, :created_at, :updated_at
|
||||
json.url in_juty_url(in_juty, format: :json)
|
||||
10
app/views/origami/in_juties/edit.html.erb
Normal file
10
app/views/origami/in_juties/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', in_juty: @in_juty %>
|
||||
</div>
|
||||
38
app/views/origami/in_juties/index.html.erb
Normal file
38
app/views/origami/in_juties/index.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li>In Juties</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_in_juty_path, :class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Dining Facility Name</th>
|
||||
<th>Commissioner Ids</th>
|
||||
<th>In time</th>
|
||||
<th>Out time</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @in_juties.each do |in_juty| %>
|
||||
<tr>
|
||||
<td><%= in_juty.dining_facility.name rescue '-' %></td>
|
||||
<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 'Show', origami_in_juty_path(in_juty) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_in_juty_path(in_juty) %></td>
|
||||
<td><%= link_to 'Destroy', origami_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
1
app/views/origami/in_juties/index.json.jbuilder
Normal file
1
app/views/origami/in_juties/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @in_juties, partial: 'in_juties/in_juty', as: :in_juty
|
||||
10
app/views/origami/in_juties/new.html.erb
Normal file
10
app/views/origami/in_juties/new.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', in_juty: @in_juty %>
|
||||
</div>
|
||||
43
app/views/origami/in_juties/show.html.erb
Normal file
43
app/views/origami/in_juties/show.html.erb
Normal file
@@ -0,0 +1,43 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
|
||||
|
||||
<span style="float: right">
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">In Juty</h4>
|
||||
<table class="table">
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td style="width:20%">Dining Facility Name</td>
|
||||
<td><%= @in_juty.dining_facility.name%></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Commissioner Name</td>
|
||||
<td>
|
||||
<%= @in_juty.commissioner.name rescue '-' %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">In Time</td>
|
||||
<td><%= @in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Out Time</td>
|
||||
<td><%= @in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %>
|
||||
<%= link_to 'Edit', edit_origami_in_juty_path(@in_juty), class: 'btn btn-info' %>
|
||||
<%= link_to 'Destroy', origami_in_juty_path(@in_juty), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
1
app/views/origami/in_juties/show.json.jbuilder
Normal file
1
app/views/origami/in_juties/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "in_juties/in_juty", in_juty: @in_juty
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
<%= simple_nested_form_for([:settings,@promotion]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
@@ -20,11 +21,23 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<%= f.input :promo_start_hour %>
|
||||
<!-- <%= f.input :promo_start_hour %> -->
|
||||
<% if !@promotion.promo_start_hour.nil?%>
|
||||
<%= f.input :promo_start_hour, as: :string, input_html: { :value => @promotion.promo_start_hour.utc.strftime('%H:%M') } %>
|
||||
<% else %>
|
||||
<%= f.input :promo_start_hour, as: :string, input_html: { } %>
|
||||
<% end %>
|
||||
<!-- <span>Promo Start Hour</span>
|
||||
<%= text_field_tag :promo_start_hour , nil, :placeholder => "From Time", :id => "fromtime", :class => 'form-control' %> -->
|
||||
</div>
|
||||
<div class="col-md-6"><%= f.input :promo_end_hour %></div>
|
||||
<div class="col-md-6">
|
||||
<!-- <%= f.input :promo_end_hour %> -->
|
||||
<% if !@promotion.promo_end_hour.nil?%>
|
||||
<%= f.input :promo_end_hour, as: :string, input_html: {:value => @promotion.promo_end_hour.utc.strftime('%H:%M') } %>
|
||||
<% else %>
|
||||
<%= f.input :promo_end_hour, as: :string, input_html: {} %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12"><%= f.input :promo_day %></div>
|
||||
@@ -40,19 +53,52 @@
|
||||
<div class="col-md-6"><%= f.input :min_qty %></div>
|
||||
</div>
|
||||
<br>
|
||||
<p><%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %></p>
|
||||
<br>
|
||||
<%= f.fields_for :promotion_products do |p| %>
|
||||
<table class="table" style="border : 1px solid #555555 !important;margin:0px">
|
||||
<tbody>
|
||||
<tr>
|
||||
<!-- <td>Promotion Code</td> -->
|
||||
<td>Item Code</td>
|
||||
<td>Min Qty</td>
|
||||
<td>Net off</td>
|
||||
<td>Net Price</td>
|
||||
<td>Percentage</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-1"><%= p.input :item_code , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :min_qty , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :net_off , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :net_price , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :percentage , :class => "form-control" %></div>
|
||||
<div class="col-md-1" style='padding-top:30px;'><%= p.link_to_remove "X"%></div>
|
||||
</div>
|
||||
<!-- <% @promotion.promotion_products.each do |pp| %>
|
||||
|
||||
<tr>
|
||||
<!-- <td><%= pp.promotion_id %></td>
|
||||
<td><%= pp.item_code %></td>
|
||||
<td><%= pp.min_qty %></td>
|
||||
<td><%= pp.net_off %></td>
|
||||
<td><%= pp.net_price %></td>
|
||||
<td><%= pp.percentage %></td>
|
||||
<td><%= link_to 'Edit', edit_settings_promotion_promotion_product_path(@promotion,pp) %></td>
|
||||
<td><%= link_to 'Destroy', settings_promotion_promotion_product_path(@promotion,pp), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
|
||||
<% end %> -->
|
||||
</tbody>
|
||||
</table>
|
||||
<%= f.fields_for :promotion_products do |pro| %>
|
||||
<table class="table" style="margin:0px">
|
||||
<tbody>
|
||||
<tr>
|
||||
<!-- <td></td> -->
|
||||
<td><%= pro.input :item_code, label: false%></td>
|
||||
<td><%= pro.input :min_qty , label: false%></td>
|
||||
<td><%= pro.input :net_off , label: false %></td>
|
||||
<td><%= pro.input :net_price , label: false %></td>
|
||||
<td><%= pro.input :percentage , label: false %></td>
|
||||
<td><%= pro.link_to_remove "X" %></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,3 +107,23 @@
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('#promotion_promo_start_date').datetimepicker({
|
||||
timepicker:false,
|
||||
format:'Y-m-d'
|
||||
});
|
||||
$('#promotion_promo_end_date').datetimepicker({
|
||||
timepicker:false,
|
||||
format:'Y-m-d'
|
||||
});
|
||||
$('#promotion_promo_start_hour').datetimepicker({
|
||||
datepicker:false,
|
||||
format:'H:m'
|
||||
});
|
||||
$('#promotion_promo_end_hour').datetimepicker({
|
||||
datepicker:false,
|
||||
format:'H:m'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
<td><%= link_to pro.promo_code, settings_promotion_path(pro) %></td>
|
||||
<td><%= pro.promo_start_date %></td>
|
||||
<td><%= pro.promo_end_date %></td>
|
||||
<td><%= pro.promo_start_hour.strftime("%I:%M %P") rescue "-" %></td>
|
||||
<td><%= pro.promo_end_hour.strftime("%I:%M %P") rescue "-" %></td>
|
||||
<td><%= pro.promo_start_hour.utc.strftime("%I:%M %P") rescue "-" %></td>
|
||||
<td><%= pro.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %></td>
|
||||
<td><%= pro.promo_day %></td>
|
||||
<td>
|
||||
<% if MenuItem.exists?(pro.original_product) %>
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<tr><td style="width:20%">Promotion code</td><td><%= @promotion.promo_code %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Date</td><td><%= @promotion.promo_start_date %></td></tr>
|
||||
<tr><td style="width:20%">Promotion End Date</td><td><%= @promotion.promo_end_date %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Hour</td><td><%= @promotion.promo_start_hour %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Hour</td><td><%= @promotion.promo_end_hour %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Hour</td><td><%= @promotion.promo_start_hour.utc.strftime("%I:%M %P") rescue "-" %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Hour</td><td><%= @promotion.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %></td></tr>
|
||||
<tr><td style="width:20%"><%= link_to 'Edit', edit_settings_promotion_path(@promotion) %></td><td><%= link_to 'Destroy', settings_promotion_path(@promotion), method: :delete, data: { confirm: 'Are you sure?' } %></td></tr>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user