suite
This commit is contained in:
parent
dd15688d60
commit
121c3ebbbb
@ -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 }});
|
||||
|
||||
|
||||
});
|
||||
|
@ -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
|
||||
|
||||
|
@ -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])
|
||||
|
82
app/controllers/admin/p_product_images_controller.rb
Executable file
82
app/controllers/admin/p_product_images_controller.rb
Executable file
@ -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
|
@ -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 = "<div class='render_block'>"+render(:partial => "public/blocks/block", :locals => {:block => mail_content.block})+render(:partial => "public/shared/render_block.html.haml")+"</div>"
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
26
app/mailers/general_mails.rb
Normal file
26
app/mailers/general_mails.rb
Normal file
@ -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
|
79
app/models/mail_history.rb
Normal file
79
app/models/mail_history.rb
Normal file
@ -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
|
@ -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
|
||||
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
11
app/models/p_product_image.rb
Executable file
11
app/models/p_product_image.rb
Executable file
@ -0,0 +1,11 @@
|
||||
class PProductImage < ActiveRecord::Base
|
||||
belongs_to :image_file
|
||||
|
||||
belongs_to :p_product
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
13
app/views/admin/mail_histories/_mail_history.html.haml
Normal file
13
app/views/admin/mail_histories/_mail_history.html.haml
Normal file
@ -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
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
||||
|
||||
|
||||
|
52
app/views/admin/p_documents/send_by_mail.html.haml
Normal file
52
app/views/admin/p_documents/send_by_mail.html.haml
Normal file
@ -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"
|
19
app/views/admin/p_product_images/_form.html.haml
Executable file
19
app/views/admin/p_product_images/_form.html.haml
Executable file
@ -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"
|
||||
|
||||
|
||||
|
||||
|
9
app/views/admin/p_product_images/_p_product_image.html.haml
Executable file
9
app/views/admin/p_product_images/_p_product_image.html.haml
Executable file
@ -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
|
||||
|
||||
|
1
app/views/admin/p_product_images/create.js.erb
Executable file
1
app/views/admin/p_product_images/create.js.erb
Executable file
@ -0,0 +1 @@
|
||||
$('#p_product_images').prepend("<%= escape_javascript(render(@p_product_images)) %>");
|
4
app/views/admin/p_product_images/destroy.js.erb
Executable file
4
app/views/admin/p_product_images/destroy.js.erb
Executable file
@ -0,0 +1,4 @@
|
||||
|
||||
$("#p_product_image_<%= @p_product_image.id.to_s %>").fadeOut(500).delay(6000).remove();
|
||||
|
||||
<%= flash_js %>
|
1
app/views/admin/p_product_images/edit.js.erb
Executable file
1
app/views/admin/p_product_images/edit.js.erb
Executable file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>");
|
0
app/views/admin/p_product_images/reorder.js.erb
Executable file
0
app/views/admin/p_product_images/reorder.js.erb
Executable file
5
app/views/admin/p_product_images/update.js.erb
Executable file
5
app/views/admin/p_product_images/update.js.erb
Executable file
@ -0,0 +1,5 @@
|
||||
close_pane_hover();
|
||||
$('#p_product_image_<%= @p_product_image.id %>').effect("highlight", 1000);
|
||||
|
||||
|
||||
<%= flash_js %>
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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
|
||||
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
|
||||
}
|
||||
|
||||
})
|
||||
});
|
4
app/views/general_mails/general.html.haml
Normal file
4
app/views/general_mails/general.html.haml
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
=mail_content("fr", @mail_slug,@arguments )
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
22
db/migrate/20190704165202_create_mail_histories.rb
Normal file
22
db/migrate/20190704165202_create_mail_histories.rb
Normal file
@ -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
|
24
db/migrate/20190804183718_create_p_product_images.rb
Executable file
24
db/migrate/20190804183718_create_p_product_images.rb
Executable file
@ -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
|
31
db/schema.rb
31
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
|
||||
|
36
pdf-2.js
Normal file
36
pdf-2.js
Normal file
@ -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: '<div style="width:100%;font-family:arial;font-size: 8px; text-align:right;color:#3c3c3b; margin-right: 20px;margin-bottom:8px;">Page <span class="pageNumber"></span> sur <span class="totalPages"></span> </div>',
|
||||
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();
|
BIN
pdf_stamp/en-tete2.pdf
Normal file
BIN
pdf_stamp/en-tete2.pdf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user