Skip to content

Commit

Permalink
Qual: Generalize hook afterPDFCreation.
Browse files Browse the repository at this point in the history
New: Add hook beforePDFCreation
  • Loading branch information
eldy committed Sep 4, 2014
1 parent e7e48f6 commit 60c633f
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 9 deletions.
25 changes: 24 additions & 1 deletion htdocs/core/modules/action/rapport.pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function __construct($db, $month, $year)
*/
function write_file($socid = 0, $catid = 0, $outputlangs='')
{
global $user,$conf,$langs;
global $user,$conf,$langs,$hookmanager;

if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
Expand All @@ -117,6 +117,17 @@ function write_file($socid = 0, $catid = 0, $outputlangs='')

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
Expand Down Expand Up @@ -149,6 +160,18 @@ function write_file($socid = 0, $catid = 0, $outputlangs='')
$pdf->Close();

$pdf->Output($file,'F');

// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

Expand Down
26 changes: 25 additions & 1 deletion htdocs/core/modules/cheque/pdf/pdf_blochet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function __construct($db)
*/
function write_file($_dir, $number, $outputlangs)
{
global $user,$conf,$langs;
global $user,$conf,$langs,$hookmanager;

if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
Expand Down Expand Up @@ -113,6 +113,17 @@ function write_file($_dir, $number, $outputlangs)

$_file = $dir . "/bordereau-".$number.".pdf";

// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

// Create PDF instance
$pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part
Expand Down Expand Up @@ -141,6 +152,7 @@ function write_file($_dir, $number, $outputlangs)
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right

$nboflines=count($this->lines);

// Define nb of page
$pages = intval($nboflines / $this->line_per_page);
if (($nboflines % $this->line_per_page)>0)
Expand All @@ -166,6 +178,18 @@ function write_file($_dir, $number, $outputlangs)
$pdf->Close();

$pdf->Output($_file,'F');

// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('adterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

if (! empty($conf->global->MAIN_UMASK))
@chmod($_file, octdec($conf->global->MAIN_UMASK));

Expand Down
11 changes: 11 additions & 0 deletions htdocs/core/modules/commande/doc/pdf_einstein.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$nblignes = count($object->lines);

// Create pdf instance
Expand Down
11 changes: 11 additions & 0 deletions htdocs/core/modules/commande/doc/pdf_proforma.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$nblignes = count($object->lines);

// Create pdf instance
Expand Down
25 changes: 24 additions & 1 deletion htdocs/core/modules/contract/doc/pdf_strato.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function __construct($db)
*/
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $user,$langs,$conf,$mysoc;
global $user,$langs,$conf,$hookmanager,$mysoc;

if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
Expand Down Expand Up @@ -145,6 +145,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
Expand Down Expand Up @@ -334,6 +345,18 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$pdf->Close();

$pdf->Output($file,'F');

// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

Expand Down
23 changes: 23 additions & 0 deletions htdocs/core/modules/expedition/doc/pdf_merou.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hi

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$nblignes = count($object->lines);

$pdf=pdf_getInstance($this->format,'mm','l');
Expand Down Expand Up @@ -329,6 +340,18 @@ function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hi
$pdf->Close();

$pdf->Output($file,'F');

// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

Expand Down
23 changes: 23 additions & 0 deletions htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hi

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$nblignes = count($object->lines);

$pdf=pdf_getInstance($this->format);
Expand Down Expand Up @@ -331,6 +342,18 @@ function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hi
$pdf->Close();

$pdf->Output($file,'F');

// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

Expand Down
11 changes: 11 additions & 0 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$nblignes = count($object->lines);

$pdf=pdf_getInstance($this->format);
Expand Down
12 changes: 12 additions & 0 deletions htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}

$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
Expand Down
11 changes: 11 additions & 0 deletions htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$nblines = count($object->lines);

// Create pdf instance
Expand Down
14 changes: 12 additions & 2 deletions htdocs/core/modules/project/pdf/pdf_baleine.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@


/**
* \class pdf_baleine
* \brief Classe permettant de generer les projets au modele Baleine
* Classe permettant de generer les projets au modele Baleine
*/

class pdf_baleine extends ModelePDFProjects
Expand Down Expand Up @@ -124,6 +123,17 @@ function write_file($object,$outputlangs)

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
Expand Down
11 changes: 11 additions & 0 deletions htdocs/core/modules/propale/doc/pdf_azur.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

// Create pdf instance
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
Expand Down

0 comments on commit 60c633f

Please sign in to comment.