--- /tmp/dsg/dolibarr/htdocs/core/modules/project/task/github_19.0.3_mod_task_simple.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/task/client_mod_task_simple.php @@ -63,2 +63 @@ - * @param Translate $langs Lang object to use for output - * @return string Descriptive text + * @return string Text with description @@ -66 +65 @@ - public function info($langs) + public function info() @@ -69 +68 @@ - return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -88,2 +87 @@ - * @param Object $object Object we need next value for - * @return boolean false if KO (there is a conflict), true if OK + * @return boolean false if conflict, true if ok @@ -91 +89 @@ - public function canBeActivated($object) + public function canBeActivated() @@ -95,2 +93 @@ - $coyymm = ''; - $max = ''; + $coyymm = ''; $max = ''; @@ -105 +102,2 @@ - if ($resql) { + if ($resql) + { @@ -107,4 +105 @@ - if ($row) { - $coyymm = substr($row[0], 0, 6); - $max = $row[0]; - } + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } @@ -112 +107,2 @@ - if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { + if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + { @@ -114 +110,3 @@ - } else { + } + else + { @@ -140 +138,2 @@ - if ($resql) { + if ($resql) + { @@ -142,6 +141,5 @@ - if ($obj) { - $max = intval($obj->max); - } else { - $max = 0; - } - } else { + if ($obj) $max = intval($obj->max); + else $max = 0; + } + else + { @@ -152,2 +150 @@ - $date = empty($object->date_c) ? dol_now() : $object->date_c; - $yymm = dol_print_date($date, "%y%m"); + $date = empty($object->date_c) ?dol_now() : $object->date_c; @@ -155,5 +152,5 @@ - if ($max >= (pow(10, 4) - 1)) { - $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is - } else { - $num = sprintf("%04s", $max + 1); - } + //$yymm = strftime("%y%m",time()); + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max + 1); --- /tmp/dsg/dolibarr/htdocs/core/modules/project/task/github_19.0.3_mod_task_universal.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/task/client_mod_task_universal.php @@ -34,3 +34,3 @@ - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ @@ -40,3 +40,3 @@ - * @var string Error code (or message) - */ - public $error = ''; + * @var string Error code (or message) + */ + public $error = ''; @@ -57,9 +57,8 @@ - /** - * Returns the description of the numbering model - * - * @param Translate $langs Lang object to use for output - * @return string Descriptive text - */ - public function info($langs) - { - global $langs, $db; + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs; @@ -68 +67 @@ - $langs->loadLangs(array("projects", "admin")); + $langs->loadLangs(array("projects", "admin")); @@ -70 +69 @@ - $form = new Form($db); + $form = new Form($this->db); @@ -87 +86 @@ - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; @@ -89 +88 @@ - $texte .= '  '; + $texte .= '  '; @@ -97 +96 @@ - } + } @@ -99,8 +98,8 @@ - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $conf, $langs, $mysoc; + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf, $langs, $mysoc; @@ -108,3 +107,3 @@ - $old_code_client = $mysoc->code_client; - $mysoc->code_client = 'CCCCCCCCCC'; - $numExample = $this->getNextValue($mysoc, ''); + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc, ''); @@ -113 +112,2 @@ - if (!$numExample) { + if (!$numExample) + { @@ -117 +117 @@ - } + } @@ -119,9 +119,9 @@ - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string Value if OK, 0 if KO - */ - public function getNextValue($objsoc, $object) - { + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Task $object Object task + * @return string Value if OK, 0 if KO + */ + public function getNextValue($objsoc, $object) + { @@ -132 +132,2 @@ - $mask = getDolGlobalString('PROJECT_TASK_UNIVERSAL_MASK'); + // On defini critere recherche compteur + $mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK; @@ -134 +135,2 @@ - if (!$mask) { + if (!$mask) + { @@ -139 +141 @@ - $date = empty($object->date_c) ? dol_now() : $object->date_c; + $date = empty($object->date_c) ?dol_now() : $object->date_c; @@ -146,13 +148,13 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next reference not yet used as a reference - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string Next not used reference - */ - public function project_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return next reference not yet used as a reference + * + * @param Societe $objsoc Object third party + * @param Task $object Object task + * @return string Next not used reference + */ + public function project_get_num($objsoc = 0, $object = '') + { + // phpcs:enable + return $this->getNextValue($objsoc, $object); + } --- /tmp/dsg/dolibarr/htdocs/core/modules/project/task/github_19.0.3_modules_task.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/task/client_modules_task.php @@ -27 +26,0 @@ - @@ -29 +27,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; @@ -33 +31 @@ - * Parent class for task models + * Parent class for projects models @@ -37 +35,7 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * @var string Error code (or message) + */ + public $error = ''; + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -41,5 +45,5 @@ - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates - */ - public static function liste_modeles($db, $maxfilenamelength = 0) + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) @@ -47 +51,3 @@ - // phpcs:enable + // phpcs:enable + global $conf; + @@ -49 +55 @@ - $list = array(); + $liste = array(); @@ -52 +58 @@ - $list = getListOfModels($db, $type, $maxfilenamelength); + $liste = getListOfModels($db, $type, $maxfilenamelength); @@ -54 +60 @@ - return $list; + return $liste; @@ -61 +67 @@ - * Parent class of task reference numbering models + * Classe mere des modeles de numerotation des references de projets @@ -63 +69 @@ -abstract class ModeleNumRefTask extends CommonNumRefGenerator +abstract class ModeleNumRefTask @@ -65 +71,78 @@ - // No overload code + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } + + /** + * Renvoi la description par defaut du modele de numerotation + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("projects"); + return $langs->trans("NoDescription"); + } + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("projects"); + return $langs->trans("NoExample"); + } + + /** + * Checks if the numbers already in the database do not + * cause conflicts that would prevent this numbering working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + return true; + } + + /** + * Renvoi prochaine valeur attribuee + * + * @param Societe $objsoc Object third party + * @param Project $project Object project + * @return string Valeur + */ + public function getNextValue($objsoc, $project) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Renvoi version du module numerotation + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + return $langs->trans("NotAvailable"); + }