|
@@ -384,6 +384,14 @@ class pdf_cyan extends ModelePDFPropales
|
|
|
|
|
|
$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;
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ $heightfocomplement = 0;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
$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;
|
|
@@ -903,6 +911,11 @@ class pdf_cyan extends ModelePDFPropales
|
|
|
$posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
|
|
|
}
|
|
|
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ if (!empty($textComplement)) {
|
|
|
+ $posy = $this->drawComplementArea($pdf, $textComplement, $posy, $outputlangs);
|
|
|
+ }
|
|
|
+
|
|
|
// Pagefoot
|
|
|
$this->_pagefoot($pdf, $object, $outputlangs);
|
|
|
if (method_exists($pdf, 'AliasNbPages')) {
|
|
@@ -1458,6 +1471,25 @@ class pdf_cyan extends ModelePDFPropales
|
|
|
$pdf->SetTextColor(0, 0, 0);
|
|
|
}
|
|
|
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ // @todo Hook
|
|
|
+ $acompte_p = (!empty($object->array_options['options_acompte']) && $object->array_options['options_acompte']>0) ?$object->array_options['options_acompte'] :0;
|
|
|
+ if (!$acompte_p)
|
|
|
+ $acompte_val = (!empty($object->array_options['options_acompte_val']) && $object->array_options['options_acompte_val']>0) ?round($object->array_options['options_acompte_val'], 2) :0;
|
|
|
+ if (!empty($object->array_options['options_acompte_aff']) && ($acompte_p || $acompte_val)) {
|
|
|
+ $index++;
|
|
|
+ $outputlangs->load('mmidocuments@mmidocuments');
|
|
|
+ if ($acompte_p)
|
|
|
+ $acompte_val = round($object->total_ttc*$acompte_p/100, 2);
|
|
|
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
|
|
+ $pdf->SetFont('', 'B', $default_font_size - 1);
|
|
|
+ if ($acompte_p)
|
|
|
+ $pdf->MultiCell($col2x, $tab2_hl, $outputlangs->transnoentities('PaymentAcomptePourcent', str_replace('.', ',', $acompte_p).' %', price($acompte_val)), 0, 'L', 0);
|
|
|
+ else
|
|
|
+ $pdf->MultiCell($col2x, $tab2_hl, $outputlangs->transnoentities('PaymentAcompte', price($acompte_val)), 0, 'L', 0);
|
|
|
+ $posy = $pdf->GetY() + 1;
|
|
|
+ }
|
|
|
+
|
|
|
$index++;
|
|
|
return ($tab2_top + ($tab2_hl * $index));
|
|
|
}
|
|
@@ -1710,6 +1742,24 @@ class pdf_cyan extends ModelePDFPropales
|
|
|
$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
|
|
|
+ // If CUSTOMER/SHIPPING contact defined, we use it
|
|
|
+ $useshippingcontact = false;
|
|
|
+ $arrayidcontact = $object->getIdContact('external', 'SHIPPING');
|
|
|
+ if (count($arrayidcontact) > 0) {
|
|
|
+ $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)) {
|
|
|
$pdf->SetTextColor(0, 0, 0);
|
|
@@ -1735,59 +1785,175 @@ class pdf_cyan extends ModelePDFPropales
|
|
|
$pdf->SetFont('', '', $default_font_size - 1);
|
|
|
$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
|
|
|
|
|
|
+ // Added by MMI Mathieu Moulin iProspective
|
|
|
+ // Adresses livraison & facturation
|
|
|
+ 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]);
|
|
|
+ }
|
|
|
|
|
|
- // 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]);
|
|
|
- }
|
|
|
+ // 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 : 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
|
|
|
- $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
|
|
|
+ $pdf->SetTextColor(0, 0, 0);
|
|
|
+ $pdf->SetFont('', '', $default_font_size - 2);
|
|
|
+ $pdf->SetXY($posx + 2, $posy - 5);
|
|
|
+ $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
|
|
|
- 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, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
|
|
|
+ $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, $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, 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, 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, $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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$pdf->SetTextColor(0, 0, 0);
|
|
@@ -1843,7 +2009,71 @@ class pdf_cyan extends ModelePDFPropales
|
|
|
$pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
|
|
|
}
|
|
|
|
|
|
- return ($tab_hl * 7);
|
|
|
+ return $posy+($tab_hl * 7);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Added by MMI Mathieu Moulin iProspective
|
|
|
+ */
|
|
|
+ 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[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoCGP")."</h3>\r\n".$object->array_options['options_cgv_cpv'];
|
|
|
+ if (!empty($object->array_options['options_propal_decennale']))
|
|
|
+ $complement[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoDecennale")."</h3>\r\n".$conf->global->MMIPROJECT_DECENNALE_TEXT;
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ $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;
|
|
|
}
|
|
|
|
|
|
|