PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/modules/societe/mod_codeclient_leopard.php

https://github.com/asterix14/dolibarr
PHP | 122 lines | 46 code | 17 blank | 59 comment | 7 complexity | 95445dcb2518749d7860bed19bfa30fa MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. * or see http://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/modules/societe/mod_codeclient_leopard.php
  21. * \ingroup societe
  22. * \brief Fichier de la classe des gestion leopard des codes clients
  23. */
  24. require_once(DOL_DOCUMENT_ROOT."/core/modules/societe/modules_societe.class.php");
  25. /**
  26. * \class mod_codeclient_leopard
  27. * \brief Classe permettant la gestion leopard des codes tiers
  28. */
  29. class mod_codeclient_leopard extends ModeleThirdPartyCode
  30. {
  31. /*
  32. * Attention ce module est utilise par defaut si aucun module n'a
  33. * ete definit dans la configuration
  34. *
  35. * Le fonctionnement de celui-ci doit donc rester le plus ouvert possible
  36. */
  37. var $nom='Leopard'; // Nom du modele
  38. var $code_modifiable; // Code modifiable
  39. var $code_modifiable_invalide; // Code modifiable si il est invalide
  40. var $code_modifiable_null; // Code modifiables si il est null
  41. var $code_null; // Code facultatif
  42. var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
  43. var $code_auto; // Numerotation automatique
  44. /**
  45. * Constructor
  46. */
  47. function mod_codeclient_leopard()
  48. {
  49. $this->code_null = 1;
  50. $this->code_modifiable = 1;
  51. $this->code_modifiable_invalide = 1;
  52. $this->code_modifiable_null = 1;
  53. $this->code_auto = 0;
  54. }
  55. /** Return description of module
  56. *
  57. * @param $langs Object langs
  58. * @return string Description of module
  59. */
  60. function info($langs)
  61. {
  62. return $langs->trans("LeopardNumRefModelDesc");
  63. }
  64. /** Return an example of result returned by getNextValue
  65. *
  66. * @param $langs Object langs
  67. * @param $objsoc Object thirdparty
  68. * @param $type Type of third party (1:customer, 2:supplier, -1:autodetect)
  69. */
  70. function getNextValue($objsoc=0,$type=-1)
  71. {
  72. global $langs;
  73. return '';
  74. }
  75. /**
  76. * Check validity of code according to its rules
  77. *
  78. * @param $db Database handler
  79. * @param $code Code to check/correct
  80. * @param $soc Object third party
  81. * @param $type 0 = customer/prospect , 1 = supplier
  82. * @return int 0 if OK
  83. * -1 ErrorBadCustomerCodeSyntax
  84. * -2 ErrorCustomerCodeRequired
  85. * -3 ErrorCustomerCodeAlreadyUsed
  86. * -4 ErrorPrefixRequired
  87. */
  88. function verif($db, &$code, $soc, $type)
  89. {
  90. global $conf;
  91. $result=0;
  92. $code = strtoupper(trim($code));
  93. if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
  94. {
  95. $result=0;
  96. }
  97. else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
  98. {
  99. $result=-2;
  100. }
  101. dol_syslog("mod_codeclient_leopard::verif type=".$type." result=".$result);
  102. return $result;
  103. }
  104. }
  105. ?>