Standardize pdf templates
This commit is contained in:
parent
85825a0104
commit
4a3a3190ea
@ -2017,7 +2017,25 @@ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0)
|
||||
if ($object->lines[$i]->special_code == 3)
|
||||
{
|
||||
$result .= $outputlangs->transnoentities("Option");
|
||||
} elseif (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht) * ($object->lines[$i]->tva_tx) / 100, 0, $outputlangs);
|
||||
}
|
||||
if (empty($hidedetails) || $hidedetails > 1)
|
||||
{
|
||||
$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc);
|
||||
if ($object->lines[$i]->situation_percent > 0)
|
||||
{
|
||||
// TODO Remove this. The total should be saved correctly in database instead of being modified here.
|
||||
$prev_progress = 0;
|
||||
$progress = 1;
|
||||
if (method_exists($object->lines[$i], 'get_prev_progress'))
|
||||
{
|
||||
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
|
||||
$progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
|
||||
}
|
||||
$result .= price($sign * ($total_ttc / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
|
||||
} else {
|
||||
$result .= price($sign * $total_ttc, 0, $outputlangs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -224,9 +224,16 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
// Load translation files required by the page
|
||||
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
|
||||
|
||||
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", "orders", "deliveries"));
|
||||
}
|
||||
|
||||
$nblines = count($object->lines);
|
||||
|
||||
if ($conf->commande->dir_output)
|
||||
if ($conf->commande->multidir_output[$conf->entity])
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
@ -325,7 +332,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->AddPage();
|
||||
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
$pagenb++;
|
||||
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
|
||||
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
@ -335,6 +342,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
|
||||
|
||||
// Incoterm
|
||||
$height_incoterms = 0;
|
||||
if ($conf->incoterm->enabled)
|
||||
{
|
||||
$desc_incoterms = $object->getIncotermsForPDF();
|
||||
@ -585,15 +593,17 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
}
|
||||
|
||||
// Show square
|
||||
if ($pagenb == 1)
|
||||
if ($pagenb == 1) {
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
|
||||
else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
|
||||
} else {
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
|
||||
}
|
||||
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
|
||||
// Affiche zone infos
|
||||
// Display infos area
|
||||
$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone totaux
|
||||
// Display total zone
|
||||
$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone versements
|
||||
@ -664,7 +674,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
* @param Object $object Object to show
|
||||
* @param int $posy Y
|
||||
* @param Translate $outputlangs Langs object
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
|
||||
{
|
||||
@ -783,20 +793,22 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
// Si mode reglement non force ou si force a CHQ
|
||||
if (!empty($conf->global->FACTURE_CHQ_NUMBER))
|
||||
{
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
|
||||
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
|
||||
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
|
||||
{
|
||||
$account = new Account($this->db);
|
||||
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
|
||||
$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))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', '', $default_font_size - 3);
|
||||
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 2;
|
||||
}
|
||||
@ -804,14 +816,14 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
|
||||
$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))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', '', $default_font_size - 3);
|
||||
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 2;
|
||||
}
|
||||
@ -822,10 +834,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
// 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 (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
|
||||
if ($object->fk_account > 0 || $object->fk_bank > 0 || !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
|
||||
$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
|
||||
$account = new Account($this->db);
|
||||
$account->fetch($bankid);
|
||||
|
||||
@ -856,15 +868,23 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $mysoc;
|
||||
global $conf, $mysoc, $hookmanager;
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$outputlangsbis = null;
|
||||
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
|
||||
$outputlangsbis = new Translate('', $conf);
|
||||
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
|
||||
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
|
||||
$default_font_size--;
|
||||
}
|
||||
|
||||
$tab2_top = $posy;
|
||||
$tab2_hl = 4;
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
|
||||
// Tableau total
|
||||
// Total table
|
||||
$col1x = 120; $col2x = 170;
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
{
|
||||
@ -878,7 +898,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
// Total HT
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
|
||||
|
||||
$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);
|
||||
@ -918,7 +938,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$tvakey = str_replace('*', '', $tvakey);
|
||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||
}
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
|
||||
$totalvat .= ' ';
|
||||
$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||
|
||||
@ -949,7 +970,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$tvakey = str_replace('*', '', $tvakey);
|
||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||
}
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
|
||||
$totalvat .= ' ';
|
||||
$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||
|
||||
@ -975,7 +997,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$tvakey = str_replace('*', '', $tvakey);
|
||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||
}
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
|
||||
$totalvat .= ' ';
|
||||
$totalvat .= vatrate($tvakey, 1).$tvacompl;
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||
|
||||
@ -1006,8 +1029,9 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$tvakey = str_replace('*', '', $tvakey);
|
||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||
}
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
|
||||
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
|
||||
$totalvat .= ' ';
|
||||
|
||||
$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
@ -1025,6 +1049,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
|
||||
foreach ($localtax_rate as $tvakey => $tvaval)
|
||||
{
|
||||
// retrieve global local tax
|
||||
if ($tvakey != 0) // On affiche pas taux 0
|
||||
{
|
||||
//$this->atleastoneratenotnull++;
|
||||
@ -1038,8 +1063,9 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$tvakey = str_replace('*', '', $tvakey);
|
||||
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
|
||||
}
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
|
||||
|
||||
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
|
||||
$totalvat .= ' ';
|
||||
|
||||
$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
|
||||
|
||||
@ -1055,7 +1081,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->SetFillColor(224, 224, 224);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalTTC", $mysoc->country_code) : ''), $useborder, 'L', 1);
|
||||
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
|
||||
@ -1078,7 +1104,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$index++;
|
||||
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
|
||||
|
||||
@ -1086,7 +1112,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->SetFillColor(224, 224, 224);
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1);
|
||||
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
|
||||
@ -1111,9 +1137,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
* @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 = '')
|
||||
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -1131,6 +1158,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
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);
|
||||
|
||||
@ -1214,10 +1245,11 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
* @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
|
||||
* @param string $titlekey Translation key to show as title of document
|
||||
* @return int Return topshift value
|
||||
*/
|
||||
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
|
||||
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $hookmanager;
|
||||
@ -1238,8 +1270,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$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 - 100;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $w;
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
|
||||
@ -1263,12 +1297,12 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
} 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');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
|
||||
}
|
||||
} else {
|
||||
$text = $this->emetteur->name;
|
||||
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1276,7 +1310,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$title = $outputlangs->transnoentities($titlekey);
|
||||
$pdf->MultiCell(100, 3, $title, '', 'R');
|
||||
$pdf->MultiCell($w, 3, $title, '', 'R');
|
||||
|
||||
$pdf->SetFont('', 'B', $default_font_size);
|
||||
|
||||
@ -1293,7 +1327,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$posy += 5;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
|
||||
@ -1323,14 +1357,14 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
|
||||
|
||||
if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
|
||||
{
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
}
|
||||
|
||||
// Get contact
|
||||
@ -1344,7 +1378,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1353,7 +1387,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$top_shift = 0;
|
||||
// Show list of linked objects
|
||||
$current_y = $pdf->getY();
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
|
||||
if ($current_y < $pdf->getY())
|
||||
{
|
||||
$top_shift = $pdf->getY() - $current_y;
|
||||
@ -1402,8 +1436,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
|
||||
|
||||
|
||||
|
||||
// If CUSTOMER contact defined on order, we use it
|
||||
// If CUSTOMER contact defined, we use it
|
||||
$usecontact = false;
|
||||
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
|
||||
if (count($arrayidcontact) > 0)
|
||||
@ -1425,9 +1458,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
|
||||
|
||||
// Show recipient
|
||||
$widthrecbox = 100;
|
||||
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
|
||||
if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
|
||||
$posy = 42 + $top_shift;
|
||||
$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
|
||||
$posy += $top_shift;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
|
||||
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
|
||||
|
||||
@ -1441,7 +1475,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
// Show recipient name
|
||||
$pdf->SetXY($posx + 2, $posy + 3);
|
||||
$pdf->SetFont('', 'B', $default_font_size);
|
||||
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
|
||||
$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
|
||||
|
||||
$posy = $pdf->getY();
|
||||
|
||||
|
||||
@ -120,7 +120,12 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
*/
|
||||
public $emetteur;
|
||||
|
||||
|
||||
/**
|
||||
* @var array of document table collumns
|
||||
*/
|
||||
public $cols;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -165,11 +170,13 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
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;
|
||||
$this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
|
||||
|
||||
|
||||
$this->tabTitleHeight = 5; // default height
|
||||
|
||||
// Use new system for position of columns, view $this->defineColumnField()
|
||||
|
||||
$this->tva = array();
|
||||
$this->localtax1 = array();
|
||||
$this->localtax2 = array();
|
||||
@ -242,7 +249,11 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
{
|
||||
if (!$arephoto)
|
||||
{
|
||||
$dir = $conf->product->dir_output.'/'.$midir;
|
||||
if ($conf->product->entity != $objphoto->entity) {
|
||||
$dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
|
||||
} else {
|
||||
$dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
|
||||
}
|
||||
|
||||
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
|
||||
{
|
||||
@ -271,7 +282,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
|
||||
|
||||
|
||||
if ($conf->commande->dir_output)
|
||||
if ($conf->commande->multidir_output[$conf->entity])
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
@ -345,20 +356,21 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
|
||||
/// Does we have at least one line with discount $this->atleastonediscount
|
||||
foreach ($object->lines as $line) {
|
||||
if ($line->remise_percent) {
|
||||
$this->atleastonediscount = true;
|
||||
break;
|
||||
}
|
||||
// Set $this->atleastonediscount if you have at least one discount
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
if ($object->lines[$i]->remise_percent)
|
||||
{
|
||||
$this->atleastonediscount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
$pagenb++;
|
||||
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
|
||||
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
@ -368,6 +380,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
|
||||
|
||||
// Incoterm
|
||||
$height_incoterms = 0;
|
||||
if ($conf->incoterm->enabled)
|
||||
{
|
||||
$desc_incoterms = $object->getIncotermsForPDF();
|
||||
@ -404,15 +417,16 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
|
||||
// Extrafields in note
|
||||
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
|
||||
if (!empty($extranote))
|
||||
{
|
||||
if (!empty($extranote)) {
|
||||
$notetoshow = dol_concatdesc($notetoshow, $extranote);
|
||||
}
|
||||
|
||||
$pagenb = $pdf->getPage();
|
||||
if ($notetoshow)
|
||||
{
|
||||
$tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
|
||||
$tab_top -= 2;
|
||||
|
||||
$tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
|
||||
$pageposbeforenote = $pagenb;
|
||||
|
||||
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
|
||||
@ -420,8 +434,6 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
|
||||
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
|
||||
|
||||
$tab_top -= 2;
|
||||
|
||||
$pdf->startTransaction();
|
||||
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
@ -582,6 +594,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
}
|
||||
}
|
||||
|
||||
// Description of product line
|
||||
if ($this->getColumnStatus('desc'))
|
||||
{
|
||||
$pdf->startTransaction();
|
||||
@ -632,7 +645,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$pdf->setTopMargin($this->marge_haute);
|
||||
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
|
||||
|
||||
// We suppose that a too long description is moved completely on next page
|
||||
// We suppose that a too long description or photo were moved completely on next page
|
||||
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
|
||||
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
|
||||
}
|
||||
@ -681,7 +694,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$nexY = max($pdf->GetY(), $nexY);
|
||||
}
|
||||
|
||||
// Total HT line
|
||||
// Total excl tax line (HT)
|
||||
if ($this->getColumnStatus('totalexcltax'))
|
||||
{
|
||||
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
|
||||
@ -689,7 +702,15 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$nexY = max($pdf->GetY(), $nexY);
|
||||
}
|
||||
|
||||
// Extrafields
|
||||
// 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))
|
||||
@ -795,14 +816,17 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
|
||||
// Show square
|
||||
if ($pagenb == $pageposbeforeprintlines)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
|
||||
else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
|
||||
} else {
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
|
||||
}
|
||||
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
|
||||
// Affiche zone infos
|
||||
// Display infos area
|
||||
$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone totaux
|
||||
// Display total zone
|
||||
$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone versements
|
||||
@ -986,20 +1010,22 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
// Si mode reglement non force ou si force a CHQ
|
||||
if (!empty($conf->global->FACTURE_CHQ_NUMBER))
|
||||
{
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
|
||||
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
|
||||
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
|
||||
{
|
||||
$account = new Account($this->db);
|
||||
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
|
||||
$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))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', '', $default_font_size - 3);
|
||||
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 2;
|
||||
}
|
||||
@ -1007,14 +1033,14 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
|
||||
$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))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', '', $default_font_size - 3);
|
||||
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 2;
|
||||
}
|
||||
@ -1025,10 +1051,10 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
// 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 (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
|
||||
if ($object->fk_account > 0 || $object->fk_bank > 0 || !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
|
||||
$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
|
||||
$account = new Account($this->db);
|
||||
$account->fetch($bankid);
|
||||
|
||||
@ -1057,30 +1083,32 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
*/
|
||||
protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
|
||||
{
|
||||
global $conf, $mysoc;
|
||||
global $conf, $mysoc, $hookmanager;
|
||||
|
||||
$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);
|
||||
@ -1234,6 +1262,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
|
||||
foreach ($localtax_rate as $tvakey => $tvaval)
|
||||
{
|
||||
// retrieve global local tax
|
||||
if ($tvakey != 0) // On affiche pas taux 0
|
||||
{
|
||||
//$this->atleastoneratenotnull++;
|
||||
@ -1321,9 +1350,10 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
* @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 = '')
|
||||
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -1341,6 +1371,10 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
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);
|
||||
|
||||
@ -1373,10 +1407,11 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
* @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
|
||||
* @param string $titlekey Translation key to show as title of document
|
||||
* @return int Return topshift value
|
||||
*/
|
||||
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
|
||||
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $hookmanager;
|
||||
@ -1397,8 +1432,10 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$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 - 100;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $w;
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
|
||||
@ -1422,12 +1459,12 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
} 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');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
|
||||
}
|
||||
} else {
|
||||
$text = $this->emetteur->name;
|
||||
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1435,7 +1472,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$title = $outputlangs->transnoentities($titlekey);
|
||||
$pdf->MultiCell(100, 3, $title, '', 'R');
|
||||
$pdf->MultiCell($w, 4, $title, '', 'R');
|
||||
|
||||
$pdf->SetFont('', 'B', $default_font_size);
|
||||
|
||||
@ -1449,10 +1486,10 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
|
||||
if ($object->ref_client)
|
||||
{
|
||||
$posy += 5;
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
|
||||
@ -1483,14 +1520,14 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
|
||||
|
||||
if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
|
||||
{
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
}
|
||||
|
||||
// Get contact
|
||||
@ -1504,7 +1541,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1513,7 +1550,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$top_shift = 0;
|
||||
// Show list of linked objects
|
||||
$current_y = $pdf->getY();
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
|
||||
if ($current_y < $pdf->getY())
|
||||
{
|
||||
$top_shift = $pdf->getY() - $current_y;
|
||||
@ -1562,8 +1599,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
|
||||
|
||||
|
||||
|
||||
// If CUSTOMER contact defined on order, we use it
|
||||
// If CUSTOMER contact defined, we use it
|
||||
$usecontact = false;
|
||||
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
|
||||
if (count($arrayidcontact) > 0)
|
||||
@ -1585,9 +1621,10 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
|
||||
|
||||
// Show recipient
|
||||
$widthrecbox = 100;
|
||||
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
|
||||
if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
|
||||
$posy = 42 + $top_shift;
|
||||
$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
|
||||
$posy += $top_shift;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
|
||||
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
|
||||
|
||||
@ -1601,7 +1638,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
// Show recipient name
|
||||
$pdf->SetXY($posx + 2, $posy + 3);
|
||||
$pdf->SetFont('', 'B', $default_font_size);
|
||||
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
|
||||
$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
|
||||
|
||||
$posy = $pdf->getY();
|
||||
|
||||
@ -1690,7 +1727,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
'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
|
||||
'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
'content' => array(
|
||||
'align' => 'L',
|
||||
@ -1698,6 +1735,7 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
),
|
||||
);
|
||||
|
||||
// Image of product
|
||||
$rank = $rank + 10;
|
||||
$this->cols['photo'] = array(
|
||||
'rank' => $rank,
|
||||
@ -1789,14 +1827,25 @@ class pdf_eratosthene extends ModelePDFCommandes
|
||||
$this->cols['totalexcltax'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 26, // in mm
|
||||
'status' => true,
|
||||
'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false,
|
||||
'title' => array(
|
||||
'textkey' => 'TotalHT'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
|
||||
// Add extrafields cols
|
||||
$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);
|
||||
|
||||
@ -289,7 +289,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
|
||||
//if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
|
||||
|
||||
if ($conf->facture->dir_output)
|
||||
if ($conf->facture->multidir_output[$conf->entity])
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
@ -300,11 +300,11 @@ class pdf_sponge extends ModelePDFFactures
|
||||
// Definition of $dir and $file
|
||||
if ($object->specimen)
|
||||
{
|
||||
$dir = $conf->facture->dir_output;
|
||||
$dir = $conf->facture->multidir_output[$conf->entity];
|
||||
$file = $dir."/SPECIMEN.pdf";
|
||||
} else {
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $conf->facture->dir_output."/".$objectref;
|
||||
$dir = $conf->facture->multidir_output[$conf->entity]."/".$objectref;
|
||||
$file = $dir."/".$objectref.".pdf";
|
||||
}
|
||||
if (!file_exists($dir))
|
||||
@ -386,14 +386,15 @@ class pdf_sponge extends ModelePDFFactures
|
||||
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
|
||||
// Does we have at least one line with discount $this->atleastonediscount
|
||||
foreach ($object->lines as $line) {
|
||||
if ($line->remise_percent) {
|
||||
$this->atleastonediscount = true;
|
||||
break;
|
||||
// Set $this->atleastonediscount if you have at least one discount
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
if ($object->lines[$i]->remise_percent)
|
||||
{
|
||||
$this->atleastonediscount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Situation invoice handling
|
||||
if ($object->situation_cycle_ref)
|
||||
@ -458,8 +459,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
|
||||
// Extrafields in note
|
||||
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
|
||||
if (!empty($extranote))
|
||||
{
|
||||
if (!empty($extranote)) {
|
||||
$notetoshow = dol_concatdesc($notetoshow, $extranote);
|
||||
}
|
||||
|
||||
@ -735,7 +735,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$nexY = max($pdf->GetY(), $nexY);
|
||||
}
|
||||
|
||||
// Total HT line
|
||||
// Total excl tax line (HT)
|
||||
if ($this->getColumnStatus('totalexcltax'))
|
||||
{
|
||||
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
|
||||
@ -743,6 +743,14 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$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) {
|
||||
@ -2216,7 +2224,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
),
|
||||
);
|
||||
|
||||
// PHOTO
|
||||
// Image of product
|
||||
$rank = $rank + 10;
|
||||
$this->cols['photo'] = array(
|
||||
'rank' => $rank,
|
||||
@ -2324,13 +2332,24 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$this->cols['totalexcltax'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 26, // in mm
|
||||
'status' => true,
|
||||
'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);
|
||||
|
||||
@ -173,8 +173,8 @@ class pdf_azur extends ModelePDFPropales
|
||||
$this->posxqty = 135;
|
||||
$this->posxunit = 151;
|
||||
} else {
|
||||
$this->posxtva = 110;
|
||||
$this->posxup = 126;
|
||||
$this->posxtva = 106;
|
||||
$this->posxup = 122;
|
||||
$this->posxqty = 145;
|
||||
$this->posxunit = 162;
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* @var string Save the name of generated file as the main doc when generating a doc with this template
|
||||
* @var int Save the name of generated file as the main doc when generating a doc with this template
|
||||
*/
|
||||
public $update_main_doc_field;
|
||||
|
||||
@ -119,7 +119,12 @@ class pdf_cyan extends ModelePDFPropales
|
||||
*/
|
||||
public $emetteur;
|
||||
|
||||
|
||||
/**
|
||||
* @var array of document table collumns
|
||||
*/
|
||||
public $cols;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -164,11 +169,13 @@ class pdf_cyan extends ModelePDFPropales
|
||||
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;
|
||||
|
||||
$this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
|
||||
|
||||
|
||||
$this->tabTitleHeight = 5; // default height
|
||||
|
||||
// Use new system for position of columns, view $this->defineColumnField()
|
||||
|
||||
$this->tva = array();
|
||||
$this->localtax1 = array();
|
||||
$this->localtax2 = array();
|
||||
@ -197,7 +204,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
// 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 traductions files required by page
|
||||
// Load translation files required by page
|
||||
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
|
||||
|
||||
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
|
||||
@ -344,15 +351,15 @@ class pdf_cyan extends ModelePDFPropales
|
||||
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
|
||||
// Does we have at least one line with discount $this->atleastonediscount
|
||||
foreach ($object->lines as $line) {
|
||||
if ($line->remise_percent) {
|
||||
$this->atleastonediscount = true;
|
||||
break;
|
||||
// Set $this->atleastonediscount if you have at least one discount
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
if ($object->lines[$i]->remise_percent)
|
||||
{
|
||||
$this->atleastonediscount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
@ -365,7 +372,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$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);
|
||||
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
@ -397,7 +404,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
}
|
||||
}
|
||||
|
||||
// Affiche notes
|
||||
// Displays notes
|
||||
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
|
||||
if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
|
||||
{
|
||||
@ -454,7 +461,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
{
|
||||
$pdf->rollbackTransaction(true);
|
||||
|
||||
// prepar pages to receive notes
|
||||
// prepare pages to receive notes
|
||||
while ($pagenb < $pageposafternote) {
|
||||
$pdf->AddPage();
|
||||
$pagenb++;
|
||||
@ -488,7 +495,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
}
|
||||
|
||||
|
||||
// apply note frame to previus pages
|
||||
// apply note frame to previous pages
|
||||
$i = $pageposbeforenote;
|
||||
while ($i < $pageposafternote) {
|
||||
$pdf->setPage($i);
|
||||
@ -544,10 +551,10 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$height_note = 0;
|
||||
}
|
||||
|
||||
// Use new auto collum system
|
||||
// Use new auto column system
|
||||
$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
// Simulation de tableau pour connaitre la hauteur de la ligne de titre
|
||||
// tab simulation to know line height
|
||||
$pdf->startTransaction();
|
||||
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
|
||||
$pdf->rollbackTransaction(true);
|
||||
@ -582,7 +589,6 @@ class pdf_cyan extends ModelePDFPropales
|
||||
{
|
||||
$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;
|
||||
@ -656,7 +662,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
|
||||
}
|
||||
|
||||
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
|
||||
$pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
|
||||
|
||||
// VAT Rate
|
||||
if ($this->getColumnStatus('vat'))
|
||||
@ -700,7 +706,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$nexY = max($pdf->GetY(), $nexY);
|
||||
}
|
||||
|
||||
// Total HT line
|
||||
// Total excl tax line (HT)
|
||||
if ($this->getColumnStatus('totalexcltax'))
|
||||
{
|
||||
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
|
||||
@ -708,6 +714,14 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$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) {
|
||||
@ -732,8 +746,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
|
||||
|
||||
|
||||
|
||||
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
|
||||
// Collection of totals by value of vat in $this->tva["rate"] = total_tva
|
||||
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
|
||||
else $tvaligne = $object->lines[$i]->total_tva;
|
||||
|
||||
@ -826,13 +839,13 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
|
||||
}
|
||||
|
||||
// Affiche zone infos
|
||||
// Display infos area
|
||||
$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone totaux
|
||||
// Display total zone
|
||||
$posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone versements
|
||||
// Display payment area
|
||||
/*
|
||||
if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
|
||||
{
|
||||
@ -1121,10 +1134,10 @@ class pdf_cyan extends ModelePDFPropales
|
||||
// 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 (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
|
||||
if ($object->fk_account > 0 || $object->fk_bank > 0 || !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
|
||||
$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
|
||||
$account = new Account($this->db);
|
||||
$account->fetch($bankid);
|
||||
|
||||
@ -1154,15 +1167,23 @@ class pdf_cyan extends ModelePDFPropales
|
||||
*/
|
||||
protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
|
||||
{
|
||||
global $conf, $mysoc;
|
||||
global $conf, $mysoc, $hookmanager;
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$outputlangsbis = null;
|
||||
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
|
||||
$outputlangsbis = new Translate('', $conf);
|
||||
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
|
||||
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
|
||||
$default_font_size--;
|
||||
}
|
||||
|
||||
$tab2_top = $posy;
|
||||
$tab2_hl = 4;
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
|
||||
// Tableau total
|
||||
// Total table
|
||||
$col1x = 120; $col2x = 170;
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
{
|
||||
@ -1173,13 +1194,6 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$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"));
|
||||
}
|
||||
|
||||
// Total HT
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
@ -1387,6 +1401,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
|
||||
if ($deja_regle > 0)
|
||||
{
|
||||
// Already paid + Deposits
|
||||
$index++;
|
||||
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
@ -1440,9 +1455,10 @@ class pdf_cyan extends ModelePDFPropales
|
||||
* @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 = '')
|
||||
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -1460,6 +1476,10 @@ class pdf_cyan extends ModelePDFPropales
|
||||
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);
|
||||
|
||||
@ -1490,9 +1510,10 @@ class pdf_cyan extends ModelePDFPropales
|
||||
* @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)
|
||||
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -1512,8 +1533,10 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$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 - 100;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $w;
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
|
||||
@ -1537,12 +1560,12 @@ class pdf_cyan extends ModelePDFPropales
|
||||
} 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');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
|
||||
}
|
||||
} else {
|
||||
$text = $this->emetteur->name;
|
||||
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1550,7 +1573,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
|
||||
$pdf->MultiCell(100, 4, $title, '', 'R');
|
||||
$pdf->MultiCell($w, 4, $title, '', 'R');
|
||||
|
||||
$pdf->SetFont('', 'B', $default_font_size);
|
||||
|
||||
@ -1567,7 +1590,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
|
||||
@ -1597,7 +1620,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
|
||||
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
@ -1609,7 +1632,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
|
||||
}
|
||||
|
||||
// Get contact
|
||||
@ -1623,7 +1646,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1632,7 +1655,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$top_shift = 0;
|
||||
// Show list of linked objects
|
||||
$current_y = $pdf->getY();
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
|
||||
if ($current_y < $pdf->getY())
|
||||
{
|
||||
$top_shift = $pdf->getY() - $current_y;
|
||||
@ -1703,9 +1726,10 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
|
||||
|
||||
// Show recipient
|
||||
$widthrecbox = 100;
|
||||
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
|
||||
if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
|
||||
$posy = 42 + $top_shift;
|
||||
$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
|
||||
$posy += $top_shift;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
|
||||
if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
|
||||
|
||||
@ -1719,7 +1743,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
// Show recipient name
|
||||
$pdf->SetXY($posx + 2, $posy + 3);
|
||||
$pdf->SetFont('', 'B', $default_font_size);
|
||||
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
|
||||
$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
|
||||
|
||||
$posy = $pdf->getY();
|
||||
|
||||
@ -1840,7 +1864,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
'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
|
||||
'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
'content' => array(
|
||||
'align' => 'L',
|
||||
@ -1848,6 +1872,7 @@ class pdf_cyan extends ModelePDFPropales
|
||||
),
|
||||
);
|
||||
|
||||
// Image of product
|
||||
$rank = $rank + 10;
|
||||
$this->cols['photo'] = array(
|
||||
'rank' => $rank,
|
||||
@ -1939,13 +1964,24 @@ class pdf_cyan extends ModelePDFPropales
|
||||
$this->cols['totalexcltax'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 26, // in mm
|
||||
'status' => true,
|
||||
'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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user