56 lines
1.1 KiB
Ruby
56 lines
1.1 KiB
Ruby
class Crm::HomeController < BaseCrmController
|
|
def index
|
|
|
|
@booking = Booking.all
|
|
@customer = Customer.all
|
|
|
|
end
|
|
|
|
def show
|
|
end
|
|
|
|
#print for crm
|
|
def print_order
|
|
|
|
@booking = Booking.find(params[:id])
|
|
|
|
@total_amount = 0.00
|
|
@total_tax = 0.00
|
|
|
|
if @booking.booking_orders
|
|
order_items = []
|
|
@booking.booking_orders.each do |bo|
|
|
order = Order.find(bo.order_id)
|
|
#if (order.status == "new")
|
|
order_items = order_items + order.order_items
|
|
#end
|
|
end
|
|
|
|
end
|
|
|
|
unique_code="CrmOrderPdf"
|
|
|
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
|
|
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
|
|
|
printer.print_crm_order(@booking,order_items,print_settings)
|
|
|
|
end
|
|
|
|
def update_sale_by_customer
|
|
|
|
sale = Sale.find(params[:sale_id])
|
|
status = sale.update_attributes(customer_id: params[:customer_id])
|
|
|
|
if status == true
|
|
render json: JSON.generate({:status => true})
|
|
else
|
|
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
|
|
|
end
|
|
end
|
|
|
|
end
|
|
|