From 4a3a65e4bfe34f3aad83296fa56c05ebaf090d12 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Tue, 18 Dec 2018 22:55:29 +0100 Subject: [PATCH] suite --- .../admin/p_price_cats_controller.rb | 76 +++++++++++++ .../public/p_customer_auths_controller.rb | 2 +- .../public/p_products_controller.rb | 1 + .../admin/admin_spaces/_ventes.html.haml | 2 + app/views/admin/p_price_cats/_form.html.haml | 9 ++ .../admin/p_price_cats/_p_price_cat.html.haml | 11 ++ app/views/admin/p_price_cats/create.js.erb | 2 + app/views/admin/p_price_cats/destroy.js.erb | 1 + app/views/admin/p_price_cats/edit.html.haml | 4 + app/views/admin/p_price_cats/edit.js.erb | 1 + app/views/admin/p_price_cats/index.html.haml | 21 ++++ app/views/admin/p_price_cats/new.html.haml | 4 + app/views/admin/p_price_cats/new.js.erb | 1 + app/views/admin/p_price_cats/show.html.haml | 1 + app/views/admin/p_price_cats/update.js.erb | 2 + .../p_sheet_lines/_p_sheet_lines.html.haml | 102 ++++++++++++------ config/routes.rb | 3 +- 17 files changed, 206 insertions(+), 37 deletions(-) create mode 100644 app/controllers/admin/p_price_cats_controller.rb create mode 100755 app/views/admin/p_price_cats/_form.html.haml create mode 100644 app/views/admin/p_price_cats/_p_price_cat.html.haml create mode 100644 app/views/admin/p_price_cats/create.js.erb create mode 100644 app/views/admin/p_price_cats/destroy.js.erb create mode 100644 app/views/admin/p_price_cats/edit.html.haml create mode 100644 app/views/admin/p_price_cats/edit.js.erb create mode 100644 app/views/admin/p_price_cats/index.html.haml create mode 100644 app/views/admin/p_price_cats/new.html.haml create mode 100644 app/views/admin/p_price_cats/new.js.erb create mode 100644 app/views/admin/p_price_cats/show.html.haml create mode 100644 app/views/admin/p_price_cats/update.js.erb diff --git a/app/controllers/admin/p_price_cats_controller.rb b/app/controllers/admin/p_price_cats_controller.rb new file mode 100644 index 0000000..079d197 --- /dev/null +++ b/app/controllers/admin/p_price_cats_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PPriceCatsController < ApplicationController + layout "admin" + before_filter :auth_admin + + before_filter :admin_space + + def admin_space + @admin_space = "ventes" + end + + def index + @p_price_cats = PPriceCat.order(:name).all + + + end + + def show + @p_price_cat = PPriceCat.find(params[:id]) + + end + + def new + + + @p_price_cat = PPriceCat.new + + + end + + + + def edit + + + @p_price_cat = PPriceCat.find(params[:id]) + end + + def create + @p_price_cat = PPriceCat.new(params.require(:p_price_cat).permit!) + + + if @p_price_cat.save + @p_price_cats = PPriceCat.order(:name).all + + else + render action: "new" + + end + + end + + + def update + @p_price_cat = PPriceCat.find(params[:id]) + + + if @p_price_cat.update_attributes(params.require(:p_price_cat).permit!) + + @p_price_cats = PPriceCat.order(:name).all + else + render action: "edit" + + end + + end + + + def destroy + @p_price_cat = PPriceCat.find(params[:id]) + @p_price_cat.destroy + + + end +end diff --git a/app/controllers/public/p_customer_auths_controller.rb b/app/controllers/public/p_customer_auths_controller.rb index bb72773..bc89b6b 100755 --- a/app/controllers/public/p_customer_auths_controller.rb +++ b/app/controllers/public/p_customer_auths_controller.rb @@ -37,7 +37,7 @@ class Public::PCustomerAuthsController < ApplicationController user.save(:validate => false) - redirect_to public_my_account_path + redirect_to public_p_products_path else diff --git a/app/controllers/public/p_products_controller.rb b/app/controllers/public/p_products_controller.rb index b1f5472..824fad3 100644 --- a/app/controllers/public/p_products_controller.rb +++ b/app/controllers/public/p_products_controller.rb @@ -3,6 +3,7 @@ class Public::PProductsController < ApplicationController layout "public" + before_filter :auth_p_customer before_filter :p_customer_validated def index diff --git a/app/views/admin/admin_spaces/_ventes.html.haml b/app/views/admin/admin_spaces/_ventes.html.haml index 6331ef3..bff6395 100644 --- a/app/views/admin/admin_spaces/_ventes.html.haml +++ b/app/views/admin/admin_spaces/_ventes.html.haml @@ -3,6 +3,8 @@ %li= link_to "Produits", admin_p_products_path %li= link_to "Résumé stocks", admin_p_product_stocks_path %li= link_to "Catégories produits", admin_p_product_cats_path +%li= link_to "Catégories prix", admin_p_price_cats_path + -if false %li= link_to "Matières premières", admin_p_brut_products_path diff --git a/app/views/admin/p_price_cats/_form.html.haml b/app/views/admin/p_price_cats/_form.html.haml new file mode 100755 index 0000000..48e125b --- /dev/null +++ b/app/views/admin/p_price_cats/_form.html.haml @@ -0,0 +1,9 @@ +=semantic_form_for [:admin, @p_price_cat], :remote => true do |f| + + .content + =f.inputs do + + = f.input :name, :label => "Nom :" + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_price_cats/_p_price_cat.html.haml b/app/views/admin/p_price_cats/_p_price_cat.html.haml new file mode 100644 index 0000000..0b69046 --- /dev/null +++ b/app/views/admin/p_price_cats/_p_price_cat.html.haml @@ -0,0 +1,11 @@ +%tr#p_price_cat{:id => p_price_cat.id} + %td= p_price_cat.name + + + + + %td.actions + = link_to i(:"trash-o"), [:admin, p_price_cat], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cette catégorie ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_price_cat_path(p_price_cat), :remote => true + + diff --git a/app/views/admin/p_price_cats/create.js.erb b/app/views/admin/p_price_cats/create.js.erb new file mode 100644 index 0000000..42bcf50 --- /dev/null +++ b/app/views/admin/p_price_cats/create.js.erb @@ -0,0 +1,2 @@ +$('#p_price_cats_rows').html("<%= escape_javascript(render(@p_price_cats))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_price_cats/destroy.js.erb b/app/views/admin/p_price_cats/destroy.js.erb new file mode 100644 index 0000000..2b30008 --- /dev/null +++ b/app/views/admin/p_price_cats/destroy.js.erb @@ -0,0 +1 @@ +$('#p_price_cat_<%= @p_price_cat.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_price_cats/edit.html.haml b/app/views/admin/p_price_cats/edit.html.haml new file mode 100644 index 0000000..684eb81 --- /dev/null +++ b/app/views/admin/p_price_cats/edit.html.haml @@ -0,0 +1,4 @@ +%h1 Modifier un distributeur + += render 'form' + diff --git a/app/views/admin/p_price_cats/edit.js.erb b/app/views/admin/p_price_cats/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_price_cats/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_price_cats/index.html.haml b/app/views/admin/p_price_cats/index.html.haml new file mode 100644 index 0000000..a1e6741 --- /dev/null +++ b/app/views/admin/p_price_cats/index.html.haml @@ -0,0 +1,21 @@ +.qi_header + .right= link_to 'Ajouter une catégorie de prix', new_admin_p_price_cat_path(), :class => "btn btn-primary", :remote => true + %h1 + Clients + %span + Catégories de prix + + +.qi_row + .qi_pannel.qi_plain.padding + %table.table + %tr + %th Nom + + %th + + + %tbody#p_price_cats_rows + =render @p_price_cats + + \ No newline at end of file diff --git a/app/views/admin/p_price_cats/new.html.haml b/app/views/admin/p_price_cats/new.html.haml new file mode 100644 index 0000000..3b1635e --- /dev/null +++ b/app/views/admin/p_price_cats/new.html.haml @@ -0,0 +1,4 @@ +%h1 Ajouter un distributeur + += render 'form' + diff --git a/app/views/admin/p_price_cats/new.js.erb b/app/views/admin/p_price_cats/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_price_cats/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_price_cats/show.html.haml b/app/views/admin/p_price_cats/show.html.haml new file mode 100644 index 0000000..16545ca --- /dev/null +++ b/app/views/admin/p_price_cats/show.html.haml @@ -0,0 +1 @@ +=debug @customer \ No newline at end of file diff --git a/app/views/admin/p_price_cats/update.js.erb b/app/views/admin/p_price_cats/update.js.erb new file mode 100644 index 0000000..42bcf50 --- /dev/null +++ b/app/views/admin/p_price_cats/update.js.erb @@ -0,0 +1,2 @@ +$('#p_price_cats_rows').html("<%= escape_javascript(render(@p_price_cats))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml b/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml index 0ce9fd3..01e9c3c 100644 --- a/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml +++ b/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml @@ -8,9 +8,7 @@ Etat %th Description - %th Taille - %th - Couleur + %th Qte @@ -26,7 +24,9 @@ -p_sheet_line_lines = sheet_line.p_sheet_line_lines.where("qte > 0") -nbr_lines = p_sheet_line_lines.count -ok = true if sheet_line.shiped - %tr.sheet_line_head + + + %tr %td - if sheet_line.shiped @@ -36,45 +36,59 @@ %br -if sheet_line.p_product.p_product_cat_id != 6 or sheet_line.externe and @p_customer_sheet =link_to "Indiquer comme livré", set_sheet_line_ship_admin_p_customer_sheet_path(@p_customer_sheet, :p_sheet_line_ids => [sheet_line.id]), :remote => true - %td - %strong - =sheet_line.product_name - -if false - %br - =debug sheet_line.ship_affects + + %td{:colspan => 1, :style => "text-align:right;"} + %table.size_table + %tr + %th{:style => "text-align:left !important;"} + =sheet_line.product_name - - %td - %td - - %td - %strong=sheet_line.qte - %td - %strong=number_to_currency sheet_line.price if sheet_line.price + -sheet_line.p_product.p_sizes.all.each do |psize| + %th.p_size_td=psize.name + - %td - %strong=number_to_currency sheet_line.price_tot if sheet_line.price_tot - - %td - %strong=number_to_currency sheet_line.price_tot_ttc if sheet_line.price_tot_ttc - - - -p_sheet_line_lines.each do |p_sheet_line_line| + %td{:colspan => 4} + -sheet_line.p_product.p_colors.all.each do |pc| + -qte_tot = 0.0 %tr %td - %td + %td{:colspan => 1, :style => "text-align:right;"} + %table.size_table + + + + + %tr + %td + =pc.name + + -sheet_line.p_product.p_sizes.all.each do |psize| + + %td.p_size_td + -psl = p_sheet_line_lines.joins(:p_product_stock).where(:p_product_stocks => {:p_size_id => psize.id, :p_color_id => pc.id} ).first + -if psl + =psl.qte + -qte_tot += psl.qte + + %td{} + =qte_tot.to_i %td - =p_sheet_line_line.p_size.name if p_sheet_line_line.p_size - %td - =p_sheet_line_line.p_color.name if p_sheet_line_line.p_color - %td - =p_sheet_line_line.qte - - %td + =number_to_currency sheet_line.price.to_f %td + =number_to_currency sheet_line.price.to_f * qte_tot.to_i + %td + =number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i + + + + + + + + @@ -86,7 +100,7 @@ %tr.sheet_line_head - %td{:style => "text-align:right;padding-right:10px;", :colspan =>7} + %td{:style => "text-align:right;padding-right:10px;", :colspan =>5} %strong =total[:label] %td @@ -108,4 +122,22 @@ + } + + .size_table{ + width:97%; + + text-align:center; + margin-right:3%; + td,th{ + text-align:right; + border:0; + border-right:solid 1px rgba(0,0,0,0.1) !important; + padding:0 3px; + } + .p_size_td{ + width:60px; + text-align:center; + } + } \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 5e76db1..ad883e9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -131,6 +131,7 @@ Rails.application.routes.draw do end end + resources :p_price_cats resources :p_ship_bills resources :p_stats resources :p_payment_types @@ -366,7 +367,7 @@ Rails.application.routes.draw do get "plan" => "public/home#plan" - root "public/my_account#index" + root "public/p_products#index"