mod_evaluation_advanced.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  6. * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. * or see https://www.gnu.org/
  21. */
  22. /**
  23. * \file htdocs/core/modules/hrm/mod_evaluation_advanced.php
  24. * \ingroup hrm
  25. * \brief File containing class for advanced numbering model of Evaluation
  26. */
  27. dol_include_once('/core/modules/hrm/modules_evaluation.php');
  28. /**
  29. * Class to manage customer Bom numbering rules advanced
  30. */
  31. class mod_evaluation_advanced extends ModeleNumRefEvaluation
  32. {
  33. /**
  34. * Dolibarr version of the loaded document
  35. * @var string
  36. */
  37. public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
  38. /**
  39. * @var string Error message
  40. */
  41. public $error = '';
  42. /**
  43. * @var string name
  44. */
  45. public $name = 'advanced';
  46. /**
  47. * Returns the description of the numbering model
  48. *
  49. * @param Translate $langs Lang object to use for output
  50. * @return string Descriptive text
  51. */
  52. public function info($langs)
  53. {
  54. global $langs, $db;
  55. $langs->load("bills");
  56. $form = new Form($db);
  57. $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
  58. $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  59. $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
  60. $texte .= '<input type="hidden" name="action" value="updateMask">';
  61. $texte .= '<input type="hidden" name="maskconstEvaluation" value="HRM_EVALUATION_ADVANCED_MASK">';
  62. $texte .= '<table class="nobordernopadding" width="100%">';
  63. $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Evaluation"), $langs->transnoentities("Evaluation"));
  64. $tooltip .= $langs->trans("GenericMaskCodes2");
  65. $tooltip .= $langs->trans("GenericMaskCodes3");
  66. $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Evaluation"), $langs->transnoentities("Evaluation"));
  67. $tooltip .= $langs->trans("GenericMaskCodes5");
  68. // Parametrage du prefix
  69. $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
  70. $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskEvaluation" value="'.getDolGlobalString('HRM_EVALUATION_ADVANCED_MASK').'">', $tooltip, 1, 1).'</td>';
  71. $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button smallpaddingimp" value="'.$langs->trans("Modify").'" name="Button"></td>';
  72. $texte .= '</tr>';
  73. $texte .= '</table>';
  74. $texte .= '</form>';
  75. return $texte;
  76. }
  77. /**
  78. * Return an example of numbering
  79. *
  80. * @return string Example
  81. */
  82. public function getExample()
  83. {
  84. global $conf, $db, $langs, $mysoc;
  85. $object = new Evaluation($db);
  86. $object->initAsSpecimen();
  87. /*$old_code_client = $mysoc->code_client;
  88. $old_code_type = $mysoc->typent_code;
  89. $mysoc->code_client = 'CCCCCCCCCC';
  90. $mysoc->typent_code = 'TTTTTTTTTT';*/
  91. $numExample = $this->getNextValue($object);
  92. /*$mysoc->code_client = $old_code_client;
  93. $mysoc->typent_code = $old_code_type;*/
  94. if (!$numExample) {
  95. $numExample = $langs->trans('NotConfigured');
  96. }
  97. return $numExample;
  98. }
  99. /**
  100. * Return next free value
  101. *
  102. * @param Object $object Object we need next value for
  103. * @return string Value if KO, <0 if KO
  104. */
  105. public function getNextValue($object)
  106. {
  107. global $db, $conf;
  108. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  109. // We get cursor rule
  110. $mask = getDolGlobalString('HRM_EVALUATION_ADVANCED_MASK');
  111. if (!$mask) {
  112. $this->error = 'NotConfigured';
  113. return 0;
  114. }
  115. $date = $object->date;
  116. $numFinal = get_next_value($db, $mask, 'hrm_evaluation', 'ref', '', null, $date);
  117. return $numFinal;
  118. }
  119. }