瀏覽代碼

MMIEntrepots :Fix display Localisation AND main category in shipping with config param SHIPPING_PDF_LOCATION

Mathieu Moulin 1 年之前
父節點
當前提交
98c14fb196
共有 2 個文件被更改,包括 18 次插入3 次删除
  1. 17 2
      htdocs/core/lib/pdf.lib.php
  2. 1 1
      htdocs/custom/mmientrepots

+ 17 - 2
htdocs/core/lib/pdf.lib.php

@@ -1702,12 +1702,27 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
 			$libelleproduitservice .= '__N__  Barcode: '.$prodser->barcode;
 	}
 	// Show Location
-	if (in_array($objecttype, ['Expedition']) && (true || !empty($conf->global->SHIPPING_PDF_LOCATION))) {
+	if (in_array($objecttype, ['Expedition']) && !empty($conf->global->SHIPPING_PDF_LOCATION) && !empty($conf->categorie->enabled)) {
 		if (!empty($prodser->array_options['options_fk_categorie'])) {
 			include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 			$categorie = new Categorie($db);
 			$categorie->fetch($prodser->array_options['options_fk_categorie']);
-			$libelleproduitservice .= '__N__  Localisation: '.$categorie->label;
+			$categorie_parent = $categorie;
+			while(empty($categorie_parent->array_options['options_fk_entrepot_loc']) && !empty($categorie_parent->fk_parent)) {
+				$fk_parent = $categorie_parent->fk_parent;
+				$categorie_parent = new Categorie($db);
+				$categorie_parent->fetch($fk_parent);
+			}
+			if(!empty($categorie_parent->array_options['options_fk_entrepot_loc'])) {
+				$sql = 'SELECT label
+					FROM '.MAIN_DB_PREFIX.'c_entrepot_loc
+					WHERE rowid='.$categorie_parent->array_options['options_fk_entrepot_loc'];
+				$q = $db->query($sql);
+				list($entrepot_loc) = $q->fetch_row();
+				$libelleproduitservice .= '__N__  Localisation: '.$entrepot_loc.' -> '.$categorie->label;
+			}
+			else
+				$libelleproduitservice .= '__N__  Localisation: '.$categorie->label;
 			//var_dump($prodser->array_options['options_fk_categorie']); die();
 		}
 	}

+ 1 - 1
htdocs/custom/mmientrepots

@@ -1 +1 @@
-Subproject commit 74356533295810930d8e4a6290ed20a6adc00b2e
+Subproject commit 8a21c260c45de8e954973e9d6c843e571601f0fa