suite
This commit is contained in:
parent
5238a52533
commit
f9d656b0cb
@ -338,52 +338,54 @@ class Admin::ProductOrdersController < ApplicationController
|
||||
end
|
||||
if @product_order.bl_number?
|
||||
|
||||
if false
|
||||
|
||||
|
||||
@temp_file = "#{Rails.root}/pdf/bl/BL_#{@product_order.id}_temp.pdf"
|
||||
@final_file = "#{Rails.root}/pdf/bl/BL_#{@product_order.id}.pdf"
|
||||
@temp_file = "#{Rails.root}/pdf/bl/BL_#{@product_order.id}_temp.pdf"
|
||||
@final_file = "#{Rails.root}/pdf/bl/BL_#{@product_order.id}.pdf"
|
||||
|
||||
|
||||
view = ActionView::Base.new(Rails.root.join('app/views'))
|
||||
view.class.include ApplicationHelper
|
||||
view.class.include Rails.application.routes.url_helpers
|
||||
view = ActionView::Base.new(Rails.root.join('app/views'))
|
||||
view.class.include ApplicationHelper
|
||||
view.class.include Rails.application.routes.url_helpers
|
||||
|
||||
pdf = view.render(
|
||||
:pdf => "#{@product_order.id}",
|
||||
:template => "admin/product_orders/bl.html.haml",
|
||||
pdf = view.render(
|
||||
:pdf => "#{@product_order.id}",
|
||||
:template => "admin/product_orders/bl.html.haml",
|
||||
|
||||
:locals => {:@product_order => @product_order})
|
||||
:locals => {:@product_order => @product_order})
|
||||
|
||||
# then save to a file
|
||||
pdf = WickedPdf.new.pdf_from_string(pdf, :margin => { top: 0, # default 10 (mm)
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0 })
|
||||
# then save to a file
|
||||
pdf = WickedPdf.new.pdf_from_string(pdf, :margin => { top: 0, # default 10 (mm)
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0 })
|
||||
|
||||
save_path = @temp_file
|
||||
File.open(save_path, 'wb') do |file|
|
||||
file << pdf
|
||||
end
|
||||
save_path = @temp_file
|
||||
File.open(save_path, 'wb') do |file|
|
||||
file << pdf
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
require 'posix/spawn'
|
||||
require 'posix/spawn'
|
||||
|
||||
::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'background', Rails.root.join('pdf_stamp', 'bl.pdf').to_s, 'output', @final_file
|
||||
::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'background', Rails.root.join('pdf_stamp', 'bl.pdf').to_s, 'output', @final_file
|
||||
|
||||
#pdftk /Users/nico/Desktop/Sanstitre4.pdf background /Users/nico/Dev/negos_app/pdf_stamp/bl.pdf output sortie.pdf
|
||||
#pdftk /Users/nico/Desktop/Sanstitre4.pdf background /Users/nico/Dev/negos_app/pdf_stamp/bl.pdf output sortie.pdf
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@data_to_send = File.open( @final_file).read
|
||||
@data_to_send = File.open( @final_file).read
|
||||
|
||||
send_data @data_to_send, :filename =>"#{@product_order.bl_number}.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment")
|
||||
send_data @data_to_send, :filename =>"#{@product_order.bl_number}.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment")
|
||||
|
||||
|
||||
|
||||
else
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -200,7 +200,7 @@ class ProductOrder < ActiveRecord::Base
|
||||
|
||||
|
||||
last_number = 0
|
||||
last_number = ProductOrder.where("paid_at is not null").where(:bill_year => self.bill_year ).order("bill_index DESC").first.bill_index if ProductOrder.where("paid_at is not null").where(:bill_year => self.bill_year ).first
|
||||
last_number = ProductOrder.where("paid_at is not null").where(:bill_year => self.bill_year, :reseaux_id => self.reseaux_id ).order("bill_index DESC").first.bill_index if ProductOrder.where("paid_at is not null").where(:bill_year => self.bill_year, :reseaux_id => self.reseaux_id ).first
|
||||
self.bill_index = last_number+1
|
||||
self.bill_number = "NG"+self.bill_year.to_s+('%04d' % self.bill_index)
|
||||
self.save(:validate => false)
|
||||
@ -252,7 +252,7 @@ class ProductOrder < ActiveRecord::Base
|
||||
|
||||
|
||||
last_number = 0
|
||||
last_number = ProductOrder.where("bl_number is not null").where(:bl_year => self.bl_year ).order("bl_index DESC").first.bl_index if ProductOrder.where("bl_number is not null").where(:bl_year => self.bl_year ).first
|
||||
last_number = ProductOrder.where("bl_number is not null").where(:bl_year => self.bl_year, :reseaux_id => self.reseaux_id ).order("bl_index DESC").first.bl_index if ProductOrder.where("bl_number is not null").where(:bl_year => self.bl_year, :reseaux_id => self.reseaux_id ).first
|
||||
self.bl_index = last_number+1
|
||||
self.bl_number = self.bl_ap+self.bl_year.to_s+('%05d' % self.bl_index)
|
||||
self.save(:validate => false)
|
||||
|
@ -98,66 +98,72 @@
|
||||
#main
|
||||
|
||||
%div{:style => "position:absolute;top:4.4cm;right:1cm;text-align:right;"}
|
||||
Bon de commande n°
|
||||
-if @product_order.reseaux_id == 19
|
||||
Commande achats n°
|
||||
-else
|
||||
Bon de commande n°
|
||||
=@product_order.bl_number
|
||||
%br
|
||||
=l @product_order.created_at, :format => :date
|
||||
|
||||
|
||||
%div{:style => "height:350px;"}
|
||||
-if @product_order.reseaux_id != 19
|
||||
%div{:style => "height:350px;"}
|
||||
-else
|
||||
%div{:style => "height:140px;"}
|
||||
|
||||
|
||||
|
||||
%table.table{:style => "position:absolute;right:1cm;top:220px"}
|
||||
%tr
|
||||
%td{:style => "width:5.5cm;border:0"}
|
||||
%h3 Adresse de facturation
|
||||
-if @product_order.reseaux_id != 19
|
||||
%table.table{:style => "position:absolute;right:1cm;top:220px"}
|
||||
%tr
|
||||
%td{:style => "width:5.5cm;border:0"}
|
||||
%h3 Adresse de facturation
|
||||
|
||||
%strong=@product_order.particular_bill.organisation
|
||||
%br
|
||||
=@product_order.particular_bill.firstname
|
||||
|
||||
=@product_order.particular_bill.name
|
||||
%br
|
||||
=@product_order.particular_bill.address_2
|
||||
|
||||
-if @product_order.particular_bill.address_3?
|
||||
%strong=@product_order.particular_bill.organisation
|
||||
%br
|
||||
=@product_order.particular_bill.address_3
|
||||
%br
|
||||
=@product_order.particular_bill.cp
|
||||
=@product_order.particular_bill.firstname
|
||||
|
||||
=@product_order.particular_bill.city
|
||||
%br
|
||||
=@product_order.particular_bill.country
|
||||
%br
|
||||
%br
|
||||
=@product_order.particular_bill.tel
|
||||
|
||||
|
||||
%td{:style => "width:5.5cm;border:0"}
|
||||
%h3 Adresse de livraison
|
||||
|
||||
%strong=@product_order.particular_bill.organisation
|
||||
%br
|
||||
=@product_order.particular_send.firstname
|
||||
|
||||
=@product_order.particular_send.name
|
||||
%br
|
||||
=@product_order.particular_send.address_2
|
||||
|
||||
-if @product_order.particular_send.address_3?
|
||||
=@product_order.particular_bill.name
|
||||
%br
|
||||
=@product_order.particular_send.address_3
|
||||
%br
|
||||
=@product_order.particular_send.cp
|
||||
=@product_order.particular_bill.address_2
|
||||
|
||||
=@product_order.particular_send.city
|
||||
%br
|
||||
=@product_order.particular_send.country
|
||||
%br
|
||||
%br
|
||||
=@product_order.particular_bill.tel
|
||||
-if @product_order.particular_bill.address_3?
|
||||
%br
|
||||
=@product_order.particular_bill.address_3
|
||||
%br
|
||||
=@product_order.particular_bill.cp
|
||||
|
||||
=@product_order.particular_bill.city
|
||||
%br
|
||||
=@product_order.particular_bill.country
|
||||
%br
|
||||
%br
|
||||
=@product_order.particular_bill.tel
|
||||
|
||||
|
||||
%td{:style => "width:5.5cm;border:0"}
|
||||
%h3 Adresse de livraison
|
||||
|
||||
%strong=@product_order.particular_bill.organisation
|
||||
%br
|
||||
=@product_order.particular_send.firstname
|
||||
|
||||
=@product_order.particular_send.name
|
||||
%br
|
||||
=@product_order.particular_send.address_2
|
||||
|
||||
-if @product_order.particular_send.address_3?
|
||||
%br
|
||||
=@product_order.particular_send.address_3
|
||||
%br
|
||||
=@product_order.particular_send.cp
|
||||
|
||||
=@product_order.particular_send.city
|
||||
%br
|
||||
=@product_order.particular_send.country
|
||||
%br
|
||||
%br
|
||||
=@product_order.particular_bill.tel
|
||||
|
||||
%table.table{:style => "width:100%;margin:1cm 0;"}
|
||||
%tr
|
||||
@ -177,7 +183,31 @@
|
||||
=image_tag "http://negos.pro"+product_order_product.product.default_image.image_file.file.large.medium.small.thumb.url, :style => "width:130px;" if product_order_product.product.default_image
|
||||
%td
|
||||
=simple_format product_order_product.archived_product.lang(:fr).bl_title
|
||||
|
||||
|
||||
-if @product_order.reseaux_id == 19
|
||||
%table.sub_products{:style => "width:100%;margin-bottom:20px;margin-top:5px;"}
|
||||
%tr
|
||||
%th Référence
|
||||
%th Nom
|
||||
|
||||
|
||||
%th Nbr
|
||||
%th Prix HT
|
||||
|
||||
-product_order_product.sub_products.each do |sub_product|
|
||||
%tr
|
||||
%td
|
||||
=sub_product.reference
|
||||
%td
|
||||
=sub_product.name
|
||||
|
||||
|
||||
%td
|
||||
=sub_product.qte_tot
|
||||
%td
|
||||
=number_to_currency sub_product.price_tot_with_qte
|
||||
|
||||
|
||||
|
||||
=# product_order_product.archived_product_size.name if product_order_product.archived_product_size
|
||||
|
||||
@ -186,44 +216,46 @@
|
||||
|
||||
%td{:style => "text-align:right;"}
|
||||
= number_to_currency(product_order_product.archived_product.final_price_ht.to_f, locale: :fr) if product_order_product.archived_product
|
||||
|
||||
%td{:style => "text-align:right;"}
|
||||
=product_order_product.qty
|
||||
%td{:style => "text-align:right;"}
|
||||
= number_to_currency(product_order_product.archived_final_price_ht_with_qty, locale: :fr) if product_order_product.archived_product
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%tr
|
||||
%td{:colspan => 3, :rowspan => 3, :style => "border:0;text-align:left;"}
|
||||
%p
|
||||
%br
|
||||
Mode de paiment :
|
||||
-if @product_order.product_order_payment_type_ok_id == 3
|
||||
CB
|
||||
-elsif @product_order.product_order_payment_type_ok_id == 1
|
||||
Chèque
|
||||
-elsif @product_order.product_order_payment_type_ok_id == 2
|
||||
Virement
|
||||
-elsif @product_order.product_order_payment_type_ok_id == 4
|
||||
Mandat administratif
|
||||
%br
|
||||
%br
|
||||
Franco de port pour le Pays Voironnais
|
||||
%td Total HT :
|
||||
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_ht, locale: :fr)
|
||||
|
||||
%tr
|
||||
-if @product_order.reseaux_id != 19
|
||||
%p
|
||||
%br
|
||||
Mode de paiment :
|
||||
-if @product_order.product_order_payment_type_ok_id == 3
|
||||
CB
|
||||
-elsif @product_order.product_order_payment_type_ok_id == 1
|
||||
Chèque
|
||||
-elsif @product_order.product_order_payment_type_ok_id == 2
|
||||
Virement
|
||||
-elsif @product_order.product_order_payment_type_ok_id == 4
|
||||
Mandat administratif
|
||||
%br
|
||||
%br
|
||||
Franco de port pour le Pays Voironnais
|
||||
%td Total HT :
|
||||
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_ht, locale: :fr)
|
||||
-if @product_order.reseaux_id != 19
|
||||
%tr
|
||||
|
||||
%td TVA :
|
||||
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_tva, locale: :fr)
|
||||
%td TVA :
|
||||
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_tva, locale: :fr)
|
||||
|
||||
%tr
|
||||
%tr
|
||||
|
||||
%td Total TTC :
|
||||
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_ttc, locale: :fr)
|
||||
%td Total TTC :
|
||||
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_ttc, locale: :fr)
|
||||
|
||||
|
||||
|
||||
@ -231,7 +263,7 @@
|
||||
|
||||
|
||||
|
||||
%br
|
||||
%br
|
||||
|
||||
<!---
|
||||
.fdp
|
||||
|
Loading…
x
Reference in New Issue
Block a user