--- /tmp/dsg/dolibarr/htdocs/core/modules/mrp/doc/github_19.0.3_doc_generic_mo_odt.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/mrp/doc/client_doc_generic_mo_odt.modules.php @@ -6,2 +6,2 @@ - * Copyright (C) 2018-2021 Philippe Grand - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018 Frédéric France @@ -44 +44,2 @@ - * @var string Dolibarr version of the loaded document + * Issuer + * @var Societe @@ -45,0 +47,11 @@ + public $emetteur; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * @var string Dolibarr version of the loaded document + */ @@ -54 +66 @@ - public function __construct($db) + public function __construct($db) @@ -59 +71 @@ - $langs->loadLangs(array("main", "companies")); + $langs->loadLangs(array("main", "companies")); @@ -76,6 +88,7 @@ - $this->option_logo = 1; // Display logo - $this->option_tva = 0; // Manage the vat option - $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 + $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 @@ -86 +99 @@ - // Get source company + // Recupere emetteur @@ -88,3 +101 @@ - 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 @@ -100 +111 @@ - public function info($langs) + public function info($langs) @@ -105 +116 @@ - $langs->loadLangs(array("errors", "companies")); + $langs->loadLangs(array("errors", "companies")); @@ -112 +122,0 @@ - $texte .= ''; @@ -122 +132,2 @@ - foreach ($listofdir as $key => $tmpdir) { + foreach ($listofdir as $key=>$tmpdir) + { @@ -126,2 +137 @@ - unset($listofdir[$key]); - continue; + unset($listofdir[$key]); continue; @@ -129,3 +139,3 @@ - if (!is_dir($tmpdir)) { - $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); - } else { + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else + { @@ -133,3 +143 @@ - if (count($tmpfiles)) { - $listoffiles = array_merge($listoffiles, $tmpfiles); - } + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); @@ -139 +146,0 @@ - $texthelp .= '

'.$langs->trans("ExampleOfDirectoriesForModelGen").''; @@ -144 +151 @@ - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); @@ -147 +154 @@ - $texte .= getDolGlobalString('MRP_MO_ADDON_PDF_ODT_PATH'); + $texte .= $conf->global->MRP_MO_ADDON_PDF_ODT_PATH; @@ -150 +157 @@ - $texte .= ''; + $texte .= ''; @@ -155 +162,2 @@ - if (getDolGlobalString('MRP_MO_ADDON_PDF_ODT_PATH')) { + if (!empty($conf->global->MRP_MO_ADDON_PDF_ODT_PATH)) + { @@ -163,9 +171,8 @@ - if ($nbofiles) { - $texte .= '
'; - // Show list of found files - foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; - $texte .= '   '.img_picto('', 'delete').''; - $texte .= '
'; - } - $texte .= '
'; + if ($nbofiles) + { + $texte .= ''; @@ -175,0 +183,3 @@ + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; @@ -184 +194 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -196 +206 @@ - 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) @@ -198 +208 @@ - // phpcs:enable + // phpcs:enable @@ -201 +211,2 @@ - if (empty($srctemplatepath)) { + if (empty($srctemplatepath)) + { @@ -207 +218,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -214,3 +226 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -222 +232,2 @@ - if ($conf->mrp->dir_output) { + if ($conf->mrp->dir_output) + { @@ -224 +235,2 @@ - if (!is_object($object)) { + if (!is_object($object)) + { @@ -226 +238 @@ - $object = new Mo($this->db); + $object = new MO($this->db); @@ -228 +240,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -234,2 +246,0 @@ - $object->fetch_thirdparty(); - @@ -238,3 +249 @@ - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -243,2 +252,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -250 +261,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -253 +265 @@ - $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); @@ -256 +268 @@ - $newfiletmp = $objectref . '_' . $newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; @@ -260,10 +272,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; @@ -275,6 +288,2 @@ - dol_mkdir($conf->mrp->dir_temp); - if (!is_writable($conf->mrp->dir_temp)) { - $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->mrp->dir_temp); - dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); - return -1; - } + dol_mkdir($conf->bom->dir_temp); + @@ -285 +294,2 @@ - if (count($arrayidcontact) > 0) { + if (count($arrayidcontact) > 0) + { @@ -292,12 +302,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 + { @@ -319,2 +329,3 @@ - if (!empty($conf->global->$paramfreetext)) { - $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); + if (!empty($conf->global->$paramfreetext)) + { + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); @@ -326 +337 @@ - $odfHandler = new Odf( + $odfHandler = new odf( @@ -329,4 +340,4 @@ - 'PATH_TO_TMP' => $conf->mrp->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. - 'DELIMITER_LEFT' => '{', - 'DELIMITER_RIGHT' => '}' + 'PATH_TO_TMP' => $conf->mrp->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' @@ -335 +346,3 @@ - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -340 +352,0 @@ - @@ -346,0 +359 @@ + @@ -350,2 +363,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -364,3 +379 @@ - 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'); @@ -375 +388,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -377,9 +391,7 @@ - if (preg_match('/logo$/', $key)) { - // Image - if (file_exists($value)) { - $odfHandler->setImage($key, $value); - } else { - $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); - } - } else { - // Text + if (preg_match('/logo$/', $key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { @@ -388,5 +400,6 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); - } - } - + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } @@ -394 +407,2 @@ - try { + try + { @@ -398 +412,3 @@ - } catch (OdfExceptionSegmentNotFound $e) { + } + catch (OdfException $e) + { @@ -402,5 +418,3 @@ - } catch (OdfException $e) { - $foundtagforlines = 0; - dol_syslog($e->getMessage(), LOG_INFO); - } - if ($foundtagforlines) { + } + if ($foundtagforlines) + { @@ -408 +422,2 @@ - foreach ($object->lines as $line) { + foreach ($object->lines as $line) + { @@ -415,2 +430,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -418,4 +435,8 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + catch (SegmentException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -428 +449,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -436 +459,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -439,2 +463,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -450 +476 @@ - if (getDolGlobalString('MAIN_ODT_AS_PDF')) { + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { @@ -454,2 +480,2 @@ - $this->error = $e->getMessage(); - dol_syslog('Error in exportAsAttachedPDF: '.$e->getMessage(), LOG_INFO); + $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); @@ -458 +484,2 @@ - } else { + } + else { @@ -462,2 +489,2 @@ - $this->error = $e->getMessage(); - dol_syslog('Error in saveToDisk: '.$e->getMessage(), LOG_INFO); + $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); @@ -471 +498,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -478 +506,3 @@ - } else { + } + else + {