merge with august_spring
This commit is contained in:
@@ -25,7 +25,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
|
||||
|
||||
@inventory_definition.created_by = current_user.id
|
||||
respond_to do |format|
|
||||
if @inventory_definition.save
|
||||
format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Inventory::StockChecksController < BaseInventoryController
|
||||
|
||||
def index
|
||||
@check = StockCheck.new
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -28,87 +28,86 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
stockcheck = StockCheck.find(stock_id)
|
||||
stockcheck_items = stockcheck.stock_check_items
|
||||
member_info = nil
|
||||
unique_code = "StockPrint"
|
||||
|
||||
unique_code = 'StockPrint'
|
||||
|
||||
shop_details = Shop.find(1)
|
||||
checker = Employee.find(stockcheck.check_by)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker.name, shop_details)
|
||||
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
|
||||
end
|
||||
|
||||
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /stock_checks
|
||||
# GET /stock_checks.json
|
||||
# def index
|
||||
# @stock_checks = StockCheck.all
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1
|
||||
# # GET /stock_checks/1.json
|
||||
# def show
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/new
|
||||
# def new
|
||||
# @stock_check = StockCheck.new
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1/edit
|
||||
# def edit
|
||||
# end
|
||||
#
|
||||
# # POST /stock_checks
|
||||
# # POST /stock_checks.json
|
||||
# def create
|
||||
# @stock_check = StockCheck.new(stock_check_params)
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @stock_check.save
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
|
||||
# format.json { render :show, status: :created, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :new }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # PATCH/PUT /stock_checks/1
|
||||
# # PATCH/PUT /stock_checks/1.json
|
||||
# def update
|
||||
# respond_to do |format|
|
||||
# if @stock_check.update(stock_check_params)
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
|
||||
# format.json { render :show, status: :ok, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :edit }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # DELETE /stock_checks/1
|
||||
# # DELETE /stock_checks/1.json
|
||||
# def destroy
|
||||
# @stock_check.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# private
|
||||
# # Use callbacks to share common setup or constraints between actions.
|
||||
# def set_stock_check
|
||||
# @stock_check = StockCheck.find(params[:id])
|
||||
# end
|
||||
#
|
||||
# # Never trust parameters from the scary internet, only allow the white list through.
|
||||
# def stock_check_params
|
||||
# params.fetch(:stock_check, {})
|
||||
# end
|
||||
# def index
|
||||
# @stock_checks = StockCheck.all
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1
|
||||
# # GET /stock_checks/1.json
|
||||
# def show
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/new
|
||||
# def new
|
||||
# @stock_check = StockCheck.new
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1/edit
|
||||
# def edit
|
||||
# end
|
||||
#
|
||||
# # POST /stock_checks
|
||||
# # POST /stock_checks.json
|
||||
# def create
|
||||
# @stock_check = StockCheck.new(stock_check_params)
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @stock_check.save
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
|
||||
# format.json { render :show, status: :created, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :new }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # PATCH/PUT /stock_checks/1
|
||||
# # PATCH/PUT /stock_checks/1.json
|
||||
# def update
|
||||
# respond_to do |format|
|
||||
# if @stock_check.update(stock_check_params)
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
|
||||
# format.json { render :show, status: :ok, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :edit }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # DELETE /stock_checks/1
|
||||
# # DELETE /stock_checks/1.json
|
||||
# def destroy
|
||||
# @stock_check.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# private
|
||||
# # Use callbacks to share common setup or constraints between actions.
|
||||
# def set_stock_check
|
||||
# @stock_check = StockCheck.find(params[:id])
|
||||
# end
|
||||
#
|
||||
# # Never trust parameters from the scary internet, only allow the white list through.
|
||||
# def stock_check_params
|
||||
# params.fetch(:stock_check, {})
|
||||
# end
|
||||
end
|
||||
|
||||
170
app/controllers/origami/in_duties_controller.rb
Normal file
170
app/controllers/origami/in_duties_controller.rb
Normal file
@@ -0,0 +1,170 @@
|
||||
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])
|
||||
@in_duty = InDuty.new
|
||||
@duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
# GET /in_duties/1
|
||||
# GET /in_duties/1.json
|
||||
def show; end
|
||||
|
||||
# GET /in_duties/new
|
||||
def new
|
||||
# this one use for new
|
||||
@in_duty = InDuty.new
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@commissioner = @in_duty.commissioner
|
||||
render partial: 'form'
|
||||
end
|
||||
|
||||
# GET /in_duties/1/edit
|
||||
def edit; end
|
||||
|
||||
def edit_in_duty
|
||||
@in_duty = InDuty.find(params[:id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@commissioner = @in_duty.commissioner
|
||||
|
||||
# render json: {in_duty: @in_duty, commissioner: @commissioner}
|
||||
render partial: 'form'
|
||||
end
|
||||
|
||||
def assign_in_duty
|
||||
@in_duty = InDuty.new
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
end
|
||||
|
||||
# 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
|
||||
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 = InDuty.new
|
||||
in_duty_id = in_duty[:id]
|
||||
unless in_duty_id.empty?
|
||||
@in_duty = InDuty.find(in_duty_id.to_i)
|
||||
end
|
||||
|
||||
@in_duty.dinning_id = in_duty_params[:dinning_id]
|
||||
@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
|
||||
if in_duty_id.nil?
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @in_duty }
|
||||
else
|
||||
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: :created, location: @in_duty }
|
||||
end
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 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_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
|
||||
|
||||
# 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]
|
||||
@in_duty.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_index_in_duty_path(@table_id), notice: 'In duty was successfully removed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_in_duty
|
||||
@in_duty = InDuty.find(params[:id])
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
end
|
||||
@@ -1,170 +0,0 @@
|
||||
class Origami::InJutiesController < BaseOrigamiController
|
||||
before_action :set_in_juty, only: %i[show edit update edit_in_juty update_for_in_juty destroy destroy_in_juty]
|
||||
|
||||
# GET /in_juties
|
||||
# GET /in_juties.json
|
||||
def index
|
||||
@in_juties = InJuty.all
|
||||
end
|
||||
|
||||
def index_in_juty
|
||||
@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
|
||||
# GET /in_juties/1.json
|
||||
def show; end
|
||||
|
||||
# GET /in_juties/new
|
||||
def new
|
||||
# this one use for new
|
||||
@in_juty = InJuty.new
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@commissioner = @in_juty.commissioner
|
||||
render partial: 'form'
|
||||
end
|
||||
|
||||
# GET /in_juties/1/edit
|
||||
def edit; end
|
||||
|
||||
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}
|
||||
render partial: 'form'
|
||||
end
|
||||
|
||||
def assign_in_juty
|
||||
@in_juty = InJuty.new
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
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
|
||||
|
||||
def create_for_in_juty
|
||||
# this one use for create and update
|
||||
in_juty = in_juty_params
|
||||
in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
|
||||
in_time = in_time.change(offset: '+06:30')
|
||||
out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
|
||||
out_time = out_time.change(offset: '+06:30')
|
||||
@in_juty = InJuty.new
|
||||
in_juty_id = in_juty[:id]
|
||||
unless in_juty_id.empty?
|
||||
@in_juty = InJuty.find(in_juty_id.to_i)
|
||||
end
|
||||
|
||||
@in_juty.dinning_id = in_juty_params[:dinning_id]
|
||||
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||
@in_juty.in_time = in_time
|
||||
@in_juty.out_time = out_time
|
||||
|
||||
respond_to do |format|
|
||||
if @in_juty.save
|
||||
if in_juty_id.nil?
|
||||
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @in_juty }
|
||||
else
|
||||
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: :created, location: @in_juty }
|
||||
end
|
||||
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
|
||||
in_juty = in_juty_params
|
||||
in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
|
||||
in_time = in_time.change(offset: '+06:30')
|
||||
out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
|
||||
out_time = out_time.change(offset: '+06:30')
|
||||
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||
@in_juty.in_time = in_time
|
||||
@in_juty.out_time = 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
|
||||
|
||||
def update_for_in_juty
|
||||
in_juty = in_juty_params
|
||||
in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
|
||||
in_time = in_time.change(offset: '+06:30')
|
||||
out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
|
||||
out_time = out_time.change(offset: '+06:30')
|
||||
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||
@in_juty.in_time = in_time
|
||||
@in_juty.out_time = 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
|
||||
# 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 removed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_in_juty
|
||||
@table_id = params[:table_id]
|
||||
@in_juty.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_index_in_juty_path(@table_id), notice: 'In juty was successfully removed.' }
|
||||
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(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
|
||||
end
|
||||
end
|
||||
50
app/controllers/reports/stock_check_controller.rb
Normal file
50
app/controllers/reports/stock_check_controller.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
class Reports::StockCheckController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
|
||||
def index
|
||||
from_date = DateTime.now.beginning_of_day.utc.getlocal
|
||||
to_date = DateTime.now.end_of_day.utc.getlocal
|
||||
unless params[:daterange].blank?
|
||||
from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
|
||||
to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
|
||||
@daterange = params[:daterange]
|
||||
end
|
||||
commissioner = params[:commissioner].to_i
|
||||
@com_id = commissioner
|
||||
@commissioner = Commissioner.active.all
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,6 +69,9 @@ class Settings::PromotionsController < ApplicationController
|
||||
# DELETE /promotions/1
|
||||
# DELETE /promotions/1.json
|
||||
def destroy
|
||||
@promotion.promotion_products.each do |pp|
|
||||
pp.destroy
|
||||
end
|
||||
@promotion.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully destroyed.' }
|
||||
@@ -87,6 +90,21 @@ class Settings::PromotionsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def find_parent_item
|
||||
res = []
|
||||
item = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
|
||||
if item.nil?
|
||||
product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
|
||||
res.push(product.name)
|
||||
res.push(product.item_code)
|
||||
else
|
||||
# menu_item = item.menu_item.pluck(:name,:item_code)
|
||||
res.push(item.item_instance_name)
|
||||
res.push(item.menu_item.item_code)
|
||||
end
|
||||
render json: res
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_promotion
|
||||
|
||||
Reference in New Issue
Block a user