ソースを参照

Merge branch '16.0-mmi' of gogs.iprospective.fr:iProspective/dolibarr into 16.0-mmi

Calicote 1 年間 前
コミット
d7ddee08ca

+ 3 - 1
.gitmodules

@@ -151,4 +151,6 @@
 	url = git@gogs.iprospective.fr:iProspective/dolibarr-module-mmisecurity.git
 	branch = 16.0
 
-
+[submodule "htdocs/custom/subtotal"]
+	path = htdocs/custom/subtotal
+	url = https://gogs.iprospective.fr/iProspective/dolibarr-module-subtotal.git

+ 30 - 0
htdocs/core/class/commonobject.class.php

@@ -10110,6 +10110,36 @@ abstract class CommonObject
 		return $mt;
 	}
 
+	/**
+	 * Get filename for PDF
+	 * @author MMI Mathieu Moulin iProspective
+	 *
+	 * @return string
+	 */
+	public function pdf_filename()
+	{
+		global $conf;
+		
+		if (empty($conf->global->MMIDOCUMENT_PDF_RENAME))
+			return;
+		
+		$thirdparty = $this->thirdparty;
+		$file_e = [];
+		$file_e[] = dol_sanitizeFileName($this->ref);
+		if (!empty($conf->global->MMIDOCUMENT_PDF_RENAME_MYSOC)) {
+			global $mysoc;
+			$file_e[] = $mysoc->name;
+		}
+		if (!empty($conf->global->MMIDOCUMENT_PDF_RENAME_THIRDPARTY)) {
+			$file_e[] = $thirdparty->name;
+		}
+		if (!empty($conf->global->MMIDOCUMENT_PDF_RENAME_REF_CUSTOMER) && !empty($this->ref_customer)) {
+			$file_e[] = $this->ref_customer;
+		}
+		$filename = preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', iconv('UTF-8','ASCII//TRANSLIT', implode('-', $file_e))));
+		return !empty($conf->global->MMIDOCUMENT_PDF_RENAME_UPPERCASE) ?strtoupper($filename) :$filename;
+	}
+
 	/**
 	 * Get total amount already paid
 	 * @author MMI Mathieu Moulin iProspective

+ 3 - 0
htdocs/core/lib/pdf.lib.php

@@ -400,6 +400,9 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali
 			}
 		}
 	} elseif ($thirdparty instanceof Contact) {
+		//var_dump($thirdparty->array_options['options_societe_name_hide']); die();
+		if (!empty($thirdparty->array_options['options_societe_name_hide']))
+			return '';
 		$socname = $thirdparty->socname;
 		if (($includealias || getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->name_alias)) {
 			// TODO PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME not completely implemented

+ 22 - 8
htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php

@@ -308,7 +308,13 @@ class pdf_eratosthene extends ModelePDFCommandes
 			} else {
 				$objectref = dol_sanitizeFileName($object->ref);
 				$dir = $conf->commande->multidir_output[$object->entity]."/".$objectref;
-				$file = $dir."/".$objectref.".pdf";
+				// MMIDocument PDF rename
+				if (!empty($conf->global->MMIDOCUMENT_PDF_RENAME)) {
+					$filename = $object->pdf_filename();
+					$file = $dir."/".$filename.".pdf";
+				}
+				else
+					$file = $dir."/".$objectref.".pdf";
 			}
 
 			if (!file_exists($dir)) {
@@ -1932,10 +1938,16 @@ class pdf_eratosthene extends ModelePDFCommandes
 		//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;
+		if (!empty($object->array_options['options_cgv_cpv'])) {
+			if (!empty($conf->global->MMIDOCUMENT_CGP_TITLE))
+				$complement[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoCGP")."</h3>";
+			$complement[] = $object->array_options['options_cgv_cpv'];
+		}
+		if (!empty($object->array_options['options_propal_decennale'])) {
+			if (!empty($conf->global->MMIPROJECT_DECENNALE_TITLE))
+				$complement[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoDecennale")."</h3>";
+			$complement[] = $conf->global->MMIPROJECT_DECENNALE_TEXT;
+		}
 		//var_dump($complement); die();
 		return !empty($complement) ?implode("\r\n", $complement) :'';
 	}
@@ -1973,9 +1985,11 @@ class pdf_eratosthene extends ModelePDFCommandes
 		$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);
+		if (!empty($conf->global->DOCUMENT_COMPLEMENT_TITLE)) {
+			$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);

+ 22 - 8
htdocs/core/modules/facture/doc/pdf_sponge.modules.php

@@ -316,7 +316,13 @@ class pdf_sponge extends ModelePDFFactures
 			} else {
 				$objectref = dol_sanitizeFileName($object->ref);
 				$dir = $conf->facture->multidir_output[$object->entity]."/".$objectref;
-				$file = $dir."/".$objectref.".pdf";
+				// MMIDocument PDF rename
+				if (!empty($conf->global->MMIDOCUMENT_PDF_RENAME)) {
+					$filename = $object->pdf_filename();
+					$file = $dir."/".$filename.".pdf";
+				}
+				else
+					$file = $dir."/".$objectref.".pdf";
 			}
 			if (!file_exists($dir)) {
 				if (dol_mkdir($dir) < 0) {
@@ -2526,10 +2532,16 @@ class pdf_sponge extends ModelePDFFactures
 		//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;
+		if (!empty($object->array_options['options_cgv_cpv'])) {
+			if (!empty($conf->global->MMIDOCUMENT_CGP_TITLE))
+				$complement[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoCGP")."</h3>";
+			$complement[] = $object->array_options['options_cgv_cpv'];
+		}
+		if (!empty($object->array_options['options_propal_decennale'])) {
+			if (!empty($conf->global->MMIPROJECT_DECENNALE_TITLE))
+				$complement[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoDecennale")."</h3>";
+			$complement[] = $conf->global->MMIPROJECT_DECENNALE_TEXT;
+		}
 		//var_dump($complement); die();
 		return !empty($complement) ?implode("\r\n", $complement) :'';
 	}
@@ -2567,9 +2579,11 @@ class pdf_sponge extends ModelePDFFactures
 		$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);
+		if (!empty($conf->global->DOCUMENT_COMPLEMENT_TITLE)) {
+			$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);

+ 22 - 8
htdocs/core/modules/propale/doc/pdf_cyan.modules.php

@@ -306,7 +306,13 @@ class pdf_cyan extends ModelePDFPropales
 			} else {
 				$objectref = dol_sanitizeFileName($object->ref);
 				$dir = $conf->propal->multidir_output[$object->entity]."/".$objectref;
-				$file = $dir."/".$objectref.".pdf";
+				// MMIDocument PDF rename
+				if (!empty($conf->global->MMIDOCUMENT_PDF_RENAME)) {
+					$filename = $object->pdf_filename();
+					$file = $dir."/".$filename.".pdf";
+				}
+				else
+					$file = $dir."/".$objectref.".pdf";
 			}
 
 			if (!file_exists($dir)) {
@@ -2055,10 +2061,16 @@ class pdf_cyan extends ModelePDFPropales
 		//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;
+		if (!empty($object->array_options['options_cgv_cpv'])) {
+			if (!empty($conf->global->MMIDOCUMENT_CGP_TITLE))
+				$complement[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoCGP")."</h3>";
+			$complement[] = $object->array_options['options_cgv_cpv'];
+		}
+		if (!empty($object->array_options['options_propal_decennale'])) {
+			if (!empty($conf->global->MMIPROJECT_DECENNALE_TITLE))
+				$complement[] = '<h3>'.$outputlangs->transnoentities("DocumentMoreInfoDecennale")."</h3>";
+			$complement[] = $conf->global->MMIPROJECT_DECENNALE_TEXT;
+		}
 
 		return !empty($complement) ?implode("\r\n", $complement) :'';
 	}
@@ -2095,9 +2107,11 @@ class pdf_cyan extends ModelePDFPropales
 		$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);
+		if (!empty($conf->global->DOCUMENT_COMPLEMENT_TITLE)) {
+			$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);

+ 4 - 2
htdocs/core/tpl/card_presend.tpl.php

@@ -50,7 +50,8 @@ if ($action == 'presend') {
 		if ($object->element == 'invoice_supplier') {
 			$fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
 		} else {
-			$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+');
+			$filename = (!empty($conf->global->MMIDOCUMENT_PDF_RENAME)) ?$object->pdf_filename() :$ref;
+			$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($filename, '/').'[^\-]+');
 		}
 
 		$file = $fileparams['fullname'];
@@ -98,7 +99,8 @@ if ($action == 'presend') {
 			if ($object->element == 'invoice_supplier') {
 				$fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
 			} else {
-				$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+');
+				$filename = (!empty($conf->global->MMIDOCUMENT_PDF_RENAME)) ?$object->pdf_filename() :$ref;
+				$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($filename, '/').'[^\-]+');
 			}
 
 			$file = $fileparams['fullname'];

+ 1 - 1
htdocs/custom/mmicommon

@@ -1 +1 @@
-Subproject commit 5913af634b383bdf61787c5b116584f00ca11790
+Subproject commit b49998c189483795d1be19de9f5d6289f33c3abc

+ 1 - 1
htdocs/custom/mmidocuments

@@ -1 +1 @@
-Subproject commit 893570973670332bc9d1d726ed003562b0eebeec
+Subproject commit 5307027be4313e6a5648ccbb0750d79d2c3c4d22

+ 1 - 1
htdocs/custom/mmiproject

@@ -1 +1 @@
-Subproject commit ce05e003fe06b1ddb98da14b2d230bbec23a4513
+Subproject commit d874dbb76b9a981c7180e1b6fa933df74dfa3179

+ 1 - 0
htdocs/custom/subtotal

@@ -0,0 +1 @@
+Subproject commit d975b846d977807edcf803d8950e5f16a4cd18e0