--- /tmp/dsg/dolibarr/htdocs/core/modules/project/task/doc/github_19.0.3_doc_generic_task_odt.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/task/doc/client_doc_generic_task_odt.modules.php @@ -6,2 +6 @@ - * Copyright (C) 2018 Frédéric France - * Copyright (C) 2023 Gauthier VERDOL + * Copyright (C) 2018 Frédéric France @@ -42,30 +41,10 @@ -if (isModEnabled("propal")) { - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -} -if (isModEnabled('facture')) { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -} -if (isModEnabled('facture')) { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -} -if (isModEnabled('commande')) { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -} -if (isModEnabled("supplier_invoice")) { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -} -if (isModEnabled("supplier_order")) { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -} -if (isModEnabled('contrat')) { - require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -} -if (isModEnabled('ficheinter')) { - require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -} -if (isModEnabled('deplacement')) { - require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -} -if (isModEnabled('agenda')) { - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -} +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -80,3 +59,15 @@ - * Dolibarr version of the loaded document - * @var string - */ + * Issuer + * @var Societe Object that emits + */ + 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 + */ @@ -91,3 +82,3 @@ - public function __construct($db) - { - global $langs, $mysoc; + public function __construct($db) + { + global $conf, $langs, $mysoc; @@ -96 +87 @@ - $langs->loadLangs(array("main", "companies")); + $langs->loadLangs(array("main", "companies")); @@ -113,6 +104,7 @@ - $this->option_logo = 1; // Display logo - $this->option_tva = 0; // Manage the vat option COMMANDE_TVAOPTION - $this->option_modereg = 0; // Display payment mode - $this->option_condreg = 0; // Display payment terms - $this->option_multilang = 0; // 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 COMMANDE_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 = 0; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte @@ -123 +115 @@ - // Get source company + // Recupere emetteur @@ -125,7 +117,5 @@ - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -137 +127 @@ - * @param string $array_key Name of the key for return array + * @param string $array_key Name of the key for return array @@ -142 +132 @@ - // phpcs:enable + // phpcs:enable @@ -146,12 +136,12 @@ - $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_title'=>$object->title, - $array_key.'_description'=>$object->description, - $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'), - $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'), - $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'), - $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'), - $array_key.'_note_private'=>$object->note_private, - $array_key.'_note_public'=>$object->note_public, - $array_key.'_public'=>$object->public, - $array_key.'_statut'=>$object->getLibStatut() + $array_key.'_id'=>$object->id, + $array_key.'_ref'=>$object->ref, + $array_key.'_title'=>$object->title, + $array_key.'_description'=>$object->description, + $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'), + $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'), + $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'), + $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'), + $array_key.'_note_private'=>$object->note_private, + $array_key.'_note_public'=>$object->note_public, + $array_key.'_public'=>$object->public, + $array_key.'_statut'=>$object->getLibStatut() @@ -161 +151,2 @@ - if (is_array($object->array_options) && count($object->array_options)) { + if (is_array($object->array_options) && count($object->array_options)) + { @@ -170 +161 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -179,13 +170,13 @@ - public function get_substitutionarray_tasks($task, $outputlangs, $array_key = 'task') - { - // phpcs:enable - global $conf, $extrafields; - - $resarray = array( - 'task_ref'=>$task->ref, - 'task_fk_project'=>$task->fk_project, - 'task_projectref'=>$task->projectref, - 'task_projectlabel'=>$task->projectlabel, - 'task_label'=>$task->label, - 'task_description'=>$task->description, - 'task_fk_parent'=>$task->fk_task_parent, + public function get_substitutionarray_tasks($task, $outputlangs, $array_key = 'task') + { + // phpcs:enable + global $conf, $extrafields; + + $resarray = array( + 'task_ref'=>$task->ref, + 'task_fk_project'=>$task->fk_project, + 'task_projectref'=>$task->projectref, + 'task_projectlabel'=>$task->projectlabel, + 'task_label'=>$task->label, + 'task_description'=>$task->description, + 'task_fk_parent'=>$task->fk_parent, @@ -193,22 +184,23 @@ - 'task_duration_formated'=>convertSecondToTime($task->duration_effective, 'allhourmin'), - 'task_planned_workload'=>$task->planned_workload, - 'task_planned_workload_formated'=>convertSecondToTime($task->planned_workload, 'allhourmin'), - 'task_progress'=>$task->progress, - 'task_public'=>$task->public, - 'task_date_start'=>dol_print_date($task->date_start, 'day'), - 'task_date_end'=>dol_print_date($task->date_end, 'day'), - 'task_note_private'=>$task->note_private, - 'task_note_public'=>$task->note_public - ); - - // Retrieve extrafields - if (is_array($task->array_options) && count($task->array_options)) { - $task->fetch_optionals(); - - $resarray = $this->fill_substitutionarray_with_extrafields($task, $resarray, $extrafields, $array_key, $outputlangs); - } - - return $resarray; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + 'task_duration_formated'=>convertSecondToTime($task->duration_effective, 'allhourmin'), + 'task_planned_workload'=>$task->planned_workload, + 'task_planned_workload_formated'=>convertSecondToTime($task->planned_workload, 'allhourmin'), + 'task_progress'=>$task->progress, + 'task_public'=>$task->public, + 'task_date_start'=>dol_print_date($task->date_start, 'day'), + 'task_date_end'=>dol_print_date($task->date_end, 'day'), + 'task_note_private'=>$task->note_private, + 'task_note_public'=>$task->note_public + ); + + // Retrieve extrafields + if (is_array($task->array_options) && count($task->array_options)) + { + $task->fetch_optionals(); + + $resarray = $this->fill_substitutionarray_with_extrafields($task, $resarray, $extrafields, $array_key, $outputlangs); + } + + return $resarray; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -224 +216 @@ - // phpcs:enable + // phpcs:enable @@ -239 +231 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -249 +241 @@ - // phpcs:enable + // phpcs:enable @@ -259 +251 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -269 +261 @@ - // phpcs:enable + // phpcs:enable @@ -283 +275 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -293 +285 @@ - // phpcs:enable + // phpcs:enable @@ -307 +299 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -317 +309 @@ - // phpcs:enable + // phpcs:enable @@ -332 +324 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -342 +334 @@ - // phpcs:enable + // phpcs:enable @@ -364 +356 @@ - $langs->loadLangs(array("errors", "companies")); + $langs->loadLangs(array("errors", "companies")); @@ -369 +361 @@ - $texte .= '
'; + $texte .= ''; @@ -371 +362,0 @@ - $texte .= ''; @@ -374 +365 @@ - $texte .= ''; + $texte .= '
'; @@ -381 +372,2 @@ - foreach ($listofdir as $key => $tmpdir) { + foreach ($listofdir as $key=>$tmpdir) + { @@ -385,2 +377 @@ - unset($listofdir[$key]); - continue; + unset($listofdir[$key]); continue; @@ -388,3 +379,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 + { @@ -392,3 +383 @@ - if (count($tmpfiles)) { - $listoffiles = array_merge($listoffiles, $tmpfiles); - } + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); @@ -398 +386,0 @@ - $texthelp .= '

'.$langs->trans("ExampleOfDirectoriesForModelGen").''; @@ -403 +391 @@ - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); @@ -406 +394 @@ - $texte .= getDolGlobalString('PROJECT_TASK_ADDON_PDF_ODT_PATH'); + $texte .= $conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH; @@ -409 +397 @@ - $texte .= ''; + $texte .= ''; @@ -414 +402,2 @@ - if (getDolGlobalString('PROJECT_TASK_ADDON_PDF_ODT_PATH')) { + if (!empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)) + { @@ -422,9 +411,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 .= ''; @@ -432,11 +420 @@ - // 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 .= '
'; + @@ -444,0 +423,3 @@ + $texte .= ''; @@ -453 +434 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -464 +445 @@ - // phpcs:enable + // phpcs:enable @@ -467 +448,2 @@ - if (empty($srctemplatepath)) { + if (empty($srctemplatepath)) + { @@ -472,3 +454 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -481 +461,2 @@ - if ($conf->project->dir_output) { + if ($conf->projet->dir_output) + { @@ -483 +464,2 @@ - if (!is_object($object)) { + if (!is_object($object)) + { @@ -487 +469,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -496 +479 @@ - $dir = $conf->project->dir_output."/".$project->ref."/"; + $dir = $conf->projet->dir_output."/".$project->ref."/"; @@ -498,3 +481 @@ - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -503,2 +484,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -511 +494,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -517 +501 @@ - $newfiletmp = $objectref . '_' . $newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; @@ -519 +503 @@ - $file = $dir . '/' . $newfiletmp . '.odt'; + $file = $dir.'/'.$newfiletmp.'.odt'; @@ -525,6 +509 @@ - dol_mkdir($conf->project->dir_temp); - if (!is_writable($conf->project->dir_temp)) { - $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->project->dir_temp); - dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); - return -1; - } + dol_mkdir($conf->projet->dir_temp); @@ -541,2 +519,0 @@ - $tmparray = array(); - $action = ''; @@ -549 +526 @@ - $odfHandler = new Odf( + $odfHandler = new odf( @@ -552 +529 @@ - 'PATH_TO_TMP' => $conf->project->dir_temp, + 'PATH_TO_TMP' => $conf->projet->dir_temp, @@ -558 +535,3 @@ - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -581 +560,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -583,7 +563,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 + { @@ -593 +573 @@ - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); @@ -598 +578,2 @@ - try { + try + { @@ -601,3 +582 @@ - if (!empty($project->fk_soc)) { - $socid = $project->fk_soc; - } + if (!empty($project->fk_soc)) $socid = $project->fk_soc; @@ -607 +586,2 @@ - foreach ($tmparray as $key => $val) { + foreach ($tmparray as $key => $val) + { @@ -622 +602,2 @@ - if ((is_array($contact_temp) && count($contact_temp) > 0)) { + if ((is_array($contact_temp) && count($contact_temp) > 0)) + { @@ -626 +607,2 @@ - if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { + if ((is_array($contact_arrray) && count($contact_arrray) > 0)) + { @@ -629 +611,2 @@ - foreach ($contact_arrray as $contact) { + foreach ($contact_arrray as $contact) + { @@ -646 +629,2 @@ - foreach ($tmparray as $key => $val) { + foreach ($tmparray as $key => $val) + { @@ -651 +635,2 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) { @@ -661 +646 @@ - $sql = "SELECT t.rowid, t.element_date as task_date, t.element_duration as task_duration, t.fk_user, t.note"; + $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; @@ -663 +648 @@ - $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; @@ -665,2 +650 @@ - $sql .= " WHERE t.fk_element =".((int) $object->id); - $sql .= " AND t.elementtype = 'task'"; + $sql .= " WHERE t.fk_task =".$object->id; @@ -668 +652 @@ - $sql .= " ORDER BY t.element_date DESC"; + $sql .= " ORDER BY t.task_date DESC"; @@ -671 +655,2 @@ - if ($resql) { + if ($resql) + { @@ -676 +661,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -689,2 +675,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -692 +680,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -694 +684,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -710 +702 @@ - $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref); @@ -714 +706,2 @@ - foreach ($filearray as $filedetail) { + foreach ($filearray as $filedetail) + { @@ -717,2 +710,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -720 +715,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -722 +719,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -731 +730,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -740 +741,2 @@ - try { + try + { @@ -743 +745 @@ - $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -747 +749,2 @@ - foreach ($filearray as $filedetail) { + foreach ($filearray as $filedetail) + { @@ -751,2 +754,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -754 +759,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -756 +763,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -763 +772,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -774 +785,2 @@ - if ((is_array($contact_temp) && count($contact_temp) > 0)) { + if ((is_array($contact_temp) && count($contact_temp) > 0)) + { @@ -778,2 +790,4 @@ - if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { - try { + if ((is_array($contact_arrray) && count($contact_arrray) > 0)) + { + try + { @@ -782 +796,2 @@ - foreach ($contact_arrray as $contact) { + foreach ($contact_arrray as $contact) + { @@ -799,2 +814,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -802 +819,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -804 +823,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -811 +832,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -825 +848 @@ - if (getDolGlobalString('MAIN_ODT_AS_PDF')) { + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { @@ -830 +853 @@ - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); @@ -833 +856,2 @@ - } else { + } + else { @@ -838 +862 @@ - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); @@ -845 +869,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -852 +877,3 @@ - } else { + } + else + {
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '