--- /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/github_doc_generic_proposal_odt.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/client_doc_generic_proposal_odt.modules.php
@@ -38,21 +38,21 @@
*/
class doc_generic_proposal_odt extends ModelePDFPropales
{
- /**
- * @var Societe Issuer object that emits
- */
- 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 string Dolibarr version of the loaded document
- */
- public $version = 'dolibarr';
+ /**
+ * @var Company Issuer object that emits
+ */
+ public $emetteur;
+
+ /**
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
+
+ /**
+ * @var string Dolibarr version of the loaded document
+ */
+ public $version = 'dolibarr';
/**
@@ -65,7 +65,7 @@
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 templates";
@@ -110,7 +110,7 @@
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);
@@ -140,7 +140,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);
}
@@ -172,14 +173,13 @@
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 .= '
';
- // Set default template for different status of proposal
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
// Model for creation
@@ -205,11 +205,11 @@
$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 .= '
';
@@ -223,11 +223,11 @@
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.
*
- * @param Propal $object Object source to build document
+ * @param Propale $object Object source to build document
* @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
@@ -237,7 +237,7 @@
*/
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
@@ -277,8 +277,6 @@
}
}
- $object->fetch_thirdparty();
-
$dir = $conf->propal->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
@@ -307,10 +305,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;
@@ -335,14 +335,16 @@
$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)))) {
- $socobject = $object->contact;
- } else {
- $socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
- $contactobject = $object->contact;
- }
- } else {
+ // On peut utiliser le nom de la societe du contact
+ if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
+ else {
+ $socobject = $object->thirdparty;
+ // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+ $contactobject = $object->contact;
+ }
+ }
+ else
+ {
$socobject = $object->thirdparty;
}
// Make substitution
@@ -351,7 +353,7 @@
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
- '__TOTAL_VAT__' => $object->total_tva
+ '__TOTAL_VAT__' => $object->total_vat
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
@@ -369,7 +371,7 @@
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
- $odfHandler = new odf(
+ $odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->propal->multidir_temp[$object->entity],
@@ -378,7 +380,8 @@
'DELIMITER_RIGHT' => '}'
)
);
- } catch (Exception $e)
+ }
+ catch (Exception $e)
{
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
@@ -395,7 +398,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);
}
@@ -426,21 +430,25 @@
{
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;
@@ -459,12 +467,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);
}
@@ -473,7 +484,8 @@
}
$odfHandler->mergeSegment($listlines);
}
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
@@ -486,9 +498,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);
}
}
@@ -502,15 +515,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);
+ $odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error = $e->getMessage();
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
@@ -525,7 +539,9 @@
$this->result = array('fullpath'=>$file);
return 1; // Success
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
--- /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/github_pdf_azur.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/client_pdf_azur.modules.php
@@ -43,75 +43,75 @@
class pdf_azur extends ModelePDFPropales
{
/**
- * @var DoliDb Database handler
- */
- public $db;
-
- /**
- * @var string model name
- */
- public $name;
-
- /**
- * @var string model description (short text)
- */
- public $description;
-
- /**
- * @var string Save the name of generated file as the main doc when generating a doc with this template
- */
+ * @var DoliDb Database handler
+ */
+ public $db;
+
+ /**
+ * @var string model name
+ */
+ public $name;
+
+ /**
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var string 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 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;
/**
@@ -166,15 +166,17 @@
// Define position of columns
$this->posxdesc = $this->marge_gauche + 1;
- if (!empty($conf->global->PRODUCT_USE_UNITS))
+ if ($conf->global->PRODUCT_USE_UNITS)
{
$this->posxtva = 101;
$this->posxup = 118;
$this->posxqty = 135;
$this->posxunit = 151;
- } else {
- $this->posxtva = 106;
- $this->posxup = 122;
+ }
+ else
+ {
+ $this->posxtva = 110;
+ $this->posxup = 126;
$this->posxqty = 145;
$this->posxunit = 162;
}
@@ -200,21 +202,21 @@
$this->atleastonediscount = 0;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Function to build pdf onto disk
- *
- * @param Propal $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
+ // phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -237,13 +239,15 @@
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
- //var_dump($objphoto->ref);exit;
+ //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'); // default
+ }
+ 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
}
@@ -265,10 +269,14 @@
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette'];
- } else {
+ }
+ else
+ {
$filename = $obj['photo'];
}
- } else {
+ }
+ else
+ {
$filename = $obj['photo'];
}
@@ -295,7 +303,9 @@
{
$dir = $conf->propal->multidir_output[$conf->entity];
$file = $dir."/SPECIMEN.pdf";
- } else {
+ }
+ else
+ {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->propal->multidir_output[$object->entity]."/".$objectref;
$file = $dir."/".$objectref.".pdf";
@@ -324,22 +334,22 @@
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Create pdf instance
- $pdf = pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $pdf->SetAutoPageBreak(1, 0);
-
- 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 = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ 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;
@@ -364,14 +374,14 @@
}
if (empty($this->atleastonediscount))
{
- $delta = ($this->postotalht - $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
+ $delta = ($this->postotalht - $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
}
// New page
@@ -379,12 +389,12 @@
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
- $heightforinfotot = 40; // Height reserved to output the info and total part
- $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
- $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;
- //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+ $heightforinfotot = 40; // Height reserved to output the info and total part
+ $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
+ $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;
+ //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
@@ -392,11 +402,11 @@
$pdf->SetTextColor(0, 0, 0);
- $tab_top = 90 + $top_shift;
+ $tab_top = 90 + $top_shift;
$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)
@@ -429,18 +439,18 @@
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 (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
{
- $tmpuser = new User($this->db);
- $tmpuser->fetch($object->user_author_id);
- $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
- if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
- if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
+ $tmpuser = new User($this->db);
+ $tmpuser->fetch($object->user_author_id);
+ $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
+ if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
+ if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
}
if ($notetoshow)
{
@@ -499,7 +509,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']))
@@ -536,15 +547,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();
}
@@ -583,7 +598,7 @@
$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
- if (!empty($conf->global->PRODUCT_USE_UNITS))
+ if ($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
@@ -605,7 +620,7 @@
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
else $tvaligne = $object->lines[$i]->total_tva;
$localtax1ligne = $object->lines[$i]->total_localtax1;
@@ -626,11 +641,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)
@@ -661,7 +676,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);
@@ -675,7 +692,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);
@@ -692,7 +711,9 @@
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
}
@@ -714,7 +735,7 @@
// Customer signature area
if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
{
- $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
+ $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
}
// Pied de page
@@ -760,7 +781,9 @@
} elseif (!empty($conf->service->enabled)) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
}
- } else {
+ }
+ else
+ {
if (!empty($conf->product->enabled)) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
} elseif (!empty($conf->service->enabled)) {
@@ -802,8 +825,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))
@@ -812,46 +835,50 @@
$this->result = array('fullpath'=>$file);
return 1; // No error
- } else {
+ }
+ else
+ {
$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
- } else {
+ }
+ else
+ {
$this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
return 0;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show payments table
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object proposal
- * @param int $posy Position y in PDF
- * @param Translate $outputlangs Object langs for output
- * @return int <0 if KO, >0 if OK
+ * @param TCPDF $pdf Object PDF
+ * @param Object $object Object proposal
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
*/
protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{
- // phpcs:enable
+ // phpcs:enable
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show miscellaneous information (payment mode, payment term, ...)
*
* @param TCPDF $pdf Object PDF
- * @param Propal $object Object to show
+ * @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);
@@ -869,21 +896,22 @@
$posxval = 52;
- // Show shipping date
- if (!empty($object->delivery_date))
- {
- $outputlangs->load("sendings");
+ // Show shipping date
+ if (!empty($object->date_livraison))
+ {
+ $outputlangs->load("sendings");
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
$pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
+ $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
$pdf->MultiCell(80, 4, $dlp, 0, 'L');
- $posy = $pdf->GetY() + 1;
- } elseif ($object->availability_code || $object->availability) // Show availability conditions
+ $posy = $pdf->GetY() + 1;
+ }
+ elseif ($object->availability_code || $object->availability) // Show availability conditions
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -909,7 +937,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');
@@ -969,13 +997,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)
{
@@ -984,13 +1012,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;
- }
+ }
}
}
}
@@ -1019,20 +1047,20 @@
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show total to pay
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object propal
- * @param int $deja_regle Amount already paid
- * @param int $posy Start position
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
+ * @param int $deja_regle Montant deja regle
+ * @param int $posy Position depart
* @param Translate $outputlangs Objet langs
- * @return int Position for continuation
+ * @return int Position pour suite
*/
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
- // phpcs:enable
+ // phpcs:enable
global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1040,7 +1068,7 @@
$tab2_hl = 4;
$pdf->SetFont('', '', $default_font_size - 1);
- // Total table
+ // Tableau total
$col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format
{
@@ -1056,14 +1084,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($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))
@@ -1072,7 +1100,9 @@
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
{
// Nothing to do
- } else {
+ }
+ else
+ {
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
@@ -1104,7 +1134,7 @@
}
}
}
- //}
+ //}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1195,7 +1225,7 @@
}
}
}
- //}
+ //}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1205,7 +1235,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++;
@@ -1297,7 +1327,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)
@@ -1381,7 +1411,7 @@
$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
- if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+ if ($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1414,8 +1444,8 @@
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $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
@@ -1434,7 +1464,7 @@
// Show Draft Watermark
if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
{
- pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
}
$pdf->SetTextColor(0, 0, 60);
@@ -1455,20 +1485,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);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ else
+ {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
- } else {
+ }
+ else
+ {
$text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -1543,16 +1578,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(100, 3, $langs->trans("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(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
}
$posy += 2;
@@ -1618,8 +1653,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;
@@ -1663,9 +1699,9 @@
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
- * @param TCPDF $pdf PDF
- * @param Propal $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
@@ -1673,24 +1709,24 @@
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, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show area for the customer to sign
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object invoice
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
{
- // phpcs:enable
+ // phpcs:enable
global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$tab_top = $posy + 4;
--- /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/github_pdf_cyan.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/client_pdf_cyan.modules.php
@@ -41,88 +41,83 @@
*/
class pdf_cyan extends ModelePDFPropales
{
+ /**
+ * @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 string 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;
-
- /**
- * @var array of document table collumns
- */
- public $cols;
/**
@@ -169,12 +164,10 @@
if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
+ $this->posxdesc = $this->marge_gauche + 1;
$this->tabTitleHeight = 5; // default height
-
- // Use new system for position of columns, view $this->defineColumnField()
$this->tva = array();
$this->localtax1 = array();
@@ -183,35 +176,32 @@
$this->atleastonediscount = 0;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Function to build pdf onto disk
- *
- * @param Propal $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
+ * 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 page
+ // Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
- global $outputlangsbis;
- $outputlangsbis = null;
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", "dict", "companies", "bills", "products", "propal"));
@@ -221,7 +211,7 @@
$hidetop = 0;
if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
- $hidetop = $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
@@ -236,13 +226,15 @@
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
- //var_dump($objphoto->ref);exit;
+ //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'); // default
+ }
+ 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
}
@@ -264,10 +256,14 @@
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette'];
- } else {
+ }
+ else
+ {
$filename = $obj['photo'];
}
- } else {
+ }
+ else
+ {
$filename = $obj['photo'];
}
@@ -295,7 +291,9 @@
{
$dir = $conf->propal->multidir_output[$conf->entity];
$file = $dir."/SPECIMEN.pdf";
- } else {
+ }
+ else
+ {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->propal->multidir_output[$object->entity]."/".$objectref;
$file = $dir."/".$objectref.".pdf";
@@ -323,27 +321,23 @@
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);
-
- 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 = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ 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;
@@ -358,14 +352,14 @@
$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++;
- }
- }
+ // Does we have at least one line with discount $this->atleastonediscount
+ foreach ($object->lines as $line) {
+ if ($line->remise_percent) {
+ $this->atleastonediscount = true;
+ break;
+ }
+ }
+
// New page
@@ -373,25 +367,25 @@
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
- $heightforinfotot = 40; // Height reserved to output the info and total part
- $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
- $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)
- //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
-
- $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
+ $heightforinfotot = 40; // Height reserved to output the info and total part
+ $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
+ $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)
+ //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$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 = 90 + $top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm
$height_incoterms = 0;
- if (!empty($conf->incoterm->enabled))
+ if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
@@ -400,7 +394,7 @@
$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);
+ $nexY = $pdf->GetY();
$height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
@@ -411,7 +405,7 @@
}
}
- // Displays notes
+ // Affiche notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
@@ -425,19 +419,20 @@
}
}
- // 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 (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
{
- $tmpuser = new User($this->db);
- $tmpuser->fetch($object->user_author_id);
- $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
- if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
- if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
+ $tmpuser = new User($this->db);
+ $tmpuser->fetch($object->user_author_id);
+ $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
+ if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
+ if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
}
$tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
@@ -447,8 +442,8 @@
{
$tab_top -= 2;
- $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
- $pageposbeforenote = $pagenb;
+ $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);
@@ -465,102 +460,106 @@
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;
- }
+ $pdf->rollbackTransaction(true);
+
+ // prepar 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 previus 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 {
+ }
+ else
+ {
$height_note = 0;
}
- // Use new auto column system
+ // Use new auto collum system
$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
- // Table simulation to know the height of the title line
+ // Simulation de tableau pour connaitre la hauteur de la ligne de titre
$pdf->startTransaction();
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
$pdf->rollbackTransaction(true);
@@ -590,69 +589,76 @@
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 + $heightforsignature + $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;
+ // We start with Photo of product line
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
+ {
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $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'];
- }
+ 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 + $heightforsignature + $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
+ $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 + $heightforsignature + $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);
+ //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $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();
+ else
+ $showpricebeforepagebreak = 0;
+ }
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ $posYAfterDescription = $pdf->GetY();
}
$nexY = $pdf->GetY();
@@ -667,92 +673,85 @@
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
+ $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);
+ $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);
+ $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);
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
+ $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);
+ $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)
+ $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);
- }
-
- // 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);
- }
- }
- }
+ $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
+ '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
- // Collection of totals by value of vat in $this->tva["rate"] = total_tva
- if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+
+ // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
else $tvaligne = $object->lines[$i]->total_tva;
$localtax1ligne = $object->lines[$i]->total_localtax1;
@@ -773,26 +772,25 @@
&& (!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) {
+ $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) {
+ 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;
- if ($posYAfterImage > $posYAfterDescription) $nexY = max($nexY, $posYAfterImage);
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
// Add line
- if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
+ 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);
@@ -803,12 +801,16 @@
// Detect if some page were added automatically and output _tableau for past pages
- while ($pagenb < $pageposafter) {
+ 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);
+ if ($pagenb == $pageposbeforeprintlines)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ }
+ 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);
$pagenb++;
@@ -816,12 +818,15 @@
$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);
+ 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);
+ }
+ 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);
// New page
@@ -835,20 +840,22 @@
// Show square
if ($pagenb == $pageposbeforeprintlines)
{
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
}
- // Display infos area
+ // Affiche zone infos
$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
- // Display total zone
+ // Affiche zone totaux
$posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
- // Display payment area
+ // Affiche zone versements
/*
if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
{
@@ -859,10 +866,10 @@
// Customer signature area
if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
{
- $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
- }
-
- // Pagefoot
+ $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
+ }
+
+ // Pied de page
$this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
@@ -905,7 +912,9 @@
} elseif (!empty($conf->service->enabled)) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
}
- } else {
+ }
+ else
+ {
if (!empty($conf->product->enabled)) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
} elseif (!empty($conf->service->enabled)) {
@@ -947,8 +956,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))
@@ -957,11 +966,15 @@
$this->result = array('fullpath'=>$file);
return 1; // No error
- } else {
+ }
+ else
+ {
$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
- } else {
+ }
+ else
+ {
$this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
return 0;
}
@@ -970,11 +983,11 @@
/**
* Show payments table
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object proposal
- * @param int $posy Position y in PDF
- * @param Translate $outputlangs Object langs for output
- * @return int <0 if KO, >0 if OK
+ * @param TCPDF $pdf Object PDF
+ * @param Object $object Object proposal
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
*/
protected function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{
@@ -984,7 +997,7 @@
* Show miscellaneous information (payment mode, payment term, ...)
*
* @param TCPDF $pdf Object PDF
- * @param Propal $object Object to show
+ * @param Object $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
* @return int Pos y
@@ -1008,21 +1021,22 @@
$posxval = 52;
- // Show shipping date
- if (!empty($object->delivery_date))
+ // Show shipping date
+ if (!empty($object->date_livraison))
{
- $outputlangs->load("sendings");
+ $outputlangs->load("sendings");
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
$pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true);
+ $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
$pdf->MultiCell(80, 4, $dlp, 0, 'L');
- $posy = $pdf->GetY() + 1;
- } elseif ($object->availability_code || $object->availability) // Show availability conditions
+ $posy = $pdf->GetY() + 1;
+ }
+ elseif ($object->availability_code || $object->availability) // Show availability conditions
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1048,7 +1062,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');
@@ -1108,13 +1122,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)
{
@@ -1123,13 +1137,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;
- }
+ }
}
}
}
@@ -1137,10 +1151,10 @@
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
{
- if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER))
- {
- $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
- if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
+ if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
+ {
+ $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
+ if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
$account = new Account($this->db);
$account->fetch($bankid);
@@ -1161,55 +1175,54 @@
/**
* Show total to pay
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object proposal
- * @param int $deja_regle Amount already paid (in the currency of invoice)
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
+ * @param int $deja_regle Montant deja regle
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
- global $conf, $mysoc, $hookmanager;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('', '', $default_font_size - 1);
+
+ // Tableau total
+ $col1x = 120; $col2x = 170;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $col2x -= 20;
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+
+ $useborder = 0;
+ $index = 0;
$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);
-
- // Total table
- $col1x = 120; $col2x = 170;
- if ($this->page_largeur < 210) // To work with US executive format
- {
- $col2x -= 20;
- }
- $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
-
- $useborder = 0;
- $index = 0;
+ }
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
$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 + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($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))
@@ -1218,7 +1231,9 @@
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
{
// Nothing to do
- } else {
+ }
+ else
+ {
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
@@ -1251,7 +1266,7 @@
}
}
}
- //}
+ //}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1345,7 +1360,7 @@
}
}
}
- //}
+ //}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1355,7 +1370,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++;
@@ -1404,7 +1419,6 @@
if ($deja_regle > 0)
{
- // Already paid + Deposits
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1420,7 +1434,7 @@
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1);
@@ -1450,7 +1464,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)
@@ -1458,10 +1472,9 @@
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom bar of array
* @param string $currency Currency code
- * @param Translate $outputlangsbis Langs object bis
* @return void
*/
- protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
{
global $conf;
@@ -1479,10 +1492,6 @@
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
- $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
- }
-
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
@@ -1501,7 +1510,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
}
}
@@ -1509,14 +1518,13 @@
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $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
- * @param Translate $outputlangsbis Object lang for output bis
* @return void
*/
- protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
global $conf, $langs;
@@ -1528,18 +1536,16 @@
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
+ if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
{
- pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
}
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $w = 100;
-
$posy = $this->marge_haute;
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1553,21 +1559,27 @@
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);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ if (is_readable($logo))
+ {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ 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 {
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
+ }
+ else
+ {
$text = $this->emetteur->name;
- $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
}
@@ -1575,20 +1587,14 @@
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
- $pdf->MultiCell($w, 4, $title, '', 'R');
+ $pdf->MultiCell(100, 4, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
- if ($object->statut == $object::STATUS_DRAFT)
- {
- $pdf->SetTextColor(128, 0, 0);
- $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
- }
- $pdf->MultiCell($w, 4, $textref, '', 'R');
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
$posy += 1;
$pdf->SetFont('', '', $default_font_size - 2);
@@ -1598,7 +1604,7 @@
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
@@ -1628,39 +1634,34 @@
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
-
- $title = $outputlangs->transnoentities("DateEndPropal");
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
- $title .= ' - '.$outputlangsbis->transnoentities("DateEndPropal");
- }
- $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
if ($object->thirdparty->code_client)
{
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
}
// 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(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
}
$posy += 2;
@@ -1668,7 +1669,7 @@
$top_shift = 0;
// Show list of linked objects
$current_y = $pdf->getY();
- $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
+ $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
if ($current_y < $pdf->getY())
{
$top_shift = $pdf->getY() - $current_y;
@@ -1690,13 +1691,10 @@
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
- $posy += $top_shift;
+ $posy = 42 + $top_shift;
$posx = $this->marge_gauche;
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
-
- $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
- $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
+ $hautcadre = 40;
// Show sender frame
$pdf->SetTextColor(0, 0, 0);
@@ -1705,19 +1703,19 @@
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
- $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
$pdf->SetTextColor(0, 0, 60);
// Show sender name
$pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
$posy = $pdf->getY();
// Show sender information
$pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If CUSTOMER contact defined, we use it
@@ -1729,8 +1727,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;
@@ -1741,10 +1740,9 @@
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
// Show recipient
- $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
+ $widthrecbox = 100;
if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
- $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
- $posy += $top_shift;
+ $posy = 42 + $top_shift;
$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
@@ -1758,7 +1756,7 @@
// Show recipient name
$pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
$posy = $pdf->getY();
@@ -1775,9 +1773,9 @@
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
- * @param TCPDF $pdf PDF
- * @param Propal $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
@@ -1785,15 +1783,15 @@
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, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
/**
* Show area for the customer to sign
*
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object proposal
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
@@ -1828,30 +1826,30 @@
/**
* Define Array Column Field
*
- * @param Propal $object object proposal
+ * @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
- );
-
- /*
+ 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
@@ -1869,168 +1867,148 @@
);
*/
- $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_PROPOSALS_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['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, 1, 0.5, 1.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
+ ),
+ );
+
+ $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_PROPOSALS_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['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;
+ }
}
}