Browse Source

MMIProject : display Project management on documents

Mathieu Moulin 1 năm trước cách đây
mục cha
commit
71b93d5407

+ 17 - 3
htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php

@@ -1691,6 +1691,10 @@ class pdf_eratosthene extends ModelePDFCommandes
 				$useshippingcontact = true;
 				$result = $object->fetch_contact($arrayidcontact[0]);
 			}
+			// If Maîtrise d'oeuvre defined, we use it
+			if (!empty($object->array_options['options_appeloffre_maitrise'])) {
+				$usemaitrisecontact = true;
+			}
 			// If CUSTOMER/BILLING contact defined, we use it
 			$usebillingcontact = false;
 			$arrayidcontact = $object->getIdContact('external', 'BILLING');
@@ -1699,7 +1703,7 @@ class pdf_eratosthene extends ModelePDFCommandes
 				$result = $object->fetch_contact($arrayidcontact[0]);
 			}
 			// MMI Hack size
-			if ($twocontacts = !empty($conf->global->MMI_DOCUMENT_PDF_SEPARATE_CONTACTS) && $useshippingcontact)
+			if ($twocontacts = !empty($conf->global->MMI_DOCUMENT_PDF_SEPARATE_CONTACTS) && ($useshippingcontact || $usemaitrisecontact))
 				$widthrecbox = 60;
 
 			// Show sender frame
@@ -1737,6 +1741,16 @@ class pdf_eratosthene extends ModelePDFCommandes
 				$arrayidcontact = $object->getIdContact('external', 'SHIPPING');
 				if (count($arrayidcontact) > 0) {
 					$usecontact = true;
+					$recipient_type = 'SHIPPING';
+					$address_type_label = $outputlangs->transnoentities("DeliveryAddress");
+					$result = $object->fetch_contact($arrayidcontact[0]);
+				}
+				// If Maîtrise d'oeuvre defined, we use it
+				$arrayidcontact = $object->getIdContact('external', 'MGMT');
+				if (count($arrayidcontact) > 0) {
+					$usecontact = true;
+					$recipient_type = 'MGMT';
+					$address_type_label = $outputlangs->transnoentities("ProjectManagementAddress");
 					$result = $object->fetch_contact($arrayidcontact[0]);
 				}
 
@@ -1747,7 +1761,7 @@ class pdf_eratosthene extends ModelePDFCommandes
 					$thirdparty = $object->thirdparty;
 				}
 
-				$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+				$carac_client_name = $recipient_type != 'MGMT' ?pdfBuildThirdpartyName($thirdparty, $outputlangs) :'';
 
 				$mode =  'target';
 				$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
@@ -1770,7 +1784,7 @@ class pdf_eratosthene extends ModelePDFCommandes
 				$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->MultiCell($widthrecbox, 5, $address_type_label, 0, $ltrdirection);
 				$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
 
 				// Show recipient name

+ 17 - 3
htdocs/core/modules/facture/doc/pdf_sponge.modules.php

@@ -2279,6 +2279,10 @@ class pdf_sponge extends ModelePDFFactures
 				$useshippingcontact = true;
 				$result = $object->fetch_contact($arrayidcontact[0]);
 			}
+			// If Maîtrise d'oeuvre defined, we use it
+			if (!empty($object->array_options['options_appeloffre_maitrise'])) {
+				$usemaitrisecontact = true;
+			}
 			// If CUSTOMER/BILLING contact defined, we use it
 			$usebillingcontact = false;
 			$arrayidcontact = $object->getIdContact('external', 'BILLING');
@@ -2286,7 +2290,7 @@ class pdf_sponge extends ModelePDFFactures
 				$usebillingcontact = true;
 				$result = $object->fetch_contact($arrayidcontact[0]);
 			}
-			if ($twocontacts = !empty($conf->global->MMI_DOCUMENT_PDF_SEPARATE_CONTACTS) && $useshippingcontact)
+			if ($twocontacts = !empty($conf->global->MMI_DOCUMENT_PDF_SEPARATE_CONTACTS) && ($useshippingcontact || $usemaitrisecontact))
 				$widthrecbox = 60;
 
 			// Show sender frame
@@ -2324,6 +2328,16 @@ class pdf_sponge extends ModelePDFFactures
 				$arrayidcontact = $object->getIdContact('external', 'SHIPPING');
 				if (count($arrayidcontact) > 0) {
 					$usecontact = true;
+					$recipient_type = 'SHIPPING';
+					$address_type_label = $outputlangs->transnoentities("DeliveryAddress");
+					$result = $object->fetch_contact($arrayidcontact[0]);
+				}
+				// If Maîtrise d'oeuvre defined, we use it
+				$arrayidcontact = $object->getIdContact('external', 'MGMT');
+				if (count($arrayidcontact) > 0) {
+					$usecontact = true;
+					$recipient_type = 'MGMT';
+					$address_type_label = $outputlangs->transnoentities("ProjectManagementAddress");
 					$result = $object->fetch_contact($arrayidcontact[0]);
 				}
 
@@ -2334,7 +2348,7 @@ class pdf_sponge extends ModelePDFFactures
 					$thirdparty = $object->thirdparty;
 				}
 
-				$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+				$carac_client_name = $recipient_type != 'MGMT' ?pdfBuildThirdpartyName($thirdparty, $outputlangs) :'';
 
 				$mode =  'target';
 				$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
@@ -2357,7 +2371,7 @@ class pdf_sponge extends ModelePDFFactures
 				$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->MultiCell($widthrecbox, 5, $address_type_label, 0, $ltrdirection);
 				$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
 
 				// Show recipient name

+ 17 - 3
htdocs/core/modules/propale/doc/pdf_cyan.modules.php

@@ -1782,6 +1782,10 @@ class pdf_cyan extends ModelePDFPropales
 				$useshippingcontact = true;
 				$result = $object->fetch_contact($arrayidcontact[0]);
 			}
+			// If Maîtrise d'oeuvre defined, we use it
+			if (!empty($object->array_options['options_appeloffre_maitrise'])) {
+				$usemaitrisecontact = true;
+			}
 			// If CUSTOMER/BILLING contact defined, we use it
 			$usebillingcontact = false;
 			$arrayidcontact = $object->getIdContact('external', 'BILLING');
@@ -1789,7 +1793,7 @@ class pdf_cyan extends ModelePDFPropales
 				$usebillingcontact = true;
 				$result = $object->fetch_contact($arrayidcontact[0]);
 			}
-			if ($twocontacts = !empty($conf->global->MMI_DOCUMENT_PDF_SEPARATE_CONTACTS) && $useshippingcontact)
+			if ($twocontacts = !empty($conf->global->MMI_DOCUMENT_PDF_SEPARATE_CONTACTS) && ($useshippingcontact || $usemaitrisecontact))
 				$widthrecbox = 60;
 
 			// Show sender frame
@@ -1827,6 +1831,16 @@ class pdf_cyan extends ModelePDFPropales
 				$arrayidcontact = $object->getIdContact('external', 'SHIPPING');
 				if (count($arrayidcontact) > 0) {
 					$usecontact = true;
+					$recipient_type = 'SHIPPING';
+					$address_type_label = $outputlangs->transnoentities("DeliveryAddress");
+					$result = $object->fetch_contact($arrayidcontact[0]);
+				}
+				// If Maîtrise d'oeuvre defined, we use it
+				$arrayidcontact = $object->getIdContact('external', 'MGMT');
+				if (count($arrayidcontact) > 0) {
+					$usecontact = true;
+					$recipient_type = 'MGMT';
+					$address_type_label = $outputlangs->transnoentities("ProjectManagementAddress");
 					$result = $object->fetch_contact($arrayidcontact[0]);
 				}
 
@@ -1837,7 +1851,7 @@ class pdf_cyan extends ModelePDFPropales
 					$thirdparty = $object->thirdparty;
 				}
 
-				$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+				$carac_client_name = $recipient_type != 'MGMT' ?pdfBuildThirdpartyName($thirdparty, $outputlangs) :'';
 
 				$mode =  'target';
 				$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
@@ -1860,7 +1874,7 @@ class pdf_cyan extends ModelePDFPropales
 				$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->MultiCell($widthrecbox, 5, $address_type_label, 0, $ltrdirection);
 				$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
 
 				// Show recipient name

+ 1 - 1
htdocs/custom/mmiproject

@@ -1 +1 @@
-Subproject commit d874dbb76b9a981c7180e1b6fa933df74dfa3179
+Subproject commit 865ba8b1349f9b45e23078d5f17eea85f38d8363