--- /tmp/dsg/dolibarr/htdocs/core/modules/project/github_19.0.3_mod_project_simple.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/client_mod_project_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 = ''; @@ -104 +101,2 @@ - if ($resql) { + if ($resql) + { @@ -106,4 +104 @@ - if ($row) { - $coyymm = substr($row[0], 0, 6); - $max = $row[0]; - } + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } @@ -111 +106,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)) + { @@ -113 +109,3 @@ - } else { + } + else + { @@ -130 +128 @@ - global $db; + global $db, $conf; @@ -137 +135 @@ - $sql .= " AND entity IN (".getEntity('projectnumber', 1, $project).")"; + $sql .= " AND entity = ".$conf->entity; @@ -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 +150 @@ - $date = (empty($project->date_c) ? dol_now() : $project->date_c); + $date = empty($project->date_c) ?dol_now() : $project->date_c; @@ -155,2 +153 @@ - //$yymm = strftime("%y%m", $date); - $yymm = dol_print_date($date, "%y%m"); + $yymm = strftime("%y%m", $date); @@ -158,5 +155,2 @@ - 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); - } + 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/github_19.0.3_mod_project_universal.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/client_mod_project_universal.php @@ -20,3 +20,3 @@ - * \file htdocs/core/modules/project/mod_project_universal.php - * \ingroup project - * \brief File containing the Universal project reference numbering model class + * \file htdocs/core/modules/project/mod_project_universal.php + * \ingroup project + * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal @@ -29 +29 @@ - * Class to manage the numbering module Universal for project references + * Classe du modele de numerotation de reference de projet Universal @@ -34,8 +34,3 @@ - * @var DoliDB $db - */ - public $db; - - /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ @@ -45,3 +40,3 @@ - * @var string Error code (or message) - */ - public $error = ''; + * @var string Error code (or message) + */ + public $error = ''; @@ -62,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; + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs; @@ -73 +67 @@ - $langs->loadLangs(array("projects", "admin")); + $langs->loadLangs(array("projects", "admin")); @@ -90 +84 @@ - // Prefix settings + // Parametrage du prefix @@ -92 +86 @@ - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; @@ -94 +88 @@ - $texte .= '  '; + $texte .= '  '; @@ -102 +96 @@ - } + } @@ -104,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; @@ -113,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, ''); @@ -118 +112,2 @@ - if (!$numExample) { + if (!$numExample) + { @@ -122 +117 @@ - } + } @@ -124,9 +119,9 @@ - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string Value if OK, 0 if KO - */ - public function getNextValue($objsoc, $project) - { + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Project $project Object project + * @return string Value if OK, 0 if KO + */ + public function getNextValue($objsoc, $project) + { @@ -137,2 +132,2 @@ - // We define criterion search counter - $mask = getDolGlobalString('PROJECT_UNIVERSAL_MASK'); + // On defini critere recherche compteur + $mask = $conf->global->PROJECT_UNIVERSAL_MASK; @@ -140 +135,2 @@ - if (!$mask) { + if (!$mask) + { @@ -145,5 +141,2 @@ - // Get entities - $entity = getEntity('projectnumber', 1, $project); - - $date = (empty($project->date_c) ? dol_now() : $project->date_c); - $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc : ''), $date, 'next', false, null, $entity); + $date = empty($project->date_c) ?dol_now() : $project->date_c; + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); @@ -155,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 Project $project Object project - * @return string Next not used reference - */ - public function project_get_num($objsoc = 0, $project = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $project); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return next reference not yet used as a reference + * + * @param Societe $objsoc Object third party + * @param Project $project Object project + * @return string Next not used reference + */ + public function project_get_num($objsoc = 0, $project = '') + { + // phpcs:enable + return $this->getNextValue($objsoc, $project); + } --- /tmp/dsg/dolibarr/htdocs/core/modules/project/github_19.0.3_modules_project.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/client_modules_project.php @@ -27 +26,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; @@ -36 +35 @@ - * @var DoliDb Database handler + * @var string Error code (or message) @@ -38,6 +37 @@ - public $db; - - /** - * @var string model description (short text) - */ - public $description; + public $error = ''; @@ -46,2 +40,2 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** @@ -50,5 +44,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) @@ -56 +50,3 @@ - // phpcs:enable + // phpcs:enable + global $conf; + @@ -58 +54 @@ - $list = array(); + $liste = array(); @@ -61 +57 @@ - $list = getListOfModels($db, $type, $maxfilenamelength); + $liste = getListOfModels($db, $type, $maxfilenamelength); @@ -63 +59 @@ - return $list; + return $liste; @@ -72 +68 @@ -abstract class ModeleNumRefProjects extends CommonNumRefGenerator +abstract class ModeleNumRefProjects @@ -74 +70,79 @@ - // 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"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); + }