pull from master
This commit is contained in:
@@ -3,8 +3,6 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
def index
|
||||
@shop = Shop.first
|
||||
|
||||
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
# @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
# @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
@@ -18,16 +16,18 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
# .sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||
# @inventories = StockJournal.inventory_balances(today).sum(:balance)
|
||||
|
||||
@total_sale = Sale.total_sale(today,current_user)
|
||||
@total_count = Sale.total_count(today,current_user)
|
||||
@total_card = Sale.total_card_sale(today,current_user)
|
||||
@total_credit = Sale.credit_payment(today,current_user)
|
||||
# @total_sale = Sale.total_sale(today,current_user)
|
||||
# @total_count = Sale.total_count(today,current_user)
|
||||
# @total_card = Sale.total_card_sale(today,current_user)
|
||||
# @total_credit = Sale.credit_payment(today,current_user)
|
||||
|
||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user)
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale('card', today, current_user)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
@@ -39,11 +39,8 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
@sale_data = nil
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user)
|
||||
@total_customer = Sale.total_customer(today,current_user)
|
||||
@total_dinein = Sale.total_dinein(today,current_user)
|
||||
@total_takeaway = Sale.total_takeaway(today,current_user)
|
||||
@total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
@total_membership = Sale.total_membership(today,current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(today,current_user)
|
||||
@total_accounts = Sale.total_account(today,current_user)
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
class Origami::InDutiesController < BaseOrigamiController
|
||||
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
|
||||
# GET /in_duties
|
||||
# GET /in_duties.json
|
||||
def index
|
||||
@in_duties = InDuty.all
|
||||
end
|
||||
|
||||
|
||||
def index_in_duty
|
||||
@duty_in = InDuty.where('dinning_id=?', params[:table_id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@duty_in = InDuty.where('dinning_id=? and sale_id=?', booking.dining_facility_id, @sale_id)
|
||||
@table = DiningFacility.find(booking.dining_facility_id)
|
||||
@in_duty = InDuty.new
|
||||
@duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10)
|
||||
end
|
||||
@@ -31,11 +29,14 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
def edit_in_duty
|
||||
@in_duty = InDuty.find(params[:id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@table = DiningFacility.find(booking.dining_facility_id)
|
||||
@commissioner = @in_duty.commissioner
|
||||
|
||||
# render json: {in_duty: @in_duty, commissioner: @commissioner}
|
||||
render partial: 'form'
|
||||
render json: {in_duty: @in_duty, commissioner: @commissioner}
|
||||
# render partial: 'form'
|
||||
end
|
||||
|
||||
def assign_in_duty
|
||||
@@ -45,20 +46,6 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# POST /in_duties
|
||||
# POST /in_duties.json
|
||||
def create
|
||||
@in_duty = InDuty.new(in_duty_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @in_duty.save
|
||||
format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @in_duty }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create_for_in_duty
|
||||
# this one use for create and update
|
||||
in_duty = in_duty_params
|
||||
@@ -66,8 +53,8 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
# in_time = in_time.change(offset: '+06:30')
|
||||
# out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
# out_time = out_time.change(offset: '+06:30')
|
||||
puts in_duty.to_json
|
||||
puts "sssssssssssssssssss"
|
||||
# puts in_duty.to_json
|
||||
# puts "sssssssssssssssssss"
|
||||
@in_duty = InDuty.new
|
||||
in_duty_id = in_duty[:id]
|
||||
unless in_duty_id.empty?
|
||||
@@ -75,6 +62,8 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
@in_duty.dinning_id = in_duty_params[:dinning_id]
|
||||
@in_duty.booking_id = in_duty_params[:booking_id]
|
||||
@in_duty.sale_id = in_duty_params[:sale_id]
|
||||
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
|
||||
@in_duty.in_time = in_duty['in_time']
|
||||
@in_duty.out_time = in_duty['out_time']
|
||||
@@ -97,38 +86,18 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# PATCH/PUT /in_duties/1
|
||||
# PATCH/PUT /in_duties/1.json
|
||||
def update
|
||||
in_duty = in_duty_params
|
||||
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
|
||||
in_time = in_time.change(offset: '+06:30')
|
||||
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
out_time = out_time.change(offset: '+06:30')
|
||||
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
|
||||
@in_duty.in_time = in_time
|
||||
@in_duty.out_time = out_time
|
||||
respond_to do |format|
|
||||
if @in_duty.save
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @in_duty }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_for_in_duty
|
||||
in_duty = in_duty_params
|
||||
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
|
||||
in_time = in_time.change(offset: '+06:30')
|
||||
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
out_time = out_time.change(offset: '+06:30')
|
||||
# in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
|
||||
# in_time = in_time.change(offset: '+06:30')
|
||||
# out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
# out_time = out_time.change(offset: '+06:30')
|
||||
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
|
||||
@in_duty.in_time = in_time
|
||||
@in_duty.out_time = out_time
|
||||
@in_duty.in_time = in_duty_params[:in_time]
|
||||
@in_duty.out_time = in_duty_params[:out_time]
|
||||
respond_to do |format|
|
||||
if @in_duty.save
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:sale_id]), notice: 'In duty was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @in_duty }
|
||||
else
|
||||
format.html { render :edit }
|
||||
@@ -139,22 +108,15 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# DELETE /in_duties/1
|
||||
# DELETE /in_duties/1.json
|
||||
def destroy
|
||||
@in_duty.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully removed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_in_duty
|
||||
@table_id = params[:table_id]
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@in_duty.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_index_in_duty_path, notice: 'In duty was successfully removed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
flash[:notice] = 'In duty was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => origami_index_in_duty_path }.to_json
|
||||
end
|
||||
|
||||
private
|
||||
@@ -166,7 +128,7 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def in_duty_params
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :booking_id, :sale_id, :commissioner_ids, :in_time, :out_time)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user