This commit is contained in:
Nicolas Bally 2019-08-06 12:06:50 +02:00
parent dd15688d60
commit 121c3ebbbb
42 changed files with 720 additions and 69 deletions

View File

@ -127,7 +127,7 @@ function select_product_images_from_manager(product_id){
manager_prompt("/admin/image_files/?manager=true&multiple=true",function(m_return){ 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 }});
}); });

View File

@ -2,7 +2,7 @@
class Admin::PCustomersController < ApplicationController class Admin::PCustomersController < ApplicationController
layout "admin" layout "admin"
before_filter :auth_admin before_filter :auth_admin, :except => "etat"
before_filter :admin_space 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 url = (Rails.env.development? ? "http://localhost:4000" : "http://shop.biocoton.net").to_s+url
puts url puts url
pdf = "pdf" pdf = "pdf-2"
command = "node #{pdf}.js #{Shellwords.escape(url)} #{Shellwords.escape(@temp_file)}" command = "node #{pdf}.js #{Shellwords.escape(url)} #{Shellwords.escape(@temp_file)} A4 3cm 3cm 1.5cm 1.5cm"
puts command puts command
system(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 @data_to_send = File.open( @final_file).read

View File

@ -3,6 +3,8 @@
class Admin::PDocumentsController < ApplicationController class Admin::PDocumentsController < ApplicationController
#before_filter :auth_admin #before_filter :auth_admin
include ActionView::Helpers::NumberHelper
#layout "admin" #layout "admin"
before_filter :admin_space before_filter :admin_space
@ -71,6 +73,32 @@ class Admin::PDocumentsController < ApplicationController
end 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 def create_avoir
@p_document = PDocument.find(params[:id]) @p_document = PDocument.find(params[:id])

View 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

View File

@ -1,7 +1,51 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
module MailHelper 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) lang_site = LangSite.find_by_slug(lang_slug)

View 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

View 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

View File

@ -28,6 +28,8 @@ class PCustomer < ActiveRecord::Base
has_many :p_compta_elements has_many :p_compta_elements
has_many :mail_histories
attr_accessor :valid_public, :generate_mdp, :valid_siren attr_accessor :valid_public, :generate_mdp, :valid_siren
before_validation do before_validation do
@ -74,9 +76,18 @@ class PCustomer < ActiveRecord::Base
if self.save 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 else
fgfdggdf = dfgdgf
end end

View File

@ -13,8 +13,11 @@ class PDocument < ActiveRecord::Base
has_many :relative_docs, :class_name => "PDocument", :foreign_key => :doc_ref_id has_many :relative_docs, :class_name => "PDocument", :foreign_key => :doc_ref_id
has_many :mail_histories, :as => :element
COMPTA_DOC_TYPES = [4,7] COMPTA_DOC_TYPES = [4,7]
include Rails.application.routes.url_helpers
has_many :p_payment_documents, :dependent => :destroy has_many :p_payment_documents, :dependent => :destroy
@ -51,6 +54,8 @@ class PDocument < ActiveRecord::Base
self.p_customer.update_caches if self.p_customer self.p_customer.update_caches if self.p_customer
end end
end end
def generate_p_compta_element def generate_p_compta_element
@ -92,6 +97,21 @@ class PDocument < ActiveRecord::Base
after_create do after_create do
generate_number generate_number
archive_sheet_line if self.p_document_type.label != "Avoir" 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 end
before_create do before_create do
self.fdp_force_price = self.element.fdp_force_price if self.p_document_type.label != "Avoir" self.fdp_force_price = self.element.fdp_force_price if self.p_document_type.label != "Avoir"

View File

@ -8,6 +8,8 @@ class PProduct < ActiveRecord::Base
belongs_to :p_ep belongs_to :p_ep
has_many :p_product_images
has_many :p_product_colors, :dependent => :destroy has_many :p_product_colors, :dependent => :destroy
has_many :p_colors, :through => :p_product_colors has_many :p_colors, :through => :p_product_colors
@ -31,6 +33,12 @@ class PProduct < ActiveRecord::Base
scope :enableds, -> {where(:archived => false, :enabled => true)} scope :enableds, -> {where(:archived => false, :enabled => true)}
def default_image
self.p_product_images.order(:position).first
end
def get_prices(p_customer=nil) def get_prices(p_customer=nil)
if p_customer if p_customer
p_price_cat = p_customer.p_price_cat p_price_cat = p_customer.p_price_cat

11
app/models/p_product_image.rb Executable file
View File

@ -0,0 +1,11 @@
class PProductImage < ActiveRecord::Base
belongs_to :image_file
belongs_to :p_product
end

View File

@ -5,4 +5,8 @@ class PProductStock < ActiveRecord::Base
has_many :p_sheet_line_lines, :dependent => :delete_all has_many :p_sheet_line_lines, :dependent => :delete_all
def delta_stock
(self.stock_ok - self.stock_th_ok)
end
end end

View File

@ -1,11 +1,14 @@
= semantic_form_for [:admin,@mail_content], :remote => true do |form| = semantic_form_for [:admin,@mail_content], :remote => true do |form|
.content .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 = form.input :message
.actions .actions
= form.submit "Sauvegarder" = form.submit "Sauvegarder"

View File

@ -4,7 +4,8 @@
%strong=mail_content.lang_site.slug %strong=mail_content.lang_site.slug
%td=mail_content.mail_type.slug %td=mail_content.mail_type.slug
%td %td
=#%strong=mail_content.subject %strong=mail_content.subject
%br
=simple_format mail_content.message =simple_format mail_content.message
%td.actions %td.actions

View 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

View File

@ -56,21 +56,16 @@
=@p_customer.particular.country =@p_customer.particular.country
%p %p
A Moirans, le A Voiron, le
=l Date.today =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 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 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 %hr

View File

@ -26,7 +26,34 @@
%li{:class => ("active" if params[:tab] == "bills")}=link_to "Factures & Avoirs", "?tab=bills#tabs" %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] == "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;"} .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" -if params[:tab] == "offres"
#offres #offres
.qi_row .qi_row

View File

@ -12,35 +12,36 @@
%div{:style => "position:relative;width:6cm;margin-right:0.2cm;float:right;"} %div{:style => "position:relative;width:6cm;margin-right:0.2cm;float:right;"}
%div{:style => "border:0px solid black;padding:4px 8px;min-height:80px;"} -if @p_document.label != "Bon de livraison"
%h3{:style => "position:absolute;top:-30px;"} Adresse de facturation %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 %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?
%br %br
=@p_document.particular_bill.address_3 =@p_document.particular_bill.firstname
%br
=@p_document.particular_bill.cp
=@p_document.particular_bill.city =@p_document.particular_bill.name
%br %br
=@p_document.particular_bill.country =@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 -if false
.p_contacts .p_contacts
-@element.particular_bill.p_contacts.each do |p_contact| -@element.particular_bill.p_contacts.each do |p_contact|
.p_contact .p_contact
=p_contact.name if p_contact.name? =p_contact.name if p_contact.name?
=p_contact.tel if p_contact.tel? =p_contact.tel if p_contact.tel?
=link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email? =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;"} %div{:style => "position:relative;width:6cm;margin-right:0.5cm;float:right;"}
@ -148,7 +149,7 @@
=p_contact.tel if p_contact.tel? =p_contact.tel if p_contact.tel?
=link_to p_contact.email, "mailto:"+p_contact.email.to_s if p_contact.email? =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 %p.reglement
Passée la date d'échéance ci-dessus, une pénalité de retard de 1% mois sera Passée la date d'échéance ci-dessus, une pénalité de retard de 1% mois sera

View File

@ -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 "Créer un avoir", create_avoir_admin_p_document_path(p_document), :data => {:confirm => "Voulez-vous vraiment créer un avoir ?"}
&nbsp;&nbsp; &nbsp;&nbsp;
=link_to i(:eye), detail_admin_p_document_path(p_document), :remote => false =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 false
-if p_document.compta_locked -if p_document.compta_locked

View File

@ -8,12 +8,14 @@
.qi_row .qi_row
.qi_pannel.qi_plain.padding .qi_pannel.qi_plain.padding
=debug @p_document.save
=debug @p_document.totals
=debug @p_document.paid_completed?
-if false -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.count
-PDocument.where("cache_to_paid >= -1.0 and cache_to_paid <= 1.0 and paid = 0").all.each do |p_doc| -PDocument.where("cache_to_paid >= -1.0 and cache_to_paid <= 1.0 and paid = 0").all.each do |p_doc|
=p_doc.id =p_doc.id
@ -115,7 +117,10 @@
%tbody=render @p_document.p_payment_documents %tbody=render @p_document.p_payment_documents
%h3 Envois de mails
%table.table
=render @p_document.mail_histories.order("sended_at DESC")

View 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"

View 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"

View 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

View File

@ -0,0 +1 @@
$('#p_product_images').prepend("<%= escape_javascript(render(@p_product_images)) %>");

View File

@ -0,0 +1,4 @@
$("#p_product_image_<%= @p_product_image.id.to_s %>").fadeOut(500).delay(6000).remove();
<%= flash_js %>

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>");

View File

@ -0,0 +1,5 @@
close_pane_hover();
$('#p_product_image_<%= @p_product_image.id %>').effect("highlight", 1000);
<%= flash_js %>

View File

@ -30,6 +30,7 @@
%th Couleur %th Couleur
%th Stock actuel %th Stock actuel
%th Stock à importer %th Stock à importer
%th Delta stock th.
-@csv.each do |row| -@csv.each do |row|
-ps = nil -ps = nil
@ -62,14 +63,20 @@
%td=ps.p_size.name if ps.p_size %td=ps.p_size.name if ps.p_size
%td=ps.p_color.name if ps.p_color %td=ps.p_color.name if ps.p_color
%td=ps.stock_ok %td=ps.stock_ok
-else -else
%td %td
%td %td
%td %td
%td
%td=row["Stock const"] %td=row["Stock const"]
-if ps
%td=ps.delta_stock
-else
%td
=submit_tag "Valider et importer", :class => "btn btn-primary" =submit_tag "Valider et importer", :class => "btn btn-primary"
@ -101,8 +108,9 @@
%td=ps.stock_ok %td=ps.stock_ok
%td=params[:"ps_#{ps.id}"] %td=params[:"ps_#{ps.id}"]
-delta = ps.delta_stock
-ps.stock_ok = params[:"ps_#{ps.id}"] -ps.stock_ok = params[:"ps_#{ps.id}"]
-ps.stock_th_ok = params[:"ps_#{ps.id}"].to_f - delta
-ps.save -ps.save
%br %br

View File

@ -1,4 +1,6 @@
%tr#p_product{:id => p_product.id} %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.code
%td %td
= p_product.name = 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(:"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(: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(: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(:pencil), edit_admin_p_product_path(p_product), :remote => true
= link_to i(:eye), admin_p_product_path(p_product)

View File

@ -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 Produits
=link_to "ajouter une marque", new_admin_label_marque_path(:p_product_id => @p_product.id), :class => "btn btn-primary" %span
%table.table Détail d'un produit :
=render @p_product.label_marques.order(:name) =@p_product.name
%br
%br
%br
%br .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
}
})
});

View File

@ -0,0 +1,4 @@
=mail_content("fr", @mail_slug,@arguments )

View File

@ -8,7 +8,7 @@
= "#{p_product.p_ep.ep}g/m²" = "#{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 current_p_customer.account_validated
-if p_product.get_prices(current_p_customer).first -if p_product.get_prices(current_p_customer).first

View File

@ -11,19 +11,42 @@
.qi_row .qi_row
.qi_pannel.qi_plain.padding .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_col
=image_tag @p_product.image_file.file.large.medium.url .col_image
.description{:style => ("margin-left:0;" if !@p_product.image_file)} =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 =simple_format @p_product.description
.clear .clear
%br %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 -if @p_product.get_prices(current_p_customer).count > 0 and @p_product.get_prices(current_p_customer).first.price > 0.0
.sub_header .sub_header
-if current_p_customer.account_validated -if current_p_customer.account_validated

View File

@ -49,6 +49,7 @@ Rails.application.configure do
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' }
DEFAULT_FROM_EMAIL = "contact@biocoton.net"
DEFAULT_SUBJECT_EMAIL = "[Biocoton] - "
end end

View File

@ -97,7 +97,8 @@ Rails.application.configure do
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 = "stop-angora.fr" DEFAULT_FROM_EMAIL = "contact@biocoton.net"
DEFAULT_SUBJECT_EMAIL = "[Biocoton] - "
end end

View File

@ -130,6 +130,15 @@ Rails.application.routes.draw do
end end
namespace :admin do namespace :admin do
resources :p_product_images do
collection do
get :reorder
end
end
resources :p_product_stocks do resources :p_product_stocks do
collection do collection do
get :export get :export
@ -152,6 +161,8 @@ Rails.application.routes.draw do
get :create_avoir get :create_avoir
post :save_avoir post :save_avoir
get :detail get :detail
get :send_by_mail
post :send_by_mail_save
end end
collection do collection do
get :multiple get :multiple

View 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

View 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

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: 20190704151954) do ActiveRecord::Schema.define(version: 20190804183718) 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
@ -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_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 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| create_table "mail_profiles", force: :cascade do |t|
t.string "civilite", limit: 255 t.string "civilite", limit: 255
t.string "firstname", 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_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 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| create_table "p_product_qtes", force: :cascade do |t|
t.integer "p_product_id", limit: 4 t.integer "p_product_id", limit: 4
t.integer "p_qte_id", limit: 4 t.integer "p_qte_id", limit: 4

36
pdf-2.js Normal file
View 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

Binary file not shown.