diff --git a/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c b/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c new file mode 100644 index 0000000..e13aa03 Binary files /dev/null and b/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c differ diff --git a/.sass-cache/d6dc4d64a1af1ff4c7903858d908aeb1a0a8c2c1/(__TEMPLATE__)c b/.sass-cache/d6dc4d64a1af1ff4c7903858d908aeb1a0a8c2c1/(__TEMPLATE__)c new file mode 100644 index 0000000..2aaa243 Binary files /dev/null and b/.sass-cache/d6dc4d64a1af1ff4c7903858d908aeb1a0a8c2c1/(__TEMPLATE__)c differ diff --git a/app/assets/javascripts/admin.coffee b/app/assets/javascripts/admin.coffee index 7a571ec..ea98f59 100644 --- a/app/assets/javascripts/admin.coffee +++ b/app/assets/javascripts/admin.coffee @@ -56,6 +56,7 @@ #= require freeze-table +#= require admin/random_hexa @@ -856,6 +857,4 @@ $(document).on 'click', '.datepicker', (e) -> $(this).next('.' + autocomplete_object + '_id').val ui.item.id return return - - - + \ No newline at end of file diff --git a/app/assets/javascripts/admin/random_hexa.js b/app/assets/javascripts/admin/random_hexa.js new file mode 100644 index 0000000..910cebf --- /dev/null +++ b/app/assets/javascripts/admin/random_hexa.js @@ -0,0 +1,2 @@ +const genRanHex = size => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join(''); + \ No newline at end of file diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index 10623e4..49a11fb 100644 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -42,7 +42,7 @@ function manager_show(url){ function manager_hide(){ $("#manager_box_place").removeClass("manager_box_place_active"); - + $('#manager_box').html(""); $("body").css("overflow", "auto"); slider_enabled = null; @@ -239,3 +239,23 @@ function select_video_from_manager(input_id){ } +function select_product_from_manager(input_id){ + + + + manager_prompt(p_product_refs_url,function(m_return){ + + $('#p_product_ref_id_'+input_id).val(m_return.id); + $('#p_product_ref_name_'+input_id).val(m_return.name); + $('#p_product_ref_qte_'+input_id).focus() + }); + +} + +function send_manager_product(product_id, product_name){ + + manager_send_response({id : product_id, name : product_name}); +} + + + diff --git a/app/assets/javascripts/nested_fields.coffee b/app/assets/javascripts/nested_fields.coffee index c589739..c0a6ca7 100644 --- a/app/assets/javascripts/nested_fields.coffee +++ b/app/assets/javascripts/nested_fields.coffee @@ -10,9 +10,11 @@ if $(link).closest("p").next("." + association + "_form").length > 0 form_element = $(link).closest("p").next("." + association + "_form") - else + else if $(link).closest("p").prev("." + association + "_form").length > 0 form_element = $(link).closest("p").prev("." + association + "_form") - + else + form_element = $(link).closest(".qi_field_wrapper").find("." + association + "_form") + form_element.append content_final $(".new_field").removeClass "new_field" diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index a53341c..cb1ee54 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -1782,4 +1782,88 @@ td{ } -// Fin \ No newline at end of file + +// Html5 Tooltip +.info { + color: #009bbf; + position: relative; + display: inline-block; + text-overflow: ellipsis; + + .info-text-top { + visibility: hidden; + background-color: #555; + color: #fff; + text-align: center; + padding: 5px; + border-radius: 6px; + max-width: 500px; + min-width: fit-content; + white-space: normal; + + /* Position the tooltip text */ + position: absolute; + z-index: 1; + bottom: 125%; + left: 50%; + margin-left: -60px; + + /* Fade in tooltip */ + opacity: 0; + transition: opacity 0.3s; + } + .info-text-top::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; + } + .info-text-bottom { + visibility: hidden; + background-color: #555; + color: #fff; + text-align: center; + padding: 5px; + border-radius: 6px; + max-width: 500px; + min-width: fit-content; + white-space: normal; + + /* Position the tooltip text */ + position: absolute; + z-index: 1; + top: 125%; + left: 200%; + margin-left: -60px; + + /* Fade in tooltip */ + opacity: 0; + transition: opacity 0.3s; + } + .info-text-bottom::after { + content: ""; + position: absolute; + bottom: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: transparent transparent #555 transparent; + } +} +.info:hover { + .info-text-top { + visibility: visible; + opacity: 1; + } + .info-text-bottom { + visibility: visible; + opacity: 1; + } +} + +// Fin diff --git a/app/assets/stylesheets/manager.scss b/app/assets/stylesheets/manager.scss index eb296d2..f03e584 100644 --- a/app/assets/stylesheets/manager.scss +++ b/app/assets/stylesheets/manager.scss @@ -2,7 +2,8 @@ #manager_box_place{ position:fixed; height:0; - width:100%; + left:100px; + right:30px; z-index:1500; top:0px; margin:0px; diff --git a/app/controllers/admin/buy_lists_controller.rb b/app/controllers/admin/buy_lists_controller.rb index cd1b7b6..515b796 100644 --- a/app/controllers/admin/buy_lists_controller.rb +++ b/app/controllers/admin/buy_lists_controller.rb @@ -8,17 +8,89 @@ class Admin::BuyListsController < ApplicationController @p_customer_sheets = PCustomerSheet.all - @p_customer_sheets = @p_customer_sheets.where(:state => ["AV BPA", "PAS BPA", "BPA"]) + @p_customer_sheets = @p_customer_sheets.where(:state => ["brouillon", "offre", "commande"]) @price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids) @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids) + if params[:search][:s_brand].present? && params[:search][:s_brand] != "" + @price_lines = @price_lines.joins(p_product_ref: :p_product).where("s_brand_id = ?", params[:search][:s_brand]) + end + + if params[:search][:state].present? && params[:search][:state] != "" + @p_customer_sheets = @p_customer_sheets.where(:state => params[:search][:state]) + @price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids) + @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids) + end + + if params[:search][:p_customer_code].present? + @p_customer_sheets = @p_customer_sheets.joins(:p_customer).where("code LIKE ?", params[:search][:p_customer_code]) + @price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids) + @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids) + end + + date_regex = /^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d$/i + + + params[:cc_creation_date_start] = Date.today.beginning_of_month.strftime('%d/%m/%Y') if !params[:cc_creation_date_start] + + if params[:cc_creation_date_start] and params[:cc_creation_date_start] =~ date_regex + #fsfds = sdfsfd + @cc_creation_date_start = Date.parse(params[:cc_creation_date_start]).beginning_of_day + params[:cc_creation_date_start]= @cc_creation_date_start.strftime('%d/%m/%Y') + else + @cc_creation_date_start = nil + end + + if true + params[:cc_creation_date_stop] = Date.today.end_of_month.strftime('%d/%m/%Y') if !params[:cc_creation_date_stop] + + + if params[:cc_creation_date_stop].to_s != "" # and params[:stop] =~ date_regex + @cc_creation_date_stop = Date.parse(params[:cc_creation_date_stop]).end_of_day + + params[:cc_creation_date_stop]= @cc_creation_date_stop.strftime('%d/%m/%Y') + + + else + @cc_creation_date_stop = nil + end + + end + @price_lines = @price_lines.where("price_lines.cc_creation_date >= ?", @cc_creation_date_start) if @cc_creation_date_start + @price_lines = @price_lines.where("price_lines.cc_creation_date <= ?", @cc_creation_date_stop.end_of_day) if @cc_creation_date_stop + + params[:wish_date_start] = Date.today.beginning_of_month.strftime('%d/%m/%Y') if !params[:wish_date_start] + + if params[:wish_date_start] and params[:wish_date_start] =~ date_regex + #fsfds = sdfsfd + @wish_date_start = Date.parse(params[:wish_date_start]).beginning_of_day + params[:wish_date_start]= @wish_date_start.strftime('%d/%m/%Y') + else + @wish_date_start = nil + end + + if true + params[:wish_date_stop] = Date.today.end_of_month.strftime('%d/%m/%Y') if !params[:wish_date_stop] + + + if params[:wish_date_stop].to_s != "" # and params[:stop] =~ date_regex + @wish_date_stop = Date.parse(params[:wish_date_stop]).end_of_day + + params[:wish_date_stop]= @wish_date_stop.strftime('%d/%m/%Y') + + + else + @wish_date_stop = nil + end + + end + @price_lines = @price_lines.joins(:price_line_block).where("price_line_blocks.wish_date >= ?", @wish_date_start) if @wish_date_start + @price_lines = @price_lines.joins(:price_line_block).where("price_line_blocks.wish_date <= ?", @wish_date_stop.end_of_day) if @wish_date_stop respond_to do |format| format.html{ - - } end diff --git a/app/controllers/admin/p_article_serial_nums_controller.rb b/app/controllers/admin/p_article_serial_nums_controller.rb new file mode 100644 index 0000000..d7ecbf7 --- /dev/null +++ b/app/controllers/admin/p_article_serial_nums_controller.rb @@ -0,0 +1,89 @@ +# -*- encoding : utf-8 -*- + +class Admin::PArticleSerialNumsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_article_serial_nums = PArticleSerialNum.all + + if params[:search][:p_serial_num_type_name].present? + @p_article_serial_nums = @p_article_serial_nums.where(p_serial_num_type_id: params[:search][:p_serial_num_type_name]) + + end + + if params[:search][:p_product_ref_cc_name] + @p_article_serial_nums = @p_article_serial_nums.joins(:p_article, :p_product_ref).where("cc_name LIKE ?","#{params[:search][:p_product_ref_cc_name]}%") + end + + if params[:search][:value] + @p_article_serial_nums = @p_article_serial_nums.where("value LIKE ?","#{params[:search][:value]}%") + end + + @p_article_serial_nums = sort_by_sorting(@p_article_serial_nums, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_article_serial_nums = @p_article_serial_nums.page(page).per(per_page) + + } + end + end + + def show + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + + end + + def new + @p_article_serial_num = PArticleSerialNum.new + # @p_article_serial_num.build_p_serial_num_value + end + + def edit + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + + end + + def create + @p_article_serial_num = PArticleSerialNum.new(params.require(:p_article_serial_num).permit!) + + if @p_article_serial_num.save + + else + render action: "new" + + end + + end + + + def update + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + + + if @p_article_serial_num.update_attributes(params.require(:p_article_serial_num).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + @p_article_serial_num.destroy + + end +end diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb new file mode 100644 index 0000000..0e40f7a --- /dev/null +++ b/app/controllers/admin/p_articles_controller.rb @@ -0,0 +1,104 @@ +# -*- encoding : utf-8 -*- + +class Admin::PArticlesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_articles = PArticle.all + + if params[:search][:p_product_color].to_s != "" + if params[:search][:p_product_color].to_s == "null" + @p_articles = @p_articles.joins(:p_product_ref).where("p_product_color_id = ?", nil) + else + @p_articles = @p_articles.joins(:p_product_ref).where("p_product_color_id = ?", params[:search][:p_product_color]) + end + end + + if params[:search][:p_product_ref_cc_name] + @p_articles = @p_articles.joins(:p_product_ref).where("cc_name LIKE ?", "#{params[:search][:p_product_ref_cc_name]}%") + end + + if params[:search][:p_grade_id] + @p_articles = @p_articles.where("p_grade_id LIKE ?", "#{params[:search][:p_grade_id]}%") + end + + if params[:search][:p_product_ref_cc_code] + @p_articles = @p_articles.joins(:p_product_ref).where("cc_code LIKE ?", "#{params[:search][:p_product_ref_cc_code]}%") + end + + if params[:search][:p_article_serial_num] + @p_articles = @p_articles.joins(:p_article_serial_nums).where("value LIKE ?", "#{params[:search][:p_article_serial_num]}%") + end + + + @p_articles = sort_by_sorting(@p_articles, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_articles = @p_articles.page(page).per(per_page) + + } + end + end + + def show + @p_article = PArticle.find(params[:id]) + + end + + def new + @p_article = PArticle.new + @p_article_serial_nums = @p_article.p_article_serial_nums.build + + @p_serial_num_type = @p_article_serial_nums.build_p_serial_num_type + # @p_serial_num_value = @p_article_serial_nums.build_p_serial_num_value + end + + def edit + @p_article = PArticle.find(params[:id]) + + end + + def create + @p_article = PArticle.new(params.require(:p_article).permit!) + + if @p_article.save + + else + render action: "new" + + end + + end + + + def update + @p_article = PArticle.find(params[:id]) + + + if @p_article.update_attributes(params.require(:p_article).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_article = PArticle.find(params[:id]) + @p_article.destroy + + end +end diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index f99ea9f..fbc5058 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -174,12 +174,14 @@ class Admin::PCustomerSheetsController < ApplicationController @p_customer_sheet.admin = current_admin - @p_customer = @p_customer_sheet.p_customer + if @p_customer_sheet.save - @p_customer_sheets = PCustomerSheet.order(:id).all + redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else + @p_customer = @p_customer_sheet.price_line_block.p_customer + render action: "new" end @@ -189,13 +191,14 @@ class Admin::PCustomerSheetsController < ApplicationController def update @p_customer_sheet = PCustomerSheet.find(params[:id]) - @p_customer = @p_customer_sheet.p_customer + if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) - @p_customer_sheets = PCustomerSheet.order(:id).all - + @p_customer = @p_customer_sheet.price_line_block.p_customer + + redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else render action: "edit" @@ -277,6 +280,89 @@ class Admin::PCustomerSheetsController < ApplicationController end - + def export_xls + @p_customer_sheets = PCustomerSheet.all + if params[:p_customer_sheet_ids].present? + @p_customer_sheets = PCustomerSheet.where(id: params[:p_customer_sheet_ids]) + end + + respond_to do |format| + format.csv { + @headers = ["BUID", "DATE", "NUMERO", "CLIENT", "REFERENCE", "EAN", "DESIGNATION", "QTE", "PRIX 1", "PRIX 2", "DEEE", "SORECOP", "FOURNISSEUR", "CODE ARTICLE MAG", "NomMarque", "Code Douanier", "Type SORECOP"] + @columns = [] + # PCustomerSheet.qi_table_order.each do |key, value| + # if value.instance_of? Hash + # name = value[:name] + # else + # name = value + # end + + # if name != "Actions" + # @headers << name.to_s + # @columns << key + # end + + # end + + xlsx_package = Axlsx::Package.new + wb = xlsx_package.workbook + wb.add_worksheet(name: "BASIC extract to Chronopost") do |sheet| + sheet.add_row @headers + + @p_customer_sheets.each do |p_customer_sheet| + p_customer_sheet.price_line_block.price_lines.each do |price_line| + line = [] + line << price_line.id + line << p_customer_sheet.created_at.strftime("%d/%d/%Y") + line << p_customer_sheet.id + line << p_customer_sheet.p_customer.code + " - " + p_customer_sheet.p_customer.particulars.first.organisation + line << price_line.p_product_ref.cc_name + # line << price_line.p_product_ref.cc_ean + line << price_line.p_product_ref.ean + line << price_line.p_product_ref.cc_name + + line << price_line.qte + line << price_line.cc_price_u_ht + line << price_line.ct_u_price_ht + line << price_line.p_product_ref.deee + line << price_line.p_product_ref.sorecop + # line << price_line.p_product_ref.referal_fournisseur + line << "Fournisseur" + line << "" + + line << price_line.p_product_ref.p_product.s_brand.name + line << "Code douanier" + line << price_line.p_product_ref.sorecop_comment + sheet.add_row line, types: line.map{|t| cell_type_from_value(t)} + # puts line + end + + + # @columns.each do |column| + + # if (p_customer_sheet.respond_to?("csv_"+column.to_s)) + # line << p_customer_sheet.send("csv_"+column.to_s) + # elsif (p_customer_sheet.respond_to?(column)) + # if p_customer_sheet.send(column.to_s).class.to_s == "BigDecimal" + # line << p_customer_sheet.send(column.to_s).to_s.gsub('.', ',') + # else + # line << p_customer_sheet.send(column.to_s) + # end + # else + # line << column.to_s + # end + # end + # sheet.add_row line, types: line.map{|t| cell_type_from_value(t)} + end + end + + @final_file = "#{Rails.root}/private_medias/export-inscrits-#{Time.now.to_s.to_slug}.xlsx" + + xlsx_package.serialize(@final_file) + send_file @final_file + } + end + end + end diff --git a/app/controllers/admin/p_grades_controller.rb b/app/controllers/admin/p_grades_controller.rb new file mode 100644 index 0000000..7a77712 --- /dev/null +++ b/app/controllers/admin/p_grades_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PGradesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_grades = PGrade.all + + @p_grades = sort_by_sorting(@p_grades, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_grades = @p_grades.page(page).per(per_page) + + } + end + end + + def show + @p_grade = PGrade.find(params[:id]) + + end + + def new + @p_grade = PGrade.new + + end + + def edit + @p_grade = PGrade.find(params[:id]) + + end + + def create + @p_grade = PGrade.new(params.require(:p_grade).permit!) + + if @p_grade.save + + else + render action: "new" + + end + + end + + + def update + @p_grade = PGrade.find(params[:id]) + + + if @p_grade.update_attributes(params.require(:p_grade).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_grade = PGrade.find(params[:id]) + @p_grade.destroy + + end +end diff --git a/app/controllers/admin/p_product_ref_specs_controller.rb b/app/controllers/admin/p_product_ref_specs_controller.rb new file mode 100644 index 0000000..9935030 --- /dev/null +++ b/app/controllers/admin/p_product_ref_specs_controller.rb @@ -0,0 +1,78 @@ +# -*- encoding : utf-8 -*- + +class Admin::PProductRefSpecsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_product_ref_specs = PProductRefSpec.all + + @p_product_ref_specs = sort_by_sorting(@p_product_ref_specs, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_product_ref_specs = @p_product_ref_specs.page(page).per(per_page) + + } + end + end + + def show + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + end + + def new + @p_product_ref_spec = PProductRefSpec.new + @p_product_ref_spec.build_p_spec_type + @p_product_ref_spec.build_p_spec_value + + end + + def edit + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + end + + def create + @p_product_ref_spec = PProductRefSpec.new(params.require(:p_product_ref_spec).permit!) + + if @p_product_ref_spec.save + + else + render action: "new" + + end + + end + + + def update + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + + if @p_product_ref_spec.update_attributes(params.require(:p_product_ref_spec).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + @p_product_ref_spec.destroy + + end +end diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index c72e779..736d823 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -42,11 +42,19 @@ class Admin::PProductRefsController < ApplicationController if params[:search][:s_brand_id].to_s != "" - @p_product_refs = @p_product_refs.where(:s_brand_id => params[:search][:s_brand_id]) + @p_product_refs = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}) end @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") respond_to do |format| + format.js{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_product_refs = @p_product_refs.page(page).per(per_page) + + } format.html{ params[:search][:per_page] = params[:search][:per_page] || 100 @@ -57,6 +65,11 @@ class Admin::PProductRefsController < ApplicationController } end + + if params[:manager].to_s == "true" + @manager = true + render :layout => false + end end @@ -93,9 +106,11 @@ class Admin::PProductRefsController < ApplicationController if @p_product_ref.update_attributes(params.require(:p_product_ref).permit!) + else - render action: "edit" + + render action: "edit" end @@ -138,27 +153,29 @@ class Admin::PProductRefsController < ApplicationController def get_infos + @p_product_ref = PProductRef.find(params[:id]) if params[:type] == "price" price = @p_product_ref.get_price(:p_customer_id => params[:p_customer_id], :qte => params[:qte]) - puts params[:p_fournisseur_id] - + + if params[:p_customer_id].to_s != "" p_customer = PCustomer.find(params[:p_customer_id]) accounting_zone_id = p_customer.accounting_zone_id + if p_customer.tva_rate tva_account_id = p_customer.tva_rate.id tva_account_value = p_customer.tva_rate.rate - + else tva_account_id = @p_product_ref.p_product.tva_rate(accounting_zone_id).id if @p_product_ref.p_product.tva_rate(accounting_zone_id) tva_account_value = @p_product_ref.p_product.tva_rate(accounting_zone_id).rate if @p_product_ref.p_product.tva_rate(accounting_zone_id) - - + + end - + elsif params[:p_fournisseur_id].to_s != "" p_fournisseur = PFournisseur.find(params[:p_fournisseur_id]) accounting_zone_id = p_fournisseur.accounting_zone_id diff --git a/app/controllers/admin/p_products_controller.rb b/app/controllers/admin/p_products_controller.rb index a0ae7f9..9cb4915 100644 --- a/app/controllers/admin/p_products_controller.rb +++ b/app/controllers/admin/p_products_controller.rb @@ -73,8 +73,11 @@ class Admin::PProductsController < ApplicationController @p_product = PProduct.new #(:p_customer_cat_ids => [3]) - @p_product.p_product_refs << PProductRef.new - + # @p_product.p_product_refs << PProductRef.new + @p_product_refs = @p_product.p_product_refs.build + @p_product_ref_specs = @p_product_refs.p_product_ref_specs.build + @p_spec_type = @p_product_ref_specs.build_p_spec_type + @p_spec_value = @p_product_ref_specs.build_p_spec_value end diff --git a/app/controllers/admin/p_serial_num_types_controller.rb b/app/controllers/admin/p_serial_num_types_controller.rb new file mode 100644 index 0000000..ef1f006 --- /dev/null +++ b/app/controllers/admin/p_serial_num_types_controller.rb @@ -0,0 +1,81 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSerialNumTypesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_serial_num_types = PSerialNumType.all + + if params[:search][:name] + @p_serial_num_types = @p_serial_num_types.where("id = ?","#{params[:search][:name]}%") + end + + + @p_serial_num_types = sort_by_sorting(@p_serial_num_types, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_serial_num_types = @p_serial_num_types.page(page).per(per_page) + + } + end + end + + def show + @p_serial_num_type = PSerialNumType.find(params[:id]) + + end + + def new + @p_serial_num_type = PSerialNumType.new + + end + + def edit + @p_serial_num_type = PSerialNumType.find(params[:id]) + + end + + def create + @p_serial_num_type = PSerialNumType.new(params.require(:p_serial_num_type).permit!) + + if @p_serial_num_type.save + + else + render action: "new" + + end + + end + + + def update + @p_serial_num_type = PSerialNumType.find(params[:id]) + + + if @p_serial_num_type.update_attributes(params.require(:p_serial_num_type).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_serial_num_type = PSerialNumType.find(params[:id]) + @p_serial_num_type.destroy + + end +end diff --git a/app/controllers/admin/p_serial_num_values_controller.rb b/app/controllers/admin/p_serial_num_values_controller.rb new file mode 100644 index 0000000..05c3bde --- /dev/null +++ b/app/controllers/admin/p_serial_num_values_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSerialNumValuesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_serial_num_values = PSerialNumValue.all + + @p_serial_num_values = sort_by_sorting(@p_serial_num_values, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_serial_num_values = @p_serial_num_values.page(page).per(per_page) + + } + end + end + + def show + @p_serial_num_value = PSerialNumValue.find(params[:id]) + + end + + def new + @p_serial_num_value = PSerialNumValue.new + + end + + def edit + @p_serial_num_value = PSerialNumValue.find(params[:id]) + + end + + def create + @p_serial_num_value = PSerialNumValue.new(params.require(:p_serial_num_value).permit!) + + if @p_serial_num_value.save + + else + render action: "new" + + end + + end + + + def update + @p_serial_num_value = PSerialNumValue.find(params[:id]) + + + if @p_serial_num_value.update_attributes(params.require(:p_serial_num_value).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_serial_num_value = PSerialNumValue.find(params[:id]) + @p_serial_num_value.destroy + + end +end diff --git a/app/controllers/admin/p_spec_types_controller.rb b/app/controllers/admin/p_spec_types_controller.rb new file mode 100644 index 0000000..5d3ed6b --- /dev/null +++ b/app/controllers/admin/p_spec_types_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSpecTypesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_spec_types = PSpecType.all + + @p_spec_types = sort_by_sorting(@p_spec_types, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_spec_types = @p_spec_types.page(page).per(per_page) + + } + end + end + + def show + @p_spec_type = PSpecType.find(params[:id]) + + end + + def new + @p_spec_type = PSpecType.new + + end + + def edit + @p_spec_type = PSpecType.find(params[:id]) + + end + + def create + @p_spec_type = PSpecType.new(params.require(:p_spec_type).permit!) + + if @p_spec_type.save + + else + render action: "new" + + end + + end + + + def update + @p_spec_type = PSpecType.find(params[:id]) + + + if @p_spec_type.update_attributes(params.require(:p_spec_type).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_spec_type = PSpecType.find(params[:id]) + @p_spec_type.destroy + + end +end diff --git a/app/controllers/admin/p_spec_values_controller.rb b/app/controllers/admin/p_spec_values_controller.rb new file mode 100644 index 0000000..2dfd736 --- /dev/null +++ b/app/controllers/admin/p_spec_values_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSpecValuesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_spec_values = PSpecValue.all + + @p_spec_values = sort_by_sorting(@p_spec_values, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_spec_values = @p_spec_values.page(page).per(per_page) + + } + end + end + + def show + @p_spec_value = PSpecValue.find(params[:id]) + + end + + def new + @p_spec_value = PSpecValue.new + + end + + def edit + @p_spec_value = PSpecValue.find(params[:id]) + + end + + def create + @p_spec_value = PSpecValue.new(params.require(:p_spec_value).permit!) + + if @p_spec_value.save + + else + render action: "new" + + end + + end + + + def update + @p_spec_value = PSpecValue.find(params[:id]) + + + if @p_spec_value.update_attributes(params.require(:p_spec_value).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_spec_value = PSpecValue.find(params[:id]) + @p_spec_value.destroy + + end +end diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 2b92020..b224d70 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -2,7 +2,7 @@ class Admin::PriceDocumentsController < ApplicationController layout "admin" - before_action :auth_admin, :except => :print + before_action :auth_admin, :except => [:print, :consult, :consult_create, :consult_edit, :consult_update] before_action :admin_space, :except => :print @@ -224,7 +224,7 @@ class Admin::PriceDocumentsController < ApplicationController def show @price_document = PriceDocument.find(params[:id]) - + @facture_achat_childrens = PriceDocument.where(doc_ref_id: @price_document.id, price_document_type: PriceDocumentType.find_by_label("Facture achat")) end def new @@ -235,11 +235,19 @@ class Admin::PriceDocumentsController < ApplicationController @price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) if @price_document.price_document_type.label == "Demande prix" - @ref_price_lines = PriceLine.where(:id => params[:price_line_ids]) - - @ref_price_lines.group(:p_product_ref_id).each do |plr| - @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + p_product_ref_id = params[:p_product_ref_ids] - [""] + p_product_ref_qte = params[:qte].permit!.to_hash + + p_product_ref_id.each do |i| + if p_product_ref_qte[i.to_s].to_i > 0 + @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => i, :qte => p_product_ref_qte[i.to_s]) + end end + + # @ref_price_lines = PriceLine.where(:id => params[:price_line_ids]) + # @ref_price_lines.group(:p_product_ref_id).each do |plr| + # @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + # end end @@ -261,6 +269,7 @@ class Admin::PriceDocumentsController < ApplicationController def consult + @consult = true @demande = PriceDocument.where(:f_token => params[:id]).first @@ -272,12 +281,34 @@ class Admin::PriceDocumentsController < ApplicationController @ref_price_lines = @demande.price_line_block.price_lines @ref_price_lines.group(:p_product_ref_id).each do |plr| - @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + @price_document.price_line_block.price_lines << PriceLine.new(:price_line_ref_id => plr.id, :p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) end end + + def consult_create + @consult = true + + @price_document = PriceDocument.new(params.require(:price_document).permit!) + @price_document.date = Date.today + if @price_document.save + redirect_to consult_edit_admin_price_document_path(:id => @price_document.token) + else + render action: "consult" + + end + + end + + + def consult_edit + @consult = true + + @price_document = PriceDocument.where(:token => params[:id]).first + end + def edit @price_document = PriceDocument.find(params[:id]) @@ -291,7 +322,11 @@ class Admin::PriceDocumentsController < ApplicationController @price_document.date = Date.today @avoir = true if @price_document.label == "Avoir" if @price_document.save - redirect_to admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id) + if @price_document.cc_label == "Demande prix" + render action: :show + else + redirect_to admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id) + end else render action: "new" @@ -305,18 +340,26 @@ class Admin::PriceDocumentsController < ApplicationController @avoir = true if @price_document.label == "Avoir" if @price_document.update_attributes(params.require(:price_document).permit!) - if params[:public_edit].to_s == "true" @price_document.reset_for_update #@price_document.unarchive_now #@price_document.archive_now - if @price_document.ref_element + if ["Facture achat", "Commande achat"].include?(@price_document.cc_label) + redirect_to [:admin, @price_document] + elsif @price_document.doc_ref_id + redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)] + elsif @price_document.ref_element redirect_to [:admin, @price_document.ref_element] else redirect_to [:admin, @price_document] end + + elsif @price_document.doc_ref_id + redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)] + elsif @price_document.ref_element + redirect_to [:admin, @price_document.ref_element] else redirect_to [:admin, @price_document] end @@ -566,5 +609,203 @@ class Admin::PriceDocumentsController < ApplicationController end - + def match_p_fournisseur + @price_document = PriceDocument.find(params[:id]) + end + + def match_p_fournisseur_save + @price_document = PriceDocument.find(params[:id]) + + if @price_document.update_attributes(params.require(:price_document).permit!) + # redirect_back(fallback_location: price_documents_ptath) + else + render action: "edit" + end + end + + def analyse_reponses + @price_document = PriceDocument.find(params[:id]) + @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id ) + end + + def analyse_reponses_save + @price_document = PriceDocument.find(params[:id]) + if @price_document.update_attributes(params.require(:price_document).permit!) + redirect_to :analyse_reponses_admin_price_document + else + render :edit + end + end + + + def generate_final_consult + price_lines_to_add = {} + + @price_document_demand = PriceDocument.find(params[:id]) + + @price_document_demand.price_line_block.price_lines.each do |pl_demand| + + pl_demand.price_line_resps.all.each do |price_line_resp| + price_lines_to_add[price_line_resp.p_fournisseur.id] = price_lines_to_add[price_line_resp.p_fournisseur.id] || {:p_fournisseur => price_line_resp.p_fournisseur, :price_lines => [] } + price_lines_to_add[price_line_resp.p_fournisseur.id][:price_lines] << price_line_resp + end + + end + + price_lines_to_add.each do |k,v| + new_final_consult = PriceDocument.new(:doc_ref_id => @price_document_demand.id,:date => Date.today, :price_document_type => PriceDocumentType.find_by_label("Consultation fournisseur")) + new_final_consult.price_line_block = PriceLineBlock.new(:p_fournisseur => v[:p_fournisseur]) + + v[:price_lines].each do |price_line_resp| + new_final_consult.price_line_block.price_lines << PriceLine.new(:p_product_ref => price_line_resp.p_product_ref, :qte => price_line_resp.qte_available, :ct_u_price_ht => price_line_resp.price_u_ht ) + end + + new_final_consult.save + + end + + @final_consult = PriceDocument.where(price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).last + redirect_to admin_price_document_path(@price_document_demand, anchor: "consult") + end + + def buy_order_create + + @final_consult = PriceDocument.find(params[:id]) + price_line_block = PriceLineBlock.new(p_fournisseur: @final_consult.price_line_block.p_fournisseur) + price_lines = PriceLine.where(price_line_block: @final_consult.price_line_block) + + @price_document = PriceDocument.new(date: Date.today, price_line_block: price_line_block, doc_ref_id: @final_consult.id, demande_de_prix_id: @final_consult.id ,:price_document_type => PriceDocumentType.find_by_label("Commande achat")) + price_lines.each do |pl| + @price_document.price_line_block.price_lines << PriceLine.new(p_product_ref: pl.p_product_ref, qte: pl.qte, ct_u_price_ht: pl.price_u_ht) + end + if @price_document.save! + redirect_to admin_price_document_path(@price_document) + end + end + + + def bon_de_reception + @past_price_document = PriceDocument.find(params[:id]) + + @p_customer_sheet = @past_price_document.ref_element + + if @p_customer_sheet + price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today) + else + price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :date => Date.today) + end + + price_document.doc_ref_id = @past_price_document.id + price_document.p_fournisseur = @past_price_document.p_fournisseur + price_document.price_line_block = @past_price_document.price_line_block.dup + + if @past_price_document.cc_label == "Commande achat" + price_document.bon_de_commande_achat_id = @past_price_document.id + price_document.reliquat = true if PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat")).count > 0 + end + + + if @past_price_document.cc_label == "Facture achat" + price_document.facture_achat_id = @past_price_document.id + end + + + price_document.price_line_block.ac_bon_de_commande_id = nil + price_document.price_line_block.ac_bon_de_livraison_id = nil + price_document.price_line_block.ac_facture_id = nil + price_document.price_line_block.ac_block_type = nil + price_document.price_line_block.ac_reliquat = nil + + + + + @past_price_document.price_line_block.price_lines.each do |pl| + new_pl = pl.dup + new_pl.price_line_ref_id = pl.id + new_pl.ac_block_type = nil + + if price_document.reliquat #and @p_customer_sheet + bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat")) + + qte_ok = PriceLine.where(:price_line_ref_id => new_pl.price_line_ref_id).where(:price_line_block_id => PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bls.ids)).sum(:qte) + + new_pl.qte = new_pl.qte - qte_ok + + end + price_document.price_line_block.price_lines << new_pl + end + + if price_document.save + #price_document.reset_for_update + #price_document.archive_now + if @p_customer_sheet + @p_customer_sheet.state = "Bon de réception achat" + @p_customer_sheet.save + end + + if price_document.doc_ref_id + redirect_to [:admin, @past_price_document] + else + redirect_to [:admin, price_document] + end + else + render :inline => price_document.errors.messages.to_s + end + end + + def facture_achat + @past_price_document = PriceDocument.find(params[:id]) + + @p_customer_sheet = @past_price_document.ref_element + + if @p_customer_sheet + price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Facture achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today) + + else + price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Facture achat"), :date => Date.today) + end + + price_document.doc_ref_id = @past_price_document.id + price_document.p_fournisseur = @past_price_document.p_fournisseur + + price_document.price_line_block = @past_price_document.price_line_block.dup + + price_document.price_line_block.ac_bon_de_commande_id = nil + price_document.price_line_block.ac_bon_de_livraison_id = nil + price_document.price_line_block.ac_facture_id = nil + price_document.price_line_block.ac_block_type = nil + price_document.price_line_block.ac_reliquat = nil + + @past_price_document.price_line_block.price_lines.each do |pl| + new_pl = pl.dup + new_pl.price_line_ref_id = pl.id + new_pl.ac_block_type = nil + + + price_document.price_line_block.price_lines << new_pl + end + + if price_document.save + #price_document.reset_for_update + #price_document.archive_now + if @p_customer_sheet + @p_customer_sheet.state = "Facture" + @p_customer_sheet.save + end + + if price_document.doc_ref_id + redirect_to [:admin, @past_price_document] + else + redirect_to [:admin, price_document] + end + else + render :inline => price_document.errors.messages.to_s + end + + + + + + end + end diff --git a/app/controllers/admin/price_line_resp_selects_controller.rb b/app/controllers/admin/price_line_resp_selects_controller.rb new file mode 100644 index 0000000..24020fd --- /dev/null +++ b/app/controllers/admin/price_line_resp_selects_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PriceLineRespSelectsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @price_line_resp_selects = PriceLineRespSelect.all + + @price_line_resp_selects = sort_by_sorting(@price_line_resp_selects, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @price_line_resp_selects = @price_line_resp_selects.page(page).per(per_page) + + } + end + end + + def show + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + + end + + def new + @price_line_resp_select = PriceLineRespSelect.new + + end + + def edit + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + + end + + def create + @price_line_resp_select = PriceLineRespSelect.new(params.require(:price_line_resp_select).permit!) + + if @price_line_resp_select.save + + else + render action: "new" + + end + + end + + + def update + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + + + if @price_line_resp_select.update_attributes(params.require(:price_line_resp_select).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + @price_line_resp_select.destroy + + end +end diff --git a/app/controllers/admin/price_lines_controller.rb b/app/controllers/admin/price_lines_controller.rb index 18930ce..0874893 100644 --- a/app/controllers/admin/price_lines_controller.rb +++ b/app/controllers/admin/price_lines_controller.rb @@ -2,7 +2,7 @@ class Admin::PriceLinesController < ApplicationController layout "admin" - before_action :auth_admin + before_action :auth_admin, :except => [:edit, :update] before_action :admin_space diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f693d7e..ce02913 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,13 +2,14 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - before_action :set_current_p_customer_sheet + #before_action :set_current_p_customer_sheet before_action :init_admin_menu before_action :qi_menu + before_action :set_navbar_dropdown def qi_menu(sym=nil) @@ -21,10 +22,24 @@ class ApplicationController < ActionController::Base @qi_menu_active = sym.to_sym else @qi_menus.each do |k, v| + + + if v[:elements] and v[:elements][sym.to_sym] @qi_menu_active = k @qi_menu_sub_menu_active = sym.to_sym break + + elsif v[:elements] + + v[:elements].each do |a,b| + if b[:sub_elements] and b[:sub_elements][sym.to_sym] + @qi_menu_active = k + @qi_menu_sub_menu_active = sym.to_sym + end + end + + end @@ -64,41 +79,53 @@ class ApplicationController < ActionController::Base if current_admin.has_permission?("products") set_sub_menu :stocks, :p_products, "Produits", admin_p_products_path + set_sub_menu :stocks, :p_product_refs, "Références", admin_p_product_refs_path - set_sub_menu :stocks, :promos_p_products, "Offres spots", promos_admin_p_products_path + set_sub_menu :stocks, :p_articles, "Articles", admin_p_articles_path + # set_sub_menu :stocks, :promos_p_products, "Offres spots", promos_admin_p_products_path end + + if current_admin.has_permission?("product-cats") set_sub_menu :stocks, :p_product_cats, "Catégories produits", admin_p_product_cats_path - set_sub_menu :stocks, :p_product_sub_cats, "Sous catégories produits", admin_p_product_sub_cats_path + # set_sub_menu :stocks, :p_product_sub_cats, "Sous catégories produits", admin_p_product_sub_cats_path end + + set_sub_menu :stocks, :p_preferences_products_menu, "Préférences", admin_p_products_path if current_admin.has_permission?("brands") - set_sub_menu :stocks, :s_brands, "Marques", admin_s_brands_path + set_sub_sub_menu :stocks, :p_preferences_products_menu, :s_brands, "Marques", admin_s_brands_path end if current_admin.has_permission?("fournisseurs") - set_sub_menu :stocks, :p_fournisseurs, "Fournisseurs", admin_p_fournisseurs_path + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_fournisseurs, "Fournisseurs", admin_p_fournisseurs_path end if current_admin.has_permission?("stocks") - set_sub_menu :stocks, :stock_alias, "Stocks", admin_line_stocks_path + set_sub_sub_menu :stocks, :p_preferences_products_menu, :stock_alias, "Stocks", admin_line_stocks_path end if current_admin.has_permission?("boutique") - set_sub_menu :stocks, :p_product_colors, "Couleurs" - set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" - set_sub_menu :stocks, :p_product_zones, "Zones produits" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_colors, "Couleurs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_article_serial_nums, "Numeros série" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_serial_num_types, "Types de Numero série" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_ref_specs, "Specs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_spec_types, "Types de specs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_spec_values, "Valeurs de specs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_grades, "Grades" if PGrade::ACTIVATED + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits" end @@ -138,7 +165,7 @@ class ApplicationController < ActionController::Base end - set_sub_menu :documents, :"p_document_type_reponse_fournisseur", "Réponses fournisseurs", admin_price_documents_path(:price_document_type_id => 2) + # set_sub_menu :documents, :"p_document_type_reponse_fournisseur", "Réponses fournisseurs", admin_price_documents_path(:price_document_type_id => PriceDocumentType.find_by(label: "Réponse fournisseur").id) @@ -189,6 +216,16 @@ class ApplicationController < ActionController::Base @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym] = {:name => name, :link => link} end + + + def set_sub_sub_menu(big_menu, sub_menu, sub_sub_menu, name, link=nil) + + link = eval("admin_#{sub_sub_menu}_path") if !link + @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym][:sub_elements] = @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym][:sub_elements] || {} + + @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym][:sub_elements][sub_sub_menu.to_sym] = {:name => name, :link => link} + + end before_action :set_product_display @@ -434,13 +471,17 @@ class ApplicationController < ActionController::Base def current_admin - if cookies[:admin_remember_token] - if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) - @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) - else - cookies[:admin_remember_token] =nil - end + if @current_admin + return @current_admin + else + if cookies[:admin_remember_token] + if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) + @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) + else + cookies[:admin_remember_token] =nil + end + end end @@ -493,7 +534,10 @@ class ApplicationController < ActionController::Base end - + def set_navbar_dropdown + @dropdown_elements = [:p_product_cats, :s_brands, :p_product_colors, :p_article_serial_nums, :p_serial_num_types, :p_product_ref_specs, :p_spec_values, :p_grades, :p_product_powers, :p_product_zones] + @dropdown_title = "Parametrage" + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9e30dd0..31e8de0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,7 +13,20 @@ module ApplicationHelper end return raw(r) end - + + def qi_js_field_price_line_form(form, model, method, options = {}) + r = "" + if options[:hidden] + r += hidden_field_tag(method, eval("form.object.#{method}"), :class => "input_#{model}_#{method} form-control",:disabled => true) + else + if options[:label] + r += label_tag(:input, options[:label], class: options[:label_class]) + end + r += text_field_tag(method, (options[:value] ? options[:value] : eval("form.object.#{method}")), :class => "input_#{model}_#{method} form-control",:disabled => true) + end + return raw(r) + end + def edit_watcher(element_type, element_id, key='' ) raw ('
') diff --git a/app/helpers/document_line_helper.rb b/app/helpers/document_line_helper.rb index 6dbbc93..0e54205 100644 --- a/app/helpers/document_line_helper.rb +++ b/app/helpers/document_line_helper.rb @@ -28,13 +28,17 @@ module DocumentLineHelper fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render("admin/"+association.to_s + "/essentials_form", :form => builder) end + elsif options[:slug] + fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| + render("admin/"+association.to_s + "/form_#{options[:slug]}", :form => builder) + end else fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render("admin/"+association.to_s + "/form", :form => builder) end end - link_to name,"#", :onclick => "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");return false;", :class => (options[:class]) + link_to name,"#", :onclick => "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");return false;", :class => (options[:class]), tabindex: options[:tabindex], style: options[:style] end end diff --git a/app/helpers/translation_helper.rb b/app/helpers/translation_helper.rb index 9021c6e..a608c96 100755 --- a/app/helpers/translation_helper.rb +++ b/app/helpers/translation_helper.rb @@ -32,7 +32,7 @@ module TranslationHelper content = capture(&block) if block_given? r = "" - if current_admin.id == 1 + if current_admin and current_admin.id == 1 r += "" r += ic(:"stethoscope") if show_icon diff --git a/app/models/line_stock.rb b/app/models/line_stock.rb index 06e170d..ab34132 100644 --- a/app/models/line_stock.rb +++ b/app/models/line_stock.rb @@ -99,7 +99,7 @@ class LineStock < ApplicationRecord end def ca_price_u_kg_ht - if self.qte_kg_per_unit != 0.0 + if self.qte_kg_per_unit.to_f != 0.0 (self.price_u_ht.to_f / self.qte_kg_per_unit).round(2) else 0.0 @@ -116,7 +116,7 @@ class LineStock < ApplicationRecord end def ca_qte_kg - self.qte * self.qte_kg_per_unit + self.qte.to_f * self.qte_kg_per_unit.to_f end diff --git a/app/models/p_article.rb b/app/models/p_article.rb new file mode 100644 index 0000000..187741f --- /dev/null +++ b/app/models/p_article.rb @@ -0,0 +1,38 @@ +class PArticle < ApplicationRecord + belongs_to :p_grade + belongs_to :p_product_ref + has_one :p_product, through: :p_product_ref + has_one :p_product_color, through: :p_product_ref + + has_many :p_article_serial_nums, dependent: :destroy + has_many :p_serial_num_values, through: :p_article_serial_nums + accepts_nested_attributes_for :p_article_serial_nums + + validates_presence_of :p_product_ref + # has_many :p_product_ref_specs, through: :p_product_ref + # accepts_nested_attributes_for :p_product_ref_specs + + if PGrade::ACTIVATED + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref => {:name => "Désignation", :reorder => true}, + :p_grade => {:name => "Grade", :reorder => true}, + :color => {:name => "Couleur"}, + :p_article_serial_nums => {:name => "N° identifiants"}, + :actions => {:name => "Actions", :reorder => false}, + } + else + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref => {:name => "Désignation", :reorder => true}, + :color => {:name => "Couleur"}, + :p_article_serial_nums => {:name => "N° identifiants"}, + :actions => {:name => "Actions", :reorder => false}, + } + end + def member_label + "#{p_product_ref.cc_name}" + end +end diff --git a/app/models/p_article_serial_num.rb b/app/models/p_article_serial_num.rb new file mode 100644 index 0000000..b17ef22 --- /dev/null +++ b/app/models/p_article_serial_num.rb @@ -0,0 +1,19 @@ +class PArticleSerialNum < ApplicationRecord + belongs_to :p_article + belongs_to :p_serial_num_type + belongs_to :p_serial_num_value, inverse_of: :p_article_serial_nums + has_one :p_product_ref, through: :p_article + # accepts_nested_attributes_for :p_serial_num_value + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :p_article => {:name => "Article", :reorder => true}, + :p_article_id => {:name => "Article ID", :reorder => true}, + :p_serial_num_type => {:name => "Type", :reorder => true}, + :value => {:name => "N°", :reorder => true}, + + :actions => {:name => "Actions", :reorder => true} + + } + +end diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 3fd7005..e1ee85d 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -192,6 +192,15 @@ class PCustomer < ApplicationRecord end + def tva_rate + if tva = TvaRate.where(:accounting_zone_id => self.accounting_zone_id).first + return tva + else + return nil + end + end + + def update_caches diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index 70d1426..9ab4cf7 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -40,6 +40,7 @@ class PCustomerSheet < ApplicationRecord :tot_amount_ht => {:name => "Total HT", :reorder => true, :sort_name => "cc_tot_amount_ht", :sort_name => "p_customer_sheets.cc_tot_amount_ht"}, :tot_amount_ttc => {:name => "Total TTC", :reorder => true, :sort_name => "cc_tot_amount_ttc", :sort_name => "p_customer_sheets.cc_tot_amount_ttc"}, :state => {:name => "Statut", :reorder => false, :as => :state}, + :check_box => {:name => "Export excel #{''}", :reorder => false}, :actions => {:name => "Actions", :reorder => false}, } @@ -256,7 +257,7 @@ class PCustomerSheet < ApplicationRecord after_create do - #self.state = "brouillon" if self.state != "Panier web" + self.state = "brouillon" if self.state != "Panier web" self.save end diff --git a/app/models/p_grade.rb b/app/models/p_grade.rb new file mode 100644 index 0000000..648e10e --- /dev/null +++ b/app/models/p_grade.rb @@ -0,0 +1,11 @@ +class PGrade < ApplicationRecord + has_many :p_articles + + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :grade => {:name => "Grade", :reorder => true}, + :actions => {:name => "Actions", :reorder => false}, + } + + ACTIVATED = false +end diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 1d77cd4..893a83c 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -5,8 +5,6 @@ class PProduct < ApplicationRecord has_many :p_product_refs, :dependent => :destroy accepts_nested_attributes_for :p_product_refs, allow_destroy: true - - has_many :p_product_ingredients, :dependent => :destroy accepts_nested_attributes_for :p_product_ingredients, allow_destroy: true @@ -17,6 +15,14 @@ class PProduct < ApplicationRecord has_many :p_product_nutris, :dependent => :destroy accepts_nested_attributes_for :p_product_nutris, allow_destroy: true + has_many :p_articles, through: :p_product_refs + + # has_many :p_product_ref_specs, through: :p_product_refs + # accepts_nested_attributes_for :p_product_ref_specs + # # has_many :p_spec_types, through: :p_product_ref_specs + # has_many :p_spec_values, through: :p_product_ref_specs + # accepts_nested_attributes_for :p_spec_types, allow_destroy: true + # accepts_nested_attributes_for :p_spec_values, allow_destroy: true has_many :p_product_images diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index ae959f6..9a7fccf 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -10,8 +10,15 @@ class PProductRef < ApplicationRecord belongs_to :p_product_color + has_many :p_articles + has_many :p_article_serial_nums, through: :p_articles + accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true + + has_many :p_product_ref_specs + accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true + #validates :ct_price_ht, :presence => true - + validate :ean, :is_integer has_many :p_customer_product_prices, :dependent => :destroy accepts_nested_attributes_for :p_customer_product_prices, allow_destroy: true @@ -36,11 +43,14 @@ class PProductRef < ApplicationRecord :description => {:name => "Description"}, :ct_sub_name => {:name => "Nom référence"}, :ct_price_ht => {:name => "Prix de vente", :as => :currency}, - - + :ean => {:name => "EAN"}, + :ca_deee => {:name => "DEEE", :as => :currency}, + :ca_sorecop => {:name => "Sorecop", :as => :currency}, + :sorecop_comment => {:name => "Type de Sorecop"}, :actions => {:name => "Actions", :reorder => false} } + acts_as_caching :fields => [:sorecop, :deee] def not_imported? if !self.p_product or !self.p_product.imported @@ -64,7 +74,9 @@ class PProductRef < ApplicationRecord def ca_name - self.p_product.name if self.p_product + if self.p_product + self.p_product.name + " - " + self.ct_sub_name + end end def ca_code @@ -141,4 +153,26 @@ class PProductRef < ApplicationRecord "#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.cat_name}" end + def ca_sorecop + if self.cc_sorecop + return self.cc_sorecop + else + "TODO Calcul sorecop" + end + end + + def ca_deee + if self.cc_deee + return self.cc_deee + else + "TODO Calcul DEEE" + end + end + + def is_integer + if ean.present? && ean.match(/\A[+-]?\d+\z/).nil? + errors.add(:ean, "ne doit être composé que de chiffres") + end + end + end diff --git a/app/models/p_product_ref_spec.rb b/app/models/p_product_ref_spec.rb new file mode 100644 index 0000000..a036951 --- /dev/null +++ b/app/models/p_product_ref_spec.rb @@ -0,0 +1,18 @@ +class PProductRefSpec < ApplicationRecord + belongs_to :p_product_ref + belongs_to :p_spec_type + belongs_to :p_spec_value + + accepts_nested_attributes_for :p_spec_type, :p_spec_value + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :p_product_ref => {:name => "Référence produit", :reorder => true}, + :p_product_ref_id => {:name => "ID Ref produit", :reorder => true}, + :p_spec_type => {:name => "Type", :reorder => true}, + :p_spec_value => {:name => "Valeur", :reorder => true}, + + :actions => {:name => "Actions", :reorder => true} + + } +end diff --git a/app/models/p_serial_num_type.rb b/app/models/p_serial_num_type.rb new file mode 100644 index 0000000..596d817 --- /dev/null +++ b/app/models/p_serial_num_type.rb @@ -0,0 +1,9 @@ +class PSerialNumType < ApplicationRecord + has_many :p_article_serial_nums + + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :name => {:name => "Type", :reorder => true}, + :actions => {:name => "Actions", :reorder => false}, + } +end diff --git a/app/models/p_serial_num_value.rb b/app/models/p_serial_num_value.rb new file mode 100644 index 0000000..c8a476f --- /dev/null +++ b/app/models/p_serial_num_value.rb @@ -0,0 +1,4 @@ +class PSerialNumValue < ApplicationRecord + has_many :p_article_serial_nums, inverse_of: :p_serial_num_value + has_many :p_articles, through: :p_article_serial_nums +end diff --git a/app/models/p_spec_type.rb b/app/models/p_spec_type.rb new file mode 100644 index 0000000..42875d3 --- /dev/null +++ b/app/models/p_spec_type.rb @@ -0,0 +1,10 @@ +class PSpecType < ApplicationRecord + has_many :p_product_ref_specs + TYPES = ["Ram", "Stockage"] + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :name => {:name => "Type", :reorder => true}, + :actions => {:name => "Actions", :reorder => true} + } +end diff --git a/app/models/p_spec_value.rb b/app/models/p_spec_value.rb new file mode 100644 index 0000000..8471de5 --- /dev/null +++ b/app/models/p_spec_value.rb @@ -0,0 +1,18 @@ +class PSpecValue < ApplicationRecord + has_many :p_product_ref_specs + + UNITS = ["Go", "Mo"] + + def member_label + "#{value} #{unit}" + end + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :value => {:name => "Valeur", :reorder => true}, + :unit => {:name => "Unité", :reorder => true}, + :actions => {:name => "Actions", :reorder => true} + } + + +end diff --git a/app/models/price_document.rb b/app/models/price_document.rb index ec4b0f8..24fcc09 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -25,8 +25,10 @@ class PriceDocument < ApplicationRecord has_many :avoir_p_payment_documents, :dependent => :destroy, :foreign_key => :avoir_id, :class_name => "PPaymentDocument" accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true - PURCHASES = ["Demande prix", "Commande achat", "Facture d'achat"] + PURCHASES = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture achat", "Consultation fournisseur"] SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] + # AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"] + AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed? @@ -269,7 +271,8 @@ class PriceDocument < ApplicationRecord :end_date => {:name => "Fin de consultation", :reorder => true}, :dp_comment => {:name => "Commentaire", :reorder => true}, :acheteur_text => {:name => "Envoyé à", :reorder => true}, - + :customer_ref => {:name => "Ref cotation", :reorder => false}, + :p_commercial => {:name => "Commercial", :reorder => false}, :p_customer => {:name => "Client", :reorder => false}, @@ -291,7 +294,7 @@ class PriceDocument < ApplicationRecord :cc_cost_ht => {:name => "Coût HT", :reorder => true, :as => :currency}, :cc_marge_ht => {:name => "Marge HT", :reorder => true, :as => :currency}, :cost_ok => {:name => "Marge calculée", :reorder => true, :as => :boolean}, - + :f_token => {:name => "Liens consultation"}, diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 7a82893..32e2d5b 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -2,6 +2,15 @@ class PriceLine < ApplicationRecord belongs_to :price_line_block belongs_to :p_product belongs_to :p_product_ref + belongs_to :p_product_power + has_many :price_line_resp_selects, :foreign_key => :price_line_demand + has_many :price_line_resps, through: :price_line_resp_selects, :source => :price_line_resp + + + has_one :p_fournisseur, :through => :price_line_block + + #has_many :price_line_demands, through: :price_line_resp_selects + default_scope { order('position ASC') } validates :p_product_ref_id, :presence => true, :if => :p_product_ref_needed? @@ -17,7 +26,10 @@ class PriceLine < ApplicationRecord :ref => {:name => "Ref", :reorder => true}, :title => {:name => "Désignation", :reorder => true}, :qte => {:name => "Qté", :reorder => true}, + :qte_available => {:name => "Qté dispo.", :reorder => true}, + + :ct_u_price_ht => {:name => "Prix de vente", :reorder => true}, :ref_fournisseur => {:name => "Réf. fournisseur", :reorder => true}, :p_product_power_id => {:name => "Chargeur", :reorder => true}, :p_product_zone_id => {:name => "Zone", :reorder => true}, @@ -26,7 +38,8 @@ class PriceLine < ApplicationRecord :ram_unit => {:name => "Ram unité", :reorder => true}, :eu => {:name => "EU ?", :reorder => true}, :fullkit => {:name => "Fullkit ?", :reorder => true}, - :lang_start => {:name => "Démarrage écran langue ?", :reorder => true} + :lang_start => {:name => "Démarrage écran langue ?", :reorder => true}, + :actions => {:name => "Actions"} } @@ -39,7 +52,9 @@ class PriceLine < ApplicationRecord BON_DE_LIVRAISON_TO_RESET = %w(block_type weight_tot tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc) - FACTURE_DACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) + FACTURE_ACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) + + BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) COMMANDE_ACHAT_TO_RESET = %w(block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) @@ -209,7 +224,7 @@ class PriceLine < ApplicationRecord def ca_product_no_remise - if self.p_product_ref and self.p_customer and p_customer_product_price = self.p_product_ref.p_customer_product_prices.where(:p_customer_id => self.p_customer.id).first + if false #self.p_product_ref and self.p_customer and p_customer_product_price = self.p_product_ref.p_customer_product_prices.where(:p_customer_id => self.p_customer.id).first p_customer_product_price.no_remise @@ -533,38 +548,36 @@ class PriceLine < ApplicationRecord - - def ca_tot_amount_ht - if ct_tot_amount_ht + if self.ct_tot_amount_ht self.ct_tot_amount_ht else - (self.ca_price_u_kg_net_ht * self.weight_qte.to_f).round(2) + (self.ca_price_u_ht * self.qte.to_f).round(3) end end def ca_tot_amount_tva - (self.tot_amount_ht * (self.tva_account_value/100)).round(2) + (self.tot_amount_ht * (self.tva_account_value/100)).round(3) end def ca_tot_amount_ttc - (self.tot_amount_ht + self.tot_amount_tva).round(2) + (self.tot_amount_ht + self.tot_amount_tva).round(3) end - - - + + + def ca_tot_discount_ht - (self.ca_price_u_ht * self.qte.to_f).round(2) - self.ca_tot_amount_ht + (self.ca_price_u_ht * self.qte.to_f).round(3) - self.ca_tot_amount_ht end - - - + + + def ca_tot_discount_tva - (self.tot_discount_ht * (self.tva_account_value/100)).round(2) + (self.tot_discount_ht * (self.tva_account_value/100)).round(3) end def ca_tot_discount_ttc - (self.tot_discount_ht+self.tot_discount_tva).round(2) + (self.tot_discount_ht+self.tot_discount_tva).round(3) end @@ -597,7 +610,12 @@ class PriceLine < ApplicationRecord AVOIR_TO_RESET = %w(block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) - + def self.asap_triage(limit) + total = self.sum(:qte).to_i + asap = self.where('cc_wish_date < ?', Date.today + limit).sum(:qte).to_i + non_asap = total - asap + return [asap, non_asap] + end diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index c116b7c..942a0ea 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -23,11 +23,12 @@ class PriceLineBlock < ApplicationRecord belongs_to :p_payment_type - PURCHASE_BLOCKS = ["Facture d'achat", "Commande achat"] + PURCHASE_BLOCKS = ["Réponse fournisseur", "Consultation fournisseur", "Facture d'achat", "Commande achat", "Demande prix", "Bon de commande achat", "Bon de réception achat", "Facture achat", "Avoir achat"] + SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] - + belongs_to :p_fournisseur - + accepts_nested_attributes_for :p_fournisseur def to_no_archive if self.imported @@ -261,7 +262,9 @@ class PriceLineBlock < ApplicationRecord end def wish_date_needed? - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + false + elsif self.block_type == "Devis" false else true @@ -270,7 +273,9 @@ class PriceLineBlock < ApplicationRecord def particular_bill_needed? if !self.imported - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + false + elsif self.block_type == "Devis" false else true @@ -280,7 +285,9 @@ class PriceLineBlock < ApplicationRecord def particular_send_needed? if !self.imported - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + false + elsif self.block_type == "Devis" false else true @@ -289,7 +296,9 @@ class PriceLineBlock < ApplicationRecord end def p_fournisseur_needed? - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + if ["Demande prix", "Consultation fournisseur", "Réponse fournisseur"].include?(self.block_type) + false + elsif PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) true else false @@ -297,9 +306,11 @@ class PriceLineBlock < ApplicationRecord end def p_customer_needed? - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) false - elsif !self.imported + elsif self.block_type == "Devis" + false + else true end end @@ -315,7 +326,9 @@ class PriceLineBlock < ApplicationRecord BON_DE_LIVRAISON_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) - FACTURE_DACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) + FACTURE_ACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) + + BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) COMMANDE_ACHAT_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) @@ -337,12 +350,12 @@ class PriceLineBlock < ApplicationRecord eval("self.ac_#{qid} = nil") end - self.archive_now(:skip_personalised_archive => true) + self.archive_now() self.price_lines.each do |pl| - pl.archive_now(:skip_personalised_archive => true) + pl.archive_now() end diff --git a/app/models/price_line_resp_select.rb b/app/models/price_line_resp_select.rb new file mode 100644 index 0000000..f656ff3 --- /dev/null +++ b/app/models/price_line_resp_select.rb @@ -0,0 +1,4 @@ +class PriceLineRespSelect < ApplicationRecord + belongs_to :price_line_demand, class_name: "PriceLine" + belongs_to :price_line_resp, class_name: "PriceLine" +end diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index fdde1af..de9fbbb 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -1,3 +1,4 @@ +-checkbox = false .qi_header .right =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" @@ -10,16 +11,76 @@ =form_tag "", :method => "get", :onsubmit => "" do -params[:search] =params[:search] || {} - %table - %tr - + %tr.form-inline + %td + Date saisie commande : + Début + %td.input-group + =text_field_tag :cc_creation_date_start, params[:cc_creation_date_start],:class => "form-control datepicker", :placeholder => "Début" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) + %td.pl-4 + Fin + %td.input-group + =text_field_tag :cc_creation_date_stop, params[:cc_creation_date_stop],:class => "form-control datepicker", :placeholder => "Fin" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) %td Statut : - =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) - - - + =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select" + + %td + Marque : + =select_tag "search[s_brand]", options_for_select([["",""],["Aucune","null"]]+SBrand.pluck(:name, :id), params[:search][:s_brand]), class: "custom-select" + %td + Code client : + =text_field_tag "search[p_customer_code]", params[:search][:p_customer_code],:class => "form-control" + + %tr.form-inline + %td{width: "110px"} + + %td.right.mx-4 + -if @cc_creation_date_start and @cc_creation_date_stop + + =link_to "< Mois précédent",request.query_parameters.merge({cc_creation_date_start: ((@cc_creation_date_start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), cc_creation_date_stop: ((@cc_creation_date_stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + %td{width: "20px"} + %td.mr-auto + -if @cc_creation_date_start and @cc_creation_date_stop + =link_to "Mois suivant >",request.query_parameters.merge({cc_creation_date_start: ((@cc_creation_date_start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), cc_creation_date_stop: ((@cc_creation_date_stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + + %tr.form-inline + %td + Date ETA : + Début + %td.input-group + =text_field_tag :wish_date_start, params[:wish_date_start],:class => "form-control datepicker", :placeholder => "Début" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) + %td.pl-4 + Fin + %td.input-group + =text_field_tag :wish_date_stop, params[:wish_date_stop],:class => "form-control datepicker", :placeholder => "Fin" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) + %tr.form-inline + %td{width: "110px"} + + %td.right.mx-4 + -if @wish_date_start and @wish_date_stop + + =link_to "< Mois précédent",request.query_parameters.merge({wish_date_start: ((@wish_date_start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), wish_date_stop: ((@wish_date_stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + %td{width: "20px"} + %td.mr-auto + -if @wish_date_start and @wish_date_stop + =link_to "Mois suivant >",request.query_parameters.merge({wish_date_start: ((@wish_date_start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), wish_date_stop: ((@wish_date_stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + + + =link_to ic(:search)+" Rechercher", "#", :class => "btn btn-default btn-qi-search", :onclick => "$(this).closest('form').submit();$(this).html('...');return false;" @@ -27,7 +88,7 @@ =#render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_customer_sheets} --nbr_td = 15 +-nbr_td = 10 .qi_pannel.padding.new_table_container .table-slider @@ -39,32 +100,42 @@ =form_tag new_admin_price_document_path(), :method => "get" do =hidden_field_tag :"document_type", "Demande prix" - =hidden_field_tag :"price_line_ids[]", "" + =hidden_field_tag :"p_product_ref_ids[]", "" + .freezeTable %table.table.table-striped.table-hover.table-bordered.data_table %thead.header %tr - %th + -if checkbox + %th + %th.mask.plus-all + =link_to ic("plus-square-o"), '#' %th Produit %th Référence - %th Qté - - %th.mask + / %th Qté + %th.mask.col-detail N° Commande - %th.mask + %th.mask.col-detail Client - %th.mask + %th.mask.col-detail Statut - %th.mask Date saisie - %th.mask Date validation + %th.mask.col-detail Commentaire + %th.mask.col-detail Date saisie + %th.mask.col-detail Date validation %th.mask Date livraison (ETA) %th.mask - Qté commandée - %th.mask Commentaire + Qté nécessaire + %th.mask + Qté en stock + %th.mask + Qté souhaité + %span.info + =ic("info-circle") + %span.info-text-bottom BPA - Qté en stock %th.mask BPA %th.mask AV BPA %th.mask PAS BPA @@ -79,17 +150,27 @@ -if p_product_id != plr.p_product_id -p_product_id = plr.p_product_id %tr.prdct_tr - -nbr_td.times.each do + -nbr_td.times.each do %td - - - + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail -ppr_lines = @price_lines.where(:p_product_ref_id => plr.p_product_ref.id) %tr.ref_tr - %td + - bpa_qte = ppr_lines.where(:cc_state => "BPA").sum(:qte).to_i + - qte_available = LineStock.where(p_product_ref_id: plr.p_product_ref.id).sum(:qte_available).to_i + + -if checkbox + %td + + %td.plus + =link_to ic("plus-square-o"), "#" %td =link_to plr.p_product_ref.p_product.name, [:admin, plr.p_product_ref] %td @@ -97,79 +178,105 @@ =plr.p_product_ref.ct_sub_name =plr.p_product_ref.p_product_color.name if plr.p_product_ref.p_product_color - %td - =ppr_lines.sum(:qte) - + %td.col-detail + + + %td.mask.col-detail + / %td.mask + %td.mask.col-detail + %td.mask.col-detail + %td.mask.col-detail + %td.mask.col-detail + %td.mask + %td.mask + ∑ + =ppr_lines.sum(:qte).to_i + %br + %span.asap + =ic(:fire) + =ppr_lines.asap_triage(20).first + %br + %span.non-asap + =ic(:hourglass) + =ppr_lines.asap_triage(20).last + %td.mask + = qte_available + %td.mask + - default_qte = [bpa_qte - qte_available, 0].max + =check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id, (true if default_qte > 0 ) + + =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: default_qte, min: 0 + + %td.mask + = bpa_qte + %td.mask + =ppr_lines.where(:cc_state => "AV BPA").sum(:qte).to_i + %td.mask + =ppr_lines.where(:cc_state => "PAS BPA").sum(:qte).to_i - %td.mask - %td.mask - %td.mask - %td.mask - %td.mask - %td.mask - %td.mask - %td.mask - - - %td.mask - =ppr_lines.where(:cc_state => "BPA").sum(:qte) - %td.mask - =ppr_lines.where(:cc_state => "AV BPA").sum(:qte) - %td.mask - =ppr_lines.where(:cc_state => "PAS BPA").sum(:qte) - - -ppr_lines.each do |price_line| - %tr - %td - =check_box_tag :"price_line_ids[]", price_line.id - %td - %td - %td - %td - =link_to [:admin, price_line.price_line_block.price_lineable] do - =price_line.price_line_block.price_lineable.id - =price_line.price_line_block.price_lineable.past_id - - - - %td - =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] - - %td - =state_helper price_line.price_line_block.price_lineable.state - - %td - = l price_line.cc_creation_date, :format => :short_date - - %td - = l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date - - - %td - = l price_line.cc_wish_date, :format => "semaine %V (%Y)" - - %td - =price_line.qte - - %td - =price_line.comment - - %td - =price_line.qte if price_line.cc_state == "BPA" - - %td - =price_line.qte if price_line.cc_state == "AV BPA" - - %td - =price_line.qte if price_line.cc_state == "PAS BPA" - + %tbody.detail + -ppr_lines.each do |price_line| + %tr + - if checkbox + %td + =check_box_tag :"price_line_ids[]", price_line.id + / %td + %td + %td + %td + %td.col-detail + =link_to [:admin, price_line.price_line_block.price_lineable] do + =price_line.price_line_block.price_lineable.id + =price_line.price_line_block.price_lineable.past_id + + + + %td.col-detail + =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] + + %td + =state_helper price_line.price_line_block.price_lineable.state + + %td + =price_line.comment + %td + = l price_line.cc_creation_date, :format => :short_date + + %td + = l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date + + %td + = l price_line.cc_wish_date, :format => "semaine %V (%Y)" + + %td + =price_line.qte.to_i + %td + + %td + + + %td + =price_line.qte.to_i if price_line.cc_state == "BPA" + + %td + =price_line.qte.to_i if price_line.cc_state == "AV BPA" + + %td + =price_line.qte.to_i if price_line.cc_state == "PAS BPA" + -p_product_id = plr.p_product_id - - %tr - -nbr_td.times.each do - %td - - =submit_tag "Créer une demande de prix", :class => "btn btn-primary" + + %tr + -nbr_td.times.each do + %td + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + + =submit_tag "Créer une demande de prix", :class => "btn btn-primary" @@ -187,10 +294,77 @@ border-bottom:3px solid red; } } + + .asap { + color: red; + } + + .non-asap { + color: darkblue; + } + + .small-input { + max-width: 100px; + } + +:javascript + // TOOGLE ORDERS DETAILS - set to hidden + $('.detail').hide() + $('.col-detail').hide() + let state = 0 + // TOGGLE ORDER LINE DETAILS + $('.plus').click(function(event){ + if( event.currentTarget.className == "plus") { + $(event.currentTarget).removeClass('plus').addClass('minus') + state += 1 + $('.col-detail').show() + $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); + }else{ + $(event.currentTarget).removeClass('minus').addClass('plus') + state -= 1 + $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); + } + $(event.currentTarget).find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + if(state == 0){ + $('.col-detail').hide() + }else{ + $('.col-detail').show() + } + }); + // TOOGLE ALL ORDERS DETAILS + $('.plus-all').click(function(event){ + if( event.currentTarget.className == "mask plus-all") { + state += $('.plus').length + $(event.currentTarget).removeClass('plus-all').addClass('minus-all') + $('tbody.detail').show(); + $('.plus').find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + $('.plus').removeClass('plus').addClass('minus') + $(event.currentTarget).find('i').removeClass('fa fa-plus-square-o').addClass('fa fa-minus-square-o') + }else{ + state -= $('.minus').length + $(event.currentTarget).removeClass('minus-all').addClass('plus-all') + $('.minus').find('i').removeClass('fa fa-minus-square-o').addClass('fa fa-plus-square-o') + $('.minus').removeClass('minus').addClass('plus') + + $('tbody.detail').hide(); + $(event.currentTarget).find('i').removeClass('fa fa-minus-square-o').addClass('fa fa-plus-square-o') + } + if(state == 0){ + $('.col-detail').hide() + }else{ + $('.col-detail').show() + } + }); + // CHECK QTE IF QTE CHANGE + $('.small-input').change(function(){ + let checkbox = $(this).closest('td').find("input[type=checkbox]") + if (this.value > 0) { + checkbox.prop("checked", true) + } else { + checkbox.prop("checked", false) + } + }) + - - - - \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/_form.html.haml b/app/views/admin/p_article_serial_nums/_form.html.haml new file mode 100644 index 0000000..545dbdf --- /dev/null +++ b/app/views/admin/p_article_serial_nums/_form.html.haml @@ -0,0 +1,19 @@ +- if params[:controller] == "admin/p_article_serial_nums" + =semantic_form_for [:admin, @p_article_serial_num], :remote => true do |f| + + .content + =f.inputs do + = f.input :p_article, as: :select, collection: PArticle.all ,:label => f.object.label_for(:p_article_id), member_label: :member_label + = f.input :p_serial_num_type_id, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id) + + = f.input :value + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + .p_article_serial_nums_form.field + =form.inputs do + = form.input :p_serial_num_type_id, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id) + = form.input :value + diff --git a/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml new file mode 100644 index 0000000..08acd41 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml @@ -0,0 +1,38 @@ +%tr#p_article_serial_num_row{:id => p_article_serial_num.id} + -tr = {} + + -tr[:p_article_id] = capture do + %td + = p_article_serial_num.p_article.id + + -tr[:p_article] = capture do + %td + = p_article_serial_num.p_article.p_product.name + \- + = p_article_serial_num.p_article.p_product_ref.ct_sub_name + \- + = p_article_serial_num.p_article.p_product_ref.p_product_color.name + + + -tr[:p_serial_num_type] = capture do + %td + = p_article_serial_num.p_serial_num_type.name + + -tr[:value] = capture do + %td + = p_article_serial_num.value + + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_article_serial_num], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_article_serial_num_path(p_article_serial_num), :remote => true + = link_to i(:eye), admin_p_article_serial_num_path(p_article_serial_num), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_article_serial_num} + + + + diff --git a/app/views/admin/p_article_serial_nums/create.js.erb b/app/views/admin/p_article_serial_nums/create.js.erb new file mode 100644 index 0000000..0f45d7b --- /dev/null +++ b/app/views/admin/p_article_serial_nums/create.js.erb @@ -0,0 +1,2 @@ +$('#p_article_serial_nums_rows').prepend("<%= escape_javascript(render(@p_article_serial_num))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/destroy.js.erb b/app/views/admin/p_article_serial_nums/destroy.js.erb new file mode 100644 index 0000000..bfed426 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/destroy.js.erb @@ -0,0 +1 @@ +$('#p_article_serial_num_row_<%= @p_article_serial_num.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/edit.js.erb b/app/views/admin/p_article_serial_nums/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/index.html.haml b/app/views/admin/p_article_serial_nums/index.html.haml new file mode 100644 index 0000000..0c3ea96 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/index.html.haml @@ -0,0 +1,30 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_article_serial_num_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PArticleSerialNum.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =hidden_field_tag :column, params[:column] + =hidden_field_tag :direction, params[:direction] + + %table + %tr + %td Type : + %td=select_tag "search[p_serial_num_type_name]", options_for_select([["",""],["Aucune","null"]]+PSerialNumType.pluck(:name, :id), params[:search][:p_serial_num_type_name]), class: "custom-select" + + %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" + + %td=text_field_tag "search[value]", params[:search][:value],:class => "form-control", :placeholder => "N° de serie" + + + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_article_serial_nums} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_article_serial_nums} + + + diff --git a/app/views/admin/p_article_serial_nums/new.js.erb b/app/views/admin/p_article_serial_nums/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/show.html.haml b/app/views/admin/p_article_serial_nums/show.html.haml new file mode 100644 index 0000000..b32815c --- /dev/null +++ b/app/views/admin/p_article_serial_nums/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_article_serial_num \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/update.js.erb b/app/views/admin/p_article_serial_nums/update.js.erb new file mode 100644 index 0000000..2a1b65c --- /dev/null +++ b/app/views/admin/p_article_serial_nums/update.js.erb @@ -0,0 +1,2 @@ +$('#p_article_serial_num_row_<%= @p_article_serial_num.id %>').replaceWith("<%= escape_javascript(render(@p_article_serial_num))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml new file mode 100644 index 0000000..ae711c0 --- /dev/null +++ b/app/views/admin/p_articles/_form.html.haml @@ -0,0 +1,20 @@ +=semantic_form_for [:admin, @p_article], :remote => true do |f| + + .content + =f.inputs do + = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct, :label => f.object.label_for(:p_product_ref) + -if PGrade::ACTIVATED + = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade" + %h4 Numero de série : + .p_article_serial_nums_form + = f.semantic_fields_for :p_article_serial_nums do |form| + =render :partial => "admin/p_article_serial_nums/form", :locals => {:form => form} + %p= link_to_add_fields "Ajouter un numéro de série", f, :p_article_serial_nums, {:class => "btn btn-primary"} + + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml new file mode 100644 index 0000000..32497fc --- /dev/null +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -0,0 +1,44 @@ +%tr#p_article_row{:id => p_article.id} + -tr = {} + + -tr[:p_product_ref_code] = capture do + %td + = p_article.p_product_ref.code + + -tr[:p_grade] = capture do + %td + -if p_article.p_grade + = p_article.p_grade.grade + + -tr[:color] = capture do + %td + = p_article.p_product_ref.p_product_color.color + + -tr[:p_product_ref] = capture do + %td + = p_article.p_product_ref.p_product.name + \- + = p_article.p_product_ref.ct_sub_name + \- + = p_article.p_product_ref.p_product_color.name + + -tr[:p_article_serial_nums] = capture do + %td + - p_article.p_article_serial_nums.each do |sn| + = sn.p_serial_num_type.name + " : " + sn.value + %br + + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_article], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_article_path(p_article), :remote => true + = link_to i(:eye), admin_p_article_path(p_article), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_article} + + + + diff --git a/app/views/admin/p_articles/create.js.erb b/app/views/admin/p_articles/create.js.erb new file mode 100644 index 0000000..4638f5f --- /dev/null +++ b/app/views/admin/p_articles/create.js.erb @@ -0,0 +1,2 @@ +$('#p_articles_rows').prepend("<%= escape_javascript(render(@p_article))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_articles/destroy.js.erb b/app/views/admin/p_articles/destroy.js.erb new file mode 100644 index 0000000..267d137 --- /dev/null +++ b/app/views/admin/p_articles/destroy.js.erb @@ -0,0 +1 @@ +$('#p_article_row_<%= @p_article.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_articles/edit.js.erb b/app/views/admin/p_articles/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_articles/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml new file mode 100644 index 0000000..0064c5c --- /dev/null +++ b/app/views/admin/p_articles/index.html.haml @@ -0,0 +1,35 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_article_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PArticle.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =hidden_field_tag :column, params[:column] + =hidden_field_tag :direction, params[:direction] + + %table + %tr + %td=text_field_tag "search[p_product_ref_cc_code]", params[:search][:p_product_ref_cc_code],:class => "form-control", :placeholder => "Code" + + %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" + + %td=text_field_tag "search[p_article_serial_num]", params[:search][:p_article_serial_num],:class => "form-control", :placeholder => "N° de serie" + + %td.pl-2 Grade : + %td=select_tag "search[p_grade_id]", options_for_select([["",""],["Aucune","null"]]+PGrade.pluck(:grade, :id), params[:search][:p_grade_id]), class: "custom-select" + + %td.pl-2 Couleur : + %td + =select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]),class: "custom-select" + + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_articles} + + + diff --git a/app/views/admin/p_articles/new.js.erb b/app/views/admin/p_articles/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_articles/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_articles/show.html.haml b/app/views/admin/p_articles/show.html.haml new file mode 100644 index 0000000..63cfc6a --- /dev/null +++ b/app/views/admin/p_articles/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_article \ No newline at end of file diff --git a/app/views/admin/p_articles/update.js.erb b/app/views/admin/p_articles/update.js.erb new file mode 100644 index 0000000..54d637a --- /dev/null +++ b/app/views/admin/p_articles/update.js.erb @@ -0,0 +1,2 @@ +$('#p_article_row_<%= @p_article.id %>').replaceWith("<%= escape_javascript(render(@p_article))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index c8c82b9..2c1194a 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -1,24 +1,28 @@ =semantic_form_for [:admin, @p_customer_sheet], :html => {:class => "qi_price_form"}, :remote => false do |form| - + =form.semantic_fields_for :price_line_block do |f| + =render :partial => "admin/price_line_blocks/form", :locals => {:f => f} + .content .qi_row - .qi_pannel.qi_plain.padding - -if @p_customer_sheet and @p_customer_sheet.state != "commande" - =#form.input :demande_type, :collection => ["Brouillon", "Demande de bon de commande","Demande de devis"], :as => :select, :include_blank => false, :label => "Type de demande :" - - =form.input :state, :collection => ["AV BPA", "PAS BPA","BPA", "Traitée"], :as => :select, :include_blank => false, :label => "Statut :" - - =form.input :past_id, :label => "N° système actuel" - - .price_line_block_form - =form.semantic_fields_for :price_line_block do |f| - =render :partial => "admin/price_line_blocks/form", :locals => {:f => f} + .qi_pannel.qi_plain.padding.row + .col-2 + -if @p_customer_sheet and @p_customer_sheet.state != "commande" + =#form.input :demande_type, :collection => ["Brouillon", "Demande de bon de commande","Demande de devis"], :as => :select, :include_blank => false, :label => "Type de demande :" + + =form.input :state, :collection => ["AV BPA", "PAS BPA","BPA", "Traitée"], :as => :select, :include_blank => false, :label => "Statut :" + + =form.input :past_id, :label => "N° système actuel" + =yield :discount + .col-2 + =yield :shipping_date + .col-8 + =yield :particular - - - .right.actions - =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" - =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" + =yield :price_lines + .large_actions + .actions + =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" + =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" .clear diff --git a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml index 5a8f2b5..7d589a3 100644 --- a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml +++ b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml @@ -43,9 +43,11 @@ -tr[:tot_amount_ttc] = capture do %td.numeraire =number_to_currency p_customer_sheet.cc_tot_amount_ttc - - - + + -tr[:check_box] = capture do + %td + =check_box_tag "p_customer_sheet_ids[]", p_customer_sheet.id, false, data: { client: p_customer_sheet.p_customer.id }, id: "p_customer_sheet_id_checkbox_#{p_customer_sheet.id}" + -tr[:actions] = capture do %td.actions -if p_customer_sheet.state == "brouillon" and p_customer_sheet.demande_type.to_s == "Brouillon" diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index 8657d2a..f61d281 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" - %h1 Ventes %span @@ -179,5 +178,77 @@ ="-" =link_to ic(:times)+" Supprimer ce filtre", params.permit!.merge({ :active_kpi => nil, :p_customer_sheet_ids => nil}) +%div + =form_tag export_xls_admin_p_customer_sheets_path(format: :csv), id: 'export-form', :method => "get" do + .table + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customer_sheets} + + %button.btn.btn-primary.ml-4{onclick: "checkMultipleClient()"} + =ic("file-excel-o") + Export xls +.modal.fade#multi-client-export{"tab-index" => "-1", "role" => "dialog", "aria-labelledby" => "Raprochement Fournisseur", "aria-hidden" => "true"} + .modal-dialog{role: "dialog"} + .modal-content + .modal-header + %h5.modal-title + Export Excel + %button.close{"data-dismiss" => "modal", "aria-label" => "Close"} + %span{"aria-hidden" => "true"} + × + .modal-body + Attention ! + %br + %br + Selection de plusieurs clients détéctée + %br + Vous avez selectionné des commandes liées à différents clients. + %br + Etes-vous sûr ? + + .modal-footer + %button.btn.btn-light{"data-dismiss" => "modal"} + Annuler l'export + %button.btn.btn-primary{"data-dismiss" => "modal", onclick: "submitExport()"} + =ic("file-excel-o") + Confirmer + +:javascript + $("#check-all").parent().on("click", function(event) { + console.log(event.currentTarget) + event.currentTarget.classList.toggle("checked") + if(event.currentTarget.classList.contains("checked")){ + $('.table input[type=checkbox]').prop("checked", true) + }else{ + $('.table input[type=checkbox]').prop("checked", false) + } + }) + + "#dataTable tbody tr" + function submitExport() { + $('#export-form').submit() + } + + function checkDiff(arr) { + return arr.every(e => e == arr[0]); + } + + const checkMultipleClient = () => { + let arr = [] + $('.table input[type=checkbox]').each(function( i ) { + if ( this.checked === true) + arr.push($(this).data('client')) + }) + if (checkDiff(arr) === false) { + $('#multi-client-export').modal('show') + } else { + submitExport() + } + } + + +:scss + th > i { + cursor: pointer; + } + -=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customer_sheets} diff --git a/app/views/admin/p_grades/_form.html.haml b/app/views/admin/p_grades/_form.html.haml new file mode 100644 index 0000000..00d2fa0 --- /dev/null +++ b/app/views/admin/p_grades/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_grade], :remote => true do |f| + + .content + =f.inputs do + = f.input :grade, :label => f.object.label_for(:grade) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_grades/_p_grade.html.haml b/app/views/admin/p_grades/_p_grade.html.haml new file mode 100644 index 0000000..9608e54 --- /dev/null +++ b/app/views/admin/p_grades/_p_grade.html.haml @@ -0,0 +1,16 @@ +%tr#p_grade_row{:id => p_grade.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_grade], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_grade_path(p_grade), :remote => true + = link_to i(:eye), admin_p_grade_path(p_grade), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_grade} + + + + \ No newline at end of file diff --git a/app/views/admin/p_grades/create.js.erb b/app/views/admin/p_grades/create.js.erb new file mode 100644 index 0000000..d562c04 --- /dev/null +++ b/app/views/admin/p_grades/create.js.erb @@ -0,0 +1,2 @@ +$('#p_grades_rows').prepend("<%= escape_javascript(render(@p_grade))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_grades/destroy.js.erb b/app/views/admin/p_grades/destroy.js.erb new file mode 100644 index 0000000..7e6a917 --- /dev/null +++ b/app/views/admin/p_grades/destroy.js.erb @@ -0,0 +1 @@ +$('#p_grade_row_<%= @p_grade.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_grades/edit.js.erb b/app/views/admin/p_grades/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_grades/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_grades/index.html.haml b/app/views/admin/p_grades/index.html.haml new file mode 100644 index 0000000..4dbb173 --- /dev/null +++ b/app/views/admin/p_grades/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_grade_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PGrade.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_grades} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_grades} + + + diff --git a/app/views/admin/p_grades/new.js.erb b/app/views/admin/p_grades/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_grades/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_grades/show.html.haml b/app/views/admin/p_grades/show.html.haml new file mode 100644 index 0000000..e63e6fc --- /dev/null +++ b/app/views/admin/p_grades/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_grade \ No newline at end of file diff --git a/app/views/admin/p_grades/update.js.erb b/app/views/admin/p_grades/update.js.erb new file mode 100644 index 0000000..0371e07 --- /dev/null +++ b/app/views/admin/p_grades/update.js.erb @@ -0,0 +1,2 @@ +$('#p_grade_row_<%= @p_grade.id %>').replaceWith("<%= escape_javascript(render(@p_grade))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml new file mode 100644 index 0000000..ffde9d3 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -0,0 +1,36 @@ +- if params[:controller] == "admin/p_product_ref_specs" + =semantic_form_for [:admin, @p_product_ref_spec], :remote => true do |f| + .content + =f.inputs do + = f.input :p_product_ref, as: :select, collection: PProductRef.pluck(:cc_name, :id) ,:label => f.object.label_for(:p_product_ref) + = f.semantic_fields_for :p_spec_type do | form | + =render :partial => "admin/p_spec_types/form", :locals => {:f => form} + = f.semantic_fields_for :p_spec_value do | form | + =render :partial => "admin/p_spec_values/form", :locals => {:f => form} + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + .p_product_ref_spec_form.field + %table + %tr + %td + %h4 spec : + + %td + -#form.object.p_spec_type = PSpecType.new if !form.object.p_spec_type + -#form.object.p_spec_value = PSpecValue.new if !form.object.p_spec_value + + = form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType.all, :include_blank => false + %td + = form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => false, :member_label => :member_label + + + =#form.inputs do + =# form.semantic_fields_for :p_spec_type do | f | + =#render :partial => "admin/p_spec_types/form", :locals => {:f => f} + =# form.semantic_fields_for :p_spec_value do | f | + =# render :partial => "admin/p_spec_values/form", :locals => {:f => f} + %tr + %td + = link_to_remove_fields ic(:"trash-o"), form diff --git a/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml new file mode 100644 index 0000000..b696059 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml @@ -0,0 +1,31 @@ +%tr#p_product_ref_spec_row{:id => p_product_ref_spec.id} + -tr = {} + -tr[:p_product_ref] = capture do + %td + = p_product_ref_spec.p_product_ref.cc_name + + -tr[:p_product_ref_id] = capture do + %td + = p_product_ref_spec.p_product_ref.id + + -tr[:p_spec_type] = capture do + %td + = p_product_ref_spec.p_spec_type.name + -tr[:p_spec_value] = capture do + %td + = p_product_ref_spec.p_spec_value.value + = p_product_ref_spec.p_spec_value.unit + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_product_ref_spec], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_product_ref_spec_path(p_product_ref_spec), :remote => true + = link_to i(:eye), admin_p_product_ref_spec_path(p_product_ref_spec), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product_ref_spec} + + + + diff --git a/app/views/admin/p_product_ref_specs/create.js.erb b/app/views/admin/p_product_ref_specs/create.js.erb new file mode 100644 index 0000000..d7a17bc --- /dev/null +++ b/app/views/admin/p_product_ref_specs/create.js.erb @@ -0,0 +1,2 @@ +$('#p_product_ref_specs_rows').prepend("<%= escape_javascript(render(@p_product_ref_spec))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/destroy.js.erb b/app/views/admin/p_product_ref_specs/destroy.js.erb new file mode 100644 index 0000000..5e87c5d --- /dev/null +++ b/app/views/admin/p_product_ref_specs/destroy.js.erb @@ -0,0 +1 @@ +$('#p_product_ref_spec_row_<%= @p_product_ref_spec.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/edit.js.erb b/app/views/admin/p_product_ref_specs/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/index.html.haml b/app/views/admin/p_product_ref_specs/index.html.haml new file mode 100644 index 0000000..f486839 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_product_ref_spec_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PProductRefSpec.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_product_ref_specs} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_ref_specs} + + + diff --git a/app/views/admin/p_product_ref_specs/new.js.erb b/app/views/admin/p_product_ref_specs/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/show.html.haml b/app/views/admin/p_product_ref_specs/show.html.haml new file mode 100644 index 0000000..e56e759 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_product_ref_spec \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/update.js.erb b/app/views/admin/p_product_ref_specs/update.js.erb new file mode 100644 index 0000000..ccaba69 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/update.js.erb @@ -0,0 +1,2 @@ +$('#p_product_ref_spec_row_<%= @p_product_ref_spec.id %>').replaceWith("<%= escape_javascript(render(@p_product_ref_spec))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index bc9ca3b..4b0b755 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -1,13 +1,12 @@ +=#debug form.object.errors.messages =# form.input :ref, :label => "Ref :" .qi_row.field .qi_pannel.qi_plain.padding %table.form-table %tr - %td - =# form.input :enabled, :label => "Actif ?" - %td - =# form.input :assembled, :label => "Assemblé ?", :input_html => {:onchange => 'if ($(this).is(":checked")) {$(this).closest(".field").find(".p_product_assembleds_part").show();}else{$(this).closest(".field").find(".p_product_assembleds_part").hide();}'} + =# form.input :enabled, :label => "Actif ?" + =# form.input :assembled, :label => "Assemblé ?", :input_html => {:onchange => 'if ($(this).is(":checked")) {$(this).closest(".field").find(".p_product_assembleds_part").show();}else{$(this).closest(".field").find(".p_product_assembleds_part").hide();}'} %td = form.input :ref, :label => "Réf int. :" @@ -21,8 +20,25 @@ %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true - - =# form.input :s_brand_id, :label => "Marque :", :collection => SBrand.all, :as => :select, :include_blank => true + %td + =form.input :ct_sorecop, :label => "Sorecop personalisée :" + %td + =form.input :sorecop_comment, :label => "Type de Sorecop :" + %td + =form.input :ct_deee, :label => "DEEE personalisée :" + %td + =form.input :ean + + + + + %tr + %td{:colspan => 4} + .p_product_ref_specs_form + = form.semantic_fields_for :p_product_ref_specs do |f| + =render :partial => "admin/p_product_ref_specs/form", :locals => {:form => f} + %p= link_to_add_fields "Ajouter une spec", form, :p_product_ref_specs + %tr @@ -42,4 +58,4 @@ %p= link_to_add_fields "Ajouter une référence fournisseur", form, :fournisseur_product_refs - \ No newline at end of file + diff --git a/app/views/admin/p_product_refs/_p_product_ref.html.haml b/app/views/admin/p_product_refs/_p_product_ref.html.haml index 33e3f52..ca09295 100644 --- a/app/views/admin/p_product_refs/_p_product_ref.html.haml +++ b/app/views/admin/p_product_refs/_p_product_ref.html.haml @@ -31,8 +31,14 @@ %td.actions =# link_to i(:"trash-o"), [:admin, p_product_ref], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce produit ? ' } , :remote => true if !PriceLine.where(:p_product_ref_id => p_product_ref).first =#debug PriceLine.where(:p_product_ref_id => p_product_ref.id).first - = link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false - = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false + + -if @manager + = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false, :target => "_blank" + = link_to i(:"check"), "#",:onclick => "send_manager_product('"+p_product_ref.id.to_s+"', '"+escape_javascript(p_product_ref.member_label.to_s)+"');return false;" + + -else + = link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false + = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product_ref} diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index 9e77e44..3a3aeaf 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -1,17 +1,19 @@ -.qi_header - .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false - %h1 - Achats - %span - Produits +-if !@manager + .qi_header + .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false + %h1 + Achats + %span + Références + .qi_search_row - =form_tag "", :method => "get", :onsubmit => "" do + =form_tag admin_p_product_refs_path, :method => "get", :onsubmit => "", :remote => true do =hidden_field_tag :column, params[:column] =hidden_field_tag :direction, params[:direction] - + =hidden_field_tag :manager, params[:manager] %table %tr %td @@ -42,7 +44,7 @@ -=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs} +#p_product_refs_index_wrapper=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs, :remote => true} @@ -52,4 +54,7 @@ }); - \ No newline at end of file + +:coffeescript + $(".qi_search_row form").on "submit", -> + $("#p_product_refs_index_wrapper").html('recherche en cours ...') \ No newline at end of file diff --git a/app/views/admin/p_product_refs/index.js.erb b/app/views/admin/p_product_refs/index.js.erb new file mode 100644 index 0000000..ab3b84a --- /dev/null +++ b/app/views/admin/p_product_refs/index.js.erb @@ -0,0 +1,9 @@ + +var p_product_refs_url = "<%= escape_javascript(request.url) %>"; + + +$('#p_product_refs_index_wrapper').html("<%= escape_javascript(render(:partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs, :remote => true}))%>"); + + + +$(".btn-qi-search").html(' Rechercher'); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/_form.html.haml b/app/views/admin/p_serial_num_types/_form.html.haml new file mode 100644 index 0000000..99f609b --- /dev/null +++ b/app/views/admin/p_serial_num_types/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_serial_num_type], :remote => true do |f| + + .content + =f.inputs do + = f.input :name, :label => f.object.label_for(:name) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + diff --git a/app/views/admin/p_serial_num_types/_p_serial_num_type.html.haml b/app/views/admin/p_serial_num_types/_p_serial_num_type.html.haml new file mode 100644 index 0000000..db6e57b --- /dev/null +++ b/app/views/admin/p_serial_num_types/_p_serial_num_type.html.haml @@ -0,0 +1,16 @@ +%tr#p_serial_num_type_row{:id => p_serial_num_type.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_serial_num_type], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_serial_num_type_path(p_serial_num_type), :remote => true + = link_to i(:eye), admin_p_serial_num_type_path(p_serial_num_type), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_serial_num_type} + + + + \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/create.js.erb b/app/views/admin/p_serial_num_types/create.js.erb new file mode 100644 index 0000000..1bcfb90 --- /dev/null +++ b/app/views/admin/p_serial_num_types/create.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_types_rows').prepend("<%= escape_javascript(render(@p_serial_num_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/destroy.js.erb b/app/views/admin/p_serial_num_types/destroy.js.erb new file mode 100644 index 0000000..25bf828 --- /dev/null +++ b/app/views/admin/p_serial_num_types/destroy.js.erb @@ -0,0 +1 @@ +$('#p_serial_num_type_row_<%= @p_serial_num_type.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/edit.js.erb b/app/views/admin/p_serial_num_types/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_types/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/index.html.haml b/app/views/admin/p_serial_num_types/index.html.haml new file mode 100644 index 0000000..80034b4 --- /dev/null +++ b/app/views/admin/p_serial_num_types/index.html.haml @@ -0,0 +1,24 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSerialNumType.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =hidden_field_tag :column, params[:column] + =hidden_field_tag :direction, params[:direction] + + %table + %tr + %td Type : + %td=select_tag "search[name]", options_for_select([["",""],["Aucune","null"]]+PSerialNumType.pluck(:name, :id), params[:search][:name]), class: "custom-select" + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_serial_num_types} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_serial_num_types} + + + diff --git a/app/views/admin/p_serial_num_types/new.js.erb b/app/views/admin/p_serial_num_types/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_types/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/show.html.haml b/app/views/admin/p_serial_num_types/show.html.haml new file mode 100644 index 0000000..6ab5cdf --- /dev/null +++ b/app/views/admin/p_serial_num_types/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_serial_num_type \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/update.js.erb b/app/views/admin/p_serial_num_types/update.js.erb new file mode 100644 index 0000000..beac1d8 --- /dev/null +++ b/app/views/admin/p_serial_num_types/update.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_type_row_<%= @p_serial_num_type.id %>').replaceWith("<%= escape_javascript(render(@p_serial_num_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/_form.html.haml b/app/views/admin/p_serial_num_values/_form.html.haml new file mode 100644 index 0000000..1872e5e --- /dev/null +++ b/app/views/admin/p_serial_num_values/_form.html.haml @@ -0,0 +1,12 @@ +/ =semantic_form_for [:admin, @p_serial_num_value], :remote => true do |f| + + +=f.inputs do + = f.input :value, :label => "Numéro" + + + + + + / .actions=f.submit "sauvegarder", :class => "btn btn-primary" + diff --git a/app/views/admin/p_serial_num_values/_p_serial_num_value.html.haml b/app/views/admin/p_serial_num_values/_p_serial_num_value.html.haml new file mode 100644 index 0000000..52d6eee --- /dev/null +++ b/app/views/admin/p_serial_num_values/_p_serial_num_value.html.haml @@ -0,0 +1,16 @@ +%tr#p_serial_num_value_row{:id => p_serial_num_value.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_serial_num_value], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_serial_num_value_path(p_serial_num_value), :remote => true + = link_to i(:eye), admin_p_serial_num_value_path(p_serial_num_value), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_serial_num_value} + + + + \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/create.js.erb b/app/views/admin/p_serial_num_values/create.js.erb new file mode 100644 index 0000000..f53ff23 --- /dev/null +++ b/app/views/admin/p_serial_num_values/create.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_values_rows').prepend("<%= escape_javascript(render(@p_serial_num_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/destroy.js.erb b/app/views/admin/p_serial_num_values/destroy.js.erb new file mode 100644 index 0000000..1622e2d --- /dev/null +++ b/app/views/admin/p_serial_num_values/destroy.js.erb @@ -0,0 +1 @@ +$('#p_serial_num_value_row_<%= @p_serial_num_value.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/edit.js.erb b/app/views/admin/p_serial_num_values/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_values/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/index.html.haml b/app/views/admin/p_serial_num_values/index.html.haml new file mode 100644 index 0000000..7e600fc --- /dev/null +++ b/app/views/admin/p_serial_num_values/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSerialNumValue.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_serial_num_values} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_serial_num_values} + + + diff --git a/app/views/admin/p_serial_num_values/new.js.erb b/app/views/admin/p_serial_num_values/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_values/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/show.html.haml b/app/views/admin/p_serial_num_values/show.html.haml new file mode 100644 index 0000000..e9b982d --- /dev/null +++ b/app/views/admin/p_serial_num_values/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_serial_num_value \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/update.js.erb b/app/views/admin/p_serial_num_values/update.js.erb new file mode 100644 index 0000000..d272f5f --- /dev/null +++ b/app/views/admin/p_serial_num_values/update.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_value_row_<%= @p_serial_num_value.id %>').replaceWith("<%= escape_javascript(render(@p_serial_num_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/_form.html.haml b/app/views/admin/p_spec_types/_form.html.haml new file mode 100644 index 0000000..2b94b28 --- /dev/null +++ b/app/views/admin/p_spec_types/_form.html.haml @@ -0,0 +1,13 @@ +- if params[:controller] == "admin/p_spec_types" + =semantic_form_for [:admin, @p_spec_type], :remote => true do |f| + + .content + =f.inputs do + %td + = f.input :name, :label => "Type" + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + =f.inputs do + = f.input :name, :label => "Type", as: :select, collection: PSpecType.pluck(:name).uniq diff --git a/app/views/admin/p_spec_types/_p_spec_type.html.haml b/app/views/admin/p_spec_types/_p_spec_type.html.haml new file mode 100644 index 0000000..fd475e3 --- /dev/null +++ b/app/views/admin/p_spec_types/_p_spec_type.html.haml @@ -0,0 +1,16 @@ +%tr#p_spec_type_row{:id => p_spec_type.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_spec_type], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_spec_type_path(p_spec_type), :remote => true + = link_to i(:eye), admin_p_spec_type_path(p_spec_type), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_type} + + + + \ No newline at end of file diff --git a/app/views/admin/p_spec_types/create.js.erb b/app/views/admin/p_spec_types/create.js.erb new file mode 100644 index 0000000..e9f7774 --- /dev/null +++ b/app/views/admin/p_spec_types/create.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_types_rows').prepend("<%= escape_javascript(render(@p_spec_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/destroy.js.erb b/app/views/admin/p_spec_types/destroy.js.erb new file mode 100644 index 0000000..e97e73c --- /dev/null +++ b/app/views/admin/p_spec_types/destroy.js.erb @@ -0,0 +1 @@ +$('#p_spec_type_row_<%= @p_spec_type.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/edit.js.erb b/app/views/admin/p_spec_types/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_types/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/index.html.haml b/app/views/admin/p_spec_types/index.html.haml new file mode 100644 index 0000000..46d02ec --- /dev/null +++ b/app/views/admin/p_spec_types/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSpecType.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_types} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_types} + + + diff --git a/app/views/admin/p_spec_types/new.js.erb b/app/views/admin/p_spec_types/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_types/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/show.html.haml b/app/views/admin/p_spec_types/show.html.haml new file mode 100644 index 0000000..6005a84 --- /dev/null +++ b/app/views/admin/p_spec_types/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_spec_type \ No newline at end of file diff --git a/app/views/admin/p_spec_types/update.js.erb b/app/views/admin/p_spec_types/update.js.erb new file mode 100644 index 0000000..2f952cc --- /dev/null +++ b/app/views/admin/p_spec_types/update.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_type_row_<%= @p_spec_type.id %>').replaceWith("<%= escape_javascript(render(@p_spec_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/_form.html.haml b/app/views/admin/p_spec_values/_form.html.haml new file mode 100644 index 0000000..509bf70 --- /dev/null +++ b/app/views/admin/p_spec_values/_form.html.haml @@ -0,0 +1,18 @@ +- if params[:controller] == "admin/p_spec_values" + =semantic_form_for [:admin, @p_spec_value], :remote => true do |f| + + .content + =f.inputs do + %td + = f.input :value, :label => "Valeur" + %td + = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + =f.inputs do + %td + = f.input :value, :label => "Valeur" + %td + = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS diff --git a/app/views/admin/p_spec_values/_p_spec_value.html.haml b/app/views/admin/p_spec_values/_p_spec_value.html.haml new file mode 100644 index 0000000..64de749 --- /dev/null +++ b/app/views/admin/p_spec_values/_p_spec_value.html.haml @@ -0,0 +1,16 @@ +%tr#p_spec_value_row{:id => p_spec_value.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_spec_value], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_spec_value_path(p_spec_value), :remote => true + = link_to i(:eye), admin_p_spec_value_path(p_spec_value), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_value} + + + + \ No newline at end of file diff --git a/app/views/admin/p_spec_values/create.js.erb b/app/views/admin/p_spec_values/create.js.erb new file mode 100644 index 0000000..8aef8dd --- /dev/null +++ b/app/views/admin/p_spec_values/create.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_values_rows').prepend("<%= escape_javascript(render(@p_spec_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/destroy.js.erb b/app/views/admin/p_spec_values/destroy.js.erb new file mode 100644 index 0000000..643c933 --- /dev/null +++ b/app/views/admin/p_spec_values/destroy.js.erb @@ -0,0 +1 @@ +$('#p_spec_value_row_<%= @p_spec_value.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/edit.js.erb b/app/views/admin/p_spec_values/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_values/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/index.html.haml b/app/views/admin/p_spec_values/index.html.haml new file mode 100644 index 0000000..8f34bd1 --- /dev/null +++ b/app/views/admin/p_spec_values/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSpecValue.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_values} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_values} + + + diff --git a/app/views/admin/p_spec_values/new.js.erb b/app/views/admin/p_spec_values/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_values/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/show.html.haml b/app/views/admin/p_spec_values/show.html.haml new file mode 100644 index 0000000..6414fbc --- /dev/null +++ b/app/views/admin/p_spec_values/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_spec_value \ No newline at end of file diff --git a/app/views/admin/p_spec_values/update.js.erb b/app/views/admin/p_spec_values/update.js.erb new file mode 100644 index 0000000..b7e6986 --- /dev/null +++ b/app/views/admin/p_spec_values/update.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_value_row_<%= @p_spec_value.id %>').replaceWith("<%= escape_javascript(render(@p_spec_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/price_documents/_form.html.haml b/app/views/admin/price_documents/_form.html.haml index fa414d2..60a7314 100644 --- a/app/views/admin/price_documents/_form.html.haml +++ b/app/views/admin/price_documents/_form.html.haml @@ -20,18 +20,27 @@ =hidden_field_tag :public_edit, params[:public_edit] - - = @price_document.price_line_block.block_type + %h3 + = @price_document.price_line_block.block_type -if @price_document.label == "Demande prix" - =f.input :avancement, :label => "Avancement (%) :" - =f.input :list_designaton, :label => "Désignation de la liste :" - =f.input :end_date, :label => "Fin de consultation :", :as => :date - =f.input :dp_comment, :label => "Commentaire demande de prix :" - =f.input :acheteur_text, :label => "Envoyé à :" - + .row + .col-4 + .row + .col + =f.input :end_date, :label => "Fin de consultation :", :as => :date + .col + =f.input :avancement, :label => "Avancement (%) :", as: :select, collection: PriceDocument::AVANCEMENT, selected: PriceDocument::AVANCEMENT.first + =f.input :list_designaton, as: :string, :label => "Désignation de la liste :" + .col + =f.input :acheteur_text, :label => "Envoyé à :", input_html: {rows: 5} + .col + =f.input :dp_comment, :label => "Commentaire demande de prix :", input_html: {rows: 5} + + + -if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 7 = f.input :date, :label => "Date du document :", :as => :date .price_line_block_form @@ -50,4 +59,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/price_documents/_form_p_fournisseur.html.haml b/app/views/admin/price_documents/_form_p_fournisseur.html.haml new file mode 100644 index 0000000..a860e68 --- /dev/null +++ b/app/views/admin/price_documents/_form_p_fournisseur.html.haml @@ -0,0 +1,16 @@ +=semantic_form_for [:admin, @price_document], url: match_p_fournisseur_save_admin_price_document_path, :html => {:class => "qi_price_form"}, :remote => true do |f| + =diag do + =f.object.errors.messages + + .content + %h1.mb-2 Rapprochemnet du fournisseur + .form-row + .col-md-6 + = f.input :public_fournisseur_name, label: "Nom indiqué par le fournisseur :", :input_html => { :disabled => true, class: "mx-3" } + .form-row + .col-md-6 + =f.semantic_fields_for :price_line_block do |form| + =form.input :p_fournisseur, as: :select, collection: PFournisseur.pluck(:name, :id), label: "Correspondance base fournisseurs :", :input_html => { class: "mx-3"} + + .large_actions + .actions=f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 77a3096..a18ec45 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -1,4 +1,9 @@ %tr#price_document_row{:id => price_document.id} + - if price_document.doc_ref_id.present? + - parent_doc = PriceDocument.find(price_document.doc_ref_id) + -else + - parent_doc = nil + -tr = {} -tr[:p_payment_type] = capture do @@ -17,7 +22,13 @@ -tr[:p_fournisseur] = capture do %td - = price_document.p_fournisseur.name if price_document.p_fournisseur + - if price_document.price_document_type.label == "Réponse fournisseur" + -if price_document.p_fournisseur.present? + = price_document.p_fournisseur.name + - else + =link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(price_document), remote: true + -else + = price_document.p_fournisseur.name if price_document.p_fournisseur -tr[:com_counter] = capture do %td @@ -50,9 +61,52 @@ -if price_document.label == "Avoir" =number_to_currency price_document.cc_to_paid_ttc + -tr[:f_token] = capture do + %td + = consult_admin_price_document_url(:id => price_document.f_token, :lang => nil) + + -tr[:avancement] = capture do + %td + - if price_document.avancement + = price_document.avancement.to_s + " %" + - elsif parent_doc and parent_doc.avancement + = parent_doc.avancement.to_s + " %" + + -tr[:list_designaton] = capture do + %td + -if price_document.list_designaton + = price_document.list_designaton + -elsif parent_doc + =parent_doc.list_designaton + + -tr[:end_date] = capture do + %td + -if price_document.end_date + =price_document.end_date + -elsif parent_doc and parent_doc.end_date + =parent_doc.end_date - + + -tr[:dp_comment] = capture do + %td + -if price_document.dp_comment + = price_document.dp_comment + -elsif parent_doc + =parent_doc.dp_comment + + -tr[:acheteur_text] = capture do + %td + -if price_document.acheteur_text + = price_document.acheteur_text + -elsif parent_doc + =parent_doc.acheteur_text + + -tr[:customer_ref] = capture do + %td + -if price_document.price_line_block.present? + = price_document.price_line_block.customer_ref + -tr[:stock_ok] = capture do %td -if !price_document.imported @@ -90,6 +144,8 @@ -tr[:actions] = capture do %td.actions + -if price_document.price_document_type.label == "Demande prix" + =link_to i("bar-chart"), analyse_reponses_admin_price_document_path(price_document) -if !price_document.imported -if current_admin.has_permission?("payments") -if !price_document.d_number? @@ -130,7 +186,6 @@ =# link_to i(:eye), admin_price_document_path(price_document), :remote => true - = link_to i(:eye), admin_price_document_path(price_document.id), :remote => false -if PriceLineBlock::PURCHASE_BLOCKS.include?(price_document.block_type) =# link_to i(:eye), admin_price_document_path(price_document.id), :remote => false @@ -145,6 +200,9 @@ = link_to i(:pencil), edit_admin_price_document_path(price_document) = link_to i(:eye), admin_price_document_path(price_document.id), :remote => false, :target => "_blank" + -if price_document.cc_label == "Bon de réception achat" + %br + =link_to "Générer la facture", facture_achat_admin_price_document_path(price_document) =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_document} - \ No newline at end of file + diff --git a/app/views/admin/price_documents/_relicats.html.haml b/app/views/admin/price_documents/_relicats.html.haml new file mode 100644 index 0000000..035846f --- /dev/null +++ b/app/views/admin/price_documents/_relicats.html.haml @@ -0,0 +1,62 @@ + +#bills + + .qi_tab_header + %h3 Bons de réception associés + .right + + + -params[:search][:per_page] = params[:search][:per_page] || 50 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@price_documents = PriceDocument.where(:bon_de_commande_achat_id => bca.id, :price_document_type_id => [5]).order("date DESC, created_at DESC") + + -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") + -@all_price_documents = @price_documents + -@price_documents = @price_documents.page(page).per(per_page) + + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "projet-factures"} + + +%h3 Etat des réceptions par articles + +- bca_price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bca.id) + +- bra_price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => @all_price_documents.ids) + +%table.table.table-striped.table-hover.table-bordered.data_table + %thead + %tr + %th + Code produit + %th + Produit + %th Quantité commandée + + %th Quantité réceptionnée + + %th Différence + %tbody + - PriceLine.where(:price_line_block_id => (bca_price_line_blocks.ids + bra_price_line_blocks.ids)).map {|pl| pl.p_product_ref_id}.uniq.each do |p_product_ref_id| + -if p_product_ref = PProductRef.where(:id => p_product_ref_id).first + %tr + %td + =link_to [:admin, p_product_ref] do + =p_product_ref.ref + %td + =link_to [:admin, p_product_ref] do + =p_product_ref.cc_name + + %td + =a = PriceLine.where(:p_product_ref_id => p_product_ref_id, :price_line_block_id => bca_price_line_blocks).sum(:qte) + + + %td + =b = PriceLine.where(:p_product_ref_id => p_product_ref_id, :price_line_block_id => bra_price_line_blocks).sum(:qte) + + %td + = a -b + + + diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml new file mode 100644 index 0000000..8627aca --- /dev/null +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -0,0 +1,321 @@ +.qi_header + %h1 + Achats + %span + Analyse des réponces à la demande de prix n° + = link_to @price_document.d_number, admin_price_document_path(@price_document) + \- + = @price_document.list_designaton + +-unmatched_fournisseur = 0 +=semantic_form_for [:admin, @price_document],url: analyse_reponses_save_admin_price_document_path, method: :post, :html => {:class => "qi_price_form"}, :remote => false do |form| + =form.semantic_fields_for :price_line_block do |f| + - price_line_block = f.object + .qi_pannel.padding.new_table_container + .table-slider + .inner + + .table-area{:style => "overflow:auto;"} + .table-area-inner + .freezeTable + %table.table.table-striped.table-hover.table-bordered.data_table + %thead.header + %tr + -nb_resp = @price_document_responses.count + %th{colspan: 12} + Consultation + %th{colspan: nb_resp} + Fournisseurs + .btn.btn-light.mx-4#reset-radio + reset + .legend.d-flex + légende : + .inlie-block.d-flex.flex-wrap.justify-content-end + .mx-2.red + = ic("diamond") + " Spot detecté !" + .mx-2.green + = ic("money") + " Meilleur prix" + .mx-2.red + = ic(:times) + " Alerte marge basse" + .mx-2.green + = ic(:check) + " Marge ok" + .mx-2.orange + = ic(:warning) + " Alerte Qté" + .mx-2.info + = ic('info-circle') + " Commentaire fournisseur" + %tr + %th + Qté à + %br + satisfaire + %th + Qté consultée + %th + Produit + %th + Référence + %th + Couleur + %th + Type + %br + chargeur + %th + Target hors + %br + Sorecop + %th + Px d'achat + %br + référence + %th + Marge + %br + théorique + %br + référence + %br + par zone + %th + Fours. + %br + de référence + %th + Date + %br + px référence + %th.limit + Spec + + -@price_document_responses.each do |resp| + %th + -if resp.p_fournisseur + =resp.p_fournisseur.name + -else + -unmatched_fournisseur += 1 + nom renseigné par le fournisseur : + %br + ="(#{resp.public_fournisseur_name})" + %br + =link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(resp), remote: true + + + %tbody + -# price_lines = f.object.price_lines + -price_lines_child_index = {} + -consult_price_lines = @price_document.price_line_block.price_lines + =f.semantic_fields_for :price_lines do |form| + - price_line = form.object + -#price_lines = @price_document.price_line_block.price_lines + -#price_lines.each do |price_line| + %tr + %td + =# ATTENTION ! On a plus accès direct aux commandes qui on engendré cette demande de prix. donc plus accès aux délais différent entre les différentes commades pour une ref donée + / ∑ + / =price_line.qte.to_i + / %br + - if price_line.cc_wish_date.present? && price_line.cc_wish_date < Date.today + 20.days + %span.red + =ic(:fire) + =price_line.qte.to_i + - else + %span.darkblue + =ic(:hourglass) + =price_line.qte.to_i + %td.ref_tr + Qté en comm + %td + = price_line.p_product_ref.p_product.name + %td + =link_to [:admin, price_line.p_product_ref] do + = price_line.p_product_ref.ct_sub_name + = price_line.p_product_ref.p_product_color.name + + %td + = price_line.p_product_ref.p_product_color.color if price_line.p_product_ref and price_line.p_product_ref.p_product_color + %td + = price_line.p_product_power.name if price_line.p_product_power + %td + / Target hors Sorecop + %td + / Px d'achat de référence + %td + / Marge théorique de référence par zone + %td + / Fournisseurs de référence + %td + / Date du px de référence + %td.limit + / spec + + =#form.input :price_line_resp_ids, collection: PriceLine.where(:price_line_ref_id => form.object.id).all, as: :check_boxes , :member_label => :id + + -#NICO : j'ai commenté l'input qu'on a fait ensemble, par contre, pour toute la suite, j'ai en fait fait un copié collé du rendu de cet inpu ou j'ai remis les champs dynamics en correspondance. + + + -#NICO : j'ai créé un hash plus haut, vide, qui va me permettre de faire correspondre à chaque ID de price_line leur index dans le nested form (qui est différent, une itération, de l'ID de l'élement... Là c'est la magie de rails.) + - price_lines_child_index[form.object.id.to_s] = form.options[:child_index] + -best_price = PriceLine.where(price_line_ref_id: price_line.id).where("ct_u_price_ht > 0").order(:ct_u_price_ht).ids + -#Nico : je commence, pour chaque price line, par faire une checkbox vide. J'aurais pu faire un checkbox tag mais par facilité j'ai copé l'HTML dans HTML2HAML et je suis partid du résultat. Les checkboxes sont ensuite dans ta boucle + %input{:autocomplete => "off", :id => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }]_price_line_resp_ids_none", :name => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }][price_line_resp_ids][]", :type => "hidden", :value => ""}/ + + =#{}"price doc id : #{@price_document_responses.ids}" + + - @price_document_responses.each do |resp| + -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first + -cell = [] + + - if line.qte_available.to_i > 0 + - if line.id == best_price[0] + -cell << "#{ic(:money)} Meilleur prix" + - if line.qte_available >= price_line.qte.to_i + - cell << "Qté dispo : #{line.qte_available.to_i}" + - else + - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" + - cell << "PA: #{line.ct_u_price_ht} €" + - # mp = calcul de la marge prévisionelle TODO + - line.id.odd? ? mp = 0.17 : mp = 0.11 + - if false + -if mp > 0.15 + - cell << "#{ic(:check)} MP: #{mp * 100} %" + -else + - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" + -else + - cell << "pas dispo" + -if line.comment.present? + - display_comment = "" + - if line.comment.length > 10 + - display_comment = "#{line.comment[0..10]} (..)" + - else + - display_comment = line.comment + - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" + + %td.p-0{class: ("best-price" if line.id == best_price[0])} + =# "reponse price_line ID : #{line.id}" + =# "price line origine : #{line.price_line_ref_id}" #NICO : simple contrôle, je récupère facilement par là l'ID de la price Line concernée. + + -#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id + -if line.price_line_ref_id.to_s != "" + %input.seletable_price{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ + %label.p-2.m-auto{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} + =sanitize(cell.join('