PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/societe/core/models/mod_codeclient_leopard.php

https://bitbucket.org/speedealing/speedealing
PHP | 123 lines | 46 code | 17 blank | 60 comment | 7 complexity | f3263b8b4914d5c4025be4a0324664b0 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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 3 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/models/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 . '/societe/core/models/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 __construct()
  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 string $langs Object langs
  58. * @return string Description of module
  59. */
  60. function info($langs)
  61. {
  62. return $langs->trans("LeopardNumRefModelDesc");
  63. }
  64. /**
  65. * Return an example of result returned by getNextValue
  66. *
  67. * @param societe $objsoc Object thirdparty
  68. * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
  69. * @return string Return next value
  70. */
  71. function getNextValue($objsoc=0,$type=-1)
  72. {
  73. global $langs;
  74. return '';
  75. }
  76. /**
  77. * Check validity of code according to its rules
  78. *
  79. * @param DoliDB $db Database handler
  80. * @param string &$code Code to check/correct
  81. * @param Societe $soc Object third party
  82. * @param int $type 0 = customer/prospect , 1 = supplier
  83. * @return int 0 if OK
  84. * -1 ErrorBadCustomerCodeSyntax
  85. * -2 ErrorCustomerCodeRequired
  86. * -3 ErrorCustomerCodeAlreadyUsed
  87. * -4 ErrorPrefixRequired
  88. */
  89. function verif($db, &$code, $soc, $type)
  90. {
  91. global $conf;
  92. $result=0;
  93. $code = strtoupper(trim($code));
  94. if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
  95. {
  96. $result=0;
  97. }
  98. else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
  99. {
  100. $result=-2;
  101. }
  102. dol_syslog("mod_codeclient_leopard::verif type=".$type." result=".$result);
  103. return $result;
  104. }
  105. }
  106. ?>