mod_contract_olive.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2014 Floran Henry <florian.henry@open-concept.pro>
  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/contract/mod_contract_olive.php
  22. * \ingroup contract
  23. * \brief File of class to manage contract numbering rules Olive
  24. */
  25. require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
  26. /**
  27. * Class to manage contract numbering rules Olive
  28. */
  29. class mod_contract_olive extends ModelNumRefContracts
  30. {
  31. /**
  32. * @var string Nom du modele
  33. * @deprecated
  34. * @see $name
  35. */
  36. public $nom = 'Olive';
  37. /**
  38. * @var string model name
  39. */
  40. public $name = 'Olive';
  41. public $code_modifiable = 1; // Code modifiable
  42. public $code_modifiable_invalide = 1; // Code modifiable si il est invalide
  43. public $code_modifiable_null = 1; // Code modifiables si il est null
  44. public $code_null = 1; // Code facultatif
  45. /**
  46. * Dolibarr version of the loaded document
  47. * @var string
  48. */
  49. public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
  50. /**
  51. * @var int Automatic numbering
  52. */
  53. public $code_auto = 0;
  54. /**
  55. * Return description of module
  56. *
  57. * @param Translate $langs Lang object to use for output
  58. * @return string Descriptive text
  59. */
  60. public function info($langs)
  61. {
  62. global $langs;
  63. $langs->load("companies");
  64. return $langs->trans("LeopardNumRefModelDesc");
  65. }
  66. /**
  67. * Return an example of result returned by getNextValue
  68. *
  69. * @param Societe $objsoc Object thirdparty
  70. * @param Contrat $contract Object contract
  71. * @return string Return next value
  72. */
  73. public function getNextValue($objsoc, $contract)
  74. {
  75. global $langs;
  76. return '';
  77. }
  78. /**
  79. * Check validity of code according to its rules
  80. *
  81. * @param DoliDB $db Database handler
  82. * @param string $code Code to check/correct
  83. * @param Product $product Object product
  84. * @param int $type 0 = product , 1 = service
  85. * @return int 0 if OK
  86. * -1 ErrorBadProductCodeSyntax
  87. * -2 ErrorProductCodeRequired
  88. * -3 ErrorProductCodeAlreadyUsed
  89. * -4 ErrorPrefixRequired
  90. */
  91. public function verif($db, &$code, $product, $type)
  92. {
  93. global $conf;
  94. $result = 0;
  95. $code = strtoupper(trim($code));
  96. if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) {
  97. $result = 0;
  98. } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))) {
  99. $result = -2;
  100. }
  101. dol_syslog("mod_contract_olive::verif type=".$type." result=".$result);
  102. return $result;
  103. }
  104. }