Fix break page on pdf for projects
This commit is contained in:
parent
382c74fec2
commit
fcf5723183
@ -18,465 +18,416 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
|
* \file htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
|
||||||
* \ingroup project
|
* \ingroup project
|
||||||
* \brief Fichier de la classe permettant de generer les projets au modele Baleine
|
* \brief Fichier de la classe permettant de generer les projets au modele Baleine
|
||||||
* \author Regis Houssin
|
* \author Regis Houssin
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/project/modules_project.php");
|
require_once(DOL_DOCUMENT_ROOT."/includes/modules/project/modules_project.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class pdf_baleine
|
* \class pdf_baleine
|
||||||
* \brief Classe permettant de generer les projets au modele Baleine
|
* \brief Classe permettant de generer les projets au modele Baleine
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class pdf_baleine extends ModelePDFProjects
|
class pdf_baleine extends ModelePDFProjects
|
||||||
{
|
{
|
||||||
var $emetteur; // Objet societe qui emet
|
var $emetteur; // Objet societe qui emet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
* \param db Database handler
|
* \param db Database handler
|
||||||
*/
|
*/
|
||||||
function pdf_baleine($db)
|
function pdf_baleine($db)
|
||||||
{
|
{
|
||||||
global $conf,$langs,$mysoc;
|
global $conf,$langs,$mysoc;
|
||||||
|
|
||||||
$langs->load("main");
|
$langs->load("main");
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
|
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->name = "baleine";
|
$this->name = "baleine";
|
||||||
$this->description = $langs->trans("DocumentModelBaleine");
|
$this->description = $langs->trans("DocumentModelBaleine");
|
||||||
|
|
||||||
// Dimension page pour format A4
|
// Dimension page pour format A4
|
||||||
$this->type = 'pdf';
|
$this->type = 'pdf';
|
||||||
$this->page_largeur = 210;
|
$this->page_largeur = 210;
|
||||||
$this->page_hauteur = 297;
|
$this->page_hauteur = 297;
|
||||||
$this->format = array($this->page_largeur,$this->page_hauteur);
|
$this->format = array($this->page_largeur,$this->page_hauteur);
|
||||||
$this->marge_gauche=10;
|
$this->marge_gauche=10;
|
||||||
$this->marge_droite=10;
|
$this->marge_droite=10;
|
||||||
$this->marge_haute=10;
|
$this->marge_haute=10;
|
||||||
$this->marge_basse=10;
|
$this->marge_basse=10;
|
||||||
|
|
||||||
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
|
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
|
||||||
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
|
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
|
||||||
$this->option_codeproduitservice = 1; // Affiche code produit-service
|
$this->option_codeproduitservice = 1; // Affiche code produit-service
|
||||||
|
|
||||||
// Recupere emmetteur
|
// Recupere emmetteur
|
||||||
$this->emetteur=$mysoc;
|
$this->emetteur=$mysoc;
|
||||||
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'<27>tait pas d<>fini
|
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'<27>tait pas d<>fini
|
||||||
|
|
||||||
// Defini position des colonnes
|
// Defini position des colonnes
|
||||||
$this->posxdesc=$this->marge_gauche+1;
|
$this->posxref=$this->marge_gauche+1;
|
||||||
$this->posxcomm=120;
|
$this->posxlabel=$this->marge_gauche+25;
|
||||||
|
$this->posxprogress=$this->marge_gauche+140;
|
||||||
}
|
$this->posxdatestart=$this->marge_gauche+150;
|
||||||
|
$this->posxdateend=$this->marge_gauche+170;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* \brief Fonction generant le projet sur le disque
|
|
||||||
* \param delivery Object project a generer
|
/**
|
||||||
* \param outputlangs Lang output object
|
* \brief Fonction generant le projet sur le disque
|
||||||
* \return int 1 if OK, <=0 if KO
|
* \param delivery Object project a generer
|
||||||
*/
|
* \param outputlangs Lang output object
|
||||||
function write_file($object,$outputlangs)
|
* \return int 1 if OK, <=0 if KO
|
||||||
{
|
*/
|
||||||
global $user,$langs,$conf;
|
function write_file($object,$outputlangs)
|
||||||
|
{
|
||||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
global $user,$langs,$conf;
|
||||||
// Force output charset to ISO, because, FPDF expect text encoded in ISO
|
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||||
$outputlangs->charset_output='ISO-8859-1';
|
// Force output charset to ISO, because, FPDF expect text encoded in ISO
|
||||||
|
$sav_charset_output=$outputlangs->charset_output;
|
||||||
$outputlangs->load("main");
|
$outputlangs->charset_output='ISO-8859-1';
|
||||||
$outputlangs->load("dict");
|
|
||||||
$outputlangs->load("companies");
|
$outputlangs->load("main");
|
||||||
$outputlangs->load("projects");
|
$outputlangs->load("dict");
|
||||||
|
$outputlangs->load("companies");
|
||||||
if ($conf->projet->dir_output)
|
$outputlangs->load("projects");
|
||||||
{
|
|
||||||
// If $object is id instead of object
|
if ($conf->projet->dir_output)
|
||||||
if (! is_object($object))
|
{
|
||||||
{
|
// If $object is id instead of object
|
||||||
$id = $object;
|
if (! is_object($object))
|
||||||
$object = new Project($this->db);
|
{
|
||||||
$object->fetch($id);
|
$id = $object;
|
||||||
|
$object = new Project($this->db);
|
||||||
if ($result < 0)
|
$object->fetch($id);
|
||||||
{
|
|
||||||
dol_print_error($db,$object->error);
|
if ($result < 0)
|
||||||
}
|
{
|
||||||
}
|
dol_print_error($db,$object->error);
|
||||||
|
}
|
||||||
$nblignes = sizeof($object->lines);
|
}
|
||||||
|
|
||||||
$objectref = dol_sanitizeFileName($object->ref);
|
$nblignes = sizeof($object->lines);
|
||||||
$dir = $conf->projet->dir_output;
|
|
||||||
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
|
$objectref = dol_sanitizeFileName($object->ref);
|
||||||
$file = $dir . "/" . $objectref . ".pdf";
|
$dir = $conf->projet->dir_output;
|
||||||
|
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
|
||||||
if (! file_exists($dir))
|
$file = $dir . "/" . $objectref . ".pdf";
|
||||||
{
|
|
||||||
if (create_exdir($dir) < 0)
|
if (! file_exists($dir))
|
||||||
{
|
{
|
||||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
if (create_exdir($dir) < 0)
|
||||||
return 0;
|
{
|
||||||
}
|
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
if (file_exists($dir))
|
}
|
||||||
{
|
|
||||||
// Protection et encryption du pdf
|
if (file_exists($dir))
|
||||||
if ($conf->global->PDF_SECURITY_ENCRYPTION)
|
{
|
||||||
{
|
// Protection et encryption du pdf
|
||||||
$pdf=new FPDI_Protection('P','mm',$this->format);
|
if ($conf->global->PDF_SECURITY_ENCRYPTION)
|
||||||
$pdfrights = array('print'); // Ne permet que l'impression du document
|
{
|
||||||
$pdfuserpass = ''; // Mot de passe pour l'utilisateur final
|
$pdf=new FPDI_Protection('P','mm',$this->format);
|
||||||
$pdfownerpass = NULL; // Mot de passe du proprietaire, cree aleatoirement si pas defini
|
$pdfrights = array('print'); // Ne permet que l'impression du document
|
||||||
$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
|
$pdfuserpass = ''; // Mot de passe pour l'utilisateur final
|
||||||
}
|
$pdfownerpass = NULL; // Mot de passe du proprietaire, cree aleatoirement si pas defini
|
||||||
else
|
$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
|
||||||
{
|
}
|
||||||
$pdf=new FPDI('P','mm',$this->format);
|
else
|
||||||
}
|
{
|
||||||
|
$pdf=new FPDI('P','mm',$this->format);
|
||||||
// Complete object by loading several other informations
|
}
|
||||||
$task = new Task($this->db);
|
|
||||||
$tasksarray = $task->getTasksArray(0,0,$object->id);
|
// Complete object by loading several other informations
|
||||||
|
$task = new Task($this->db);
|
||||||
$object->lines=$tasksarray;
|
$tasksarray = $task->getTasksArray(0,0,$object->id);
|
||||||
$nblignes=sizeof($object->lines);
|
|
||||||
|
$object->lines=$tasksarray;
|
||||||
$pdf->Open();
|
$nblignes=sizeof($object->lines);
|
||||||
$pagenb=0;
|
|
||||||
$pdf->SetDrawColor(128,128,128);
|
$pdf->Open();
|
||||||
|
$pagenb=0;
|
||||||
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
|
$pdf->SetDrawColor(128,128,128);
|
||||||
$pdf->SetSubject($outputlangs->transnoentities("Project"));
|
|
||||||
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
|
||||||
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
|
$pdf->SetSubject($outputlangs->transnoentities("Project"));
|
||||||
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
|
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
||||||
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
|
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
||||||
|
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
|
||||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
|
||||||
$pdf->SetAutoPageBreak(1,0);
|
|
||||||
|
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||||
// New page
|
$pdf->SetAutoPageBreak(1,0);
|
||||||
$pdf->AddPage();
|
|
||||||
$pagenb++;
|
// New page
|
||||||
$this->_pagehead($pdf, $object, 1, $outputlangs);
|
$pdf->AddPage();
|
||||||
$pdf->SetFont('Arial','', 9);
|
$pagenb++;
|
||||||
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
|
$this->_pagehead($pdf, $object, 1, $outputlangs);
|
||||||
$pdf->SetTextColor(0,0,0);
|
$pdf->SetFont('Arial','', 9);
|
||||||
|
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
|
||||||
$tab_top = 50;
|
$pdf->SetTextColor(0,0,0);
|
||||||
$tab_height = 210;
|
|
||||||
|
$tab_top = 50;
|
||||||
// Affiche notes
|
$tab_height = 200;
|
||||||
if (! empty($object->note_public))
|
$tab_top_newpage = 40;
|
||||||
{
|
$tab_height_newpage = 210;
|
||||||
$tab_top = 48;
|
|
||||||
|
// Affiche notes
|
||||||
$pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page
|
if (! empty($object->note_public))
|
||||||
$pdf->SetXY ($this->posxdesc-1, $tab_top);
|
{
|
||||||
$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'J');
|
$pdf->SetFont('Arial','', 9);
|
||||||
$nexY = $pdf->GetY();
|
$pdf->SetXY ($this->posxref-1, $tab_top-2);
|
||||||
$height_note=$nexY-$tab_top;
|
$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'J');
|
||||||
|
$nexY = $pdf->GetY();
|
||||||
// Rect prend une longueur en 3eme param
|
$height_note=$nexY-($tab_top-2);
|
||||||
$pdf->SetDrawColor(192,192,192);
|
|
||||||
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
|
// Rect prend une longueur en 3eme param
|
||||||
|
$pdf->SetDrawColor(192,192,192);
|
||||||
$tab_height = $tab_height - $height_note;
|
$pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
|
||||||
$tab_top = $nexY+6;
|
|
||||||
}
|
$tab_height = $tab_height - $height_note;
|
||||||
else
|
$tab_top = $nexY+6;
|
||||||
{
|
}
|
||||||
$height_note=0;
|
else
|
||||||
}
|
{
|
||||||
|
$height_note=0;
|
||||||
$iniY = $tab_top + 7;
|
}
|
||||||
$curY = $tab_top + 7;
|
|
||||||
$nexY = $tab_top + 7;
|
$iniY = $tab_top + 7;
|
||||||
|
$curY = $tab_top + 7;
|
||||||
// Boucle sur les lignes
|
$nexY = $tab_top + 7;
|
||||||
for ($i = 0 ; $i < $nblignes ; $i++)
|
|
||||||
{
|
// Boucle sur les lignes
|
||||||
$curY = $nexY;
|
for ($i = 0 ; $i < $nblignes ; $i++)
|
||||||
|
{
|
||||||
// Description of ligne
|
$curY = $nexY;
|
||||||
$ref=$object->lines[$i]->ref;
|
|
||||||
$libelleline=$object->lines[$i]->label;
|
// Description of ligne
|
||||||
|
$ref=$object->lines[$i]->ref;
|
||||||
$pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page
|
$libelleline=$object->lines[$i]->label;
|
||||||
|
$progress=$object->lines[$i]->progress.'%';
|
||||||
$pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($ref), 0, 1);
|
$datestart=dol_print_date($object->lines[$i]->date_start,'day');
|
||||||
$pdf->writeHTMLCell(108, 3, $this->posxdesc+10, $curY, $outputlangs->convToOutputCharset($libelleline), 0, 1);
|
$dateend=dol_print_date($object->lines[$i]->date_end,'day');
|
||||||
|
|
||||||
$pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
|
|
||||||
$nexY = $pdf->GetY();
|
$pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page
|
||||||
|
|
||||||
$nexY+=2; // Passe espace entre les lignes
|
$pdf->SetXY($this->posxref, $curY);
|
||||||
|
$pdf->MultiCell(60, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
|
||||||
// Cherche nombre de lignes a venir pour savoir si place suffisante
|
$pdf->SetXY($this->posxlabel, $curY);
|
||||||
if ($i < ($nblignes - 1)) // If it's not last line
|
$pdf->MultiCell(108, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
|
||||||
{
|
$pdf->SetXY($this->posxprogress, $curY);
|
||||||
//on recupere la description du produit suivant
|
$pdf->MultiCell(16, 3, $progress, 0, 'L');
|
||||||
$follow_descproduitservice = $object->lines[$i+1]->label;
|
$pdf->SetXY($this->posxdatestart, $curY);
|
||||||
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
|
$pdf->MultiCell(20, 3, $datestart, 0, 'L');
|
||||||
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
|
$pdf->SetXY($this->posxdateend, $curY);
|
||||||
}
|
$pdf->MultiCell(20, 3, $dateend, 0, 'L');
|
||||||
else // If it's last line
|
|
||||||
{
|
|
||||||
$nblineFollowDesc = 0;
|
$pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
|
||||||
}
|
$nexY = $pdf->GetY();
|
||||||
|
|
||||||
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
|
$nexY+=2; // Passe espace entre les lignes
|
||||||
{
|
|
||||||
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
|
// Cherche nombre de lignes a venir pour savoir si place suffisante
|
||||||
|
if ($i < ($nblignes - 1)) // If it's not last line
|
||||||
$this->_pagefoot($pdf, $object, $outputlangs);
|
{
|
||||||
|
//on recupere la description du produit suivant
|
||||||
// New page
|
$follow_descproduitservice = $object->lines[$i+1]->label;
|
||||||
$pdf->AddPage();
|
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
|
||||||
$pagenb++;
|
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
|
||||||
$this->_pagehead($pdf, $object, 0, $outputlangs);
|
}
|
||||||
$pdf->SetFont('Arial','', 9);
|
else // If it's last line
|
||||||
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
|
{
|
||||||
$pdf->SetTextColor(0,0,0);
|
$nblineFollowDesc = 0;
|
||||||
|
}
|
||||||
$nexY = $tab_top_newpage + 7;
|
|
||||||
}
|
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
|
||||||
}
|
{
|
||||||
|
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
|
||||||
// Show square
|
|
||||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
|
$this->_pagefoot($pdf, $object, $outputlangs);
|
||||||
$bottomlasttab=$tab_top + $tab_height + 1;
|
|
||||||
|
// New page
|
||||||
/*
|
$pdf->AddPage();
|
||||||
* Pied de page
|
$pagenb++;
|
||||||
*/
|
$this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||||
$this->_pagefoot($pdf,$object,$outputlangs);
|
$pdf->SetFont('Arial','', 9);
|
||||||
$pdf->AliasNbPages();
|
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
|
||||||
|
$pdf->SetTextColor(0,0,0);
|
||||||
$pdf->Close();
|
|
||||||
|
$tab_top=$tab_top_newpage;
|
||||||
$pdf->Output($file);
|
$tab_height=$tab_height_newpage;
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
$nexY = $tab_top + 7;
|
||||||
|
}
|
||||||
return 1; // Pas d'erreur
|
}
|
||||||
}
|
|
||||||
else
|
// Show square
|
||||||
{
|
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
|
||||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
$bottomlasttab=$tab_top + $tab_height + 1;
|
||||||
return 0;
|
|
||||||
}
|
/*
|
||||||
}
|
* Pied de page
|
||||||
|
*/
|
||||||
$this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR");
|
$this->_pagefoot($pdf,$object,$outputlangs);
|
||||||
return 0;
|
$pdf->AliasNbPages();
|
||||||
}
|
|
||||||
|
$pdf->Close();
|
||||||
|
|
||||||
/*
|
$pdf->Output($file);
|
||||||
* \brief Affiche la grille des lignes
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
* \param pdf objet PDF
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
*/
|
|
||||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
|
return 1; // Pas d'erreur
|
||||||
{
|
}
|
||||||
global $conf,$mysoc;
|
else
|
||||||
|
{
|
||||||
// Montants exprimes en (en tab_top - 1)
|
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||||
$pdf->SetTextColor(0,0,0);
|
return 0;
|
||||||
$pdf->SetFont('Arial','',8);
|
}
|
||||||
//$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie));
|
}
|
||||||
//$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre);
|
|
||||||
|
$this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR");
|
||||||
$pdf->SetDrawColor(128,128,128);
|
return 0;
|
||||||
|
}
|
||||||
// Rect prend une longueur en 3eme param
|
|
||||||
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
|
|
||||||
// line prend une position y en 3eme param
|
/*
|
||||||
$pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6);
|
* \brief Affiche la grille des lignes
|
||||||
|
* \param pdf objet PDF
|
||||||
$pdf->SetFont('Arial','',10);
|
*/
|
||||||
|
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
|
||||||
$pdf->SetXY ($this->posxdesc-1, $tab_top+2);
|
{
|
||||||
$pdf->MultiCell(80,2, $outputlangs->transnoentities("Tasks"),'','L');
|
global $conf,$mysoc;
|
||||||
|
|
||||||
}
|
// Montants exprimes en (en tab_top - 1)
|
||||||
|
$pdf->SetTextColor(0,0,0);
|
||||||
/**
|
$pdf->SetFont('Arial','',8);
|
||||||
* \brief Affiche en-tete bon livraison
|
//$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie));
|
||||||
* \param pdf objet PDF
|
//$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre);
|
||||||
* \param delivery object delivery
|
|
||||||
* \param showadress 0=non, 1=oui
|
$pdf->SetDrawColor(128,128,128);
|
||||||
*/
|
|
||||||
function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
|
// Rect prend une longueur en 3eme param
|
||||||
{
|
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
|
||||||
global $langs,$conf,$mysoc;
|
// line prend une position y en 3eme param
|
||||||
|
$pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6);
|
||||||
pdf_pagehead($pdf,$outputlangs,$pdf->page_hauteur);
|
|
||||||
|
$pdf->SetFont('Arial','',10);
|
||||||
$pdf->SetTextColor(0,0,60);
|
|
||||||
$pdf->SetFont('Arial','B',13);
|
$pdf->SetXY ($this->posxref-1, $tab_top+2);
|
||||||
|
$pdf->MultiCell(80,2, $outputlangs->transnoentities("Tasks"),'','L');
|
||||||
$posy=$this->marge_haute;
|
|
||||||
|
}
|
||||||
$pdf->SetXY($this->marge_gauche,$posy);
|
|
||||||
|
/**
|
||||||
// Logo
|
* \brief Affiche en-tete bon livraison
|
||||||
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
|
* \param pdf objet PDF
|
||||||
if ($mysoc->logo)
|
* \param delivery object delivery
|
||||||
{
|
* \param showadress 0=non, 1=oui
|
||||||
if (is_readable($logo))
|
*/
|
||||||
{
|
function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
|
||||||
$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
|
{
|
||||||
}
|
global $langs,$conf,$mysoc;
|
||||||
else
|
|
||||||
{
|
pdf_pagehead($pdf,$outputlangs,$pdf->page_hauteur);
|
||||||
$pdf->SetTextColor(200,0,0);
|
|
||||||
$pdf->SetFont('Arial','B',8);
|
$pdf->SetTextColor(0,0,60);
|
||||||
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
|
$pdf->SetFont('Arial','B',13);
|
||||||
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
|
|
||||||
}
|
$posy=$this->marge_haute;
|
||||||
}
|
|
||||||
else $pdf->MultiCell(100, 4, $this->emetteur->nom, 0, 'L');
|
$pdf->SetXY($this->marge_gauche,$posy);
|
||||||
|
|
||||||
$pdf->SetFont('Arial','B',13);
|
// Logo
|
||||||
$pdf->SetXY(100,$posy);
|
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
|
||||||
$pdf->SetTextColor(0,0,60);
|
if ($mysoc->logo)
|
||||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '' , 'R');
|
{
|
||||||
$pdf->SetFont('Arial','',12);
|
if (is_readable($logo))
|
||||||
|
{
|
||||||
$posy+=6;
|
$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
|
||||||
$pdf->SetXY(100,$posy);
|
}
|
||||||
$pdf->SetTextColor(0,0,60);
|
else
|
||||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
|
{
|
||||||
$posy+=6;
|
$pdf->SetTextColor(200,0,0);
|
||||||
$pdf->SetXY(100,$posy);
|
$pdf->SetFont('Arial','B',8);
|
||||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
|
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
|
||||||
|
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
|
||||||
$pdf->SetTextColor(0,0,60);
|
}
|
||||||
|
}
|
||||||
// Add list of linked orders
|
else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->nom), 0, 'L');
|
||||||
// TODO mutualiser
|
|
||||||
$object->load_object_linked();
|
$pdf->SetFont('Arial','B',13);
|
||||||
|
$pdf->SetXY(100,$posy);
|
||||||
if ($conf->commande->enabled)
|
$pdf->SetTextColor(0,0,60);
|
||||||
{
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '' , 'R');
|
||||||
$outputlangs->load('orders');
|
$pdf->SetFont('Arial','',12);
|
||||||
foreach($object->linked_object as $key => $val)
|
|
||||||
{
|
$posy+=6;
|
||||||
if ($key == 'commande')
|
$pdf->SetXY(100,$posy);
|
||||||
{
|
$pdf->SetTextColor(0,0,60);
|
||||||
for ($i = 0; $i<sizeof($val);$i++)
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
|
||||||
{
|
$posy+=6;
|
||||||
$newobject=new Commande($this->db);
|
$pdf->SetXY(100,$posy);
|
||||||
$result=$newobject->fetch($val[$i]);
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
|
||||||
if ($result >= 0)
|
|
||||||
{
|
$pdf->SetTextColor(0,0,60);
|
||||||
$posy+=4;
|
|
||||||
$pdf->SetXY(100,$posy);
|
// Add list of linked orders
|
||||||
$pdf->SetFont('Arial','',9);
|
// TODO mutualiser
|
||||||
$text=$newobject->ref;
|
$object->load_object_linked();
|
||||||
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
|
|
||||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
if ($conf->commande->enabled)
|
||||||
}
|
{
|
||||||
}
|
$outputlangs->load('orders');
|
||||||
}
|
foreach($object->linked_object as $key => $val)
|
||||||
}
|
{
|
||||||
}
|
if ($key == 'commande')
|
||||||
|
{
|
||||||
if ($showadress)
|
for ($i = 0; $i<sizeof($val);$i++)
|
||||||
{
|
{
|
||||||
// Emetteur
|
$newobject=new Commande($this->db);
|
||||||
/* $posy=42;
|
$result=$newobject->fetch($val[$i]);
|
||||||
$hautcadre=40;
|
if ($result >= 0)
|
||||||
$pdf->SetTextColor(0,0,0);
|
{
|
||||||
$pdf->SetFont('Arial','',8);
|
$posy+=4;
|
||||||
$pdf->SetXY($this->marge_gauche,$posy-5);
|
$pdf->SetXY(100,$posy);
|
||||||
$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":");
|
$pdf->SetFont('Arial','',9);
|
||||||
|
$text=$newobject->ref;
|
||||||
|
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
|
||||||
$pdf->SetXY($this->marge_gauche,$posy);
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
||||||
$pdf->SetFillColor(230,230,230);
|
}
|
||||||
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$pdf->SetXY($this->marge_gauche+2,$posy+3);
|
}
|
||||||
|
|
||||||
// Nom emetteur
|
}
|
||||||
$pdf->SetTextColor(0,0,60);
|
|
||||||
$pdf->SetFont('Arial','B',11);
|
/**
|
||||||
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->nom), 0, 'L');
|
* \brief Show footer of page
|
||||||
|
* \param pdf PDF factory
|
||||||
// Sender properties
|
* \param object Object invoice
|
||||||
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
|
* \param outputlangs Object lang for output
|
||||||
|
* \remarks Need this->emetteur object
|
||||||
$pdf->SetFont('Arial','',9);
|
*/
|
||||||
$pdf->SetXY($this->marge_gauche+2,$posy+9);
|
function _pagefoot(&$pdf,$object,$outputlangs)
|
||||||
$pdf->MultiCell(80, 3, $carac_emetteur);
|
{
|
||||||
|
return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
|
||||||
// Client destinataire
|
}
|
||||||
$posy=42;
|
|
||||||
$pdf->SetTextColor(0,0,0);
|
|
||||||
$pdf->SetFont('Arial','',8);
|
|
||||||
$pdf->SetXY(102,$posy-5);
|
|
||||||
$pdf->MultiCell(80,5, $outputlangs->transnoentities("DeliveryAddress").":");
|
|
||||||
|
|
||||||
// Cadre client destinataire
|
|
||||||
$pdf->rect(100, $posy, 100, $hautcadre);
|
|
||||||
|
|
||||||
$object->fetch_client();
|
|
||||||
|
|
||||||
// Recipient name
|
|
||||||
if (! empty($usecontact))
|
|
||||||
{
|
|
||||||
// On peut utiliser le nom de la societe du contact
|
|
||||||
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
|
|
||||||
else $socname = $object->client->nom;
|
|
||||||
$carac_client_name=$outputlangs->convToOutputCharset($socname);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
|
|
||||||
}
|
|
||||||
|
|
||||||
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
|
|
||||||
|
|
||||||
// Show customer/recipient
|
|
||||||
$pdf->SetXY(102,$posy+3);
|
|
||||||
$pdf->SetFont('Arial','B',11);
|
|
||||||
$pdf->MultiCell(106,4, $carac_client_name, 0, 'L');
|
|
||||||
|
|
||||||
$pdf->SetFont('Arial','',9);
|
|
||||||
$pdf->SetXY(102,$posy+8);
|
|
||||||
$pdf->MultiCell(86,4, $carac_client);
|
|
||||||
*/ }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Show footer of page
|
|
||||||
* \param pdf PDF factory
|
|
||||||
* \param object Object invoice
|
|
||||||
* \param outputlangs Object lang for output
|
|
||||||
* \remarks Need this->emetteur object
|
|
||||||
*/
|
|
||||||
function _pagefoot(&$pdf,$object,$outputlangs)
|
|
||||||
{
|
|
||||||
return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user