Browse Source

MMIShipping : Extrafields fk_entrepot fk_address and option to display address in reception

Mathieu Moulin 1 year ago
parent
commit
6a090adcdd

+ 1 - 1
.gitmodules

@@ -77,7 +77,7 @@
 [submodule "htdocs/custom/mmishipping"]
 	path = htdocs/custom/mmishipping
 	url = git@gogs.iprospective.fr:iProspective/dolibarr-module-mmishipping.git
-	branch = 16.0
+	branch = 19.0
 [submodule "htdocs/custom/abricot"]
 	path = htdocs/custom/abricot
 	url = git@gogs.iprospective.fr:iProspective/dolibarr-module-abricot.git

+ 35 - 2
htdocs/core/modules/reception/doc/pdf_squille.modules.php

@@ -1000,7 +1000,40 @@ class pdf_squille extends ModelePdfReception
 				$carac_emetteur .= "\n";
 			}
 
-			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
+			// MMI Hack adresse réception
+			// Entrepôt réception
+			//var_dump($object->array_options);
+			if (getDolGlobalInt('MMI_RECEPTION_SENDER_ADDRESS') && !empty($object->array_options['options_fk_entrepot'])) {
+				require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
+
+				$entrepot = new Entrepot($this->db);
+				$entrepot->fetch($object->array_options['options_fk_entrepot']);
+				
+				$nom_emetteur = $entrepot->label;
+				$carac_emetteur .= $entrepot->address."\r\n";
+				$carac_emetteur .= $entrepot->zip.' '.$entrepot->town."\r\n";
+				$carac_emetteur .= $entrepot->country;
+			}
+			// Adresse client réception (direct fournisseur)
+			elseif (getDolGlobalInt('MMI_RECEPTION_SENDER_ADDRESS') && !empty($object->array_options['options_fk_adresse'])) {
+				require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+
+				$contact = new Contact($this->db);
+				$contact->fetch($object->array_options['options_fk_adresse']);
+
+				$nom_emetteur = $contact->lastname.' '.$contact->firstname;
+				$carac_emetteur .= $contact->address."\r\n";
+				$carac_emetteur .= $contact->zip.' '.$contact->town."\r\n";
+				$carac_emetteur .= $contact->country;
+			}
+			// 
+			else {
+				$nom_emetteur = $this->emetteur->name;
+				$carac_emetteur .= getDolGlobalString('MAIN_INFO_SOCIETE_ADDRESS');
+			}
+
+			// le thitrdparty n'a rien à faire ici, c'est plutôt le user !
+			//$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
 
 			// Show sender
 			$posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
@@ -1078,7 +1111,7 @@ class pdf_squille extends ModelePdfReception
 			// Show sender name
 			$pdf->SetXY($posx + 2, $posy + 3);
 			$pdf->SetFont('', 'B', $default_font_size);
-			$pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+			$pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($nom_emetteur), 0, 'L');
 			$posy = $pdf->getY();
 
 			// Show sender information

+ 1 - 1
htdocs/custom/mmiproduct

@@ -1 +1 @@
-Subproject commit 7531b8f1acfaab9686893c447ce7c1f242e51ad7
+Subproject commit da6dafd321bdb7cef7fd4790817a08eac03ab5ae

+ 1 - 1
htdocs/custom/mmishipping

@@ -1 +1 @@
-Subproject commit 11acc8c2eeecb8754d3c156ec867c34b8db0c7ef
+Subproject commit 8d7d3811545c29244903a725ead95aa42eaf236d