--- /tmp/dsg/dolibarr/htdocs/core/modules/usergroup/doc/github_19.0.3_doc_generic_usergroup_odt.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/usergroup/doc/client_doc_generic_usergroup_odt.modules.php
@@ -42,2 +42,2 @@
-	 * Dolibarr version of the loaded document

-	 * @var string

+	 * Issuer

+	 * @var Societe

@@ -44,0 +45,12 @@
+	public $emetteur;

+

+	/**

+     * @var array Minimum version of PHP required by module.

+     * e.g.: PHP ≥ 5.5 = array(5, 5)

+     */

+	public $phpmin = array(5, 5);

+

+	/**

+   * Dolibarr version of the loaded document

+   * @var string

+   */

@@ -53 +65 @@
-	public function __construct($db)

+    public function __construct($db)

@@ -55 +67 @@
-		global $langs, $mysoc;

+		global $conf, $langs, $mysoc;

@@ -58 +70 @@
-		$langs->loadLangs(array("main", "companies"));

+        $langs->loadLangs(array("main", "companies"));

@@ -75,6 +87,7 @@
-		$this->option_logo = 1; // Display logo

-		$this->option_tva = 0; // Manage the vat option USERGROUP_TVAOPTION

-		$this->option_modereg = 0; // Display payment mode

-		$this->option_condreg = 0; // Display payment terms

-		$this->option_multilang = 1; // Available in several languages

-		$this->option_escompte = 0; // Displays if there has been a discount

+		$this->option_logo = 1; // Affiche logo

+		$this->option_tva = 0; // Gere option tva USERGROUP_TVAOPTION

+		$this->option_modereg = 0; // Affiche mode reglement

+		$this->option_condreg = 0; // Affiche conditions reglement

+		$this->option_codeproduitservice = 0; // Affiche code produit-service

+		$this->option_multilang = 1; // Dispo en plusieurs langues

+		$this->option_escompte = 0; // Affiche si il y a eu escompte

@@ -85 +98 @@
-		// Get source company

+		// Recupere emetteur

@@ -87,3 +100 @@
-		if (!$this->emetteur->country_code) {

-			$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined

-		}

+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined

@@ -99 +110 @@
-	public function info($langs)

+    public function info($langs)

@@ -104 +115 @@
-		$langs->loadLangs(array("errors", "companies"));

+        $langs->loadLangs(array("errors", "companies"));

@@ -108,3 +118,0 @@
-		$odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0;

-		$odtPath = trim(getDolGlobalString('USERGROUP_ADDON_PDF_ODT_PATH'));

-

@@ -112 +120 @@
-		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';

+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';

@@ -114 +121,0 @@
-		$texte .= '<input type="hidden" name="page_y" value="">';

@@ -117 +124,2 @@
-		if ($odtChosen) {

+		if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)

+		{

@@ -127 +135 @@
-		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));

+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH)));

@@ -129 +137,2 @@
-		foreach ($listofdir as $key => $tmpdir) {

+		foreach ($listofdir as $key=>$tmpdir)

+		{

@@ -133,6 +142,5 @@
-				unset($listofdir[$key]);

-				continue;

-			}

-			if (!is_dir($tmpdir)) {

-				$texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);

-			} else {

+				unset($listofdir[$key]); continue;

+			}

+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);

+			else

+			{

@@ -140,3 +148 @@
-				if (count($tmpfiles)) {

-					$listoffiles = array_merge($listoffiles, $tmpfiles);

-				}

+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);

@@ -146 +151,0 @@
-		$texthelp .= '<br><br><span class="opacitymedium">'.$langs->trans("ExampleOfDirectoriesForModelGen").'</span>';

@@ -151 +156 @@
-		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);

+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);

@@ -154 +159 @@
-		$texte .= $odtPath;

+		$texte .= $conf->global->USERGROUP_ADDON_PDF_ODT_PATH;

@@ -157 +162 @@
-		$texte .= '<input type="submit" class="button button-edit reposition smallpaddingimp" name="modify" value="'.dol_escape_htmltag($langs->trans("Modify")).'">';

+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';

@@ -161 +166,2 @@
-		if (count($listofdir)) {

+		if (count($listofdir))

+		{

@@ -164 +170,2 @@
-			if ($odtChosen) {

+			if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)

+			{

@@ -166 +173 @@
-				$list = ModelePDFUserGroup::liste_modeles($this->db);

+				$liste = ModelePDFUserGroup::liste_modeles($this->db);

@@ -171 +178 @@
-				$texte .= $form->selectarray('value2', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_DEFAULT'));

+				$texte .= $form->selectarray('value2', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT);

@@ -177 +184 @@
-				$texte .= $form->selectarray('value3', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_TOBILL'));

+				$texte .= $form->selectarray('value3', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL);

@@ -183 +190 @@
-				$texte .= $form->selectarray('value4', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_CLOSED'));

+				$texte .= $form->selectarray('value4', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED);

@@ -187,8 +193,0 @@
-			$texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';

-			// Show list of found files

-			foreach ($listoffiles as $file) {

-				$texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=usergroups/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a>';

-				$texte .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?modulepart=doctemplates&keyforuploaddir=USERGROUP_ADDON_PDF_ODT_PATH&action=deletefile&token='.newToken().'&file='.urlencode(basename($file['name'])).'">'.img_picto('', 'delete').'</a>';

-				$texte .= '<br>';

-			}

-			$texte .= '</div>';

@@ -196,11 +194,0 @@
-		// Add input to upload a new template file.

-		$texte .= '<div>'.$langs->trans("UploadNewTemplate");

-		$maxfilesizearray = getMaxFileSizeArray();

-		$maxmin = $maxfilesizearray['maxmin'];

-		if ($maxmin > 0) {

-			$texte .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">';	// MAX_FILE_SIZE must precede the field type=file

-		}

-		$texte .= ' <input type="file" name="uploadfile">';

-		$texte .= '<input type="hidden" value="USERGROUP_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';

-		$texte .= '<input type="submit" class="button smallpaddingimp reposition" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';

-		$texte .= '</div>';

@@ -209,0 +198,3 @@
+		$texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';

+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");

+		$texte .= '</td>';

@@ -218 +209 @@
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

@@ -230 +221 @@
-	public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)

+    public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)

@@ -232 +223 @@
-		// phpcs:enable

+        // phpcs:enable

@@ -235 +226,2 @@
-		if (empty($srctemplatepath)) {

+		if (empty($srctemplatepath))

+		{

@@ -241 +233,2 @@
-		if (!is_object($hookmanager)) {

+		if (!is_object($hookmanager))

+		{

@@ -248,3 +241 @@
-		if (!is_object($outputlangs)) {

-			$outputlangs = $langs;

-		}

+		if (!is_object($outputlangs)) $outputlangs = $langs;

@@ -257 +248,2 @@
-		if ($conf->user->dir_output) {

+		if ($conf->user->dir_output)

+		{

@@ -259 +251,2 @@
-			if (!is_object($object)) {

+			if (!is_object($object))

+			{

@@ -263 +256,2 @@
-				if ($result < 0) {

+				if ($result < 0)

+				{

@@ -269 +263 @@
-			$dir = $conf->user->dir_output.'/usergroups';

+			$dir = $conf->usergroup->dir_output;

@@ -271,3 +265 @@
-			if (!preg_match('/specimen/i', $objectref)) {

-				$dir .= "/".$objectref;

-			}

+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

@@ -276,2 +268,4 @@
-			if (!file_exists($dir)) {

-				if (dol_mkdir($dir) < 0) {

+			if (!file_exists($dir))

+			{

+				if (dol_mkdir($dir) < 0)

+				{

@@ -283 +277,2 @@
-			if (file_exists($dir)) {

+			if (file_exists($dir))

+			{

@@ -286 +281 @@
-				$newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);

+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);

@@ -290 +285 @@
-				$newfiletmp = $objectref . '_' . $newfiletmp;

+				$newfiletmp = $objectref.'_'.$newfiletmp;

@@ -294,10 +289,11 @@
-				if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {

-					$format = getDolGlobalString('MAIN_DOC_USE_TIMING');

-					if ($format == '1') {

-						$format = '%Y%m%d%H%M%S';

-					}

-					$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;

-				} else {

-					$filename = $newfiletmp . '.' . $newfileformat;

-				}

-				$file = $dir . '/' . $filename;

+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))

+				{

+				    $format = $conf->global->MAIN_DOC_USE_TIMING;

+				    if ($format == '1') $format = '%Y%m%d%H%M%S';

+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;

+				}

+				else

+				{

+					$filename = $newfiletmp.'.'.$newfileformat;

+				}

+				$file = $dir.'/'.$filename;

@@ -310,5 +306 @@
-				if (!is_writable($conf->user->dir_temp)) {

-					$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->user->dir_temp);

-					dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);

-					return -1;

-				}

+

@@ -319 +311,2 @@
-				if (count($arrayidcontact) > 0) {

+				if (count($arrayidcontact) > 0)

+				{

@@ -325,12 +318,12 @@
-				if (!empty($usecontact)) {

-					// We can use the company of contact instead of thirdparty company

-					if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {

-						$object->contact->fetch_thirdparty();

-						$socobject = $object->contact->thirdparty;

-						$contactobject = $object->contact;

-					} else {

-						$socobject = $object->thirdparty;

-						// if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use

-						$contactobject = $object->contact;

-					}

-				} else {

+				if (!empty($usecontact))

+				{

+					// On peut utiliser le nom de la societe du contact

+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;

+					else {

+                        $socobject = $object->thirdparty;

+                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use

+                        $contactobject = $object->contact;

+                    }

+				}

+				else

+				{

@@ -345 +338 @@
-				'__TOTAL_VAT__' => $object->total_tva

+				'__TOTAL_VAT__' => $object->total_vat

@@ -355,2 +348,3 @@
-				if (!empty($conf->global->$paramfreetext)) {

-					$newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);

+				if (!empty($conf->global->$paramfreetext))

+				{

+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);

@@ -362 +356 @@
-					$odfHandler = new Odf(

+                    $odfHandler = new odf(

@@ -386 +380,3 @@
-				} catch (OdfException $e) {

+				}

+				catch (OdfException $e)

+				{

@@ -399,3 +395 @@
-				if ($usecontact && is_object($contactobject)) {

-					$array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');

-				}

+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');

@@ -409,9 +403,11 @@
-				foreach ($tmparray as $key => $value) {

-					try {

-						if (preg_match('/logo$/', $key)) { // Image

-							if (file_exists($value)) {

-								$odfHandler->setImage($key, $value);

-							} else {

-								$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');

-							}

-						} else { // Text

+				foreach ($tmparray as $key=>$value)

+				{

+					try

+					{

+						if (preg_match('/logo$/', $key)) // Image

+						{

+							if (file_exists($value)) $odfHandler->setImage($key, $value);

+							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');

+						}

+						else    // Text

+						{

@@ -420 +416,3 @@
-					} catch (OdfException $e) {

+					}

+					catch (OdfException $e)

+					{

@@ -425 +423,2 @@
-				try {

+				try

+				{

@@ -429 +428,3 @@
-					} catch (OdfExceptionSegmentNotFound $e) {

+					}

+					catch (OdfException $e)

+					{

@@ -433,6 +434,5 @@
-					} catch (OdfException $e) {

-						$foundtagforlines = 0;

-						dol_syslog($e->getMessage(), LOG_INFO);

-					}

-					if ($foundtagforlines) {

-						foreach ($object->members as $u) {

+					}

+					if ($foundtagforlines)

+					{

+						foreach ($object->members as $u)

+						{

@@ -446,2 +446,4 @@
-							foreach ($tmparray as $key => $val) {

-								try {

+							foreach ($tmparray as $key => $val)

+							{

+								try

+								{

@@ -451 +453,3 @@
-								} catch (OdfException $e) {

+								}

+								catch (OdfException $e)

+								{

@@ -453 +457,3 @@
-								} catch (SegmentException $e) {

+								}

+								catch (SegmentException $e)

+								{

@@ -461 +467,3 @@
-				} catch (OdfException $e) {

+				}

+				catch (OdfException $e)

+				{

@@ -469 +477,2 @@
-				foreach ($tmparray as $key => $value) {

+				foreach ($tmparray as $key => $value)

+				{

@@ -472 +481,3 @@
-					} catch (OdfException $e) {

+					}

+					catch (OdfException $e)

+					{

@@ -482 +493 @@
-				if (getDolGlobalString('MAIN_ODT_AS_PDF')) {

+				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {

@@ -490 +501,2 @@
-				} else {

+				}

+				else {

@@ -502 +514,2 @@
-				dolChmod($file);

+				if (!empty($conf->global->MAIN_UMASK))

+					@chmod($file, octdec($conf->global->MAIN_UMASK));

@@ -509 +522,3 @@
-			} else {

+			}

+			else

+			{

@@ -515,2 +530,2 @@
-		return -1;

-	}

+        return -1;

+    }