|
@@ -431,6 +431,16 @@ class pdf_sponge extends ModelePDFFactures
|
|
|
|
|
|
// $tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
|
|
|
$tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
|
|
|
+
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ // Text complement
|
|
|
+ if (!empty($conf->global->DOCUMENT_SHOW_COMPLEMENT)) {
|
|
|
+ $textComplement = $this->textComplement($object, $outputlangs);
|
|
|
+ $heightfocomplement = $this->heightComplementArea($pdf, $textComplement, $default_font_size);
|
|
|
+ //var_dump($heightfocomplement); die();
|
|
|
+ //$heightforsignature += $heightfocomplement;
|
|
|
+ }
|
|
|
+
|
|
|
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
|
|
|
|
|
|
// You can add more thing under header here, if you increase $extra_under_address_shift too.
|
|
@@ -978,6 +988,12 @@ class pdf_sponge extends ModelePDFFactures
|
|
|
$posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
|
|
|
}
|
|
|
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ // Text complement
|
|
|
+ if (!empty($textComplement)) {
|
|
|
+ $posy = $this->drawComplementArea($pdf, $textComplement, $posy, $outputlangs);
|
|
|
+ }
|
|
|
+
|
|
|
// Pagefoot
|
|
|
$this->_pagefoot($pdf, $object, $outputlangs);
|
|
|
if (method_exists($pdf, 'AliasNbPages')) {
|
|
@@ -1212,6 +1228,23 @@ class pdf_sponge extends ModelePDFFactures
|
|
|
$posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
|
|
|
}
|
|
|
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ // Show shipping date
|
|
|
+ if (!empty($object->array_options['options_date_livraison_aff']) && !empty($object->array_options['options_date_livraison'])) {
|
|
|
+ $outputlangs->load("sendings");
|
|
|
+ $pdf->SetFont('', 'B', $default_font_size - 2);
|
|
|
+ $pdf->SetXY($this->marge_gauche, $posy);
|
|
|
+ $liv_type = $object->array_options['options_date_livraison_aff'];
|
|
|
+ $titre = $outputlangs->transnoentities(($liv_type==2 ?'DeliveryDate' :"DateDeliveryPlanned")).':';
|
|
|
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 2);
|
|
|
+ $pdf->SetXY($posxval, $posy);
|
|
|
+ $dlp = dol_print_date($object->array_options['options_date_livraison'], "daytext", false, $outputlangs, true);
|
|
|
+ $pdf->MultiCell(80, 4, $dlp, 0, 'L');
|
|
|
+
|
|
|
+ $posy = $pdf->GetY() + 1;
|
|
|
+ }
|
|
|
+
|
|
|
if ($object->type != 2) {
|
|
|
// Check a payment mode is defined
|
|
|
if (empty($object->mode_reglement_code)
|
|
@@ -2183,7 +2216,26 @@ class pdf_sponge extends ModelePDFFactures
|
|
|
|
|
|
$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
|
|
|
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
|
|
|
-
|
|
|
+
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ // Multiple contacts shipping & invoice
|
|
|
+ // If CUSTOMER/SHIPPING contact defined, we use it
|
|
|
+ $useshippingcontact = false;
|
|
|
+ $arrayidcontact = $object->getIdContact('external', 'SHIPPING');
|
|
|
+ if (count($arrayidcontact) > 0) {
|
|
|
+ $usecontact = true;
|
|
|
+ $useshippingcontact = true;
|
|
|
+ $result = $object->fetch_contact($arrayidcontact[0]);
|
|
|
+ }
|
|
|
+ // If CUSTOMER/BILLING contact defined, we use it
|
|
|
+ $usebillingcontact = false;
|
|
|
+ $arrayidcontact = $object->getIdContact('external', 'BILLING');
|
|
|
+ if (count($arrayidcontact) > 0) {
|
|
|
+ $usebillingcontact = true;
|
|
|
+ $result = $object->fetch_contact($arrayidcontact[0]);
|
|
|
+ }
|
|
|
+ if ($twocontacts = !empty($conf->global->MMI_DOCUMENT_PDF_SEPARATE_CONTACTS) && $useshippingcontact)
|
|
|
+ $widthrecbox = 60;
|
|
|
|
|
|
// Show sender frame
|
|
|
if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
|
|
@@ -2210,58 +2262,175 @@ class pdf_sponge extends ModelePDFFactures
|
|
|
$pdf->SetFont('', '', $default_font_size - 1);
|
|
|
$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
|
|
|
|
|
|
- // If BILLING contact defined on invoice, we use it
|
|
|
- $usecontact = false;
|
|
|
- $arrayidcontact = $object->getIdContact('external', 'BILLING');
|
|
|
- if (count($arrayidcontact) > 0) {
|
|
|
- $usecontact = true;
|
|
|
- $result = $object->fetch_contact($arrayidcontact[0]);
|
|
|
- }
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ // Multiple contacts shipping & invoice
|
|
|
+ if ($twocontacts) {
|
|
|
+ // ---- RECIPIENT SHIPPING
|
|
|
+
|
|
|
+ // If CUSTOMER/SHIPPING contact defined, we use it
|
|
|
+ $usecontact = false;
|
|
|
+ $arrayidcontact = $object->getIdContact('external', 'SHIPPING');
|
|
|
+ if (count($arrayidcontact) > 0) {
|
|
|
+ $usecontact = true;
|
|
|
+ $result = $object->fetch_contact($arrayidcontact[0]);
|
|
|
+ }
|
|
|
|
|
|
- // Recipient name
|
|
|
- if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
|
|
|
- $thirdparty = $object->contact;
|
|
|
- } else {
|
|
|
- $thirdparty = $object->thirdparty;
|
|
|
- }
|
|
|
+ // Recipient name
|
|
|
+ if ($usecontact && ($object->contact->socid == $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
|
|
|
+ $thirdparty = $object->contact;
|
|
|
+ } else {
|
|
|
+ $thirdparty = $object->thirdparty;
|
|
|
+ }
|
|
|
|
|
|
- $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
|
|
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
|
|
|
|
|
- $mode = 'target';
|
|
|
- $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
|
|
|
+ $mode = 'target';
|
|
|
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
|
|
|
|
|
|
- // Show recipient
|
|
|
- $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 = !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;
|
|
|
- }
|
|
|
+ // Show recipient
|
|
|
+ $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
|
|
|
+
|
|
|
+ if ($this->page_largeur < 210) {
|
|
|
+ $widthrecbox = 84; // To work with US executive format
|
|
|
+ }
|
|
|
+ $widthrecbox = 60;
|
|
|
+ $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;
|
|
|
+ }
|
|
|
|
|
|
- // Show recipient frame
|
|
|
- if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
|
|
|
+ // Show recipient frame
|
|
|
$pdf->SetTextColor(0, 0, 0);
|
|
|
$pdf->SetFont('', '', $default_font_size - 2);
|
|
|
$pdf->SetXY($posx + 2, $posy - 5);
|
|
|
- $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
|
|
|
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("DeliveryAddress"), 0, $ltrdirection);
|
|
|
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
|
|
|
+
|
|
|
+ // Show recipient name
|
|
|
+ $pdf->SetXY($posx + 2, $posy + 3);
|
|
|
+ $pdf->SetFont('', 'B', $default_font_size);
|
|
|
+ $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
|
|
|
+
|
|
|
+ $posy = $pdf->getY();
|
|
|
+
|
|
|
+ // Show recipient information
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 1);
|
|
|
+ $pdf->SetXY($posx + 2, $posy);
|
|
|
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
|
|
|
+
|
|
|
+ // ---- RECIPIENT INVOICE
|
|
|
+
|
|
|
+ // If CUSTOMER contact defined, we use it
|
|
|
+ $usecontact = false;
|
|
|
+ $arrayidcontact = $object->getIdContact('external', 'BILLING');
|
|
|
+ if (count($arrayidcontact) > 0) {
|
|
|
+ $usecontact = true;
|
|
|
+ $result = $object->fetch_contact($arrayidcontact[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Recipient name
|
|
|
+ if ($usecontact && ($object->contact->socid == $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
|
|
|
+ $thirdparty = $object->contact;
|
|
|
+ } else {
|
|
|
+ $thirdparty = $object->thirdparty;
|
|
|
+ }
|
|
|
+
|
|
|
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
|
|
+
|
|
|
+ $mode = 'target';
|
|
|
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
|
|
|
+
|
|
|
+ // Show recipient
|
|
|
+ $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
|
|
|
+
|
|
|
+ if ($this->page_largeur < 210) {
|
|
|
+ $widthrecbox = 84; // To work with US executive format
|
|
|
+ }
|
|
|
+ $widthrecbox = 60;
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+ $posx -= $widthrecbox +5;
|
|
|
+
|
|
|
+ // Show recipient frame
|
|
|
+ $pdf->SetTextColor(0, 0, 0);
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 2);
|
|
|
+ $pdf->SetXY($posx + 2, $posy - 5);
|
|
|
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillAddress"), 0, $ltrdirection);
|
|
|
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
|
|
|
+
|
|
|
+ // Show recipient name
|
|
|
+ $pdf->SetXY($posx + 2, $posy + 3);
|
|
|
+ $pdf->SetFont('', 'B', $default_font_size);
|
|
|
+ $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
|
|
|
+
|
|
|
+ $posy = $pdf->getY();
|
|
|
+
|
|
|
+ // Show recipient information
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 1);
|
|
|
+ $pdf->SetXY($posx + 2, $posy);
|
|
|
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
|
|
|
}
|
|
|
+ // 1 seule adresse
|
|
|
+ else {
|
|
|
+ // If CUSTOMER contact defined, we use it
|
|
|
+ $usecontact = false;
|
|
|
+ $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
|
|
|
+ if (count($arrayidcontact) > 0) {
|
|
|
+ $usecontact = true;
|
|
|
+ $result = $object->fetch_contact($arrayidcontact[0]);
|
|
|
+ }
|
|
|
|
|
|
- // Show recipient name
|
|
|
- $pdf->SetXY($posx + 2, $posy + 3);
|
|
|
- $pdf->SetFont('', 'B', $default_font_size);
|
|
|
- $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
|
|
|
+ // Recipient name
|
|
|
+ if ($usecontact && ($object->contact->socid == $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
|
|
|
+ $thirdparty = $object->contact;
|
|
|
+ } else {
|
|
|
+ $thirdparty = $object->thirdparty;
|
|
|
+ }
|
|
|
|
|
|
- $posy = $pdf->getY();
|
|
|
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
|
|
|
|
|
- // Show recipient information
|
|
|
- $pdf->SetFont('', '', $default_font_size - 1);
|
|
|
- $pdf->SetXY($posx + 2, $posy);
|
|
|
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
|
|
|
+ $mode = 'target';
|
|
|
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
|
|
|
+
|
|
|
+ // Show recipient
|
|
|
+ $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 = !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;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Show recipient frame
|
|
|
+ if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
|
|
|
+ $pdf->SetTextColor(0, 0, 0);
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 2);
|
|
|
+ $pdf->SetXY($posx + 2, $posy - 5);
|
|
|
+ $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
|
|
|
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Show recipient name
|
|
|
+ $pdf->SetXY($posx + 2, $posy + 3);
|
|
|
+ $pdf->SetFont('', 'B', $default_font_size);
|
|
|
+ $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
|
|
|
+
|
|
|
+ $posy = $pdf->getY();
|
|
|
+
|
|
|
+ // Show recipient information
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 1);
|
|
|
+ $pdf->SetXY($posx + 2, $posy);
|
|
|
+ $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$pdf->SetTextColor(0, 0, 0);
|
|
@@ -2285,6 +2454,72 @@ class pdf_sponge extends ModelePDFFactures
|
|
|
return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Added by MMI Mathieu Moulin iProspective
|
|
|
+ * Text complement
|
|
|
+ */
|
|
|
+ protected function textComplement(&$object, $outputlangs)
|
|
|
+ {
|
|
|
+ global $conf;
|
|
|
+ $outputlangs->load('mmidocuments@mmidocuments');
|
|
|
+
|
|
|
+ //var_dump($object); die();
|
|
|
+ //var_dump($object->array_options['options_cgv_cpv']); die();
|
|
|
+ $complement = [];
|
|
|
+ if (!empty($object->array_options['options_cgv_cpv']))
|
|
|
+ $complement[] = '<p><b>'.$outputlangs->transnoentities("DocumentMoreInfoCGP")."</b></p>\r\n".$object->array_options['options_cgv_cpv'];
|
|
|
+ if (!empty($object->array_options['options_propal_decennale']))
|
|
|
+ $complement[] = '<p><b>'.$outputlangs->transnoentities("DocumentMoreInfoDecennale")."</b></p>\r\n".$conf->global->MMIPROJECT_DECENNALE_TEXT;
|
|
|
+ //var_dump($complement); die();
|
|
|
+ return !empty($complement) ?implode("\r\n", $complement) :'';
|
|
|
+ }
|
|
|
+ protected function heightComplement(&$pdf, $text, $default_font_size)
|
|
|
+ {
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 2);
|
|
|
+ $useborder = 0;
|
|
|
+ $cellpadding = 0;
|
|
|
+ $reseth = false;
|
|
|
+ $autopadding = true;
|
|
|
+ $largcol = ($this->page_largeur - $this->marge_droite - $this->marge_gauche);
|
|
|
+ return $pdf->getStringHeight($largcol, strip_tags($text), $reseth, $autopadding, $cellpadding, $useborder);
|
|
|
+ }
|
|
|
+ protected function heightComplementArea(&$pdf, $text, $default_font_size)
|
|
|
+ {
|
|
|
+ $marg_top = 8;
|
|
|
+ $tab_titre = 4;
|
|
|
+ $tab_text = $this->heightComplement($pdf, $text, $default_font_size);
|
|
|
+ //var_dump($tab_text);
|
|
|
+ return $marg_top + $tab_titre + $tab_text;
|
|
|
+ }
|
|
|
+ protected function drawComplementArea(&$pdf, $text, $posy, $outputlangs)
|
|
|
+ {
|
|
|
+ global $conf;
|
|
|
+ $outputlangs->load('mmidocuments@mmidocuments');
|
|
|
+
|
|
|
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
|
|
|
+ $marg_top = 8;
|
|
|
+ $tab_top = $posy + $marg_top;
|
|
|
+
|
|
|
+ $posx = $this->marge_gauche;
|
|
|
+ $largcol = ($this->page_largeur - $this->marge_droite - $posx);
|
|
|
+
|
|
|
+ $pdf->SetFillColor(255, 255, 255);
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 2);
|
|
|
+
|
|
|
+ // Titre
|
|
|
+ $pdf->SetXY($posx, $tab_top);
|
|
|
+ $tab_titre = 4;
|
|
|
+ $pdf->WriteHTMLCell($largcol, $tab_titre, $posx, $posy+$marg_top, '<b>'.$outputlangs->transnoentities("DocumentMoreInfo").'</b>', 0);
|
|
|
+ // Texte
|
|
|
+ $pdf->SetXY($posx, $tab_top + $tab_titre);
|
|
|
+ $tab_text = $this->heightComplement($pdf, $text, $default_font_size);
|
|
|
+ //var_dump($tab_text); die();
|
|
|
+ $pdf->WriteHTMLCell($largcol, $tab_text, $posx,$tab_top+$tab_titre, $text, 1, 'L');
|
|
|
+ //var_dump($tab_top + $tab_titre + $tab_text); die();
|
|
|
+
|
|
|
+ return $tab_top + $tab_titre + $tab_text;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Define Array Column Field
|
|
|
*
|