diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index 3c15690..28017dd 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -141,6 +141,8 @@ class Admin::PCustomerSheetsController < ApplicationController def generate_bc @p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer_sheet.generate_bc + @p_customer_sheet.customer_validation_at = Time.now + @p_customer_sheet.save redirect_to :back diff --git a/app/controllers/public/p_orders_controller.rb b/app/controllers/public/p_orders_controller.rb index 24719c7..df3ea4a 100644 --- a/app/controllers/public/p_orders_controller.rb +++ b/app/controllers/public/p_orders_controller.rb @@ -78,11 +78,15 @@ class Public::POrdersController < ApplicationController @p_customer_sheet.particular_send.force_validation=true @p_customer_sheet.ecom_status = "commande" + @p_customer_sheet.customer_validation_at = Time.now + if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) and @p_customer_sheet.particular_bill.save and @p_customer_sheet.particular_send.save @p_customer_sheet.generate_bc @p_customer_sheet.generate_fa if @p_customer_sheet.acompte_percent? + AdminMailer.notify_order().deliver + cookies[:current_p_customer_sheet_id] = nil redirect_to thank_public_p_order_path(:id => @p_customer_sheet.id) diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index 3027de4..78a12d6 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -7,4 +7,8 @@ class AdminMailer < ActionMailer::Base def notify_comments mail :to => "n.bally@quartz.xyz", :subject => "Nouveaux commentaires à modérer sur le blog", :from => "n.bally@quartz.xyz" end + + def notify_order + mail :to => "ducoin@jrh.fr", :subject => "Nouvelle commande enregistrée par le site", :from => "n.bally@quartz.xyz" + end end \ No newline at end of file diff --git a/app/models/p_document.rb b/app/models/p_document.rb index 55a7b87..70f136f 100644 --- a/app/models/p_document.rb +++ b/app/models/p_document.rb @@ -117,6 +117,13 @@ class PDocument < ActiveRecord::Base self.fdp_force_price = self.element.fdp_force_price if self.p_document_type.label != "Avoir" self.acompte_percent = self.element.acompte_percent + self.obs_devis = self.element.obs_devis + self.obs_bdc = self.element.obs_bdc + self.obs_bdl = self.element.obs_bdl + + + + if self.element_type == "PCustomerSheet" and self.element.particular_bill self.particular_bill = self.element.particular_bill.dup self.particular_bill.owner = nil diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index 61fe388..93c9221 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -162,10 +162,11 @@ -if @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.particular =render :partial => "admin/p_customers/apercu", :locals => {:particular => @p_customer_sheet.p_customer.particular} + %br .addresses.row + .columns.span_6 - %h3 Adresse de facturation - + -if @p_customer_sheet.p_customer =form.inputs do = form.input :particular_bill_id, :collection => @p_customer_sheet.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de facturation" @@ -174,8 +175,7 @@ = form.input :particular_bill_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" .columns.span_6 - %h3 Adresse de livraison - + -if @p_customer_sheet.p_customer =form.inputs do = form.input :particular_send_id, :collection => @p_customer_sheet.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de livraison" @@ -207,6 +207,21 @@ = form.input :fdp_force_price, :label => "Frais de port (calculés automatiquement si vides) :" + %table{:style => "width:100%;"} + + %tr + %td{:style => "width:33%;"} + = form.input :obs_devis, :label => "Observation devis :" + %td{:style => "width:33%;"} + = form.input :obs_bdc, :label => "Observation bon de commande :" + %td{:style => "width:33%;"} + = form.input :obs_bdl, :label => "Observation bon de livraison :" + + + + + + -if false %p 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 b81d4a4..51ad5c1 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 @@ -2,10 +2,12 @@ %tr#p_customer_sheet{:id => p_customer_sheet.id} %td="##{p_customer_sheet.id}" %td=l p_customer_sheet.created_at, :format => :date + %td=l p_customer_sheet.customer_validation_at, :format => "%d/%m/%Y %H:%M" if p_customer_sheet.customer_validation_at + -if !@p_customer %td= p_customer_sheet.p_customer.show_name if p_customer_sheet.p_customer - %td= p_customer_sheet.sheet_lines_not_shiped.count - %td= p_customer_sheet.sheet_lines_shiped.count + =#%td= p_customer_sheet.sheet_lines_not_shiped.count + =#%td= p_customer_sheet.sheet_lines_shiped.count %td diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index d1f3ad9..74a905a 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -12,11 +12,14 @@ %tr %th ID %th Date + %th Date validation + %th Client - %th Non livrés - %th Livrés + =#%th Non livrés + =#%th Livrés %th Total HT + %th Total TTC %th Statut %th diff --git a/app/views/admin/p_customers/_etat.html.haml b/app/views/admin/p_customers/_etat.html.haml index 5caa698..6101b01 100644 --- a/app/views/admin/p_customers/_etat.html.haml +++ b/app/views/admin/p_customers/_etat.html.haml @@ -8,7 +8,7 @@ %th Réf %th Débit %th Crédit - %th Soldé ? + %th Soldé %th.action %tbody.lines diff --git a/app/views/admin/p_customers/_p_customer.html.haml b/app/views/admin/p_customers/_p_customer.html.haml index 866140e..93ee3ab 100644 --- a/app/views/admin/p_customers/_p_customer.html.haml +++ b/app/views/admin/p_customers/_p_customer.html.haml @@ -14,7 +14,28 @@ -if false %td{:style => "text-align:right;"}=number_to_currency p_customer.p_customer_sheets.sum(:a_ok_total) - + %td + -emails = [] + + + -p_contacts = p_customer.p_contacts + + -p_customer.particulars.each do |p| + -p_contacts = p_contacts + p.p_contacts + + + -p_contacts.uniq.each do |p_c| + + -emails << p_c.email + + -emails << p_customer.email + + -emails = emails.uniq + + =emails.size + + + %td.actions = link_to i(:"trash-o"), [:admin, p_customer], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet auteur ? ' } , :remote => true = link_to i(:pencil), edit_admin_p_customer_path(p_customer), :remote => true diff --git a/app/views/admin/p_customers/etat.html.haml b/app/views/admin/p_customers/etat.html.haml index dbe7490..63b629e 100644 --- a/app/views/admin/p_customers/etat.html.haml +++ b/app/views/admin/p_customers/etat.html.haml @@ -112,7 +112,7 @@ %th Réf %th Débit %th Crédit - %th{:style => "width:20px"} Soldé ? + %th{:style => "width:20px"} Soldé -if !@p_customer %th Solde -if !params[:html] diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index ba23427..c9d40b6 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -20,6 +20,7 @@ %th CP %th Ville %th Encours + %th Nbr emails %th @@ -48,7 +49,7 @@ %th CP %th Ville %th Encours - + %th Nbr emails %th diff --git a/app/views/admin/p_documents/_general.html.haml b/app/views/admin/p_documents/_general.html.haml index 64a5029..5e15304 100644 --- a/app/views/admin/p_documents/_general.html.haml +++ b/app/views/admin/p_documents/_general.html.haml @@ -112,6 +112,34 @@ =render :partial => "admin/p_sheet_lines/print_p_sheet_lines", :locals => {:sheet_lines => @p_document.p_sheet_lines } + -if @p_document.obs_devis? and @p_document.label == "Devis" + .obs + %div Observations : + =simple_format @p_document.obs_devis + + -elsif @p_document.obs_bdc? and @p_document.label == "Bon de commande" + .obs + %div Observations : + =simple_format @p_document.obs_bdc + + -elsif @p_document.obs_bdl? and @p_document.label == "Bon de livraison" + .obs + %div Observations : + =simple_format @p_document.obs_bdl + + :scss + .obs{ + //padding-top:20px; + + div{ + position:relative; + top:10px; + text-decoration:underline; + } + } + + + %table.en-tete-table{:style => "width:auto;position:relative;"} %tr %th Conditions de réglement diff --git a/app/views/admin/p_product_stocks/import_stocks.html.haml b/app/views/admin/p_product_stocks/import_stocks.html.haml index b47fd91..a5e5c9b 100644 --- a/app/views/admin/p_product_stocks/import_stocks.html.haml +++ b/app/views/admin/p_product_stocks/import_stocks.html.haml @@ -34,10 +34,10 @@ -@csv.each do |row| -ps = nil - -if row["Stock const"].to_s != "" - -if row["Ref variante"].to_s != "" and PProductStock.where(:code => row["Ref variante"]).count == 1 + -if row["Stock Disponible"].to_s != "" + -if row["Article"].to_s != "" and PProductStock.where(:code => row["Article"]).count == 1 -m = "Par réf." - -ps = PProductStock.where(:code => row["Ref variante"]).first + -ps = PProductStock.where(:code => row["Article"]).first -elsif row["ID variante"].to_s != "" and PProductStock.where(:id => row["ID variante"]).count == 1 @@ -52,9 +52,9 @@ %tr %td =check_box_tag :"ids[]", ps.id, true if ps - =hidden_field_tag "ps_#{ps.id}", row["Stock const"] if ps + =hidden_field_tag "ps_#{ps.id}", row["Stock Disponible"] if ps - %td=row["Ref variante"] + %td=row["Article"] %td=row["ID variante"] %td=m @@ -72,7 +72,7 @@ - %td=row["Stock const"] + %td=row["Stock Disponible"] -if ps %td=ps.delta_stock -else diff --git a/app/views/admin_mailer/notify_comments.html.haml b/app/views/admin_mailer/notify_comments.html.haml index 0585a5b..344d49b 100644 --- a/app/views/admin_mailer/notify_comments.html.haml +++ b/app/views/admin_mailer/notify_comments.html.haml @@ -2,11 +2,7 @@ Bonjour, %p - Il y a des nouveaux commentaires à modérer sur le blog. - -%p - Voici le lien direct pour le faire : - =link_to "https://3p.quartz.xyz/admin/comments?lang=fr", "https://3p.quartz.xyz/admin/comments?lang=fr" + Une nouvelle commande a été passée par le site, à retrouver sur l'espace d'administration. %p Bonne journée ! \ No newline at end of file diff --git a/app/views/admin_mailer/notify_order.html.haml b/app/views/admin_mailer/notify_order.html.haml new file mode 100644 index 0000000..344d49b --- /dev/null +++ b/app/views/admin_mailer/notify_order.html.haml @@ -0,0 +1,8 @@ +%p + Bonjour, + +%p + Une nouvelle commande a été passée par le site, à retrouver sur l'espace d'administration. + +%p + Bonne journée ! \ No newline at end of file diff --git a/app/views/public/p_orders/_cart_totals.html.haml b/app/views/public/p_orders/_cart_totals.html.haml index d0c49bd..4d14081 100644 --- a/app/views/public/p_orders/_cart_totals.html.haml +++ b/app/views/public/p_orders/_cart_totals.html.haml @@ -1,15 +1,18 @@ -total_with_labels = @p_customer_sheet.total_with_labels_table +=render :partial => "public/p_orders/warning", :locals => {:style => "max-width:500px;float:left;"} -%table{:style => "width:100%;"} +%table{:style => "float:right;"} -total_with_labels.each do |index, total| %tr + %td{:style => "text-align:right;"} %strong =total[:label] %td.price_td =number_to_currency total[:value] - \ No newline at end of file + +.clear \ No newline at end of file diff --git a/app/views/public/p_orders/_warning.html.haml b/app/views/public/p_orders/_warning.html.haml new file mode 100644 index 0000000..f49d96a --- /dev/null +++ b/app/views/public/p_orders/_warning.html.haml @@ -0,0 +1,23 @@ +-style = style || "" + +-tot = 0 +-@p_customer_sheet.p_sheet_lines.each do |psl| + -psl.p_sheet_line_lines.each do |psll| + -psll.qte + -stock = 0 + -stock = psll.p_product_stock.stock_th_ok if psll.p_product_stock.stock_th_ok > 0 + -surplus = (stock - psll.qte.to_i) + + -if surplus < 0 + -tot += (surplus*-1) + +-if tot > 0 + + .alert.alert-warning{:style => style} + =ic :warning +   + Attention : + =tot + unité(s) + ne sont pas en stock. Notre équipe commerciale vous contactera pour vous indiquer une date de livraison. + diff --git a/app/views/public/p_orders/cart.html.haml b/app/views/public/p_orders/cart.html.haml index a9e829a..90e6f10 100644 --- a/app/views/public/p_orders/cart.html.haml +++ b/app/views/public/p_orders/cart.html.haml @@ -57,11 +57,17 @@ =builder.hidden_field :p_product_stock_id,:label => false, :as => :string =builder.input :qte,:label => false, :as => :string, :input_html => {:class => "qte"} .stock_line{:style => "text-align:left;font-size:0.8em;color:rgba(0,0,0,0.5)"} - - %span{:style => "font-size:0.75em;"} -    - Stock : - =ps.stock_th_ok + -if ps.stock_th_ok < 0 + -show_stock = 0 + -else + -show_stock = ps.stock_th_ok + + %span{:style => ("color:red;" if show_stock <= 0).to_s} + %span{:style => "font-size:0.75em;"} +    + Stock : + =show_stock + %td.price.price_td{:data => {:price => form.object.price}} =number_to_currency form.object.price @@ -95,7 +101,7 @@ - + #cart_totals=render :partial => "cart_totals" diff --git a/app/views/public/p_orders/recap.html.haml b/app/views/public/p_orders/recap.html.haml index 9abd9fe..96d5013 100644 --- a/app/views/public/p_orders/recap.html.haml +++ b/app/views/public/p_orders/recap.html.haml @@ -209,7 +209,7 @@ } - + =render :partial => "public/p_orders/warning" =semantic_form_for [:public, @p_customer_sheet],:url => recap_save_public_p_orders_path(), :html => { :method => :post, :onchange =>""}, :remote => false do |form| =form.input :cgv, :label => raw("J'ai lu et j'accepte les conditions générales de vente") diff --git a/app/views/public/p_products/show.html.haml b/app/views/public/p_products/show.html.haml index e4a91af..9d3c10e 100644 --- a/app/views/public/p_products/show.html.haml +++ b/app/views/public/p_products/show.html.haml @@ -47,7 +47,7 @@ - -if @p_product.get_prices(current_p_customer).count > 0 and @p_product.get_prices(current_p_customer).first.price > 0.0 + -if @p_product.get_prices(current_p_customer) and @p_product.get_prices(current_p_customer).count > 0 and @p_product.get_prices(current_p_customer).first.price.to_f > 0.0 .sub_header -if current_p_customer.account_validated .right @@ -130,11 +130,16 @@ =builder.hidden_field :p_product_stock_id,:label => false, :as => :string =builder.input :qte,:label => false, :input_html => {:class => "qte"} .stock_line{:style => "text-align:left;font-size:0.8em;color:rgba(0,0,0,0.5)"} - - %span{:style => "font-size:0.75em;"} -    - Stock : - =ps.stock_th_ok + -if ps.stock_th_ok < 0 + -show_stock = 0 + -else + -show_stock = ps.stock_th_ok + + %span{:style => ("color:red;" if show_stock <= 0).to_s} + %span{:style => "font-size:0.75em;"} +    + Stock : + =show_stock %td.price.price_td{:data => {:price => form.object.price}} =number_to_currency form.object.price diff --git a/db/migrate/20191113214457_add_customer_validation_to_p_customer_sheets.rb b/db/migrate/20191113214457_add_customer_validation_to_p_customer_sheets.rb new file mode 100644 index 0000000..bcf611d --- /dev/null +++ b/db/migrate/20191113214457_add_customer_validation_to_p_customer_sheets.rb @@ -0,0 +1,5 @@ +class AddCustomerValidationToPCustomerSheets < ActiveRecord::Migration + def change + add_column :p_customer_sheets, :customer_validation_at, :datetime + end +end diff --git a/db/migrate/20191113231005_add_infos_to_p_customer_sheets.rb b/db/migrate/20191113231005_add_infos_to_p_customer_sheets.rb new file mode 100644 index 0000000..d0a2aba --- /dev/null +++ b/db/migrate/20191113231005_add_infos_to_p_customer_sheets.rb @@ -0,0 +1,12 @@ +class AddInfosToPCustomerSheets < ActiveRecord::Migration + def change + add_column :p_customer_sheets, :obs_devis, :text + add_column :p_customer_sheets, :obs_bdc, :text + add_column :p_customer_sheets, :obs_bdl, :text + + add_column :p_documents, :obs_devis, :text + add_column :p_documents, :obs_bdc, :text + add_column :p_documents, :obs_bdl, :text + + end +end diff --git a/db/schema.rb b/db/schema.rb index 06ece72..ddb0a40 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190804183718) do +ActiveRecord::Schema.define(version: 20191113231005) do create_table "admin_admin_roles", force: :cascade do |t| t.integer "admin_id", limit: 4 @@ -821,35 +821,39 @@ ActiveRecord::Schema.define(version: 20190804183718) do end create_table "p_customer_sheets", force: :cascade do |t| - t.integer "p_customer_id", limit: 4 - t.string "state", limit: 255 - t.string "comments", limit: 255 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "particular_bill_id", limit: 4 - t.integer "particular_send_id", limit: 4 + t.integer "p_customer_id", limit: 4 + t.string "state", limit: 255 + t.string "comments", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "particular_bill_id", limit: 4 + t.integer "particular_send_id", limit: 4 t.date "wish_start" t.date "wish_stop" - t.decimal "a_total_cost_ok", precision: 14, scale: 4 - t.decimal "a_ok_total", precision: 14, scale: 4 - t.boolean "stock_done", default: false - t.integer "p_commercial_id", limit: 4 - t.boolean "imported", default: false - t.string "npiece", limit: 255 - t.string "ecom_status", limit: 255 - t.integer "p_payment_type_id", limit: 4 - t.boolean "cgv", default: false - t.boolean "comptant", default: true - t.boolean "acompte", default: false - t.decimal "acompte_percent", precision: 10 - t.integer "payment_delais", limit: 4 - t.boolean "payment_fin_de_mois", default: false + t.decimal "a_total_cost_ok", precision: 14, scale: 4 + t.decimal "a_ok_total", precision: 14, scale: 4 + t.boolean "stock_done", default: false + t.integer "p_commercial_id", limit: 4 + t.boolean "imported", default: false + t.string "npiece", limit: 255 + t.string "ecom_status", limit: 255 + t.integer "p_payment_type_id", limit: 4 + t.boolean "cgv", default: false + t.boolean "comptant", default: true + t.boolean "acompte", default: false + t.decimal "acompte_percent", precision: 10 + t.integer "payment_delais", limit: 4 + t.boolean "payment_fin_de_mois", default: false t.datetime "paid_start_at" - t.boolean "paid", default: false + t.boolean "paid", default: false t.datetime "paid_at" - t.integer "p_price_cat_id", limit: 4 - t.decimal "fdp_force_price", precision: 10, scale: 2 - t.string "cust_ref", limit: 255 + t.integer "p_price_cat_id", limit: 4 + t.decimal "fdp_force_price", precision: 10, scale: 2 + t.string "cust_ref", limit: 255 + t.datetime "customer_validation_at" + t.text "obs_devis", limit: 65535 + t.text "obs_bdc", limit: 65535 + t.text "obs_bdl", limit: 65535 end add_index "p_customer_sheets", ["p_payment_type_id"], name: "index_p_customer_sheets_on_p_payment_type_id", using: :btree @@ -985,6 +989,9 @@ ActiveRecord::Schema.define(version: 20190804183718) do t.decimal "cache_fdp", precision: 13, scale: 2 t.decimal "cache_total_tva", precision: 13, scale: 2 t.decimal "cache_to_paid", precision: 13, scale: 2 + t.text "obs_devis", limit: 65535 + t.text "obs_bdc", limit: 65535 + t.text "obs_bdl", limit: 65535 end create_table "p_eps", force: :cascade do |t|