shop code

This commit is contained in:
Myat Zin Wai Maw
2019-11-22 18:24:02 +06:30
parent 5a3f328789
commit d1ab2c194d
106 changed files with 834 additions and 895 deletions

View File

@@ -1,22 +1,22 @@
class Crm::DiningQueuesController < BaseCrmController
load_and_authorize_resource
before_action :set_dining_queue, only: [:show, :edit, :update, :destroy]
# GET /crm/dining_queues
# GET /crm/dining_queues.json
def index
today = DateTime.now.strftime('%Y-%m-%d')
@dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc")
@complete_queue = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc")
@dining_queues = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc")
@complete_queue = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc")
if params[:term]
@customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%")
else
@customer = Customer.all
end
respond_to do |format|
format.html
respond_to do |format|
format.html
format.json { render :json => @customer.to_json }
end
end
@@ -41,16 +41,16 @@ class Crm::DiningQueuesController < BaseCrmController
def create
puts dining_queue_params
@dining_queue = DiningQueue.new(dining_queue_params)
@dining_queue.shop_code = @shop.shop_code
respond_to do |format|
if @dining_queue.save
# unique_code = "QueueNoPdf"
# unique_code = "QueueNoPdf"
# # get printer info
# print_settings = PrintSetting.find_by_unique_code(unique_code)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_queue_no(print_settings,@dining_queue)
format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully created.' }
@@ -88,7 +88,7 @@ class Crm::DiningQueuesController < BaseCrmController
def assign
@queue = DiningQueue.find(params[:id])
@tables = DiningFacility.where("status = 'available' ")
@tables = DiningFacility.where("status = 'available' and shop_code='#{@shop.shop_code}' and type!='HotelRoom'")
respond_to do |format|
format.html # index.html.erb
end
@@ -105,42 +105,46 @@ class Crm::DiningQueuesController < BaseCrmController
# type = "RoomBooking"
# end
booking = Booking.create({:dining_facility_id => params[:table_id],:type => type,
:checkin_at => Time.now.utc,:customer_id => queue.customer_id,:booking_status => "assign" })
booking = Booking.create({:dining_facility_id => params[:table_id],
:type => type,
:checkin_at => Time.now.utc,
:customer_id => queue.customer_id,
:booking_status => "assign",
:shop_code => @shop.shop_code})
booking.save!
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
# status = DiningFacility.find(table_id).update_attributes(status: "occupied")
if status == true
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully assigned .'})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
end
def cancel_queue
queue = DiningQueue.find(params[:id])
status = queue.update_attributes(id: params[:id],status:"Cancel")
if status == true
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully canceled .'})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_dining_queue
@dining_queue = DiningQueue.find(params[:id])
@dining_queue = DiningQueue.find_by_id_and_shop_code(params[:id],@shop.shop_code)
end
# Never trust parameters from the scary internet, only allow the white list through.
def dining_queue_params
params.require(:dining_queue).permit(:customer_id, :name, :contact_no, :queue_no,:status,:seater,:remark)
end
end