This commit is contained in:
Nicolas VARROT 2016-09-27 12:42:12 +02:00
parent d3c14a3165
commit 5d1e383e6a
3 changed files with 5 additions and 11 deletions

View File

@ -121,7 +121,7 @@ class Admin::OffersController < ApplicationController
def download_zip def download_zip
require 'zip' require 'zip'
@offer = Offer.find(params[:id]) @offer = Offer.find(params[:id])
@ -145,7 +145,7 @@ class Admin::OffersController < ApplicationController
if document.document.file if document.document.file
if document.particulars? if document.particulars?
zipfile.add("#{customer_name}/#{document_name}/#{document.title}-NÉGOS.pdf", document.get_particularized_document_file.path) zipfile.add("#{customer_name}/#{document_name}/#{document.title}-NÉGOS.pdf", document.get_particularized_document_file_path)
else else
zipfile.add("#{customer_name}/#{document_name}/#{document.title}-NÉGOS.pdf", document.document.current_path) zipfile.add("#{customer_name}/#{document_name}/#{document.title}-NÉGOS.pdf", document.document.current_path)
end end

View File

@ -34,13 +34,7 @@ class Public::DocumentsController < ApplicationController
end end
if @document.particulars if @document.particulars
send_data @document.get_particularized_document_file_path , :filename =>"negos-document-#{@document.id}.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment")
send_data @document.get_particularized_document_file , :filename =>"negos-document-#{@document.id}.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment")
#render :inline => "j" #render :inline => "j"
else else

View File

@ -75,7 +75,7 @@ class Document < ActiveRecord::Base
end end
def get_particularized_document_file def get_particularized_document_file_path
@temp_file = "#{Rails.root}/pdf/documents/#{self.id}_temp.pdf" @temp_file = "#{Rails.root}/pdf/documents/#{self.id}_temp.pdf"
@final_file = "#{Rails.root}/pdf/documents/#{self.id}.pdf" @final_file = "#{Rails.root}/pdf/documents/#{self.id}.pdf"
@final_file2 = "#{Rails.root}/pdf/documents/#{self.id}-2.pdf" @final_file2 = "#{Rails.root}/pdf/documents/#{self.id}-2.pdf"
@ -110,8 +110,8 @@ class Document < ActiveRecord::Base
::POSIX::Spawn::Child.new 'pdftk', "A="+self.document.file.path, 'B='+@final_file ,"cat", "B1", "A2-end", 'output', @final_file2 ::POSIX::Spawn::Child.new 'pdftk', "A="+self.document.file.path, 'B='+@final_file ,"cat", "B1", "A2-end", 'output', @final_file2
@final_file2
@data_to_send = File.open( @final_file2).read
end end
end end