--- /tmp/dsg/dolibarr/htdocs/core/modules/bom/doc/github_19.0.3_doc_generic_bom_odt.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/bom/doc/client_doc_generic_bom_odt.modules.php @@ -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")); @@ -80 +92 @@ - // Get source company + // Recupere emetteur @@ -82,3 +94 @@ - 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 @@ -94 +104 @@ - public function info($langs) + public function info($langs) @@ -99 +109 @@ - $langs->loadLangs(array("errors", "companies")); + $langs->loadLangs(array("errors", "companies")); @@ -104 +114 @@ - $texte .= '
'; + $texte .= ''; @@ -106 +115,0 @@ - $texte .= ''; @@ -116 +125,2 @@ - foreach ($listofdir as $key => $tmpdir) { + foreach ($listofdir as $key=>$tmpdir) + { @@ -120,2 +130 @@ - unset($listofdir[$key]); - continue; + unset($listofdir[$key]); continue; @@ -123,3 +132,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 + { @@ -127,3 +136 @@ - if (count($tmpfiles)) { - $listoffiles = array_merge($listoffiles, $tmpfiles); - } + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); @@ -133 +139,0 @@ - $texthelp .= '

'.$langs->trans("ExampleOfDirectoriesForModelGen").''; @@ -138 +144 @@ - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); @@ -141 +147 @@ - $texte .= getDolGlobalString('BOM_ADDON_PDF_ODT_PATH'); + $texte .= $conf->global->BOM_ADDON_PDF_ODT_PATH; @@ -144 +150 @@ - $texte .= ''; + $texte .= ''; @@ -149 +155,2 @@ - if (getDolGlobalString('BOM_ADDON_PDF_ODT_PATH')) { + if (!empty($conf->global->BOM_ADDON_PDF_ODT_PATH)) + { @@ -157,9 +164,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 .= ''; @@ -167,11 +172,0 @@ - // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate"); - $maxfilesizearray = getMaxFileSizeArray(); - $maxmin = $maxfilesizearray['maxmin']; - if ($maxmin > 0) { - $texte .= ''; // MAX_FILE_SIZE must precede the field type=file - } - $texte .= ' '; - $texte .= ''; - $texte .= ''; - $texte .= '
'; @@ -180,0 +176,3 @@ + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; @@ -189 +187 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -201 +199 @@ - 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) @@ -203 +201 @@ - // phpcs:enable + // phpcs:enable @@ -206 +204,2 @@ - if (empty($srctemplatepath)) { + if (empty($srctemplatepath)) + { @@ -212 +211,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -219,3 +219 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -225 +222,0 @@ - // Load translation files required by the page @@ -228 +225,2 @@ - if ($conf->bom->dir_output) { + if ($conf->bom->dir_output) + { @@ -230 +228,2 @@ - if (!is_object($object)) { + if (!is_object($object)) + { @@ -232 +231 @@ - $object = new BOM($this->db); + $object = new Bom($this->db); @@ -234 +233,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -240,3 +239,0 @@ - $object->fetch_thirdparty(); - $object->fetch_product(); - @@ -245,3 +242 @@ - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -250,2 +245,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -257 +254,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -260 +258 @@ - $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); @@ -263 +261 @@ - $newfiletmp = $objectref . '_' . $newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; @@ -267,10 +265,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; @@ -283,5 +282 @@ - if (!is_writable($conf->bom->dir_temp)) { - $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->bom->dir_temp); - dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); - return -1; - } + @@ -292 +287,2 @@ - if (count($arrayidcontact) > 0) { + if (count($arrayidcontact) > 0) + { @@ -299,12 +295,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 + { @@ -326,2 +322,3 @@ - if (!empty($conf->global->$paramfreetext)) { - $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); + if (!empty($conf->global->$paramfreetext)) + { + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); @@ -333 +330 @@ - $odfHandler = new Odf( + $odfHandler = new odf( @@ -342 +339,3 @@ - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -357,2 +356,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -371,3 +372 @@ - 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'); @@ -382 +381,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -384,7 +384,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 + { @@ -393,2 +393,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -398 +400,2 @@ - try { + try + { @@ -402 +405,3 @@ - } catch (OdfExceptionSegmentNotFound $e) { + } + catch (OdfException $e) + { @@ -406,5 +411,3 @@ - } catch (OdfException $e) { - $foundtagforlines = 0; - dol_syslog($e->getMessage(), LOG_INFO); - } - if ($foundtagforlines) { + } + if ($foundtagforlines) + { @@ -412 +415,2 @@ - foreach ($object->lines as $line) { + foreach ($object->lines as $line) + { @@ -414,11 +417,0 @@ - - if ($line->fk_product > 0) { - $line->fetch_product(); - - $line->product_ref = $line->product->ref; - $line->product_desc = $line->product->description; - $line->product_label = $line->product->label; - $line->product_type = $line->product->type; - $line->product_barcode = $line->product->barcode; - } - @@ -430,2 +423,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -433,4 +428,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); @@ -443 +442,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -451 +452,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -454,2 +456,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -465 +469 @@ - if (getDolGlobalString('MAIN_ODT_AS_PDF')) { + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { @@ -469,2 +473,2 @@ - $this->error = $e->getMessage(); - dol_syslog($e->getMessage(), LOG_INFO); + $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); @@ -473 +477,2 @@ - } else { + } + else { @@ -477,2 +482,2 @@ - $this->error = $e->getMessage(); - dol_syslog($e->getMessage(), LOG_INFO); + $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); @@ -486 +491,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -493 +499,3 @@ - } else { + } + else + {