mod_delivery_saphir.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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-2007 Regis Houssin <regis.houssin@inodbox.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. * or see https://www.gnu.org/
  19. */
  20. /**
  21. * \file htdocs/core/modules/delivery/mod_livraison_saphir.php
  22. * \ingroup expedition
  23. * \brief Fichier contenant la classe du modele de numerotation de reference de livraison Saphir
  24. */
  25. require_once DOL_DOCUMENT_ROOT.'/core/modules/delivery/modules_delivery.php';
  26. /**
  27. * \class mod_delivery_saphir
  28. * \brief Classe du modele de numerotation de reference de livraison Saphir
  29. */
  30. class mod_delivery_saphir extends ModeleNumRefDeliveryOrder
  31. {
  32. /**
  33. * Dolibarr version of the loaded document
  34. * @var string
  35. */
  36. public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
  37. /**
  38. * @var string Error message
  39. */
  40. public $error = '';
  41. /**
  42. * @var string Nom du modele
  43. * @deprecated
  44. * @see $name
  45. */
  46. public $nom = 'Saphir';
  47. /**
  48. * @var string model name
  49. */
  50. public $name = 'Saphir';
  51. /**
  52. * Returns the description of the numbering model
  53. *
  54. * @return string Texte descripif
  55. */
  56. public function info()
  57. {
  58. global $conf, $langs, $db;
  59. $langs->load("bills");
  60. $form = new Form($db);
  61. $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
  62. $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  63. $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
  64. $texte .= '<input type="hidden" name="action" value="updateMask">';
  65. $texte .= '<input type="hidden" name="maskconstdelivery" value="DELIVERY_SAPHIR_MASK">';
  66. $texte .= '<table class="nobordernopadding" width="100%">';
  67. $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery"));
  68. $tooltip .= $langs->trans("GenericMaskCodes2");
  69. $tooltip .= $langs->trans("GenericMaskCodes3");
  70. $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery"));
  71. $tooltip .= $langs->trans("GenericMaskCodes5");
  72. // Parametrage du prefix
  73. $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
  74. $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdelivery" value="'.$conf->global->DELIVERY_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
  75. $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
  76. $texte .= '</tr>';
  77. $texte .= '</table>';
  78. $texte .= '</form>';
  79. return $texte;
  80. }
  81. /**
  82. * Return an example of number
  83. *
  84. * @return string Example
  85. */
  86. public function getExample()
  87. {
  88. global $conf, $langs, $mysoc;
  89. $old_code_client = $mysoc->code_client;
  90. $mysoc->code_client = 'CCCCCCCCCC';
  91. $numExample = $this->getNextValue($mysoc, '');
  92. $mysoc->code_client = $old_code_client;
  93. if (!$numExample)
  94. {
  95. $numExample = $langs->trans('NotConfigured');
  96. }
  97. return $numExample;
  98. }
  99. /**
  100. * Return next value
  101. *
  102. * @param Societe $objsoc Object third party
  103. * @param Object $object Object delivery
  104. * @return string Value if OK, 0 if KO
  105. */
  106. public function getNextValue($objsoc, $object)
  107. {
  108. global $db, $conf;
  109. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  110. // On defini critere recherche compteur
  111. $mask = $conf->global->DELIVERY_SAPHIR_MASK;
  112. if (!$mask)
  113. {
  114. $this->error = 'NotConfigured';
  115. return 0;
  116. }
  117. $numFinal = get_next_value($db, $mask, 'delivery', 'ref', '', $objsoc, $object->date_livraison);
  118. return $numFinal;
  119. }
  120. /**
  121. * Return next free value
  122. *
  123. * @param Societe $objsoc Object third party
  124. * @param string $objforref Object for number to search
  125. * @return string Next free value
  126. */
  127. public function getNumRef($objsoc, $objforref)
  128. {
  129. return $this->getNextValue($objsoc, $objforref);
  130. }
  131. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  132. /**
  133. * Return next free ref
  134. *
  135. * @param Societe $objsoc Object thirdparty
  136. * @param Object $object Objet livraison
  137. * @return string Texte descripif
  138. */
  139. public function delivery_get_num($objsoc = 0, $object = '')
  140. {
  141. // phpcs:enable
  142. return $this->getNextValue($objsoc, $object);
  143. }
  144. }