mod_arctic.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 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) 2013 Juanjo Menent <jmenent@2byte.es>
  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/fichinter/mod_arctic.php
  24. * \ingroup fiche intervention
  25. * \brief File with Arctic numbering module for interventions
  26. */
  27. require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
  28. /**
  29. * Class to manage numbering of intervention cards with rule Artic.
  30. */
  31. class mod_arctic extends ModeleNumRefFicheinter
  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 Nom du modele
  44. * @deprecated
  45. * @see $name
  46. */
  47. public $nom = 'arctic';
  48. /**
  49. * @var string model name
  50. */
  51. public $name = 'arctic';
  52. /**
  53. * Returns the description of the numbering model
  54. *
  55. * @return string Texte descripif
  56. */
  57. public function info()
  58. {
  59. global $db, $conf, $langs;
  60. $langs->load("bills");
  61. $form = new Form($db);
  62. $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
  63. $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  64. $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
  65. $texte .= '<input type="hidden" name="action" value="updateMask">';
  66. $texte .= '<input type="hidden" name="maskconst" value="FICHINTER_ARTIC_MASK">';
  67. $texte .= '<table class="nobordernopadding" width="100%">';
  68. $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
  69. $tooltip .= $langs->trans("GenericMaskCodes2");
  70. $tooltip .= $langs->trans("GenericMaskCodes3");
  71. $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
  72. $tooltip .= $langs->trans("GenericMaskCodes5");
  73. // Setting the prefix
  74. $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
  75. $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.getDolGlobalString("FICHINTER_ARTIC_MASK").'">', $tooltip, 1, 1).'</td>';
  76. $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button" value="'.$langs->trans("Modify").'"></td>';
  77. $texte .= '</tr>';
  78. $texte .= '</table>';
  79. $texte .= '</form>';
  80. return $texte;
  81. }
  82. /**
  83. * Return an example of numbering
  84. *
  85. * @return string Example
  86. */
  87. public function getExample()
  88. {
  89. global $conf, $langs, $mysoc;
  90. $old_code_client = $mysoc->code_client;
  91. $mysoc->code_client = 'CCCCCCCCCC';
  92. $numExample = $this->getNextValue($mysoc, '');
  93. $mysoc->code_client = $old_code_client;
  94. if (!$numExample) {
  95. $numExample = $langs->trans('NotConfigured');
  96. }
  97. return $numExample;
  98. }
  99. /**
  100. * Return next free value
  101. *
  102. * @param Societe $objsoc Object thirdparty
  103. * @param Object $object Object we need next value for
  104. * @return string Value if KO, <0 if KO
  105. */
  106. public function getNextValue($objsoc = 0, $object = '')
  107. {
  108. global $db, $conf;
  109. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  110. // We define the search criteria of the counter
  111. $mask = getDolGlobalString("FICHINTER_ARTIC_MASK");
  112. if (!$mask) {
  113. $this->error = 'NotConfigured';
  114. return 0;
  115. }
  116. $numFinal = get_next_value($db, $mask, 'fichinter', 'ref', '', $objsoc, $object->datec);
  117. return $numFinal;
  118. }
  119. /**
  120. * Return next free value
  121. *
  122. * @param Societe $objsoc Object third party
  123. * @param Object $objforref Object for number to search
  124. * @return string Next free value
  125. */
  126. public function getNumRef($objsoc, $objforref)
  127. {
  128. return $this->getNextValue($objsoc, $objforref);
  129. }
  130. }