diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js
index f56086c..92e7581 100644
--- a/app/assets/javascripts/manager.js
+++ b/app/assets/javascripts/manager.js
@@ -127,7 +127,7 @@ function select_product_images_from_manager(product_id){
manager_prompt("/admin/image_files/?manager=true&multiple=true",function(m_return){
- $.ajax({url:"/admin/product_images/", type: "POST", data : { image_file_ids : m_return, product_id : product_id }});
+ $.ajax({url:"/admin/p_product_images/", type: "POST", data : { image_file_ids : m_return, p_product_id : product_id }});
});
diff --git a/app/controllers/admin/p_customers_controller.rb b/app/controllers/admin/p_customers_controller.rb
index 42000f7..cc79055 100644
--- a/app/controllers/admin/p_customers_controller.rb
+++ b/app/controllers/admin/p_customers_controller.rb
@@ -2,7 +2,7 @@
class Admin::PCustomersController < ApplicationController
layout "admin"
- before_filter :auth_admin
+ before_filter :auth_admin, :except => "etat"
before_filter :admin_space
@@ -189,13 +189,13 @@ class Admin::PCustomersController < ApplicationController
url = (Rails.env.development? ? "http://localhost:4000" : "http://shop.biocoton.net").to_s+url
puts url
- pdf = "pdf"
- command = "node #{pdf}.js #{Shellwords.escape(url)} #{Shellwords.escape(@temp_file)}"
+ pdf = "pdf-2"
+ command = "node #{pdf}.js #{Shellwords.escape(url)} #{Shellwords.escape(@temp_file)} A4 3cm 3cm 1.5cm 1.5cm"
puts command
system(command)
- ::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'stamp', "#{Rails.root}/pdf_stamp/en-tete.pdf", 'output', @final_file
+ ::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'stamp', "#{Rails.root}/pdf_stamp/en-tete2.pdf", 'output', @final_file
@data_to_send = File.open( @final_file).read
diff --git a/app/controllers/admin/p_documents_controller.rb b/app/controllers/admin/p_documents_controller.rb
index 1735266..561d6f8 100755
--- a/app/controllers/admin/p_documents_controller.rb
+++ b/app/controllers/admin/p_documents_controller.rb
@@ -3,6 +3,8 @@
class Admin::PDocumentsController < ApplicationController
#before_filter :auth_admin
+ include ActionView::Helpers::NumberHelper
+
#layout "admin"
before_filter :admin_space
@@ -71,6 +73,32 @@ class Admin::PDocumentsController < ApplicationController
end
+ def send_by_mail
+ @p_document = PDocument.find(params[:id])
+ @p_customer = @p_document.p_customer
+
+ render :layout => "admin"
+ end
+
+ def send_by_mail_save
+ @p_document = PDocument.find(params[:id])
+ @p_customer = @p_document.p_customer
+
+
+ params[:emails].each do |email|
+
+ mail_history = MailHistory.generateMail("envoi_facture", email, {:element => @p_document, :p_customer => @p_customer, :mail_options => {:arguments => {:lien => admin_p_document_url(@p_document.token), :numero => @p_document.d_number, :document => @p_document.label.downcase, :date => @p_document.created_at.to_date.to_s, :montant => number_to_currency(@p_document.cache_total_ttc)}}})
+
+ mail_history.deliver_mail
+
+
+ end
+
+ redirect_to detail_admin_p_document_path(@p_document)
+
+
+ end
+
def create_avoir
@p_document = PDocument.find(params[:id])
diff --git a/app/controllers/admin/p_product_images_controller.rb b/app/controllers/admin/p_product_images_controller.rb
new file mode 100755
index 0000000..0ab74f2
--- /dev/null
+++ b/app/controllers/admin/p_product_images_controller.rb
@@ -0,0 +1,82 @@
+# -*- encoding : utf-8 -*-
+class Admin::PProductImagesController < ApplicationController
+ layout "admin"
+
+
+ def reorder
+ i = 0
+ params[:order].each do |p_product_image_id|
+ i += 1
+ p_product_image = PProductImage.find(p_product_image_id)
+ p_product_image.position = i
+ p_product_image.save
+ end
+
+ end
+
+ def create
+
+ @product = PProduct.find(params[:p_product_id])
+ @p_product_images = []
+ if params[:image_file_ids].kind_of?(Array)
+ params[:image_file_ids].each do |image_file_id|
+ image_file = ImageFile.find(image_file_id)
+ p_product_image = PProductImage.create(:image_file_id => image_file.id, :title => image_file.name, :description => image_file.description, :p_product_id => @product.id )
+
+ @p_product_images << p_product_image
+ end
+ end
+
+
+
+ respond_to do |format|
+
+ format.js
+
+ end
+ end
+
+
+
+ def edit
+ @p_product_image = PProductImage.find(params[:id])
+
+ if request.xhr?
+ render :layout => false
+ end
+
+ end
+
+
+
+
+
+ def show
+
+
+ end
+
+ def update
+ @p_product_image = PProductImage.find(params[:id])
+ respond_to do |format|
+ if @p_product_image.update_attributes(params.require(:p_product_image).permit!)
+
+ format.js
+ else
+ format.html { render :action => "edit", :layout => false}
+ format.js { render :action => "edit" }
+ end
+
+ end
+ end
+
+ def destroy
+
+ @p_product_image = PProductImage.find(params[:id])
+ @p_product_image.destroy
+
+
+ end
+
+
+end
diff --git a/app/helpers/mail_helper.rb b/app/helpers/mail_helper.rb
index e76bf1a..e37b17f 100644
--- a/app/helpers/mail_helper.rb
+++ b/app/helpers/mail_helper.rb
@@ -1,7 +1,51 @@
# -*- encoding : utf-8 -*-
module MailHelper
- def mail_content(mail_content, lang_slug, arguments = {})
+ def mail_content(lang, slug, arguments = {})
+
+ 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
+ r = "
"+render(:partial => "public/blocks/block", :locals => {:block => mail_content.block})+render(:partial => "public/shared/render_block.html.haml")+"
"
+
+
+ else
+
+
+ r = simple_format(@content)
+
+ end
+
+
+
+
+ if mail_content.mail_template and mail_content.mail_template.template_html?
+ template = mail_content.mail_template.template_html
+
+
+ r = template.gsub(/\[contenu\]/, r)
+
+
+
+
+ raw r
+
+
+
+ else
+ raw r
+ end
+
+
+
+ end
+
+
+
+ def mail_content2(mail_content, lang_slug, arguments = {})
lang_site = LangSite.find_by_slug(lang_slug)
diff --git a/app/mailers/general_mails.rb b/app/mailers/general_mails.rb
new file mode 100644
index 0000000..1350eb5
--- /dev/null
+++ b/app/mailers/general_mails.rb
@@ -0,0 +1,26 @@
+# -*- encoding : utf-8 -*-
+class GeneralMails < ActionMailer::Base
+ add_template_helper(MailHelper)
+
+ layout 'mail'
+
+ default from: DEFAULT_FROM_EMAIL
+
+
+
+ def general(lang_slug, mail_slug, email, subject, content)
+ #@options = options
+
+ @mail_slug = mail_slug
+ @content = content
+ @lang = LangSite.find_by_slug(lang_slug.to_s)
+
+
+
+ mail(:to => email, :subject => subject)
+ end
+
+
+
+
+end
diff --git a/app/models/mail_history.rb b/app/models/mail_history.rb
new file mode 100644
index 0000000..fae36bb
--- /dev/null
+++ b/app/models/mail_history.rb
@@ -0,0 +1,79 @@
+class MailHistory < ActiveRecord::Base
+ belongs_to :element, :polymorphic => true
+ belongs_to :mail_type
+ belongs_to :mail_content
+ belongs_to :p_customer
+ belongs_to :lang_site
+
+ def self.generateMail(slug, to, options = {})
+
+ options[:lang_slug] = options[:lang_slug] || "fr"
+ options[:mail_options] = options[:mail_options] || {}
+
+ @lang_site = LangSite.find_by_slug(options[:lang_slug])
+
+ @mail_content = MailContent.find_key(@lang_site, slug)
+
+ @mail_type = @mail_content.mail_type
+
+ @lang_slug = options[:lang_slug]
+
+ @options = options[:mail_options]
+
+
+
+ @email = to
+
+
+
+ arguments = options[:mail_options][:arguments] || {}
+
+
+ s = @mail_content.subject.to_s
+ arguments.each_pair do |key, value|
+ s = s.gsub(/\[#{key.to_s}\]/, value.to_s)
+
+ end
+ @subject = DEFAULT_SUBJECT_EMAIL.to_s+s
+
+ r = @mail_content.message
+ arguments.each_pair do |key, value|
+ r = r.gsub(/\[#{key.to_s}\]/, value.to_s)
+
+ end
+
+ @content = r
+
+
+
+
+ mail_history = MailHistory.create(:lang_site => @lang_site, :email => @email, :element => options[:element], :subject => @subject, :content => @content, :p_customer => options[:p_customer], :mail_content => @mail_content, :mail_type => @mail_type)
+
+
+
+
+ return mail_history
+
+
+ end
+
+ def deliver_mail
+ mail = GeneralMails.general(self.lang_site.slug, self.mail_type.slug, self.email , self.subject, self.content)
+
+ self.subject_cache = self.subject
+ self.content_cache = mail.body.encoded
+
+ mail.deliver
+
+ self.sended = true
+ self.sended_at = Time.now
+
+ self.save
+
+
+
+
+ end
+
+
+end
diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb
index 5f8b579..5d2cd6f 100644
--- a/app/models/p_customer.rb
+++ b/app/models/p_customer.rb
@@ -28,6 +28,8 @@ class PCustomer < ActiveRecord::Base
has_many :p_compta_elements
+ has_many :mail_histories
+
attr_accessor :valid_public, :generate_mdp, :valid_siren
before_validation do
@@ -74,9 +76,18 @@ class PCustomer < ActiveRecord::Base
if self.save
- GeneralMailer.send_qi_mail("fr", "generation_mdp", self.email, {"mdp" => ps}).deliver
+
+
+
+ mail_history = MailHistory.generateMail("generation_mdp", self.email, {:element => self, :p_customer => self, :mail_options => {:arguments => {:mdp => ps}}})
+
+ mail_history.deliver_mail
+
+
+
+
else
- fgfdggdf = dfgdgf
+
end
diff --git a/app/models/p_document.rb b/app/models/p_document.rb
index 30a3511..55a7b87 100644
--- a/app/models/p_document.rb
+++ b/app/models/p_document.rb
@@ -13,8 +13,11 @@ class PDocument < ActiveRecord::Base
has_many :relative_docs, :class_name => "PDocument", :foreign_key => :doc_ref_id
+ has_many :mail_histories, :as => :element
+
COMPTA_DOC_TYPES = [4,7]
+ include Rails.application.routes.url_helpers
has_many :p_payment_documents, :dependent => :destroy
@@ -51,6 +54,8 @@ class PDocument < ActiveRecord::Base
self.p_customer.update_caches if self.p_customer
end
+
+
end
def generate_p_compta_element
@@ -92,6 +97,21 @@ class PDocument < ActiveRecord::Base
after_create do
generate_number
archive_sheet_line if self.p_document_type.label != "Avoir"
+
+ if self.label == "Bon de livraison"
+ lien_bl = admin_p_document_url(self.token)
+ nom_client = self.p_customer.show_name
+ numero_offre = self.element_id
+ lien_offre = admin_p_customer_sheet_url(self.element_id)
+
+ mail_history = MailHistory.generateMail("notif_bl", "contact@jegeremaboite.fr", {:element => self, :mail_options => {:arguments => {:lien_bl => lien_bl,:nom_client => nom_client,:numero_offre => numero_offre,:lien_offre => lien_offre}}})
+
+ mail_history.deliver_mail
+
+
+ end
+
+
end
before_create do
self.fdp_force_price = self.element.fdp_force_price if self.p_document_type.label != "Avoir"
diff --git a/app/models/p_product.rb b/app/models/p_product.rb
index 2a41e1b..70b9185 100644
--- a/app/models/p_product.rb
+++ b/app/models/p_product.rb
@@ -8,6 +8,8 @@ class PProduct < ActiveRecord::Base
belongs_to :p_ep
+ has_many :p_product_images
+
has_many :p_product_colors, :dependent => :destroy
has_many :p_colors, :through => :p_product_colors
@@ -31,6 +33,12 @@ class PProduct < ActiveRecord::Base
scope :enableds, -> {where(:archived => false, :enabled => true)}
+
+ def default_image
+ self.p_product_images.order(:position).first
+ end
+
+
def get_prices(p_customer=nil)
if p_customer
p_price_cat = p_customer.p_price_cat
diff --git a/app/models/p_product_image.rb b/app/models/p_product_image.rb
new file mode 100755
index 0000000..f1024cd
--- /dev/null
+++ b/app/models/p_product_image.rb
@@ -0,0 +1,11 @@
+class PProductImage < ActiveRecord::Base
+ belongs_to :image_file
+
+ belongs_to :p_product
+
+
+
+
+
+
+end
diff --git a/app/models/p_product_stock.rb b/app/models/p_product_stock.rb
index 710fa63..cabd8b8 100644
--- a/app/models/p_product_stock.rb
+++ b/app/models/p_product_stock.rb
@@ -5,4 +5,8 @@ class PProductStock < ActiveRecord::Base
has_many :p_sheet_line_lines, :dependent => :delete_all
+ def delta_stock
+ (self.stock_ok - self.stock_th_ok)
+ end
+
end
diff --git a/app/views/admin/mail_contents/_form.html.haml b/app/views/admin/mail_contents/_form.html.haml
index 0b9ba9f..61fc4c5 100755
--- a/app/views/admin/mail_contents/_form.html.haml
+++ b/app/views/admin/mail_contents/_form.html.haml
@@ -1,11 +1,14 @@
= semantic_form_for [:admin,@mail_content], :remote => true do |form|
.content
- =# form.input :subject
- = form.input :enabled, :label => "Actif ?", :as => :boolean
- = form.input :mail_template_id, :label => "Template : ", :collection => MailTemplate.all, :include_blank => true, :as => :select
- = form.input :content_type, :label => "Type de contenu", :collection => ["text", "blocs"], :include_blank => false, :as => :select
+ =# form.input :enabled, :label => "Actif ?", :as => :boolean
+ =# form.input :mail_template_id, :label => "Template : ", :collection => MailTemplate.all, :include_blank => true, :as => :select
+
+
+ = #form.input :content_type, :label => "Type de contenu", :collection => ["text", "blocs"], :include_blank => false, :as => :select
+
+ = form.input :subject
= form.input :message
.actions
= form.submit "Sauvegarder"
diff --git a/app/views/admin/mail_contents/_mail_content.html.haml b/app/views/admin/mail_contents/_mail_content.html.haml
index dc295b3..83dbd4c 100755
--- a/app/views/admin/mail_contents/_mail_content.html.haml
+++ b/app/views/admin/mail_contents/_mail_content.html.haml
@@ -4,7 +4,8 @@
%strong=mail_content.lang_site.slug
%td=mail_content.mail_type.slug
%td
- =#%strong=mail_content.subject
+ %strong=mail_content.subject
+ %br
=simple_format mail_content.message
%td.actions
diff --git a/app/views/admin/mail_histories/_mail_history.html.haml b/app/views/admin/mail_histories/_mail_history.html.haml
new file mode 100644
index 0000000..8b25c73
--- /dev/null
+++ b/app/views/admin/mail_histories/_mail_history.html.haml
@@ -0,0 +1,13 @@
+%tr
+ %td
+ =l mail_history.sended_at
+
+
+ %td
+ = mail_history.email
+
+ %td
+ %strong
+ = mail_history.subject
+ =link_to "+", "#", :onclick => "$(this).next('.content').toggle();return false;"
+ .content{:style => "display:none;"}=simple_format mail_history.content
\ No newline at end of file
diff --git a/app/views/admin/p_customers/etat.html.haml b/app/views/admin/p_customers/etat.html.haml
index 4f7fffc..dbe7490 100644
--- a/app/views/admin/p_customers/etat.html.haml
+++ b/app/views/admin/p_customers/etat.html.haml
@@ -56,21 +56,16 @@
=@p_customer.particular.country
%p
- A Moirans, le
+ A Voiron, le
=l Date.today
- %div{:style => "height:2.6cm;"}
-
+ %div{:style => "height:3.5cm;"}
- %p Bonjour
-
%p Veuillez trouver votre relevé de compte ci-dessous et de nous faire parvenir un règlement si des échéances sont dépassées.
%p Merci de vérifier si vous avez en votre possession toutes les factures référencées, si cela n’était pas le cas merci de nous le signaler.
-
-
- %p Cordialement
+
%hr
diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml
index 11ca6c9..31bd364 100644
--- a/app/views/admin/p_customers/show.html.haml
+++ b/app/views/admin/p_customers/show.html.haml
@@ -26,7 +26,34 @@
%li{:class => ("active" if params[:tab] == "bills")}=link_to "Factures & Avoirs", "?tab=bills#tabs"
%li{:class => ("active" if params[:tab] == "payments")}=link_to "Paiements", "?tab=payments#tabs"
+ %li{:class => ("active" if params[:tab] == "mails")}=link_to "Mails", "?tab=mails#tabs"
+
+
+
.tab-content{:style => "min-height:1000px;margin-bottom:300px;"}
+
+ -if params[:tab] == "mails"
+ #mails
+ .qi_row
+ .qi_pannel.qi_plain.padding
+
+ %h3 Mails
+ %table.table.table-hover.table-striped
+ %tr
+
+ %th Date
+
+
+ %th Destinataire
+ %th Mail
+
+
+
+ %tbody#mail_histories_rows
+ =render @p_customer.mail_histories.order("sended_at DESC")
+
+
+
-if params[:tab] == "offres"
#offres
.qi_row
diff --git a/app/views/admin/p_documents/_general.html.haml b/app/views/admin/p_documents/_general.html.haml
index 4c3244e..64a5029 100644
--- a/app/views/admin/p_documents/_general.html.haml
+++ b/app/views/admin/p_documents/_general.html.haml
@@ -12,35 +12,36 @@
%div{:style => "position:relative;width:6cm;margin-right:0.2cm;float:right;"}
- %div{:style => "border:0px solid black;padding:4px 8px;min-height:80px;"}
- %h3{:style => "position:absolute;top:-30px;"} Adresse de facturation
+ -if @p_document.label != "Bon de livraison"
+ %div{:style => "border:0px solid black;padding:4px 8px;min-height:80px;"}
+ %h3{:style => "position:absolute;top:-30px;"} Adresse de facturation
- %strong=@p_document.particular_bill.organisation
- %br
- =@p_document.particular_bill.firstname
-
- =@p_document.particular_bill.name
- %br
- =@p_document.particular_bill.address_2
-
- -if @p_document.particular_bill.address_3?
+ %strong=@p_document.particular_bill.organisation
%br
- =@p_document.particular_bill.address_3
- %br
- =@p_document.particular_bill.cp
+ =@p_document.particular_bill.firstname
- =@p_document.particular_bill.city
- %br
- =@p_document.particular_bill.country
+ =@p_document.particular_bill.name
+ %br
+ =@p_document.particular_bill.address_2
+
+ -if @p_document.particular_bill.address_3?
+ %br
+ =@p_document.particular_bill.address_3
+ %br
+ =@p_document.particular_bill.cp
+
+ =@p_document.particular_bill.city
+ %br
+ =@p_document.particular_bill.country
- -if false
- .p_contacts
- -@element.particular_bill.p_contacts.each do |p_contact|
- .p_contact
- =p_contact.name if p_contact.name?
- =p_contact.tel if p_contact.tel?
- =link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email?
+ -if false
+ .p_contacts
+ -@element.particular_bill.p_contacts.each do |p_contact|
+ .p_contact
+ =p_contact.name if p_contact.name?
+ =p_contact.tel if p_contact.tel?
+ =link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email?
%div{:style => "position:relative;width:6cm;margin-right:0.5cm;float:right;"}
@@ -148,7 +149,7 @@
=p_contact.tel if p_contact.tel?
=link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email?
- -if @p_document.d_prefix == "F"
+ -if @p_document.label == "Facture"
%p.reglement
Passée la date d'échéance ci-dessus, une pénalité de retard de 1% mois sera
diff --git a/app/views/admin/p_documents/_p_document.html.haml b/app/views/admin/p_documents/_p_document.html.haml
index bd6294d..7c30ed0 100644
--- a/app/views/admin/p_documents/_p_document.html.haml
+++ b/app/views/admin/p_documents/_p_document.html.haml
@@ -140,6 +140,8 @@
=link_to "Créer un avoir", create_avoir_admin_p_document_path(p_document), :data => {:confirm => "Voulez-vous vraiment créer un avoir ?"}
=link_to i(:eye), detail_admin_p_document_path(p_document), :remote => false
+
+ =link_to i(:envelope), send_by_mail_admin_p_document_path(p_document), :remote => false
-if false
-if p_document.compta_locked
diff --git a/app/views/admin/p_documents/detail.html.haml b/app/views/admin/p_documents/detail.html.haml
index 36b900e..3eafdf7 100644
--- a/app/views/admin/p_documents/detail.html.haml
+++ b/app/views/admin/p_documents/detail.html.haml
@@ -8,12 +8,14 @@
.qi_row
.qi_pannel.qi_plain.padding
- =debug @p_document.save
- =debug @p_document.totals
- =debug @p_document.paid_completed?
-if false
+ =debug @p_document.save
+ =debug @p_document.totals
+
+ =debug @p_document.paid_completed?
+
=PDocument.where("cache_to_paid >= -1.0 and cache_to_paid <= 1.0 and paid = 0").all.count
-PDocument.where("cache_to_paid >= -1.0 and cache_to_paid <= 1.0 and paid = 0").all.each do |p_doc|
=p_doc.id
@@ -115,7 +117,10 @@
%tbody=render @p_document.p_payment_documents
-
+
+ %h3 Envois de mails
+ %table.table
+ =render @p_document.mail_histories.order("sended_at DESC")
diff --git a/app/views/admin/p_documents/send_by_mail.html.haml b/app/views/admin/p_documents/send_by_mail.html.haml
new file mode 100644
index 0000000..64e4f4c
--- /dev/null
+++ b/app/views/admin/p_documents/send_by_mail.html.haml
@@ -0,0 +1,52 @@
+.qi_header
+ %h1
+ Documents
+ %span
+ Envoyer un document
+
+
+.qi_row
+ .qi_pannel.qi_plain.padding
+ %strong
+ Envoi du document
+ =@p_document.label
+ =@p_document.d_number
+ %div
+ =form_tag send_by_mail_save_admin_p_document_path(@p_document), :method => "post" do
+ -params[:emails] = params[:emails] ||[]
+
+
+ %table.table.table-striped
+ -p_contacts = @p_customer.p_contacts
+
+ -p_contacts = p_contacts + @p_document.particular_send.p_contacts if @p_document.particular_send
+
+ -p_contacts = p_contacts + @p_document.particular_bill.p_contacts if @p_document.particular_bill
+
+
+ -p_contacts.uniq.each do |p_c|
+
+ %tr
+ %td
+ = check_box_tag :"emails[]", p_c.email, (true if params[:emails].include?(p_c.email.to_s)), {:id => "emails_#{p_c.email}"}
+
+ %td
+ =p_c.email
+
+ %td
+ =p_c.civilite
+
+ %td
+ =p_c.firstname
+
+ %td
+ =p_c.name
+
+ %td
+ =p_c.p_contact_types.map { |pct| pct.name}.join(" | ")
+
+
+
+
+
+ =submit_tag "Envoyer le document par mail", :class => "btn btn-primary"
\ No newline at end of file
diff --git a/app/views/admin/p_product_images/_form.html.haml b/app/views/admin/p_product_images/_form.html.haml
new file mode 100755
index 0000000..8b73f67
--- /dev/null
+++ b/app/views/admin/p_product_images/_form.html.haml
@@ -0,0 +1,19 @@
+= semantic_form_for [:portlet, @p_product_image], :remote => true do |form|
+ .content
+
+ %h3 Modifier les infos
+
+ = form.inputs do
+ = form.input :title, :label => "Titre :"
+ = form.input :tags, :label => "Tags :"
+ = form.input :description, :label => "Description :", :as => :text, :input_html => {:class => "text_editor"}
+
+
+
+
+ .actions
+ =form.submit "Sauvegarder", :class => "btn btn-primary"
+
+
+
+
diff --git a/app/views/admin/p_product_images/_p_product_image.html.haml b/app/views/admin/p_product_images/_p_product_image.html.haml
new file mode 100755
index 0000000..5ce0ffa
--- /dev/null
+++ b/app/views/admin/p_product_images/_p_product_image.html.haml
@@ -0,0 +1,9 @@
+-if p_product_image.image_file
+ .p_product_image.image_square#p_product_image{:id => p_product_image.id, :data => { :title => p_product_image.title , :description => p_product_image.description, :id => p_product_image.id} }
+ .img{:style => "background-image : url('#{p_product_image.image_file.file.large.medium.small.thumb.url}');"}
+
+ .actions
+ =link_to i(:"trash-o"), [:admin, p_product_image], :data => {:confirm => 'Voulez-vous vraiment supprimer cette image ?'}, :method => :delete, :remote => true
+ =#link_to i(:pencil), edit_admin_p_product_image_path(p_product_image), :remote => true
+
+
\ No newline at end of file
diff --git a/app/views/admin/p_product_images/create.js.erb b/app/views/admin/p_product_images/create.js.erb
new file mode 100755
index 0000000..c87cac5
--- /dev/null
+++ b/app/views/admin/p_product_images/create.js.erb
@@ -0,0 +1 @@
+$('#p_product_images').prepend("<%= escape_javascript(render(@p_product_images)) %>");
\ No newline at end of file
diff --git a/app/views/admin/p_product_images/destroy.js.erb b/app/views/admin/p_product_images/destroy.js.erb
new file mode 100755
index 0000000..6d54382
--- /dev/null
+++ b/app/views/admin/p_product_images/destroy.js.erb
@@ -0,0 +1,4 @@
+
+$("#p_product_image_<%= @p_product_image.id.to_s %>").fadeOut(500).delay(6000).remove();
+
+<%= flash_js %>
\ No newline at end of file
diff --git a/app/views/admin/p_product_images/edit.js.erb b/app/views/admin/p_product_images/edit.js.erb
new file mode 100755
index 0000000..3d94bc2
--- /dev/null
+++ b/app/views/admin/p_product_images/edit.js.erb
@@ -0,0 +1 @@
+show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>");
\ No newline at end of file
diff --git a/app/views/admin/p_product_images/reorder.js.erb b/app/views/admin/p_product_images/reorder.js.erb
new file mode 100755
index 0000000..e69de29
diff --git a/app/views/admin/p_product_images/update.js.erb b/app/views/admin/p_product_images/update.js.erb
new file mode 100755
index 0000000..7585a46
--- /dev/null
+++ b/app/views/admin/p_product_images/update.js.erb
@@ -0,0 +1,5 @@
+close_pane_hover();
+$('#p_product_image_<%= @p_product_image.id %>').effect("highlight", 1000);
+
+
+<%= flash_js %>
\ No newline at end of file
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 8271b29..539aa05 100644
--- a/app/views/admin/p_product_stocks/import_stocks.html.haml
+++ b/app/views/admin/p_product_stocks/import_stocks.html.haml
@@ -30,6 +30,7 @@
%th Couleur
%th Stock actuel
%th Stock à importer
+ %th Delta stock th.
-@csv.each do |row|
-ps = nil
@@ -62,14 +63,20 @@
%td=ps.p_size.name if ps.p_size
%td=ps.p_color.name if ps.p_color
%td=ps.stock_ok
+
-else
%td
%td
%td
+ %td
%td=row["Stock const"]
+ -if ps
+ %td=ps.delta_stock
+ -else
+ %td
=submit_tag "Valider et importer", :class => "btn btn-primary"
@@ -101,8 +108,9 @@
%td=ps.stock_ok
%td=params[:"ps_#{ps.id}"]
-
+ -delta = ps.delta_stock
-ps.stock_ok = params[:"ps_#{ps.id}"]
+ -ps.stock_th_ok = params[:"ps_#{ps.id}"].to_f - delta
-ps.save
%br
diff --git a/app/views/admin/p_products/_p_product.html.haml b/app/views/admin/p_products/_p_product.html.haml
index d487721..f21b814 100644
--- a/app/views/admin/p_products/_p_product.html.haml
+++ b/app/views/admin/p_products/_p_product.html.haml
@@ -1,4 +1,6 @@
%tr#p_product{:id => p_product.id}
+ %td
+ =image_tag p_product.default_image.image_file.file.large.medium.small.url, :style => "width:100px;" if p_product.default_image
%td= p_product.code
%td
= p_product.name
@@ -25,11 +27,12 @@
- %td.actions
+ %td.actions{:style => "width:200px;"}
= link_to i(:"trash-o"), [:admin, p_product], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet auteur ? ' } , :remote => true
= link_to i(:cubes), stock_admin_p_product_path(p_product), :remote => true
= link_to i(:euro), degressif_admin_p_product_path(p_product), :remote => true
= link_to i(:pencil), edit_admin_p_product_path(p_product), :remote => true
+ = link_to i(:eye), admin_p_product_path(p_product)
diff --git a/app/views/admin/p_products/show.html.haml b/app/views/admin/p_products/show.html.haml
index c2e1b9a..e48c533 100644
--- a/app/views/admin/p_products/show.html.haml
+++ b/app/views/admin/p_products/show.html.haml
@@ -1,10 +1,48 @@
-%h1=@p_product.name
+.qi_header
+ .right
+
+ = link_to i(:pencil), edit_admin_p_product_path(@p_product), :data => {:remote => true}
+ %h1
-%h2 Marques
-=link_to "ajouter une marque", new_admin_label_marque_path(:p_product_id => @p_product.id), :class => "btn btn-primary"
-%table.table
- =render @p_product.label_marques.order(:name)
-%br
-%br
-%br
-%br
\ No newline at end of file
+ Produits
+ %span
+ Détail d'un produit :
+ =@p_product.name
+
+
+
+.qi_row
+
+
+
+ .qi_pannel.qi_plain.padding
+ .qi_sub_header
+ %h2 Images du produit
+
+ %p
+ =link_to "Ajouter des images", "#", :onclick => "select_product_images_from_manager('#{@p_product.id.to_s}');return false;", :class => "btn btn-primary"
+ %br
+ #p_product_images
+ =render :collection => @p_product.p_product_images.order("position"), :partial => "admin/p_product_images/p_product_image"
+ %p{:style => "clear:both;"}
+
+ :coffeescript
+
+ adjustment = ""
+
+ $('#p_product_images').sortable({
+
+ stop: () ->
+ result = []
+ $(this).find(".p_product_image").each ->
+ result.push $(this).data("id")
+
+ $.ajax({
+ url:"/admin/p_product_images/reorder.js",
+ type: "GET",
+ data: {
+ order : result
+ }
+
+ })
+ });
\ No newline at end of file
diff --git a/app/views/general_mails/general.html.haml b/app/views/general_mails/general.html.haml
new file mode 100644
index 0000000..30f0ae1
--- /dev/null
+++ b/app/views/general_mails/general.html.haml
@@ -0,0 +1,4 @@
+
+=mail_content("fr", @mail_slug,@arguments )
+
+
\ No newline at end of file
diff --git a/app/views/public/p_products/_p_product.html.haml b/app/views/public/p_products/_p_product.html.haml
index 844bb76..8bf7a00 100644
--- a/app/views/public/p_products/_p_product.html.haml
+++ b/app/views/public/p_products/_p_product.html.haml
@@ -8,7 +8,7 @@
= "#{p_product.p_ep.ep}g/m²"
- .img.with_ratio{:style => ("background: grey url('"+(p_product.image_file.file.large.medium.small.thumb.url if p_product.image_file).to_s+"?u="+(p_product.image_file.updated_at if p_product.image_file).to_s+"') no-repeat center center;background-size:contain;" ), :data => {:ratio => "1.10"}}
+ .img.with_ratio{:style => ("background: grey url('"+(p_product.default_image.image_file.file.large.medium.small.thumb.url if p_product.default_image and p_product.default_image.image_file).to_s+"?u="+(p_product.default_image.image_file.updated_at if p_product.default_image and p_product.default_image.image_file).to_s+"') no-repeat center center;background-size:contain;" ), :data => {:ratio => "1.10"}}
-if current_p_customer.account_validated
-if p_product.get_prices(current_p_customer).first
diff --git a/app/views/public/p_products/show.html.haml b/app/views/public/p_products/show.html.haml
index 0150a17..e4a91af 100644
--- a/app/views/public/p_products/show.html.haml
+++ b/app/views/public/p_products/show.html.haml
@@ -11,19 +11,42 @@
.qi_row
.qi_pannel.qi_plain.padding
- -if @p_product.image_file
+ -if @p_product.default_image and @p_product.default_image.image_file
.image_col
- =image_tag @p_product.image_file.file.large.medium.url
- .description{:style => ("margin-left:0;" if !@p_product.image_file)}
+ .col_image
+ =image_tag @p_product.default_image.image_file.file.large.medium.url, :id => "product_default_image", :data => {:zoom_image => @p_product.default_image.image_file.file.url } if @p_product.default_image
+
+ -if @p_product.p_product_images.count > 1
+ .p_product_images
+ -@p_product.p_product_images.order(:position).each do |product_image|
+ =link_to image_tag(product_image.image_file.file.square.url), "#", :onclick => "$('#product_default_image').attr('data-zoom-image', $(this).data('zoom-url'));$('#product_default_image').attr('src', $(this).data('large-url'));$('#product_default_image').data('elevateZoom').swaptheimage($(this).data('large-url'), $(this).data('zoom-url')); return false;", :data => {:large_url => product_image.image_file.file.large.medium.url, :zoom_url => product_image.image_file.file.url}
+ .description{:style => ("margin-left:0;" if !@p_product.default_image)}
=simple_format @p_product.description
.clear
%br
+ :scss
+ .col_image{
+
+
+ #product_default_image{
+ width:100%;
-
+
+ }
+
+ .p_product_images{
+ img{
+ width:23%;
+ }
+ }
+
+ }
+
+
-if @p_product.get_prices(current_p_customer).count > 0 and @p_product.get_prices(current_p_customer).first.price > 0.0
.sub_header
-if current_p_customer.account_validated
diff --git a/config/environments/development.rb b/config/environments/development.rb
index a09af37..887d484 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -49,6 +49,7 @@ Rails.application.configure do
config.action_mailer.default_url_options = { :host => HOSTNAME }
Rails.application.routes.default_url_options = config.action_mailer.default_url_options = { :host => HOSTNAME, :protocol => 'http' }
-
+ DEFAULT_FROM_EMAIL = "contact@biocoton.net"
+ DEFAULT_SUBJECT_EMAIL = "[Biocoton] - "
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 0087ea0..f063e7a 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -97,7 +97,8 @@ Rails.application.configure do
Rails.application.routes.default_url_options = config.action_mailer.default_url_options = { :host => HOSTNAME, :protocol => 'http' }
- ANGORA_HOSTNAME = "stop-angora.fr"
+ DEFAULT_FROM_EMAIL = "contact@biocoton.net"
+ DEFAULT_SUBJECT_EMAIL = "[Biocoton] - "
end
diff --git a/config/routes.rb b/config/routes.rb
index 743a02f..596ab04 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -130,6 +130,15 @@ Rails.application.routes.draw do
end
namespace :admin do
+
+ resources :p_product_images do
+ collection do
+ get :reorder
+ end
+
+
+ end
+
resources :p_product_stocks do
collection do
get :export
@@ -152,6 +161,8 @@ Rails.application.routes.draw do
get :create_avoir
post :save_avoir
get :detail
+ get :send_by_mail
+ post :send_by_mail_save
end
collection do
get :multiple
diff --git a/db/migrate/20190704165202_create_mail_histories.rb b/db/migrate/20190704165202_create_mail_histories.rb
new file mode 100644
index 0000000..91fe1f0
--- /dev/null
+++ b/db/migrate/20190704165202_create_mail_histories.rb
@@ -0,0 +1,22 @@
+class CreateMailHistories < ActiveRecord::Migration
+ def change
+ create_table :mail_histories do |t|
+ t.string :email
+ t.string :element_type
+ t.integer :element_id
+ t.text :body
+ t.text :content
+ t.string :subject
+ t.text :content_cache
+ t.string :subject_cache
+ t.references :p_customer
+ t.references :mail_content
+ t.references :mail_type
+ t.datetime :sended_at
+ t.boolean :sended, :default => false
+ t.references :lang_site
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20190804183718_create_p_product_images.rb b/db/migrate/20190804183718_create_p_product_images.rb
new file mode 100755
index 0000000..b59fa0b
--- /dev/null
+++ b/db/migrate/20190804183718_create_p_product_images.rb
@@ -0,0 +1,24 @@
+class CreatePProductImages < ActiveRecord::Migration
+ def change
+ create_table :p_product_images do |t|
+ t.string :title
+ t.text :description
+ t.integer :position
+ t.references :image_file, index: false
+ t.references :p_product, index: false
+
+ t.timestamps null: false
+
+
+ end
+
+ PProduct.all.each do |pp|
+ if pp.image_file
+ pp.p_product_images.create(:image_file_id => pp.image_file_id, :position => 1)
+
+ end
+ end
+
+ #add_foreign_key :product_images, :image_files
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fec8a88..06ece72 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: 20190704151954) do
+ActiveRecord::Schema.define(version: 20190804183718) do
create_table "admin_admin_roles", force: :cascade do |t|
t.integer "admin_id", limit: 4
@@ -540,6 +540,25 @@ ActiveRecord::Schema.define(version: 20190704151954) do
add_index "mail_contents", ["mail_template_id"], name: "index_mail_contents_on_mail_template_id", using: :btree
add_index "mail_contents", ["mail_type_id"], name: "index_mail_contents_on_mail_type_id", using: :btree
+ create_table "mail_histories", force: :cascade do |t|
+ t.string "email", limit: 255
+ t.string "element_type", limit: 255
+ t.integer "element_id", limit: 4
+ t.text "body", limit: 65535
+ t.text "content", limit: 65535
+ t.string "subject", limit: 255
+ t.text "content_cache", limit: 65535
+ t.string "subject_cache", limit: 255
+ t.integer "p_customer_id", limit: 4
+ t.integer "mail_content_id", limit: 4
+ t.integer "mail_type_id", limit: 4
+ t.datetime "sended_at"
+ t.boolean "sended", default: false
+ t.integer "lang_site_id", limit: 4
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "mail_profiles", force: :cascade do |t|
t.string "civilite", limit: 255
t.string "firstname", limit: 255
@@ -1101,6 +1120,16 @@ ActiveRecord::Schema.define(version: 20190704151954) do
add_index "p_product_colors", ["p_color_id"], name: "index_p_product_colors_on_p_color_id", using: :btree
add_index "p_product_colors", ["p_product_id"], name: "index_p_product_colors_on_p_product_id", using: :btree
+ create_table "p_product_images", force: :cascade do |t|
+ t.string "title", limit: 255
+ t.text "description", limit: 65535
+ t.integer "position", limit: 4
+ t.integer "image_file_id", limit: 4
+ t.integer "p_product_id", limit: 4
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "p_product_qtes", force: :cascade do |t|
t.integer "p_product_id", limit: 4
t.integer "p_qte_id", limit: 4
diff --git a/pdf-2.js b/pdf-2.js
new file mode 100644
index 0000000..041e7de
--- /dev/null
+++ b/pdf-2.js
@@ -0,0 +1,36 @@
+'use strict';
+
+const puppeteer = require('puppeteer');
+
+const createPdf = async() => {
+ let browser;
+ try {
+ browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
+ const page = await browser.newPage();
+ //await page.setViewport({width: 794, height: 1122, deviceScaleFactor: 1});
+ await page.goto(process.argv[2], {timeout: 3000, waitUntil: 'networkidle2'});
+ await page.waitFor(250);
+
+
+ await page._emulationManager._client.send(
+ 'Emulation.setDefaultBackgroundColorOverride',
+ { color: { r: 0, g: 0, b: 0, a: 0 } }
+ );
+ await page.pdf({
+ path: process.argv[3],
+ format: process.argv[4],
+ footerTemplate: 'Page sur
',
+ displayHeaderFooter: true,
+ margin: { top: process.argv[5], bottom: process.argv[6], left: process.argv[7], right: process.argv[8] },
+ printBackground: false
+ });
+ } catch (err) {
+ console.log(err.message);
+ } finally {
+ if (browser) {
+ browser.close();
+ }
+ process.exit();
+ }
+};
+createPdf();
\ No newline at end of file
diff --git a/pdf_stamp/en-tete2.pdf b/pdf_stamp/en-tete2.pdf
new file mode 100644
index 0000000..66b08b4
Binary files /dev/null and b/pdf_stamp/en-tete2.pdf differ