This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/app/controllers/public/price_lines_controller.rb
2021-08-23 10:26:02 +02:00

87 lines
1.8 KiB
Ruby

class Public::PriceLinesController < ApplicationController
layout "public"
def create
if params[:configurateur]
@price_line = @current_p_customer_sheet.price_line_block.price_lines.new(params.require(:price_line).permit!)
if @price_line.save
if !request.xhr?
redirect_to cart_public_p_orders_path
end
end
else
if @p_product_ref = PProductRef.find(params[:price_line][:p_product_ref_id])
if price_line = @current_p_customer_sheet.price_line_block.price_lines.where(:p_product_ref_id => @p_product_ref.id).first
price_line.qte = price_line.qte + params[:price_line][:qte].to_f
else
price_line = @current_p_customer_sheet.price_line_block.price_lines.build(:qte => params[:price_line][:qte], :p_product_ref_id => @p_product_ref.id)
end
puts "ESSAI"
puts @current_p_customer_sheet.id
puts "ESSAI"
puts price_line.price_line_block.errors
puts price_line.save
puts price_line.errors.messages
#raise
if !request.xhr?
redirect_to public_p_product_path(@p_product_ref.p_product)
end
end
end
end
def edit
@price_line = @current_p_customer_sheet.price_line_block.price_lines.find(params[:id])
end
def update
@price_line = @current_p_customer_sheet.price_line_block.price_lines.find(params[:id])
if @price_line.update_attributes(params.require(:price_line).permit!)
if !request.xhr?
redirect_to cart_public_p_orders_path()
end
end
end
def destroy
@price_line = @current_p_customer_sheet.price_line_block.price_lines.find(params[:id])
if @price_line.destroy
if !request.xhr?
redirect_to cart_public_p_orders_path()
end
end
end
end