This commit is contained in:
Nicolas Bally 2018-12-17 14:34:56 +01:00
parent 331548c6a9
commit 5ceaeded7d
45 changed files with 810 additions and 284 deletions

View File

@ -35,6 +35,8 @@
#= require admin/trunk8.js #= require admin/trunk8.js
#=require sheet_prices
portlet_to_move = false portlet_to_move = false
content_type_to_move =false content_type_to_move =false
window.disable_portlet_select = false window.disable_portlet_select = false

View File

@ -13,6 +13,7 @@
#= require redactor_plugins/fontsize #= require redactor_plugins/fontsize
#= require redactor_plugins/fontfamily #= require redactor_plugins/fontfamily
#= require redactor_plugins/fontcolor #= require redactor_plugins/fontcolor
#= require vendor/accounting
#= require vendor/flipclock.js #= require vendor/flipclock.js
#= require vendor/jquery.cookiebar.js #= require vendor/jquery.cookiebar.js
@ -22,6 +23,8 @@
#= require nested_fields #= require nested_fields
#=require sheet_prices
top = 20 top = 20
@scroll_ajust = () -> @scroll_ajust = () ->

View File

@ -0,0 +1,16 @@
@udpate_sheet_lines = ->
$(".p_sheet_line_field").each ->
price = parseFloat($(this).find(".price").data("price"))
price_tot = 0
qte_tot = 0
$(this).find(".color_line").each ->
qte = 0
$(this).find("input.qte").each ->
qte += parseFloat($(this).val()) if parseFloat($(this).val())
price_color = qte * price
$(this).find(".price_color_tot").html(accounting.formatMoney(price_color))
qte_tot += qte
$(this).find(".qte_tot").html(qte_tot)
$(this).find(".price_tot").html(accounting.formatMoney(qte_tot*price))

View File

@ -130,6 +130,14 @@ class Admin::PCustomerSheetsController < ApplicationController
end end
def generate_fa
@p_customer_sheet = PCustomerSheet.find(params[:id])
@p_customer_sheet.generate_fa
redirect_to :back
end
def generate_bc def generate_bc
@p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer_sheet = PCustomerSheet.find(params[:id])
@p_customer_sheet.generate_bc @p_customer_sheet.generate_bc

View File

@ -68,8 +68,9 @@ class Admin::PCustomersController < ApplicationController
@p_customer = PCustomer.new(params.require(:p_customer).permit!) @p_customer = PCustomer.new(params.require(:p_customer).permit!)
if @p_customer.save
if @p_customer.save
@p_customer.generate_mdp_now if @p_customer.generate_mdp and @p_customer.generate_mdp != "0"
else else
render action: "new" render action: "new"
@ -83,7 +84,7 @@ class Admin::PCustomersController < ApplicationController
if @p_customer.update_attributes(params.require(:p_customer).permit!) if @p_customer.update_attributes(params.require(:p_customer).permit!)
@p_customer.generate_mdp_now if @p_customer.generate_mdp and @p_customer.generate_mdp != "0"
else else
render action: "edit" render action: "edit"

View File

@ -24,7 +24,7 @@ class Admin::PDocumentsController < ApplicationController
@p_document = PDocument.find_by_token(params[:id]) @p_document = PDocument.find_by_token(params[:id])
@element = @p_document.element @element = @p_document.element
params[:inline] = true params[:inline] = true
if true if false
@temp_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}_temp.pdf" @temp_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}_temp.pdf"
@final_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}.pdf" @final_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}.pdf"

View File

@ -23,7 +23,7 @@ class Public::PCustomerAuthsController < ApplicationController
user = PCustomer.find_by_email(params[:email]) user = PCustomer.find_by_email(params[:email])
if user && user.authenticate(params[:password]) if user && user.password_digest && user.authenticate(params[:password].to_s)
#session[:forum_user_id] = user.id #session[:forum_user_id] = user.id

View File

@ -18,8 +18,12 @@ class Public::POrdersController < ApplicationController
if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!)
respond_to do |format|
format.html { redirect_to cart_public_p_orders_path()}
format.js { render :layout => false }
end
redirect_to cart_public_p_orders_path()
else else
render action: "cart" render action: "cart"

View File

@ -1,13 +1,12 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
module MailHelper module MailHelper
def mail_content(slug, lang, arguments = {}) def mail_content(mail_content, lang_slug, arguments = {})
lang_site = LangSite.find_by_slug(lang_slug)
lang_site = LangSite.find_by_slug(lang)
mail_content = MailContent.joins(:mail_type).where(:lang_site_id => lang_site.id, :mail_types => { :slug => slug}).first
@new_site = true
if mail_content.content_type == "blocs" and mail_content.block if mail_content.content_type == "blocs" and mail_content.block
r = "<div class='render_block'>"+render(:partial => "public/blocks/block", :locals => {:block => mail_content.block})+render(:partial => "public/shared/render_block.html.haml")+"</div>" r = "<div class='render_block'>"+render(:partial => "public/blocks/block", :locals => {:block => mail_content.block})+render(:partial => "public/shared/render_block.html.haml")+"</div>"

View File

@ -1,10 +1,10 @@
class AdminMailer < ActionMailer::Base class AdminMailer < ActionMailer::Base
def password_reset(admin) def password_reset(admin)
@admin = admin @admin = admin
mail :to => admin.email, :subject => "Reinitialisation du mot de passe.", :from => "info@nicolasbally.com" mail :to => admin.email, :subject => "Reinitialisation du mot de passe.", :from => "n.bally@quartz.xyz"
end end
def notify_comments def notify_comments
mail :to => "info@3p.quartz.xyz,perrotmathilde@orange.fr", :subject => "Nouveaux commentaires à modérer sur le blog", :from => "info@3p.quartz.xyz" mail :to => "n.bally@quartz.xyz", :subject => "Nouveaux commentaires à modérer sur le blog", :from => "n.bally@quartz.xyz"
end end
end end

23
app/mailers/general_mailer.rb Executable file
View File

@ -0,0 +1,23 @@
class GeneralMailer < ActionMailer::Base
default from: "contact@biocoton.net"
add_template_helper(MailHelper)
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.question.deliver.subject
#
def send_qi_mail(lang_slug, slug, to, options)
@mail_content = MailContent.find_key(LangSite.find_by_slug(lang_slug), slug)
@lang_slug = lang_slug
@options = options
mail to: to, :subject => "[Biocoton] "+@mail_content.subject.to_s
end
end

View File

@ -1,5 +1,5 @@
class QuestionMailer < ActionMailer::Base class QuestionMailer < ActionMailer::Base
default from: "info@3p.quartz.xyz" default from: "info@quartz.xyz"
# Subject can be set in your I18n file at config/locales/en.yml # Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup: # with the following lookup:
@ -9,7 +9,7 @@ class QuestionMailer < ActionMailer::Base
def send_contact(contact) def send_contact(contact)
@contact = contact @contact = contact
mail to: "info@3p.quartz.xyz",:reply_to => @contact.email.to_s, :subject => "[Contact site] "+@contact.raison_text mail to: "info@quartz.xyz",:reply_to => @contact.email.to_s, :subject => "[Contact site] "+@contact.raison_text
end end

View File

@ -2,4 +2,16 @@ class MailType < ActiveRecord::Base
has_many :mail_contents has_many :mail_contents
belongs_to :mail_type_reference, :class_name => "MailType" belongs_to :mail_type_reference, :class_name => "MailType"
def self.generate_mail_content(slug)
mc = MailType.new(:slug => slug)
LangSite.all.each do |ls|
mc.mail_contents.new(:lang_site_id => ls.id, :content_type => "text")
end
mc.save
end
end end

6
app/models/p_box_fdp.rb Normal file
View File

@ -0,0 +1,6 @@
class PBoxFdp < ActiveRecord::Base
belongs_to :p_product
belongs_to :element, :polymorphic => true
end

View File

@ -20,12 +20,34 @@ class PCustomer < ActiveRecord::Base
belongs_to :p_price_cat belongs_to :p_price_cat
attr_accessor :valid_public attr_accessor :valid_public, :generate_mdp
before_validation do
self.generate_token if !self.token? and self.email?
end
def generate_mdp_now
ps = SecureRandom.hex(4)
self.password = ps
self.password_confirmation = ps
if !self.email?
errors.add(:email, "Doit être présent")
end
if self.save
GeneralMailer.send_qi_mail("fr", "generation_mdp", self.email, {"mdp" => ps}).deliver
else
fgfdggdf = dfgdgf
end
end
def public_validation? def public_validation?

View File

@ -1,5 +1,10 @@
class PCustomerSheet < ActiveRecord::Base class PCustomerSheet < ActiveRecord::Base
has_many :p_documents, :as => :element has_many :p_documents, :as => :element
has_many :p_box_fdps, :as => :element
accepts_nested_attributes_for :p_box_fdps, allow_destroy: true
belongs_to :p_customer belongs_to :p_customer
accepts_nested_attributes_for :p_customer accepts_nested_attributes_for :p_customer
@ -247,6 +252,15 @@ class PCustomerSheet < ActiveRecord::Base
end end
def generate_fa
if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Facture acompte"))
self.state = "commande"
self.save
end
end
def generate_bc def generate_bc
if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Bon de commande")) if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Bon de commande"))
@ -297,6 +311,11 @@ class PCustomerSheet < ActiveRecord::Base
end end
def generate_fdp
end
STATES = ["panier", "brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"] STATES = ["panier", "brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"]
ECOM_STATUS = ["commande", "commande validée", "en livraison", "livrée"] ECOM_STATUS = ["commande", "commande validée", "en livraison", "livrée"]

View File

@ -2,7 +2,7 @@ class PDegressif < ActiveRecord::Base
belongs_to :p_product belongs_to :p_product
has_many :p_price_cat_p_degressifs has_many :p_price_cat_p_degressifs, :dependent => :destroy
has_many :p_price_cats, :through => :p_price_cat_p_degressifs has_many :p_price_cats, :through => :p_price_cat_p_degressifs

View File

@ -18,6 +18,9 @@ class PDocument < ActiveRecord::Base
archive_sheet_line archive_sheet_line
end end
before_create do before_create do
self.fdp_force_price = self.element.fdp_force_price
self.acompte_percent = self.element.acompte_percent
if self.element_type == "PCustomerSheet" and self.element.particular_bill if self.element_type == "PCustomerSheet" and self.element.particular_bill
self.particular_bill = self.element.particular_bill.dup self.particular_bill = self.element.particular_bill.dup
self.particular_bill.owner = nil self.particular_bill.owner = nil
@ -35,6 +38,7 @@ class PDocument < ActiveRecord::Base
self.th_paid_completed? self.th_paid_completed?
if self.element_type == "PCustomerSheet" if self.element_type == "PCustomerSheet"
self.p_customer = self.element.p_customer self.p_customer = self.element.p_customer
end end
@ -55,6 +59,7 @@ class PDocument < ActiveRecord::Base
if self.element_type == "PCustomerSheet" if self.element_type == "PCustomerSheet"
self.save
self.element.p_sheet_lines.joins(:p_product).each do |p_sheet_line| self.element.p_sheet_lines.joins(:p_product).each do |p_sheet_line|
n_sheet_line = p_sheet_line.dup n_sheet_line = p_sheet_line.dup
@ -67,10 +72,58 @@ class PDocument < ActiveRecord::Base
p_colors_archiveds = []
p_sizes_archiveds = []
p_sheet_line.p_sheet_line_lines.each do |psll| p_sheet_line.p_sheet_line_lines.each do |psll|
new_psll = psll.dup new_psll = psll.dup
new_psll.fige
#Attention avant fonction fige
#new_psll.fige ########
if new_psll.p_product_stock.p_color
if p_color = p_colors_archiveds[new_psll.p_product_stock.p_color_id]
else
p_color = new_psll.p_product_stock.p_color.dup
p_color.archived = true
p_colors_archiveds[new_psll.p_product_stock.p_color_id] = p_color
end
new_psll.p_color = p_color
end
if new_psll.p_product_stock.p_size
if p_size = p_sizes_archiveds[new_psll.p_product_stock.p_size_id]
else
p_size = new_psll.p_product_stock.p_size.dup
p_size.archived = true
p_sizes_archiveds[new_psll.p_product_stock.p_size_id] = p_size
end
new_psll.p_size = p_size
end
new_psll.ok_code = new_psll.p_product_stock.code
#end ################
n_sheet_line.p_sheet_line_lines << new_psll n_sheet_line.p_sheet_line_lines << new_psll

View File

@ -8,16 +8,16 @@ class PProduct < ActiveRecord::Base
belongs_to :p_ep belongs_to :p_ep
has_many :p_product_colors has_many :p_product_colors, :dependent => :destroy
has_many :p_colors, :through => :p_product_colors has_many :p_colors, :through => :p_product_colors
has_many :p_product_certifs has_many :p_product_certifs, :dependent => :destroy
has_many :p_certifs, :through => :p_product_certifs has_many :p_certifs, :through => :p_product_certifs
has_many :p_product_sizes has_many :p_product_sizes, :dependent => :destroy
has_many :p_sizes, :through => :p_product_sizes has_many :p_sizes, :through => :p_product_sizes
has_many :p_product_qtes has_many :p_product_qtes, :dependent => :destroy
has_many :p_qtes, :through => :p_product_qtes has_many :p_qtes, :through => :p_product_qtes
@ -51,11 +51,11 @@ class PProduct < ActiveRecord::Base
def generate_degressif def generate_degressif
vals = [100,200,300,400,500,1000,3000,5000,10000] vals = [0]#[100,200,300,400,500,1000,3000,5000,10000]
vals.each do |val| vals.each do |val|
self.p_degressifs.create(:nbr => val) self.p_degressifs.create(:nbr => val, :p_price_cat_ids => PPriceCat.all.ids)
end end

View File

@ -2,4 +2,7 @@ class PProductStock < ActiveRecord::Base
belongs_to :p_product belongs_to :p_product
belongs_to :p_color belongs_to :p_color
belongs_to :p_size belongs_to :p_size
has_many :p_sheet_line_lines, :dependent => :delete_all
end end

View File

@ -1,6 +1,8 @@
class PSheetLine < ActiveRecord::Base class PSheetLine < ActiveRecord::Base
belongs_to :p_customer_sheet belongs_to :p_customer_sheet
belongs_to :p_document
has_one :p_customer, :through => :p_customer_sheet has_one :p_customer, :through => :p_customer_sheet
belongs_to :p_product belongs_to :p_product
belongs_to :p_tank belongs_to :p_tank
@ -138,7 +140,7 @@ class PSheetLine < ActiveRecord::Base
product_degressif = self.p_product.p_degressifs.joins(:p_price_cats).where("nbr >= ?", self.qte).where(:p_price_cats => {:id => p_price_cat.id}).order("nbr ASC").first product_degressif = self.p_product.p_degressifs.joins(:p_price_cats).where("nbr <= ?", self.qte).where(:p_price_cats => {:id => p_price_cat.id}).order("nbr DESC").first
if product_degressif if product_degressif
price = product_degressif.price.to_f price = product_degressif.price.to_f
@ -355,8 +357,8 @@ class PSheetLine < ActiveRecord::Base
r[:fdp] = {:label =>"Frais de port HT",:value => fdp} r[:fdp] = {:label =>"Frais de port HT",:value => fdp}
total = total +fdp total = total +fdp.to_f
total_ttc = total_ttc + (fdp*1.2) total_ttc = total_ttc + (fdp.to_f*1.2)
r[:total] = {:label =>"Total HT",:value => total} r[:total] = {:label =>"Total HT",:value => total}
r[:tva] = {:label =>"TVA",:value => total_ttc - total} r[:tva] = {:label =>"TVA",:value => total_ttc - total}
r[:total_ttc] = {:label =>"Total TTC",:value => total_ttc} r[:total_ttc] = {:label =>"Total TTC",:value => total_ttc}
@ -370,14 +372,30 @@ class PSheetLine < ActiveRecord::Base
def self.frais_de_port(p_sheet_lines) def self.frais_de_port(p_sheet_lines)
if PSheetLine.total_articles(p_sheet_lines)[:total] > PSheetLine.franco_port
0.0
else
PSheetLine.ship_affects(p_sheet_lines) * PSheetLine.carton_price
if p_sheet_lines[0] and ((p_sheet_lines[0].p_customer_sheet and p_sheet_lines[0].p_customer_sheet.fdp_force_price) or (p_sheet_lines[0].p_document and p_sheet_lines[0].p_document.fdp_force_price))
if p_sheet_lines[0].p_document
p_sheet_lines[0].p_document.fdp_force_price
elsif p_sheet_lines[0].p_customer_sheet
p_sheet_lines[0].p_customer_sheet.fdp_force_price
end
else
if PSheetLine.total_articles(p_sheet_lines)[:total] > PSheetLine.franco_port
0.0
else
PSheetLine.ship_affects(p_sheet_lines) * PSheetLine.carton_price
end
end end
end end
def self.ship_affects(p_sheet_lines) def self.ship_affects(p_sheet_lines)

View File

@ -1,7 +1,7 @@
=semantic_form_for [:admin, @p_customer_sheet], :remote => false do |form| =semantic_form_for [:admin, @p_customer_sheet], :remote => false, :html => {:id => "cart_form"} do |form|
.content .content
%h3 Client %h3 Client
@ -203,27 +203,30 @@
%p= link_to_add_fields "Ajouter une ligne", form, :p_sheet_lines %p= link_to_add_fields "Ajouter une ligne", form, :p_sheet_lines
= form.input :fdp_force_price, :label => "Frais de port (calculés automatiquement si vides) :"
%p
%strong Totaux
%table{:style => "width:100%;"} -if false
%td{:style => "text-align:right;"} %p
Total HT : %strong Totaux
%td.price_td
.price_emp.p_sheet_lines_tot_ht
%table{:style => "width:100%;"} %table{:style => "width:100%;"}
%td{:style => "text-align:right;"} %td{:style => "text-align:right;"}
TVA : Total HT :
%td.price_td %td.price_td
.price_emp.p_sheet_lines_tot_tva .price_emp.p_sheet_lines_tot_ht
%table{:style => "width:100%;"} %table{:style => "width:100%;"}
%td{:style => "text-align:right;"} %td{:style => "text-align:right;"}
Total TTC : TVA :
%td.price_td %td.price_td
.price_emp.p_sheet_lines_tot_ttc .price_emp.p_sheet_lines_tot_tva
%table{:style => "width:100%;"}
%td{:style => "text-align:right;"}
Total TTC :
%td.price_td
.price_emp.p_sheet_lines_tot_ttc
%hr %hr
@ -293,3 +296,15 @@
} }
} }
:coffeescript
udpate_sheet_lines()
$("#cart_form").change ->
udpate_sheet_lines()
$("#cart_form").keyup ->
udpate_sheet_lines()

View File

@ -9,10 +9,7 @@
%td %td
-totals = PSheetLine.totals(p_customer_sheet.p_sheet_lines) -totals = PSheetLine.totals(p_customer_sheet.p_sheet_lines)
-if p_customer_sheet.state_ok? =number_to_currency totals[:total]
=number_to_currency totals[:ok_total]
-else
=number_to_currency totals[:total]
%td=raw p_customer_sheet.state_html %td=raw p_customer_sheet.state_html

View File

@ -122,12 +122,18 @@
%p=link_to "Générer le bon de commande", generate_bc_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-success" %p=link_to "Générer le bon de commande", generate_bc_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-success"
%p=link_to "Marquer l'offre comme refusée", reject_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-danger" %p=link_to "Marquer l'offre comme refusée", reject_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-danger"
-if @p_customer_sheet.acompte_percent?
%p=link_to "Générer la facture d'acompte", generate_fa_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary"
-elsif @p_customer_sheet.state == "commande" and @p_customer_sheet.p_sheet_lines.joins(:p_product).where("bl = 0 and (p_products.p_product_cat_id != 6 OR (p_products.p_product_cat_id = 6 and externe = 1))").count > 0 -elsif @p_customer_sheet.state == "commande" and @p_customer_sheet.p_sheet_lines.joins(:p_product).where("bl = 0 and (p_products.p_product_cat_id != 6 OR (p_products.p_product_cat_id = 6 and externe = 1))").count > 0
%p=link_to "Générer le bon de livraison", generate_bl_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" %p=link_to "Générer le bon de livraison", generate_bl_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary"
=#-elsif @p_customer_sheet.state == "livrée" =#-elsif @p_customer_sheet.state == "livrée"
%p=link_to "Générer la facture", generate_f_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" %p=link_to "Générer la facture", generate_f_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary"
-if @p_customer_sheet.acompte_percent?
%p=link_to "Générer la facture d'acompte", generate_fa_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary"
.clear .clear

View File

@ -9,6 +9,9 @@
= form.input :code, :label => "Code client :" = form.input :code, :label => "Code client :"
= form.input :email, :label => "Email client (login) :" = form.input :email, :label => "Email client (login) :"
= form.input :generate_mdp, :label => "Forcer la génération d'un nouveau mot de passe ? (un mail sera envoyé au client)", :as => :boolean
= form.input :password, :label => "Mot de passe :" = form.input :password, :label => "Mot de passe :"
@ -44,8 +47,6 @@
%p= link_to_add_fields "Ajouter une contact au client", form, :p_contacts %p= link_to_add_fields "Ajouter une contact au client", form, :p_contacts
%hr
= form.input :mlm_token, :label => "Code parrain :"
%hr %hr

View File

@ -1,7 +1,7 @@
%tr.p_degressif_form.field %tr.p_degressif_form.field
%td{:style => "width:30%"} %td{:style => "width:30%"}
=form.input :nbr, :label => "Nombre max :" =form.input :nbr, :label => "Nombre min :"
%td{:style => "width:40%"} %td{:style => "width:40%"}
=form.input :price, :label => "Prix" =form.input :price, :label => "Prix"
%td{:style => "width:20%"} %td{:style => "width:20%"}

View File

@ -2,6 +2,7 @@
%div{:style => "position:absolute;top:4.4cm;right:1cm;text-align:right;"} %div{:style => "position:absolute;top:4.4cm;right:1cm;text-align:right;"}
=@p_document.label =@p_document.label
&nbsp;
=@p_document.d_number =@p_document.d_number
%br %br

View File

@ -25,9 +25,6 @@
- p_product.p_qtes.each do |p_qte| - p_product.p_qtes.each do |p_qte|
=p_qte.qte =p_qte.qte
=debug p_product.p_degressifs.count
%td.actions %td.actions

View File

@ -1,98 +1,215 @@
.product_stock_form.field -if true
%hr #p_sheet_line.product_stock_form.field.p_sheet_line_field{:id => form.object.id}
%table{:style => "width:100%;"}
%tr -if form.object.lock != true
%td =link_to_remove_fields ic(:"trash-o"), form
%label Produit :
%input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)} %label Produit :
%input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)}
= form.hidden_field :p_product_id, :class => "p_product_id" = form.hidden_field :p_product_id, :class => "p_product_id"
:javascript :javascript
$( function() { $( function() {
$('.p_product_autocomplete_input').autocomplete({ $('.p_product_autocomplete_input').autocomplete({
source: function( request, response ) { source: function( request, response ) {
$.ajax( { $.ajax( {
url: "/admin/p_products/autocomplete.json", url: "/admin/p_products/autocomplete.json",
dataType: "json", dataType: "json",
data: { data: {
search: request.term search: request.term
},
success: function(data){
arr = jQuery.map( data, function( item ) {
return {
label: item.code+" "+item.name,
value: item.code+" "+item.name,
id: item.id
}
});
response(arr)
}
} );
}, },
minLength: 2, success: function(data){
select: function( event, ui ) {
$(this).next(".p_product_id").val(ui.item.id) arr = jQuery.map( data, function( item ) {
return {
label: item.code+" "+item.name,
value: item.code+" "+item.name,
id: item.id
}
});
//return false response(arr)
}
}); }
} );
},
minLength: 2,
select: function( event, ui ) {
$(this).next(".p_product_id").val(ui.item.id)
//return false
}
});
} ); } );
%td
-p_product = form.object.p_product if form.object.p_product
%table.table.order_table
%tr
%th
-if form.object.p_product -if form.object.p_product
-p_product = form.object.p_product -p_product.p_sizes.all.each do |p_size|
%th.size_th
=p_size.name
%th.price_td PU
%th.price_td
Prix tot.
-if form.object.p_product
-p_product.p_colors.all.each do |p_color|
%tr.color_line
%td=p_color.name
%table.table -p_product.p_sizes.all.each do |p_size|
%tr %td
%th Taille -ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first
%th Couleur
%th Qte
-s = "a"
-si = 1
-if true
-p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps|
-si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count()
%tr
-if ps.p_size_id != s
-s = ps.p_size_id
%td{:rowspan => si}
=si
=ps.p_size.name if ps.p_size
%td
=ps.p_color.name if ps.p_color
%td
-p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock => ps.id).first
-if ps
-p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock_id => ps.id).first
-if p_sheet_line_line
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
=builder.input :qte,:label => false, :as => :string =builder.hidden_field :p_product_stock_id,:label => false, :as => :string
=builder.input :qte,:label => false, :as => :string, :input_html => {:class => "qte"}
%td.price.price_td{:data => {:price => form.object.price}}
=number_to_currency form.object.price
%td.price_color_tot.price_td
-if form.object.p_product
%table{:style => "width:100%"}
%tr
%td
&nbsp
%td.qte_tot.price_td{:style => "font-weight:bold;"}
%strong=form.object.qte
%td.price.price_td{:style => "font-weight:bold;", :data => {:price => form.object.price}}
%strong=number_to_currency form.object.price
%td.price_tot.price_td{:style => "font-weight:bold;"}
=number_to_currency form.object.price_tot
%br
-if false
.product_stock_form.field
%hr
%table{:style => "width:100%;"}
%tr
%td
%label Produit :
%input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)}
= form.hidden_field :p_product_id, :class => "p_product_id"
:javascript
$( function() {
$('.p_product_autocomplete_input').autocomplete({
source: function( request, response ) {
$.ajax( {
url: "/admin/p_products/autocomplete.json",
dataType: "json",
data: {
search: request.term
},
success: function(data){
arr = jQuery.map( data, function( item ) {
return {
label: item.code+" "+item.name,
value: item.code+" "+item.name,
id: item.id
}
});
response(arr)
}
} );
},
minLength: 2,
select: function( event, ui ) {
$(this).next(".p_product_id").val(ui.item.id)
//return false
}
});
} );
%td
-if form.object.p_product
-p_product = form.object.p_product
%table.table
%tr
%th Taille
%th Couleur
%th Qte
-s = "a"
-si = 1
-if true
-p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps|
-si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count()
%tr
-if ps.p_size_id != s
-s = ps.p_size_id
%td{:rowspan => si}
=si
=ps.p_size.name if ps.p_size
%td
=ps.p_color.name if ps.p_color
%td
-p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock => ps.id).first
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
=builder.input :qte,:label => false, :as => :string
-if form.object.lock != true
=link_to_remove_fields ic(:"trash-o"), form

View File

@ -8,9 +8,9 @@
%th %th
Description Description
%th %th
Taille
%th %th
Couleur
%th %th
Qte Qte
%th %th
@ -25,10 +25,58 @@
-p_sheet_line_lines = sheet_line.p_sheet_line_lines.where("qte > 0") -p_sheet_line_lines = sheet_line.p_sheet_line_lines.where("qte > 0")
-nbr_lines = p_sheet_line_lines.count -nbr_lines = p_sheet_line_lines.count
-ok = true if sheet_line.shiped -ok = true if sheet_line.shiped
%tr.sheet_line_head
%tr
%td{:colspan => 3, :style => "text-align:right;"}
%table.size_table
%tr
%th{:style => "text-align:left !important;"}
=sheet_line.product_name
fdfd
-p_sheet_line_lines.group(:p_size_id).uniq.each do |psize|
%th.p_size_td=psize.p_size.name
%td{:colspan => 4}
-p_sheet_line_lines.group(:p_color_id).uniq.each do |pc|
-qte_tot = 0.0
%tr
%td{:colspan => 3, :style => "text-align:right;"}
%table.size_table
%tr
%td
=pc.p_color.name
-p_sheet_line_lines.group(:p_size_id).uniq.each do |psize|
%td.p_size_td
-psl = p_sheet_line_lines.where(:p_size_id => psize.p_size_id, :p_color_id => pc.p_color_id ).first
-if psl
=psl.qte
-qte_tot += psl.qte
%td{}
=qte_tot.to_i
%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
%tr.tr_sheet_line_head
%td %td
=sheet_line.product_name
%td %td
%td %td
@ -48,22 +96,6 @@
=number_to_currency sheet_line.price_tot_ttc if sheet_line.price_tot_ttc =number_to_currency sheet_line.price_tot_ttc if sheet_line.price_tot_ttc
-p_sheet_line_lines.each do |p_sheet_line_line|
%tr
%td
%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
%td
%td
-total_with_labels = PSheetLine.total_with_labels(sheet_lines) -total_with_labels = PSheetLine.total_with_labels(sheet_lines)
-total_with_labels.each do |index, total| -total_with_labels.each do |index, total|
@ -76,6 +108,24 @@
%td %td
=number_to_currency total[:value] =number_to_currency total[:value]
-if @p_document and @p_document.label == "Facture Acompte"
%tr
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
Pourcentage d'acompte :
%td
=@p_document.acompte_percent.to_s+"%"
%tr
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
Acompte HT :
%td
=number_to_currency @p_document.total_with_labels_table[:total][:value] * (@p_document.acompte_percent.to_f/100)
%tr.sheet_line_head
%td{:style => "text-align:right;padding-right:10px;", :colspan =>6}
%strong Acompte TTC :
%td
%strong=number_to_currency @p_document.total_with_labels_table[:total_ttc][:value] * (@p_document.acompte_percent.to_f/100)
:scss :scss
@ -85,6 +135,16 @@
} }
} }
.tr_sheet_line_head{
td, th{
border:0;
border-bottom: 1px solid rgba(0,0,0,0.5) !important;
}
}
.marges{ .marges{
td{ td{
vertical-align:top; vertical-align:top;
@ -93,4 +153,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;
}
} }

View File

@ -0,0 +1 @@
=mail_content(@mail_content, @lang_slug, @options)

View File

@ -0,0 +1,15 @@
-total_with_labels = @p_customer_sheet.total_with_labels_table
%table{:style => "width:100%;"}
-total_with_labels.each do |index, total|
%tr
%td{:style => "text-align:right;"}
%strong
=total[:label]
%td.price_td
=number_to_currency total[:value]

View File

@ -9,33 +9,14 @@
.qi_row .qi_row
.qi_pannel.qi_plain.padding .qi_pannel.qi_plain.padding
=semantic_form_for [:public, @p_customer_sheet],:url => update_cart_public_p_orders_path(), :html => { :method => :post, :onchange =>""}, :remote => false do |form| =semantic_form_for [:public, @p_customer_sheet],:url => update_cart_public_p_orders_path(), :html => { :method => :post, :onchange =>"", :id => "cart_form"}, :remote => true do |form|
.p_sheet_lines_form .p_sheet_lines_form
=form.semantic_fields_for :p_sheet_lines do |form| =form.semantic_fields_for :p_sheet_lines do |form|
#p_sheet_line.product_stock_form.field{:id => form.object.id} #p_sheet_line.product_stock_form.field.p_sheet_line_field{:id => form.object.id}
%hr
%table{:style => "width:100%"}
%tr
%th Produit :
%th{:style => "width:15px;"}
Quantité
%th
Prix U
%th
Prix Tot
%th{:style => "width:15px;"}
%tr
%td
=form.object.p_product.name
@ -46,21 +27,6 @@
%td.qte
=form.object.qte
%td.price
=number_to_currency form.object.price
%td.price_tot
=number_to_currency form.object.price_tot
%td
=link_to_remove_fields ic(:"trash-o"), form
= form.hidden_field :p_product_id, :class => "p_product_id" = form.hidden_field :p_product_id, :class => "p_product_id"
-if form.object.p_product -if form.object.p_product
@ -68,36 +34,59 @@
-p_product = form.object.p_product -p_product = form.object.p_product
%table.table %table.table.order_table
%tr %tr
%th Taille %th
%th Couleur =form.object.p_product.name
%th Qte =link_to_remove_fields ic(:"trash-o"), form
-s = "a"
-si = 1
-p_product.p_sizes.all.each do |p_size|
%th.size_th
=p_size.name
-if true %th.price_td PU
-p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps| %th.price_td
Prix tot.
-si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count() -p_product.p_colors.all.each do |p_color|
%tr.color_line
%tr %td=p_color.name
-if ps.p_size_id != s
-s = ps.p_size_id
%td{:rowspan => si}
=si
=ps.p_size.name if ps.p_size
-p_product.p_sizes.all.each do |p_size|
%td %td
=ps.p_color.name if ps.p_color -ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first
%td -if ps
-p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock => ps.id).first -p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock_id => ps.id).first
-if p_sheet_line_line
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
=builder.hidden_field :p_product_stock_id,:label => false, :as => :string
=builder.input :qte,:label => false, :as => :string, :input_html => {:class => "qte"}
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| %td.price.price_td{:data => {:price => form.object.price}}
=builder.input :qte,:label => false, :as => :string, :input_html => {:maxlength => 10} =number_to_currency form.object.price
%td.price_color_tot.price_td
%table{:style => "width:100%"}
%tr
%td
&nbsp
%td.qte_tot.price_td{:style => "font-weight:bold;"}
%strong=form.object.qte
%td.price.price_td{:style => "font-weight:bold;", :data => {:price => form.object.price}}
%strong=number_to_currency form.object.price
%td.price_tot.price_td{:style => "font-weight:bold;"}
=number_to_currency form.object.price_tot
%br
@ -107,33 +96,16 @@
%p
%strong Totaux
-total_with_labels = form.object.total_with_labels_table
%table{:style => "width:100%;"}
-total_with_labels.each do |index, total|
%tr
%td{:style => "text-align:right;"}
%strong
=total[:label]
%td.price_td
=number_to_currency total[:value]
#cart_totals=render :partial => "cart_totals"
%hr %hr
=form.submit "sauvegarder", :class => "btn btn-primary" =#form.submit "sauvegarder", :class => "btn btn-primary"
=link_to "Suivant", particulars_public_p_orders_path =link_to "Suivant", particulars_public_p_orders_path, :class => "btn btn-primary"
:scss :scss
@ -162,3 +134,21 @@
} }
} }
:scss
.size_th{
width:80px;
}
:coffeescript
udpate_sheet_lines()
$("#cart_form").change ->
udpate_sheet_lines()
$(this).submit()
$("#cart_form").keyup ->
udpate_sheet_lines()
$(this).submit()

View File

@ -0,0 +1 @@
$('#cart_totals').html("<%= escape_javascript(render(:partial => "cart_totals"))%>");

View File

@ -56,39 +56,70 @@
-p_product = form.object.p_product -p_product = form.object.p_product
-if false
%table.table.order_table
%tr
%th Taille
%th Couleur
%th Qte
-s = "a"
-si = 1
-if true
-p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps|
-si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count()
%tr
-if ps.p_size_id != s
-s = ps.p_size_id
%td{:rowspan => si}
=ps.p_size.name if ps.p_size
%td
=ps.p_color.name if ps.p_color
%td
-p_sheet_line_line = @p_sheet_line.p_sheet_line_lines.new(:p_product_stock_id => ps.id)
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
=builder.hidden_field :p_product_stock_id,:label => false, :as => :string
=builder.input :qte,:label => false, :as => :string
%table.table.order_table %table.table.order_table
%tr %tr
%th Taille %th
%th Couleur -p_product.p_sizes.all.each do |p_size|
%th Qte %th.size_th
-s = "a" =p_size.name
-si = 1
-p_product.p_colors.all.each do |p_color|
%tr
%td=p_color.name
-if true -p_product.p_sizes.all.each do |p_size|
-p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps|
-si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count()
%tr
-if ps.p_size_id != s
-s = ps.p_size_id
%td{:rowspan => si}
=ps.p_size.name if ps.p_size
%td %td
=ps.p_color.name if ps.p_color -ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first
%td -if ps
-p_sheet_line_line = @p_sheet_line.p_sheet_line_lines.new(:p_product_stock_id => ps.id) -p_sheet_line_line = @p_sheet_line.p_sheet_line_lines.new(:p_product_stock_id => ps.id)
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
=builder.hidden_field :p_product_stock_id,:label => false, :as => :string
=builder.input :qte,:label => false, :as => :string
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
=builder.hidden_field :p_product_stock_id,:label => false, :as => :string
=builder.input :qte,:label => false, :as => :string
=form.submit "Commander", :class => "btn btn-primary" =form.submit "Commander", :class => "btn btn-primary"
:scss
.size_th{
width:80px;
}

View File

@ -44,11 +44,11 @@ Rails.application.configure do
#config.action_mailer.delivery_method = :file #config.action_mailer.delivery_method = :file
config.action_mailer.delivery_method = :smtp config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } config.action_mailer.smtp_settings = { :address => "127.0.0.1", :port => 1025 }
config.action_mailer.default_url_options = { :host => HOSTNAME } config.action_mailer.default_url_options = { :host => HOSTNAME }
Rails.application.routes.default_url_options = config.action_mailer.default_url_options = { :host => HOSTNAME, :protocol => 'http' } Rails.application.routes.default_url_options = config.action_mailer.default_url_options = { :host => HOSTNAME, :protocol => 'http' }
ANGORA_HOSTNAME = "angora.local:3000"
end end

View File

@ -4,7 +4,7 @@ upstream coton_app_unicorn {
server { server {
listen [::]:80; listen [::]:80;
server_name 3p.quartz.xyz ; server_name biocoton.quartz.xyz ;
root /srv/www/web/coton_app/current/public; root /srv/www/web/coton_app/current/public;
try_files $uri/index.html $uri @unicorn; try_files $uri/index.html $uri @unicorn;
@ -24,8 +24,8 @@ server {
server { server {
listen [::]:80; listen [::]:80;
server_name www.3p.quartz.xyz; server_name www.biocoton.quartz.xyz;
rewrite ^(.*) http://3p.quartz.xyz$1 permanent; rewrite ^(.*) http://biocoton.quartz.xyz$1 permanent;
} }

View File

@ -192,6 +192,7 @@ Rails.application.routes.draw do
member do member do
get :generate_d get :generate_d
get :generate_fp get :generate_fp
get :generate_fa
get :generate_bc get :generate_bc
get :generate_bl get :generate_bl
get :generate_f get :generate_f

View File

@ -0,0 +1,18 @@
class CreatePBoxFdps < ActiveRecord::Migration
def change
create_table :p_box_fdps do |t|
t.references :p_product, index: true, foreign_key: true
t.references :p_sheet_line
t.integer :p_product_archived_id
t.decimal :nbr_el, precision: 10, scale: 2
t.decimal :nbr_in_box, precision: 10, scale: 2
t.integer :qte
t.decimal :price, precision: 10, scale: 2
t.text :notes
t.integer :element_id
t.string :element_type
t.timestamps null: false
end
end
end

View File

@ -0,0 +1,5 @@
class AddFdpForcePriceToPCustomerSheets < ActiveRecord::Migration
def change
add_column :p_customer_sheets, :fdp_force_price, :decimal, precision: 10, scale: 2
end
end

View File

@ -0,0 +1,5 @@
class AddFdpForcePriceToPDocuments < ActiveRecord::Migration
def change
add_column :p_documents, :fdp_force_price, :decimal, precision: 10, scale: 2
end
end

View File

@ -0,0 +1,6 @@
class AddAcompteToPDocuments < ActiveRecord::Migration
def change
add_column :p_documents, :acompte_percent, :decimal, precision: 10, scale: 2
add_column :p_documents, :acompte_value, :decimal, precision: 10, scale: 2
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20181126002517) do ActiveRecord::Schema.define(version: 20181217112205) do
create_table "admin_admin_roles", force: :cascade do |t| create_table "admin_admin_roles", force: :cascade do |t|
t.integer "admin_id", limit: 4 t.integer "admin_id", limit: 4
@ -706,6 +706,23 @@ ActiveRecord::Schema.define(version: 20181126002517) do
t.datetime "updated_at" t.datetime "updated_at"
end end
create_table "p_box_fdps", force: :cascade do |t|
t.integer "p_product_id", limit: 4
t.integer "p_sheet_line_id", limit: 4
t.integer "p_product_archived_id", limit: 4
t.decimal "nbr_el", precision: 10, scale: 2
t.decimal "nbr_in_box", precision: 10, scale: 2
t.integer "qte", limit: 4
t.decimal "price", precision: 10, scale: 2
t.text "notes", limit: 65535
t.integer "element_id", limit: 4
t.string "element_type", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "p_box_fdps", ["p_product_id"], name: "index_p_box_fdps_on_p_product_id", using: :btree
create_table "p_certifs", force: :cascade do |t| create_table "p_certifs", force: :cascade do |t|
t.string "name", limit: 255 t.string "name", limit: 255
t.text "description", limit: 65535 t.text "description", limit: 65535
@ -781,6 +798,7 @@ ActiveRecord::Schema.define(version: 20181126002517) do
t.boolean "paid", default: false t.boolean "paid", default: false
t.datetime "paid_at" t.datetime "paid_at"
t.integer "p_price_cat_id", limit: 4 t.integer "p_price_cat_id", limit: 4
t.decimal "fdp_force_price", precision: 10, scale: 2
end end
add_index "p_customer_sheets", ["p_payment_type_id"], name: "index_p_customer_sheets_on_p_payment_type_id", using: :btree add_index "p_customer_sheets", ["p_payment_type_id"], name: "index_p_customer_sheets_on_p_payment_type_id", using: :btree
@ -894,6 +912,9 @@ ActiveRecord::Schema.define(version: 20181126002517) do
t.datetime "theo_paid_at" t.datetime "theo_paid_at"
t.boolean "paid", default: false t.boolean "paid", default: false
t.datetime "paid_at" t.datetime "paid_at"
t.decimal "fdp_force_price", precision: 10, scale: 2
t.decimal "acompte_percent", precision: 10, scale: 2
t.decimal "acompte_value", precision: 10, scale: 2
end end
create_table "p_eps", force: :cascade do |t| create_table "p_eps", force: :cascade do |t|
@ -1549,6 +1570,7 @@ ActiveRecord::Schema.define(version: 20181126002517) do
add_foreign_key "mail_contents", "mail_types" add_foreign_key "mail_contents", "mail_types"
add_foreign_key "menu_item_langs", "image_files" add_foreign_key "menu_item_langs", "image_files"
add_foreign_key "menu_item_langs", "lang_sites" add_foreign_key "menu_item_langs", "lang_sites"
add_foreign_key "p_box_fdps", "p_products"
add_foreign_key "p_customer_sheets", "p_payment_types" add_foreign_key "p_customer_sheets", "p_payment_types"
add_foreign_key "p_customer_sheets", "p_price_cats" add_foreign_key "p_customer_sheets", "p_price_cats"
add_foreign_key "p_customers", "p_price_cats" add_foreign_key "p_customers", "p_price_cats"

23
test/fixtures/p_box_fdps.yml vendored Normal file
View File

@ -0,0 +1,23 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
p_product_id:
p_product_archived_id: 1
nbr_el: 9.99
nbr_in_box: 9.99
qte: 1
price: 9.99
notes: MyText
element_id: 1
element_type: MyString
two:
p_product_id:
p_product_archived_id: 1
nbr_el: 9.99
nbr_in_box: 9.99
qte: 1
price: 9.99
notes: MyText
element_id: 1
element_type: MyString

View File

@ -0,0 +1,7 @@
require 'test_helper'
class PBoxFdpTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end