--- /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/github_doc_generic_invoice_odt.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/client_doc_generic_invoice_odt.modules.php
@@ -46,15 +46,15 @@
public $emetteur;
/**
- * @var array Minimum version of PHP required by module.
- * e.g.: PHP ≥ 5.6 = array(5, 6)
- */
- public $phpmin = array(5, 6);
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
/**
- * Dolibarr version of the loaded document
- * @var string
- */
+ * Dolibarr version of the loaded document
+ * @var string
+ */
public $version = 'dolibarr';
@@ -63,12 +63,12 @@
*
* @param DoliDB $db Database handler
*/
- public function __construct($db)
- {
+ public function __construct($db)
+ {
global $conf, $langs, $mysoc;
// Load translation files required by the page
- $langs->loadLangs(array("main", "companies"));
+ $langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT/ODS templates";
@@ -99,7 +99,7 @@
// Recupere emetteur
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
- }
+ }
/**
@@ -108,12 +108,12 @@
* @param Translate $langs Lang object to use for output
* @return string Description
*/
- public function info($langs)
- {
+ public function info($langs)
+ {
global $conf, $langs;
// Load translation files required by the page
- $langs->loadLangs(array("errors", "companies"));
+ $langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db);
@@ -137,7 +137,8 @@
unset($listofdir[$key]); continue;
}
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
- else {
+ else
+ {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
@@ -168,18 +169,18 @@
}
if ($nbofiles)
{
- $texte .= '
';
- // Show list of found files
- foreach ($listoffiles as $file) {
- $texte .= '- '.$file['name'].'
'.img_picto('', 'listlight').'';
+ $texte .= '
';
+ foreach ($listoffiles as $file)
+ {
+ $texte .= $file['name'].'
';
}
$texte .= '
';
}
- // Add input to upload a new template file.
- $texte .= '
'.$langs->trans("UploadNewTemplate").' ';
- $texte .= '';
- $texte .= '';
- $texte .= '
';
+ // Add input to upload a new template file.
+ $texte .= '
'.$langs->trans("UploadNewTemplate").' ';
+ $texte .= '';
+ $texte .= '';
+ $texte .= '
';
$texte .= '';
$texte .= '
';
@@ -191,9 +192,9 @@
$texte .= '';
return $texte;
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to build a document on disk using the generic odt module.
*
@@ -205,9 +206,9 @@
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
- public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
- {
- // phpcs:enable
+ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ // phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
@@ -247,8 +248,6 @@
}
}
- $object->fetch_thirdparty();
-
$dir = $conf->facture->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
@@ -277,10 +276,12 @@
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
- $format = $conf->global->MAIN_DOC_USE_TIMING;
- if ($format == '1') $format = '%Y%m%d%H%M%S';
+ $format = $conf->global->MAIN_DOC_USE_TIMING;
+ if ($format == '1') $format = '%Y%m%d%H%M%S';
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
- } else {
+ }
+ else
+ {
$filename = $newfiletmp.'.'.$newfileformat;
}
$file = $dir.'/'.$filename;
@@ -305,9 +306,10 @@
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ // On peut utiliser le nom de la societe du contact
+ if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
$socobject = $object->contact;
- } else {
+ else {
$socobject = $object->thirdparty;
// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
$contactobject = $object->contact;
@@ -346,7 +348,7 @@
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
- $odfHandler = new odf(
+ $odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->facture->dir_temp,
@@ -355,7 +357,8 @@
'DELIMITER_RIGHT' => '}'
)
);
- } catch (Exception $e)
+ }
+ catch (Exception $e)
{
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
@@ -371,7 +374,8 @@
// Make substitutions into odt of freetext
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@@ -405,21 +409,25 @@
//var_dump($value);exit;
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- } else // Text
+ }
+ else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Replace tags of lines
- try {
+ try
+ {
$foundtagforlines = 1;
try {
$listlines = $odfHandler->setSegment('lines');
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
@@ -438,12 +446,15 @@
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val)
{
- try {
+ try
+ {
$listlines->setVars($key, $val, true, 'UTF-8');
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
- } catch (SegmentException $e)
+ }
+ catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@@ -452,7 +463,8 @@
}
$odfHandler->mergeSegment($listlines);
}
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
@@ -465,9 +477,10 @@
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
@@ -481,15 +494,16 @@
$odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) {
$this->error = $e->getMessage();
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
- } else {
+ }
+ else {
try {
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error = $e->getMessage();
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
@@ -504,12 +518,14 @@
$this->result = array('fullpath'=>$file);
return 1; // Success
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
return -1;
- }
+ }
}
--- /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/github_pdf_crabe.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/client_pdf_crabe.modules.php
@@ -43,76 +43,76 @@
*/
class pdf_crabe extends ModelePDFFactures
{
- /**
- * @var DoliDb Database handler
- */
- public $db;
-
- /**
- * @var string model name
- */
- public $name;
-
- /**
- * @var string model description (short text)
- */
- public $description;
-
- /**
- * @var int Save the name of generated file as the main doc when generating a doc with this template
- */
- public $update_main_doc_field;
-
- /**
- * @var string document type
- */
- public $type;
-
- /**
- * @var array Minimum version of PHP required by module.
- * e.g.: PHP ≥ 5.6 = array(5, 6)
- */
- public $phpmin = array(5, 6);
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
+ /**
+ * @var string model name
+ */
+ public $name;
+
+ /**
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
+
+ /**
+ * @var string document type
+ */
+ public $type;
+
+ /**
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
+
+ /**
+ * Dolibarr version of the loaded document
+ * @var string
+ */
public $version = 'dolibarr';
/**
- * @var int page_largeur
- */
- public $page_largeur;
-
- /**
- * @var int page_hauteur
- */
- public $page_hauteur;
-
- /**
- * @var array format
- */
- public $format;
-
- /**
- * @var int marge_gauche
- */
+ * @var int page_largeur
+ */
+ public $page_largeur;
+
+ /**
+ * @var int page_hauteur
+ */
+ public $page_hauteur;
+
+ /**
+ * @var array format
+ */
+ public $format;
+
+ /**
+ * @var int marge_gauche
+ */
public $marge_gauche;
/**
- * @var int marge_droite
- */
+ * @var int marge_droite
+ */
public $marge_droite;
/**
- * @var int marge_haute
- */
+ * @var int marge_haute
+ */
public $marge_haute;
/**
- * @var int marge_basse
- */
+ * @var int marge_basse
+ */
public $marge_basse;
/**
@@ -183,7 +183,9 @@
$this->posxup = 118;
$this->posxqty = 135;
$this->posxunit = 151;
- } else {
+ }
+ else
+ {
$this->posxtva = 110;
$this->posxup = 126;
$this->posxqty = 145;
@@ -197,14 +199,14 @@
$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
- $this->posxpicture -= 20;
- $this->posxtva -= 20;
- $this->posxup -= 20;
- $this->posxqty -= 20;
- $this->posxunit -= 20;
- $this->posxdiscount -= 20;
- $this->posxprogress -= 20;
- $this->postotalht -= 20;
+ $this->posxpicture -= 20;
+ $this->posxtva -= 20;
+ $this->posxup -= 20;
+ $this->posxqty -= 20;
+ $this->posxunit -= 20;
+ $this->posxdiscount -= 20;
+ $this->posxprogress -= 20;
+ $this->postotalht -= 20;
}
$this->tva = array();
@@ -216,21 +218,21 @@
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Function to build pdf onto disk
- *
- * @param Facture $object Object to generate
- * @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Function to build pdf onto disk
+ *
+ * @param Object $object Object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
*/
- public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
@@ -276,16 +278,18 @@
{
$object->fetch_thirdparty();
- $deja_regle = $object->getSommePaiement((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_credit_notes_included = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_deposits_included = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
+ $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
// Definition of $dir and $file
if ($object->specimen)
{
$dir = $conf->facture->dir_output;
$file = $dir."/SPECIMEN.pdf";
- } else {
+ }
+ else
+ {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->facture->dir_output."/".$objectref;
$file = $dir."/".$objectref.".pdf";
@@ -318,28 +322,27 @@
// Create pdf instance
$pdf = pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $pdf->SetAutoPageBreak(1, 0);
-
- $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
- if ($heightforinfotot > 220) $heightforinfotot = 220;
- $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
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
-
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
-
- // Set path to the background PDF File
- if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
- $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
- $tplidx = $pdf->importPage(1);
- }
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment 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
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+
+ if (class_exists('TCPDF'))
+ {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+
+ // Set path to the background PDF File
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ {
+ $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
$pdf->Open();
$pagenb = 0;
@@ -354,7 +357,7 @@
// Set certificate
$cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
- // If user has no certificate, we try to take the company one
+ // If use has no certificate, we try to take the company one
if (!$cert) {
$cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
}
@@ -379,16 +382,16 @@
$this->atleastonediscount++;
}
}
- if (empty($this->atleastonediscount)) // retrieve space not used by discount
- {
- $delta = ($this->posxprogress - $this->posxdiscount);
- $this->posxpicture += $delta;
- $this->posxtva += $delta;
- $this->posxup += $delta;
- $this->posxqty += $delta;
- $this->posxunit += $delta;
- $this->posxdiscount += $delta;
- // post of fields after are not modified, stay at same position
+ if (empty($this->atleastonediscount)) // retreive space not used by discount
+ {
+ $delta = ($this->posxprogress - $this->posxdiscount);
+ $this->posxpicture += $delta;
+ $this->posxtva += $delta;
+ $this->posxup += $delta;
+ $this->posxqty += $delta;
+ $this->posxunit += $delta;
+ $this->posxdiscount += $delta;
+ // post of fields after are not modified, stay at same position
}
$progress_width = 0;
@@ -420,7 +423,7 @@
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm
- if (!empty($conf->incoterm->enabled))
+ if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
@@ -453,18 +456,17 @@
if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
- // Extrafields in note
- $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
- if (!empty($extranote)) {
- $notetoshow = dol_concatdesc($notetoshow, $extranote);
- }
+ // Extrafields in note
+ $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+ if (!empty($extranote)) {
+ $notetoshow = dol_concatdesc($notetoshow, $extranote);
+ }
if ($notetoshow)
{
$tab_top -= 2;
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
-
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
@@ -516,7 +518,8 @@
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
+ else
+ $showpricebeforepagebreak = 0;
}
if (isset($imglinesize['width']) && isset($imglinesize['height']))
@@ -552,15 +555,19 @@
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1);
}
- } else {
+ }
+ else
+ {
// We found a page break
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
+ else
+ $showpricebeforepagebreak = 0;
}
- } else // No pagebreak
+ }
+ else // No pagebreak
{
$pdf->commitTransaction();
}
@@ -608,17 +615,17 @@
// Discount on line
if ($object->lines[$i]->remise_percent)
{
- $pdf->SetXY($this->posxdiscount - 2, $curY);
- $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
- $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
+ $pdf->SetXY($this->posxdiscount - 2, $curY);
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+ $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
}
// Situation progress
if ($this->situationinvoice)
{
- $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
- $pdf->SetXY($this->posxprogress, $curY);
- $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
+ $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
+ $pdf->SetXY($this->posxprogress, $curY);
+ $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
}
// Total HT line
@@ -633,10 +640,10 @@
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
{
- if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
} else {
- if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
else $tvaligne = $sign * $object->lines[$i]->total_tva;
}
@@ -658,11 +665,11 @@
&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
- $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
- $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
- }
-
- // retrieve global local tax
+ $localtax1_type = $localtaxtmp_array[0];
+ $localtax2_type = $localtaxtmp_array[2];
+ }
+
+ // retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
@@ -693,7 +700,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -707,7 +716,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -724,7 +735,9 @@
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
@@ -756,8 +769,8 @@
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
}
if (!empty($conf->global->MAIN_UMASK))
@@ -766,11 +779,15 @@
$this->result = array('fullpath'=>$file);
return 1; // No error
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
return 0;
}
@@ -782,23 +799,23 @@
/**
* Show payments table
*
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object invoice
- * @param int $posy Position y in PDF
- * @param Translate $outputlangs Object langs for output
- * @param int $heightforfooter height for footer
- * @return int <0 if KO, >0 if OK
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object invoice
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @param int $heightforfooter height for footer
+ * @return int <0 if KO, >0 if OK
*/
protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $conf;
- $sign = 1;
- if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
$current_page = $pdf->getPage();
- $tab3_posx = 120;
+ $tab3_posx = 120;
$tab3_top = $posy + 8;
$tab3_width = 80;
$tab3_height = 4;
@@ -854,7 +871,7 @@
$pdf->SetXY($tab3_posx, $tab3_top + $y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
- $pdf->MultiCell(20, 3, price((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
$pdf->MultiCell(20, 3, $text, 0, 'L', 0);
$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
@@ -864,7 +881,9 @@
$i++;
}
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
return -1;
}
@@ -902,7 +921,7 @@
$pdf->SetXY($tab3_posx, $tab3_top + $y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
- $pdf->MultiCell(20, 3, price($sign * ((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
@@ -916,7 +935,9 @@
}
return $tab3_top + $y + 3;
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
return -1;
}
@@ -939,8 +960,8 @@
*/
protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
{
- // phpcs:enable
- $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
+ // phpcs:enable
+ $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
$pdf->SetFont('', '', $default_font_size - 3);
@@ -967,15 +988,15 @@
/**
* Show miscellaneous information (payment mode, payment term, ...)
*
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
* @return void
*/
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
- // phpcs:enable
+ // phpcs:enable
global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1004,7 +1025,7 @@
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
@@ -1087,13 +1108,13 @@
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
$posy = $pdf->GetY() + 2;
- }
+ }
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
{
@@ -1102,13 +1123,13 @@
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
$posy = $pdf->GetY() + 2;
- }
+ }
}
}
}
@@ -1141,7 +1162,7 @@
/**
* Show total to pay
*
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
* @param Facture $object Object invoice
* @param int $deja_regle Amount already paid (in the currency of invoice)
* @param int $posy Position depart
@@ -1150,13 +1171,13 @@
*/
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
- // phpcs:enable
+ // phpcs:enable
global $conf, $mysoc;
- $sign = 1;
- if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy;
$tab2_hl = 4;
@@ -1178,14 +1199,14 @@
$pdf->SetXY($col1x, $tab2_top + 0);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
$pdf->SetFillColor(248, 248, 248);
- $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$this->atleastoneratenotnull = 0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -1194,8 +1215,10 @@
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
{
// Nothing to do
- } else {
- // FIXME amount of vat not supported with multicurrency
+ }
+ else
+ {
+ // FIXME amount of vat not supported with multicurrency
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1229,7 +1252,7 @@
}
}
}
- //}
+ //}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1264,7 +1287,7 @@
}
}
- //}
+ //}
// VAT
foreach ($this->tva as $tvakey => $tvaval)
@@ -1321,7 +1344,7 @@
}
}
}
- //}
+ //}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1406,8 +1429,8 @@
}
$pdf->SetTextColor(0, 0, 0);
- $creditnoteamount = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
- $depositsamount = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
+ $creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
+ $depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
//print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (!empty($object->paye)) $resteapayer = 0;
@@ -1466,7 +1489,7 @@
/**
* Show table for lines
*
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
* @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle)
* @param int $nexY Y (not used)
@@ -1560,23 +1583,23 @@
if ($this->atleastonediscount)
{
- $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
+ $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
+ $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
$pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
- }
- }
-
- if ($this->situationinvoice) {
- $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
- if (empty($hidetop)) {
- $pdf->SetXY($this->posxprogress, $tab_top + 1);
- $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
- }
- }
-
- $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+ }
+ }
+
+ if ($this->situationinvoice) {
+ $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxprogress, $tab_top + 1);
+ $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
+ }
+ }
+
+ $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
@@ -1588,8 +1611,8 @@
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return void
@@ -1607,9 +1630,9 @@
// Show Draft Watermark
if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
- {
- pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
- }
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
+ }
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
@@ -1617,7 +1640,7 @@
$w = 110;
$posy = $this->marge_haute;
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - $w;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1631,20 +1654,25 @@
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
- } else {
+ }
+ else {
$logo = $logodir.'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
- $height = pdf_getHeightForLogo($logo);
+ $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ }
+ else
+ {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
- } else {
+ }
+ else
+ {
$text = $this->emetteur->name;
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -1658,7 +1686,7 @@
if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
- if ($this->situationinvoice) $title = $outputlangs->transnoentities("PDFInvoiceSituation");
+ if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
$pdf->MultiCell($w, 3, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
@@ -1773,16 +1801,16 @@
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
- $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
- if (count($arrayidcontact) > 0)
- {
- $usertmp = new User($this->db);
- $usertmp->fetch($arrayidcontact[0]);
- $posy += 4;
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
- }
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0)
+ {
+ $usertmp = new User($this->db);
+ $usertmp->fetch($arrayidcontact[0]);
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
}
$posy += 1;
@@ -1843,8 +1871,9 @@
$result = $object->fetch_contact($arrayidcontact[0]);
}
- // Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ //Recipient name
+ // On peut utiliser le nom de la societe du contact
+ if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
@@ -1889,9 +1918,9 @@
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
- * @param TCPDF $pdf PDF
- * @param Facture $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
@@ -1899,7 +1928,7 @@
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
}
--- /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/github_pdf_sponge.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/client_pdf_sponge.modules.php
@@ -43,82 +43,82 @@
*/
class pdf_sponge extends ModelePDFFactures
{
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
/**
- * @var DoliDb Database handler
- */
- public $db;
+ * @var string model name
+ */
+ public $name;
/**
- * @var string model name
- */
- public $name;
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
/**
- * @var string model description (short text)
- */
- public $description;
+ * @var string document type
+ */
+ public $type;
/**
- * @var int Save the name of generated file as the main doc when generating a doc with this template
- */
- public $update_main_doc_field;
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
/**
- * @var string document type
- */
- public $type;
+ * Dolibarr version of the loaded document
+ * @var string
+ */
+ public $version = 'dolibarr';
+
+ /**
+ * @var int page_largeur
+ */
+ public $page_largeur;
/**
- * @var array Minimum version of PHP required by module.
- * e.g.: PHP ≥ 5.6 = array(5, 6)
- */
- public $phpmin = array(5, 6);
+ * @var int page_hauteur
+ */
+ public $page_hauteur;
/**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
-
- /**
- * @var int page_largeur
- */
- public $page_largeur;
+ * @var array format
+ */
+ public $format;
/**
- * @var int page_hauteur
- */
- public $page_hauteur;
+ * @var int marge_gauche
+ */
+ public $marge_gauche;
/**
- * @var array format
- */
- public $format;
+ * @var int marge_droite
+ */
+ public $marge_droite;
/**
- * @var int marge_gauche
- */
- public $marge_gauche;
+ * @var int marge_haute
+ */
+ public $marge_haute;
/**
- * @var int marge_droite
- */
- public $marge_droite;
-
- /**
- * @var int marge_haute
- */
- public $marge_haute;
-
- /**
- * @var int marge_basse
- */
+ * @var int marge_basse
+ */
public $marge_basse;
- /**
- * Issuer
- * @var Societe Object that emits
- */
+ /**
+ * Issuer
+ * @var Societe Object that emits
+ */
public $emetteur;
/**
@@ -193,761 +193,771 @@
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Function to build pdf onto disk
- *
- * @param Facture $object Object to generate
- * @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Function to build pdf onto disk
+ *
+ * @param Object $object Object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
*/
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
- // phpcs:enable
- global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
-
- dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
-
- 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
- if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
-
- // Load translation files required by the page
- $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
-
- global $outputlangsbis;
- $outputlangsbis = null;
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
- $outputlangsbis = new Translate('', $conf);
- $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
- $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
- }
-
- $nblines = count($object->lines);
-
- $hidetop = 0;
- if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
- $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
- }
-
- // Loop on each lines to detect if there is at least one image to show
- $realpatharray = array();
- $this->atleastonephoto = false;
- if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
- {
- $objphoto = new Product($this->db);
-
- for ($i = 0; $i < $nblines; $i++)
- {
- if (empty($object->lines[$i]->fk_product)) continue;
-
- $objphoto->fetch($object->lines[$i]->fk_product);
- //var_dump($objphoto->ref);exit;
- if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
- {
- $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
- $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
- } else {
- $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
- $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
- }
-
- $arephoto = false;
- foreach ($pdir as $midir)
- {
- if (!$arephoto)
- {
- if ($conf->product->entity != $objphoto->entity) {
- $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
- } else {
- $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
- }
-
- foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
- {
- if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
- {
- if ($obj['photo_vignette'])
- {
- $filename = $obj['photo_vignette'];
- } else {
- $filename = $obj['photo'];
- }
- } else {
- $filename = $obj['photo'];
- }
-
- $realpath = $dir.$filename;
- $arephoto = true;
- $this->atleastonephoto = true;
- }
- }
- }
-
- if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
- }
- }
-
- //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
-
- if ($conf->facture->multidir_output[$conf->entity])
- {
- $object->fetch_thirdparty();
-
- $deja_regle = $object->getSommePaiement((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_credit_notes_included = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_deposits_included = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
-
- // Definition of $dir and $file
- if ($object->specimen)
- {
- $dir = $conf->facture->multidir_output[$conf->entity];
- $file = $dir."/SPECIMEN.pdf";
- } else {
- $objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->facture->multidir_output[$object->entity]."/".$objectref;
- $file = $dir."/".$objectref.".pdf";
- }
- if (!file_exists($dir))
- {
- if (dol_mkdir($dir) < 0)
- {
- $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
- return 0;
- }
- }
-
- 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
-
- // Set nblines with the new facture lines content after hook
- $nblines = count($object->lines);
- $nbpayments = count($object->getListOfPayments());
-
- // Create pdf instance
- $pdf = pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $pdf->SetAutoPageBreak(1, 0);
-
- $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment 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
- $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
-
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
-
- // Set path to the background PDF File
- if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
- $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
- $tplidx = $pdf->importPage(1);
- }
-
- $pdf->Open();
- $pagenb = 0;
- $pdf->SetDrawColor(128, 128, 128);
-
- $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
- $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
- $pdf->SetCreator("Dolibarr ".DOL_VERSION);
- $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
- $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
- if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
-
- // Set certificate
- $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
- // If user has no certificate, we try to take the company one
- if (!$cert) {
- $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
- }
- // If a certificate is found
- if ($cert) {
- $info = array(
- 'Name' => $this->emetteur->name,
- 'Location' => getCountry($this->emetteur->country_code, 0),
- 'Reason' => 'INVOICE',
- 'ContactInfo' => $this->emetteur->email
- );
- $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
- }
-
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
-
- // Set $this->atleastonediscount if you have at least one discount
- for ($i = 0; $i < $nblines; $i++)
- {
- if ($object->lines[$i]->remise_percent)
- {
- $this->atleastonediscount++;
- }
- }
-
-
- // Situation invoice handling
- if ($object->situation_cycle_ref)
- {
- $this->situationinvoice = true;
- }
-
- // New page
- $pdf->AddPage();
- if (!empty($tplidx)) $pdf->useTemplate($tplidx);
- $pagenb++;
-
- $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
- $pdf->SetTextColor(0, 0, 0);
-
- $tab_top = 90 + $top_shift;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
- $tab_height = 130 - $top_shift;
- $tab_height_newpage = 150;
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
-
- $nexY = $tab_top - 1;
-
- // Incoterm
- $height_incoterms = 0;
- if (!empty($conf->incoterm->enabled))
- {
- $desc_incoterms = $object->getIncotermsForPDF();
- if ($desc_incoterms)
- {
+ // phpcs:enable
+ global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
+
+ dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
+
+ 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
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
+
+ // Load translation files required by the page
+ $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
+
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
+ }
+
+ $nblines = count($object->lines);
+
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ }
+
+ // Loop on each lines to detect if there is at least one image to show
+ $realpatharray = array();
+ $this->atleastonephoto = false;
+ if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
+ {
+ $objphoto = new Product($this->db);
+
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if (empty($object->lines[$i]->fk_product)) continue;
+
+ $objphoto->fetch($object->lines[$i]->fk_product);
+ //var_dump($objphoto->ref);exit;
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ {
+ $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
+ $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
+ }
+ else
+ {
+ $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
+ $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
+ }
+
+ $arephoto = false;
+ foreach ($pdir as $midir)
+ {
+ if (!$arephoto)
+ {
+ $dir = $conf->product->dir_output.'/'.$midir;
+
+ foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
+ {
+ if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+ {
+ if ($obj['photo_vignette'])
+ {
+ $filename = $obj['photo_vignette'];
+ }
+ else
+ {
+ $filename = $obj['photo'];
+ }
+ }
+ else
+ {
+ $filename = $obj['photo'];
+ }
+
+ $realpath = $dir.$filename;
+ $arephoto = true;
+ $this->atleastonephoto = true;
+ }
+ }
+ }
+
+ if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
+ }
+ }
+
+ //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
+
+ if ($conf->facture->dir_output)
+ {
+ $object->fetch_thirdparty();
+
+ $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+
+ // Definition of $dir and $file
+ if ($object->specimen)
+ {
+ $dir = $conf->facture->dir_output;
+ $file = $dir."/SPECIMEN.pdf";
+ }
+ else
+ {
+ $objectref = dol_sanitizeFileName($object->ref);
+ $dir = $conf->facture->dir_output."/".$objectref;
+ $file = $dir."/".$objectref.".pdf";
+ }
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ }
+
+ 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
+
+ // Set nblines with the new facture lines content after hook
+ $nblines = count($object->lines);
+ $nbpayments = count($object->getListOfPayments());
+
+ // Create pdf instance
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment 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
+ $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
+
+ if (class_exists('TCPDF'))
+ {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+
+ // Set path to the background PDF File
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ {
+ $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
+
+ $pdf->Open();
+ $pagenb = 0;
+ $pdf->SetDrawColor(128, 128, 128);
+
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+
+ // Set certificate
+ $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
+ // If use has no certificate, we try to take the company one
+ if (!$cert) {
+ $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
+ }
+ // If a certificate is found
+ if ($cert) {
+ $info = array(
+ 'Name' => $this->emetteur->name,
+ 'Location' => getCountry($this->emetteur->country_code, 0),
+ 'Reason' => 'INVOICE',
+ 'ContactInfo' => $this->emetteur->email
+ );
+ $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
+ }
+
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+
+ // Does we have at least one line with discount $this->atleastonediscount
+ foreach ($object->lines as $line) {
+ if ($line->remise_percent) {
+ $this->atleastonediscount = true;
+ break;
+ }
+ }
+
+
+ // Situation invoice handling
+ if ($object->situation_cycle_ref)
+ {
+ $this->situationinvoice = true;
+ }
+
+ // New page
+ $pdf->AddPage();
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pagenb++;
+
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->SetTextColor(0, 0, 0);
+
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
+ $tab_height = 130 - $top_shift;
+ $tab_height_newpage = 150;
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
+
+ $nexY = $tab_top - 1;
+
+ // Incoterm
+ $height_incoterms = 0;
+ if ($conf->incoterm->enabled)
+ {
+ $desc_incoterms = $object->getIncotermsForPDF();
+ if ($desc_incoterms)
+ {
$tab_top -= 2;
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
- $nexY = max($pdf->GetY(), $nexY);
- $height_incoterms = $nexY - $tab_top;
-
- // Rect takes a length in 3rd parameter
- $pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
-
- $tab_top = $nexY + 6;
- $height_incoterms += 4;
- }
- }
-
- // Displays notes
- $notetoshow = empty($object->note_public) ? '' : $object->note_public;
- if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
- {
- // Get first sale rep
- if (is_object($object->thirdparty))
- {
- $salereparray = $object->thirdparty->getSalesRepresentatives($user);
- $salerepobj = new User($this->db);
- $salerepobj->fetch($salereparray[0]['id']);
- if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
- }
- }
-
- // Extrafields in note
- $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
- if (!empty($extranote)) {
- $notetoshow = dol_concatdesc($notetoshow, $extranote);
- }
-
- $pagenb = $pdf->getPage();
- if ($notetoshow)
- {
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $nexY = max($pdf->GetY(), $nexY);
+ $height_incoterms = $nexY - $tab_top;
+
+ // Rect takes a length in 3rd parameter
+ $pdf->SetDrawColor(192, 192, 192);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
+
+ $tab_top = $nexY + 6;
+ $height_incoterms += 4;
+ }
+ }
+
+ // Display notes
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ {
+ // Get first sale rep
+ if (is_object($object->thirdparty))
+ {
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
+ $salerepobj->fetch($salereparray[0]['id']);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
+ }
+ }
+
+ // Extrafields in note
+ $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+ if (!empty($extranote))
+ {
+ $notetoshow = dol_concatdesc($notetoshow, $extranote);
+ }
+
+ $pagenb = $pdf->getPage();
+ if ($notetoshow)
+ {
$tab_top -= 2;
- $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
- $pageposbeforenote = $pagenb;
-
- $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
- complete_substitutions_array($substitutionarray, $outputlangs, $object);
- $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
- $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
- $pdf->startTransaction();
-
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
- // Description
- $pageposafternote = $pdf->getPage();
- $posyafter = $pdf->GetY();
-
- if ($pageposafternote > $pageposbeforenote)
- {
- $pdf->rollbackTransaction(true);
-
- // prepare pages to receive notes
- while ($pagenb < $pageposafternote) {
- $pdf->AddPage();
- $pagenb++;
- if (!empty($tplidx)) $pdf->useTemplate($tplidx);
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- // $this->_pagefoot($pdf,$object,$outputlangs,1);
- $pdf->setTopMargin($tab_top_newpage);
- // The only function to edit the bottom margin of current page to set it.
- $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
- }
-
- // back to start
- $pdf->setPage($pageposbeforenote);
- $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
- $pageposafternote = $pdf->getPage();
-
- $posyafter = $pdf->GetY();
-
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text
- {
- $pdf->AddPage('', '', true);
- $pagenb++;
- $pageposafternote++;
- $pdf->setPage($pageposafternote);
- $pdf->setTopMargin($tab_top_newpage);
- // The only function to edit the bottom margin of current page to set it.
- $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
- //$posyafter = $tab_top_newpage;
- }
-
-
- // apply note frame to previous pages
- $i = $pageposbeforenote;
- while ($i < $pageposafternote) {
- $pdf->setPage($i);
-
-
- $pdf->SetDrawColor(128, 128, 128);
- // Draw note frame
- if ($i > $pageposbeforenote) {
- $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
- $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
- } else {
- $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
- $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
- }
-
- // Add footer
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
- $this->_pagefoot($pdf, $object, $outputlangs, 1);
-
- $i++;
- }
-
- // apply note frame to last page
- $pdf->setPage($pageposafternote);
- if (!empty($tplidx)) $pdf->useTemplate($tplidx);
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $height_note = $posyafter - $tab_top_newpage;
- $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
- } else // No pagebreak
- {
- $pdf->commitTransaction();
- $posyafter = $pdf->GetY();
- $height_note = $posyafter - $tab_top;
- $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
-
-
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
- {
- // not enough space, need to add page
- $pdf->AddPage('', '', true);
- $pagenb++;
- $pageposafternote++;
- $pdf->setPage($pageposafternote);
- if (!empty($tplidx)) $pdf->useTemplate($tplidx);
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-
- $posyafter = $tab_top_newpage;
- }
- }
-
- $tab_height = $tab_height - $height_note;
- $tab_top = $posyafter + 6;
- } else {
- $height_note = 0;
- }
-
- // Use new auto column system
- $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
-
- // Table simulation to know the height of the title line
- $pdf->startTransaction();
- $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
- $pdf->rollbackTransaction(true);
-
- $nexY = $tab_top + $this->tabTitleHeight;
-
- // Loop on each lines
- $pageposbeforeprintlines = $pdf->getPage();
- $pagenb = $pageposbeforeprintlines;
- for ($i = 0; $i < $nblines; $i++)
- {
- $curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
- $pdf->SetTextColor(0, 0, 0);
-
- // Define size of image if we need it
- $imglinesize = array();
- if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
-
- $pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore = $pdf->getPage();
-
- $showpricebeforepagebreak = 1;
- $posYAfterImage = 0;
- $posYAfterDescription = 0;
-
- if ($this->getColumnStatus('photo'))
- {
- // We start with Photo of product line
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
- {
- $pdf->AddPage('', '', true);
- if (!empty($tplidx)) $pdf->useTemplate($tplidx);
- $pdf->setPage($pageposbefore + 1);
-
- $curY = $tab_top_newpage;
+ $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
+ $pageposbeforenote = $pagenb;
+
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+ $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
+ $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
+
+ $pdf->startTransaction();
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ // Description
+ $pageposafternote = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+
+ if ($pageposafternote > $pageposbeforenote)
+ {
+ $pdf->rollbackTransaction(true);
+
+ // prepare pages to receive notes
+ while ($pagenb < $pageposafternote) {
+ $pdf->AddPage();
+ $pagenb++;
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ // $this->_pagefoot($pdf,$object,$outputlangs,1);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ }
+
+ // back to start
+ $pdf->setPage($pageposbeforenote);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pageposafternote = $pdf->getPage();
+
+ $posyafter = $pdf->GetY();
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text
+ {
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ //$posyafter = $tab_top_newpage;
+ }
+
+
+ // apply note frame to previous pages
+ $i = $pageposbeforenote;
+ while ($i < $pageposafternote) {
+ $pdf->setPage($i);
+
+
+ $pdf->SetDrawColor(128, 128, 128);
+ // Draw note frame
+ if ($i > $pageposbeforenote) {
+ $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ }
+ else {
+ $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+ }
+
+ // Add footer
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+
+ $i++;
+ }
+
+ // apply note frame to last page
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $height_note = $posyafter - $tab_top_newpage;
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ $posyafter = $pdf->GetY();
+ $height_note = $posyafter - $tab_top;
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
+ {
+ // not enough space, need to add page
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+
+ $posyafter = $tab_top_newpage;
+ }
+ }
+
+ $tab_height = $tab_height - $height_note;
+ $tab_top = $posyafter + 6;
+ }
+ else
+ {
+ $height_note = 0;
+ }
+
+ // Use new auto column system
+ $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
+
+ // Table simulation to know the height of the title line
+ $pdf->startTransaction();
+ $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
+ $pdf->rollbackTransaction(true);
+
+ $nexY = $tab_top + $this->tabTitleHeight;
+
+ // Loop on each lines
+ $pageposbeforeprintlines = $pdf->getPage();
+ $pagenb = $pageposbeforeprintlines;
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ $curY = $nexY;
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetTextColor(0, 0, 0);
+
+ // Define size of image if we need it
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
+
+ $pdf->setTopMargin($tab_top_newpage);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
+
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+
+ if ($this->getColumnStatus('photo'))
+ {
+ // We start with Photo of product line
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
+ {
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pdf->setPage($pageposbefore + 1);
+
+ $curY = $tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
- }
-
- if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
- {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
- // $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage = $curY + $imglinesize['height'];
- }
- }
-
- // Description of product line
- if ($this->getColumnStatus('desc'))
- {
- $pdf->startTransaction();
-
- $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
- $pageposafter = $pdf->getPage();
-
- if ($pageposafter > $pageposbefore) // There is a pagebreak
- {
- $pdf->rollbackTransaction(true);
- $pageposafter = $pageposbefore;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
-
- $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
-
- $pageposafter = $pdf->getPage();
- $posyafter = $pdf->GetY();
- //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
- {
- if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
- {
- $pdf->AddPage('', '', true);
- if (!empty($tplidx)) $pdf->useTemplate($tplidx);
- $pdf->setPage($pageposafter + 1);
- }
- } else {
- // We found a page break
+ else
+ $showpricebeforepagebreak = 0;
+ }
+
+ if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
+ {
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ // $pdf->Image does not increase value return by getY, so we save it manually
+ $posYAfterImage = $curY + $imglinesize['height'];
+ }
+ }
+
+ // Description of product line
+ if ($this->getColumnStatus('desc'))
+ {
+ $pdf->startTransaction();
+
+ $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+ $pageposafter = $pdf->getPage();
+
+ if ($pageposafter > $pageposbefore) // There is a pagebreak
+ {
+ $pdf->rollbackTransaction(true);
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+
+ $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
+ {
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
+ {
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pdf->setPage($pageposafter + 1);
+ }
+ }
+ else
+ {
+ // We found a page break
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
- }
- } else // No pagebreak
- {
- $pdf->commitTransaction();
- }
- $posYAfterDescription = $pdf->GetY();
- }
-
- $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
-
- $pageposafter = $pdf->getPage();
- $pdf->setPage($pageposbefore);
- $pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
-
- // We suppose that a too long description or photo were moved completely on next page
- if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
- $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
- }
-
- $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
-
- // VAT Rate
- if ($this->getColumnStatus('vat'))
- {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Unit price before discount
- if ($this->getColumnStatus('subprice'))
- {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Quantity
- // Enough for 6 chars
- if ($this->getColumnStatus('qty'))
- {
- $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Situation progress
- if ($this->getColumnStatus('progress'))
- {
- $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'progress', $progress);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Unit
- if ($this->getColumnStatus('unit'))
- {
- $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Discount on line
- if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
- {
- $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Total excl tax line (HT)
- if ($this->getColumnStatus('totalexcltax'))
- {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Total with tax line (TTC)
- if ($this->getColumnStatus('totalincltax'))
- {
- $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Extrafields
- if (!empty($object->lines[$i]->array_options)) {
- foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
- if ($this->getColumnStatus($extrafieldColKey))
- {
- $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
- $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
- $nexY = max($pdf->GetY(), $nexY);
- }
- }
- }
-
-
- $parameters = array(
- 'object' => $object,
- 'i' => $i,
- 'pdf' =>& $pdf,
- 'curY' =>& $curY,
- 'nexY' =>& $nexY,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails
- );
- $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
-
-
- $sign = 1;
- if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
- // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
- if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
- {
- if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
- else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
- } else {
- if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
- else $tvaligne = $sign * $object->lines[$i]->total_tva;
- }
-
- $localtax1ligne = $object->lines[$i]->total_localtax1;
- $localtax2ligne = $object->lines[$i]->total_localtax2;
- $localtax1_rate = $object->lines[$i]->localtax1_tx;
- $localtax2_rate = $object->lines[$i]->localtax2_tx;
- $localtax1_type = $object->lines[$i]->localtax1_type;
- $localtax2_type = $object->lines[$i]->localtax2_type;
-
- if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
- if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
- if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
-
- $vatrate = (string) $object->lines[$i]->tva_tx;
-
- // Retrieve type from database for backward compatibility with old records
- if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
- && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
- {
- $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
- $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
- $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
- }
-
- // retrieve global local tax
- if ($localtax1_type && $localtax1ligne != 0) {
- $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
- }
- if ($localtax2_type && $localtax2ligne != 0) {
- $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- }
-
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
- if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
- $this->tva[$vatrate] += $tvaligne;
-
- $nexY = max($nexY, $posYAfterImage);
-
- // Add line
- if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
- $pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
- //$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
- $pdf->SetLineStyle(array('dash'=>0));
- }
-
- // Detect if some page were added automatically and output _tableau for past pages
- while ($pagenb < $pageposafter) {
- $pdf->setPage($pagenb);
- if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
- }
- $this->_pagefoot($pdf, $object, $outputlangs, 1);
- $pagenb++;
- $pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- }
-
- if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
- if ($pagenb == $pageposafter) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
- }
- $this->_pagefoot($pdf, $object, $outputlangs, 1);
- // New page
- $pdf->AddPage();
- if (!empty($tplidx)) $pdf->useTemplate($tplidx);
- $pagenb++;
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- }
- }
-
- // Show square
- if ($pagenb == $pageposbeforeprintlines)
- {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
- $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
- $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- }
-
- // Display infos area
- $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
-
- // Display total zone
- $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
-
- // Display payment area
- if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
- {
- $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
- }
-
- // Pagefoot
- $this->_pagefoot($pdf, $object, $outputlangs);
- if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
-
- $pdf->Close();
-
- $pdf->Output($file, 'F');
-
- // Add pdfgeneration hook
- $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 ($reshook < 0)
- {
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
- }
-
- if (!empty($conf->global->MAIN_UMASK))
- @chmod($file, octdec($conf->global->MAIN_UMASK));
-
- $this->result = array('fullpath'=>$file);
-
- return 1; // No error
- } else {
- $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
- return 0;
- }
- } else {
- $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
- return 0;
- }
+ else
+ $showpricebeforepagebreak = 0;
+ }
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ }
+
+ $nexY = $pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $pdf->setPage($pageposbefore);
+ $pdf->setTopMargin($this->marge_haute);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+
+ // We suppose that a too long description or photo were moved completely on next page
+ if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
+ }
+
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+
+ // VAT Rate
+ if ($this->getColumnStatus('vat'))
+ {
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Unit price before discount
+ if ($this->getColumnStatus('subprice'))
+ {
+ $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Quantity
+ // Enough for 6 chars
+ if ($this->getColumnStatus('qty'))
+ {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Situation progress
+ if ($this->getColumnStatus('progress'))
+ {
+ $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'progress', $progress);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Unit
+ if ($this->getColumnStatus('unit'))
+ {
+ $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Discount on line
+ if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
+ {
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Total HT line
+ if ($this->getColumnStatus('totalexcltax'))
+ {
+ $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Extrafields
+ if (!empty($object->lines[$i]->array_options)) {
+ foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
+ if ($this->getColumnStatus($extrafieldColKey))
+ {
+ $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
+ $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+ }
+ }
+
+
+ $parameters = array(
+ 'object' => $object,
+ 'i' => $i,
+ 'pdf' =>& $pdf,
+ 'curY' =>& $curY,
+ 'nexY' =>& $nexY,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails
+ );
+ $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
+
+
+ $sign = 1;
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
+ $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
+ if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
+ {
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
+ else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
+ } else {
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $sign * $object->lines[$i]->total_tva;
+ }
+
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
+
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
+
+ $vatrate = (string) $object->lines[$i]->tva_tx;
+
+ // Retrieve type from database for backward compatibility with old records
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
+ {
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
+ $localtax1_type = $localtaxtmp_array[0];
+ $localtax2_type = $localtaxtmp_array[2];
+ }
+
+ // retrieve global local tax
+ if ($localtax1_type && $localtax1ligne != 0) {
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
+ }
+ if ($localtax2_type && $localtax2ligne != 0) {
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
+ }
+
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
+ $this->tva[$vatrate] += $tvaligne;
+
+ $nexY = max($nexY, $posYAfterImage);
+
+ // Add line
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
+ $pdf->setPage($pageposafter);
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
+ //$pdf->SetDrawColor(190,190,200);
+ $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
+ $pdf->SetLineStyle(array('dash'=>0));
+ }
+
+ // Detect if some page were added automatically and output _tableau for past pages
+ while ($pagenb < $pageposafter) {
+ $pdf->setPage($pagenb);
+ if ($pagenb == $pageposbeforeprintlines) {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
+ }
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ $pagenb++;
+ $pdf->setPage($pagenb);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
+ if ($pagenb == $pageposafter) {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
+ }
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ // New page
+ $pdf->AddPage();
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pagenb++;
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ }
+
+ // Show square
+ if ($pagenb == $pageposbeforeprintlines)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+
+ // Display infos area
+ $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
+
+ // Display total zone
+ $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+
+ // Display payment area
+ if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
+ {
+ $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
+ }
+
+ // Pagefoot
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
+
+ $pdf->Close();
+
+ $pdf->Output($file, 'F');
+
+ // Add pdfgeneration hook
+ $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 ($reshook < 0)
+ {
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
+ }
+
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ $this->result = array('fullpath'=>$file);
+
+ return 1; // No error
+ }
+ else
+ {
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ }
+ else
+ {
+ $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
+ return 0;
+ }
}
/**
* Show payments table
*
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object invoice
- * @param int $posy Position y in PDF
- * @param Translate $outputlangs Object langs for output
- * @return int <0 if KO, >0 if OK
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object invoice
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
*/
public function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{
global $conf;
- $sign = 1;
- if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
-
- $tab3_posx = 120;
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+
+ $tab3_posx = 120;
$tab3_top = $posy + 8;
$tab3_width = 80;
$tab3_height = 4;
@@ -1011,7 +1021,7 @@
$pdf->SetXY($tab3_posx, $tab3_top + $y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
- $pdf->MultiCell(20, 3, price((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
$pdf->MultiCell(20, 3, $text, 0, 'L', 0);
$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
@@ -1021,7 +1031,9 @@
$i++;
}
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
return -1;
}
@@ -1048,7 +1060,7 @@
$pdf->SetXY($tab3_posx, $tab3_top + $y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
- $pdf->MultiCell(20, 3, price($sign * ((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
@@ -1062,7 +1074,9 @@
}
return $tab3_top + $y + 3;
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
return -1;
}
@@ -1072,8 +1086,8 @@
/**
* Show miscellaneous information (payment mode, payment term, ...)
*
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
+ * @param tcpdf $pdf Object PDF
+ * @param Object $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
* @return int Pos y
@@ -1108,7 +1122,7 @@
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
@@ -1190,13 +1204,13 @@
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
$posy = $pdf->GetY() + 2;
- }
+ }
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
{
@@ -1205,13 +1219,13 @@
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
$posy = $pdf->GetY() + 2;
- }
+ }
}
}
}
@@ -1242,7 +1256,7 @@
/**
* Show total to pay
*
- * @param TCPDF $pdf Object PDF
+ * @param TCPDI $pdf Object PDF
* @param Facture $object Object invoice
* @param int $deja_regle Amount already paid (in the currency of invoice)
* @param int $posy Position depart
@@ -1253,20 +1267,20 @@
{
global $conf, $mysoc, $hookmanager;
- $sign = 1;
- if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- $outputlangsbis = null;
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
- $outputlangsbis = new Translate('', $conf);
- $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
- $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
- $default_font_size--;
- }
-
- $tab2_top = $posy;
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
+ $default_font_size--;
+ }
+
+ $tab2_top = $posy;
$tab2_hl = 4;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -1298,9 +1312,10 @@
}
if (!empty($i)) {
- $avancementGlobal = $percent / $i;
- } else {
- $avancementGlobal = 0;
+ $avancementGlobal = $percent / $i;
+ }
+ else {
+ $avancementGlobal = 0;
}
$object->fetchPreviousNextSituationInvoice();
@@ -1309,131 +1324,132 @@
$total_a_payer = 0;
$total_a_payer_ttc = 0;
foreach ($TPreviousIncoice as &$fac) {
- $total_a_payer += $fac->total_ht;
- $total_a_payer_ttc += $fac->total_ttc;
+ $total_a_payer += $fac->total_ht;
+ $total_a_payer_ttc += $fac->total_ttc;
}
$total_a_payer += $object->total_ht;
$total_a_payer_ttc += $object->total_ttc;
if (!empty($avancementGlobal)) {
- $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
- $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
- } else {
- $total_a_payer = 0;
- $total_a_payer_ttc = 0;
+ $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
+ $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
+ }
+ else {
+ $total_a_payer = 0;
+ $total_a_payer_ttc = 0;
}
$i = 1;
if (!empty($TPreviousIncoice)) {
- $pdf->setY($tab2_top);
- $posy = $pdf->GetY();
-
- foreach ($TPreviousIncoice as &$fac) {
- if ($posy > $this->page_hauteur - 4) {
- $this->_pagefoot($pdf, $object, $outputlangs, 1);
- $pdf->addPage();
- $pdf->setY($this->marge_haute);
- $posy = $pdf->GetY();
- }
-
- // cumul TVA précédent
- $index++;
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
-
- $pdf->SetXY($col2x, $posy);
-
- $facSign = '';
- if ($i > 1) {
- $facSign = $fac->total_ht >= 0 ? '+' : '';
- }
-
- $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
-
- $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
-
- $i++;
- $posy += $tab2_hl;
-
- $pdf->setY($posy);
- }
-
- // Display current total
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
-
- $pdf->SetXY($col2x, $posy);
- $facSign = '';
- if ($i > 1) {
- $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
- }
-
- if ($fac->type === facture::TYPE_CREDIT_NOTE) {
- $facSign = '-'; // les avoirs
- }
-
-
- $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
- $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
-
- $posy += $tab2_hl;
-
- // Display all total
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
-
- $pdf->SetXY($col2x, $posy);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
- $pdf->SetFont('', '', $default_font_size - 2);
-
- $posy += $tab2_hl;
-
- if ($posy > $this->page_hauteur - 4) {
- $pdf->addPage();
- $pdf->setY($this->marge_haute);
- $posy = $pdf->GetY();
- }
-
- $tab2_top = $posy;
- $index = 0;
+ $pdf->setY($tab2_top);
+ $posy = $pdf->GetY();
+
+ foreach ($TPreviousIncoice as &$fac) {
+ if ($posy > $this->page_hauteur - 4) {
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
+
+ // cumul TVA précédent
+ $index++;
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+
+ $facSign = '';
+ if ($i > 1) {
+ $facSign = $fac->total_ht >= 0 ? '+' : '';
+ }
+
+ $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
+
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+
+ $i++;
+ $posy += $tab2_hl;
+
+ $pdf->setY($posy);
+ }
+
+ // Display current total
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+ $facSign = '';
+ if ($i > 1) {
+ $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
+ }
+
+ if ($fac->type === facture::TYPE_CREDIT_NOTE) {
+ $facSign = '-'; // les avoirs
+ }
+
+
+ $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+
+ $posy += $tab2_hl;
+
+ // Display all total
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetFont('', '', $default_font_size - 2);
+
+ $posy += $tab2_hl;
+
+ if ($posy > $this->page_hauteur - 4) {
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
+
+ $tab2_top = $posy;
+ $index = 0;
}
$tab2_top += 3;
// Get Total HT
- $total_ht = (!empty($conf->multicurrency->enabled) && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
+ $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
// Total remise
$total_line_remise = 0;
foreach ($object->lines as $i => $line) {
- $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
- // Gestion remise sous forme de ligne négative
- if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
+ $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
+ // Gestion remise sous forme de ligne négative
+ if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
}
if ($total_line_remise > 0) {
- if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
-
- $index++;
- }
- // Show total NET before discount
- if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
-
- $index++;
- }
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
+
+ $index++;
+ }
+ // Show total NET before discount
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
+
+ $index++;
+ }
}
// Total HT
@@ -1441,14 +1457,14 @@
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
- $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
$pdf->SetFillColor(248, 248, 248);
- $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$this->atleastoneratenotnull = 0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -1457,8 +1473,10 @@
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
{
// Nothing to do
- } else {
- // FIXME amount of vat not supported with multicurrency
+ }
+ else
+ {
+ // FIXME amount of vat not supported with multicurrency
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1493,7 +1511,7 @@
}
}
}
- //}
+ //}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1526,7 +1544,7 @@
}
}
}
- //}
+ //}
// VAT
// Situations totals migth be wrong on huge amounts
@@ -1537,12 +1555,13 @@
}
if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
- if (!empty($sum_pdf_tva))
- {
+ if (!empty($sum_pdf_tva))
+ {
$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
- } else {
- $coef_fix_tva = 1;
- }
+ }
+ else {
+ $coef_fix_tva = 1;
+ }
foreach ($this->tva as $tvakey => $tvaval) {
@@ -1608,7 +1627,7 @@
}
}
}
- //}
+ //}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1618,7 +1637,7 @@
foreach ($localtax_rate as $tvakey => $tvaval)
{
- // retrieve global local tax
+ // retrieve global local tax
if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
@@ -1667,6 +1686,8 @@
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
+
+
// Retained warranty
if ($object->displayRetainedWarranty())
{
@@ -1700,8 +1721,8 @@
$pdf->SetTextColor(0, 0, 0);
- $creditnoteamount = $object->getSumCreditNotesUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
- $depositsamount = $object->getSumDepositsUsed((!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? 1 : 0);
+ $creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
+ $depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (!empty($object->paye)) $resteapayer = 0;
@@ -1727,7 +1748,7 @@
$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
}
- /*
+ // Escompte
if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
{
$index++;
@@ -1740,7 +1761,6 @@
$resteapayer = 0;
}
- */
$index++;
$pdf->SetTextColor(0, 0, 60);
@@ -1776,7 +1796,7 @@
/**
* Show table for lines
*
- * @param TCPDF $pdf Object PDF
+ * @param tcpdf $pdf Object PDF
* @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle)
* @param int $nexY Y (not used)
@@ -1828,7 +1848,7 @@
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
if (empty($hidetop)) {
- $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
}
}
@@ -1836,8 +1856,8 @@
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
+ * @param Tcpdf $pdf Object PDF
+ * @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @param Translate $outputlangsbis Object lang for output bis
@@ -1855,10 +1875,10 @@
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
- {
- pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
- }
+ if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
+ }
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
@@ -1866,7 +1886,7 @@
$w = 110;
$posy = $this->marge_haute;
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - $w;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1880,19 +1900,25 @@
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
- } else {
+ }
+ else {
$logo = $logodir.'/logos/'.$this->emetteur->logo;
}
- if (is_readable($logo)) {
- $height = pdf_getHeightForLogo($logo);
+ if (is_readable($logo))
+ {
+ $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ }
+ else
+ {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
- } else {
+ }
+ else
+ {
$text = $this->emetteur->name;
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -1906,13 +1932,14 @@
if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
- if ($this->situationinvoice) $title = $outputlangs->transnoentities("PDFInvoiceSituation");
+ if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
$title .= ' - ';
if ($object->type == 0) {
- if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities("PDFInvoiceSituation");
+ if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities("InvoiceSituation");
$title .= $outputlangsbis->transnoentities("PdfInvoiceTitle");
- } elseif ($object->type == 1) $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
+ }
+ elseif ($object->type == 1) $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
elseif ($object->type == 2) $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
elseif ($object->type == 3) $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
elseif ($object->type == 4) $title .= $outputlangsbis->transnoentities("InvoiceProForma");
@@ -1925,7 +1952,7 @@
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
- if ($object->statut == $object::STATUS_DRAFT)
+ if ($object->statut == Facture::STATUS_DRAFT)
{
$pdf->SetTextColor(128, 0, 0);
$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
@@ -2007,7 +2034,7 @@
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
$title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
}
- $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
{
@@ -2040,16 +2067,16 @@
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
- $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
- if (count($arrayidcontact) > 0)
- {
- $usertmp = new User($this->db);
- $usertmp->fetch($arrayidcontact[0]);
- $posy += 4;
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
- }
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0)
+ {
+ $usertmp = new User($this->db);
+ $usertmp->fetch($arrayidcontact[0]);
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
}
$posy += 1;
@@ -2099,7 +2126,7 @@
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
- // If BILLING contact defined, we use it
+ // If BILLING contact defined on invoice, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'BILLING');
if (count($arrayidcontact) > 0)
@@ -2108,8 +2135,9 @@
$result = $object->fetch_contact($arrayidcontact[0]);
}
- // Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ //Recipient name
+ // On peut utiliser le nom de la societe du contact
+ if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
@@ -2154,9 +2182,9 @@
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
- * @param TCPDF $pdf PDF
- * @param Facture $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
@@ -2164,37 +2192,37 @@
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
/**
* Define Array Column Field
*
- * @param Facture $object common object
- * @param Translate $outputlangs langs
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return null
- */
- public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
- {
- global $conf, $hookmanager;
-
- // Default field style for content
- $this->defaultContentsFieldsStyle = array(
- 'align' => 'R', // R,C,L
- 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
-
- // Default field style for content
- $this->defaultTitlesFieldsStyle = array(
- 'align' => 'C', // R,C,L
- 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
-
- /*
+ * @param object $object common object
+ * @param Translate $outputlangs langs
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return null
+ */
+ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ global $conf, $hookmanager;
+
+ // Default field style for content
+ $this->defaultContentsFieldsStyle = array(
+ 'align' => 'R', // R,C,L
+ 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ // Default field style for content
+ $this->defaultTitlesFieldsStyle = array(
+ 'align' => 'C', // R,C,L
+ 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ /*
* For exemple
$this->cols['theColKey'] = array(
'rank' => $rank, // int : use for ordering columns
@@ -2212,184 +2240,165 @@
);
*/
- $rank = 0; // do not use negative rank
- $this->cols['desc'] = array(
- 'rank' => $rank,
- 'width' => false, // only for desc
- 'status' => true,
- 'title' => array(
- 'textkey' => 'Designation', // use lang key is usefull in somme case with module
- 'align' => 'L',
- // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
- // 'label' => ' ', // the final label
- 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- 'content' => array(
- 'align' => 'L',
- 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- );
-
- // Image of product
- $rank = $rank + 10;
- $this->cols['photo'] = array(
- 'rank' => $rank,
- 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Photo',
- 'label' => ' '
- ),
- 'content' => array(
- 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- 'border-left' => false, // remove left line separator
- );
-
- if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
- {
- $this->cols['photo']['status'] = true;
- }
-
-
- $rank = $rank + 10;
- $this->cols['vat'] = array(
- 'rank' => $rank,
- 'status' => false,
- 'width' => 16, // in mm
- 'title' => array(
- 'textkey' => 'VAT'
- ),
- 'border-left' => true, // add left line separator
- );
-
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
- {
- $this->cols['vat']['status'] = true;
- }
-
- $rank = $rank + 10;
- $this->cols['subprice'] = array(
- 'rank' => $rank,
- 'width' => 19, // in mm
- 'status' => true,
- 'title' => array(
- 'textkey' => 'PriceUHT'
- ),
- 'border-left' => true, // add left line separator
- );
-
- // Adapt dynamically the width of subprice, if text is too long.
- $tmpwidth = 0;
- $nblines = count($object->lines);
- for ($i = 0; $i < $nblines; $i++) {
- $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
- $tmpwidth = max($tmpwidth, $tmpwidth2);
- }
- if ($tmpwidth > 10) {
- $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
- }
-
- $rank = $rank + 10;
- $this->cols['qty'] = array(
- 'rank' => $rank,
- 'width' => 16, // in mm
- 'status' => true,
- 'title' => array(
- 'textkey' => 'Qty'
- ),
- 'border-left' => true, // add left line separator
- );
-
- $rank = $rank + 10;
- $this->cols['progress'] = array(
- 'rank' => $rank,
- 'width' => 19, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Progress'
- ),
- 'border-left' => true, // add left line separator
- );
-
- if ($this->situationinvoice)
- {
- $this->cols['progress']['status'] = true;
- }
-
- $rank = $rank + 10;
- $this->cols['unit'] = array(
- 'rank' => $rank,
- 'width' => 11, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Unit'
- ),
- 'border-left' => true, // add left line separator
- );
- if (!empty($conf->global->PRODUCT_USE_UNITS)) {
- $this->cols['unit']['status'] = true;
- }
-
- $rank = $rank + 10;
- $this->cols['discount'] = array(
- 'rank' => $rank,
- 'width' => 13, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'ReductionShort'
- ),
- 'border-left' => true, // add left line separator
- );
- if ($this->atleastonediscount) {
- $this->cols['discount']['status'] = true;
- }
-
- $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
- $this->cols['totalexcltax'] = array(
- 'rank' => $rank,
- 'width' => 26, // in mm
- 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false,
- 'title' => array(
- 'textkey' => 'TotalHT'
- ),
- 'border-left' => true, // add left line separator
- );
-
- $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
- $this->cols['totalincltax'] = array(
- 'rank' => $rank,
- 'width' => 26, // in mm
- 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true,
- 'title' => array(
- 'textkey' => 'TotalTTC'
- ),
- 'border-left' => true, // add left line separator
- );
-
- // Add extrafields cols
- if (!empty($object->lines)) {
- $line = reset($object->lines);
- $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
- }
-
- $parameters = array(
- 'object' => $object,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails,
- 'hidedesc' => $hidedesc,
- 'hideref' => $hideref
- );
-
- $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
- if ($reshook < 0)
- {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- } elseif (empty($reshook))
- {
- $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
- } else {
- $this->cols = $hookmanager->resArray;
- }
+ $rank = 0; // do not use negative rank
+ $this->cols['desc'] = array(
+ 'rank' => $rank,
+ 'width' => false, // only for desc
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Designation', // use lang key is usefull in somme case with module
+ 'align' => 'L',
+ // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+ // 'label' => ' ', // the final label
+ 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'content' => array(
+ 'align' => 'L',
+ 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ );
+
+ // PHOTO
+ $rank = $rank + 10;
+ $this->cols['photo'] = array(
+ 'rank' => $rank,
+ 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Photo',
+ 'label' => ' '
+ ),
+ 'content' => array(
+ 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'border-left' => false, // remove left line separator
+ );
+
+ if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
+ {
+ $this->cols['photo']['status'] = true;
+ }
+
+
+ $rank = $rank + 10;
+ $this->cols['vat'] = array(
+ 'rank' => $rank,
+ 'status' => false,
+ 'width' => 16, // in mm
+ 'title' => array(
+ 'textkey' => 'VAT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
+ {
+ $this->cols['vat']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['subprice'] = array(
+ 'rank' => $rank,
+ 'width' => 19, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'PriceUHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ $rank = $rank + 10;
+ $this->cols['qty'] = array(
+ 'rank' => $rank,
+ 'width' => 16, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Qty'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ $rank = $rank + 10;
+ $this->cols['progress'] = array(
+ 'rank' => $rank,
+ 'width' => 19, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Progress'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ if ($this->situationinvoice)
+ {
+ $this->cols['progress']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['unit'] = array(
+ 'rank' => $rank,
+ 'width' => 11, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Unit'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if ($conf->global->PRODUCT_USE_UNITS) {
+ $this->cols['unit']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['discount'] = array(
+ 'rank' => $rank,
+ 'width' => 13, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'ReductionShort'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if ($this->atleastonediscount) {
+ $this->cols['discount']['status'] = true;
+ }
+
+ $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
+ $this->cols['totalexcltax'] = array(
+ 'rank' => $rank,
+ 'width' => 26, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'TotalHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ // Add extrafields cols
+ if (!empty($object->lines)) {
+ $line = reset($object->lines);
+ $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
+ }
+
+ $parameters = array(
+ 'object' => $object,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails,
+ 'hidedesc' => $hidedesc,
+ 'hideref' => $hideref
+ );
+
+ $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
+ if ($reshook < 0)
+ {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ }
+ elseif (empty($reshook))
+ {
+ $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
+ }
+ else
+ {
+ $this->cols = $hookmanager->resArray;
+ }
}
}
|