TODO: - AJAX for add_p_article and add_stock_movement_p_article in stock_movement views - Fix select p_article with in stock_movement partial view - Fix query to display available p_article in stock_movement partial
75 lines
1.3 KiB
Ruby
75 lines
1.3 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
require "awesome_print"
|
|
class Admin::PriceLinesController < ApplicationController
|
|
layout "admin"
|
|
before_action :auth_admin, :except => [:edit, :update]
|
|
|
|
before_action :admin_space
|
|
|
|
def admin_space
|
|
@admin_space = "default"
|
|
end
|
|
|
|
def index
|
|
@price_lines = PriceLine.order(:name).all
|
|
|
|
end
|
|
|
|
def show
|
|
@price_line = PriceLine.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
@price_line = PriceLine.new
|
|
|
|
end
|
|
|
|
def edit
|
|
@price_line = PriceLine.find(params[:id])
|
|
|
|
end
|
|
|
|
def create
|
|
@price_line = PriceLine.new(params.require(:price_line).permit!)
|
|
|
|
if @price_line.save
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@price_line = PriceLine.find(params[:id])
|
|
@price_document = @price_line.price_line_block.price_lineable
|
|
|
|
if @price_line.update_attributes(params.require(:price_line).permit!)
|
|
|
|
else
|
|
render action: "edit"
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@price_line = PriceLine.find(params[:id])
|
|
@price_line.destroy
|
|
|
|
end
|
|
|
|
def add_p_article
|
|
@price_line = PriceLine.find(params[:price_line_id])
|
|
# @p_article = PArticle.new#@price_line.p_articles.build
|
|
# @p_article_serial_nums = @p_article.p_article_serial_nums.build
|
|
end
|
|
|
|
def add_price_line_p_article
|
|
@price_line = PriceLine.find(params[:price_line_id])
|
|
end
|
|
end
|