modules_barcode.class.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. * or see http://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/modules/barcode/modules_barcode.class.php
  20. * \ingroup barcode
  21. * \brief File with parent classes for barcode document modules and numbering modules
  22. */
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
  24. /**
  25. * Parent class for barcode document models
  26. */
  27. abstract class ModeleBarCode
  28. {
  29. var $error='';
  30. /**
  31. * Return if a model can be used or not
  32. *
  33. * @return boolean true if model can be used
  34. */
  35. function isEnabled()
  36. {
  37. return true;
  38. }
  39. }
  40. /**
  41. * Parent class for barcode numbering models
  42. */
  43. abstract class ModeleNumRefBarCode
  44. {
  45. var $error='';
  46. /** Return default description of numbering model
  47. *
  48. * @param Translate $langs Object langs
  49. * @return string Descriptive text
  50. */
  51. function info($langs)
  52. {
  53. $langs->load("bills");
  54. return $langs->trans("NoDescription");
  55. }
  56. /** Return model name
  57. *
  58. * @param Translate $langs Object langs
  59. * @return string Model name
  60. */
  61. function getNom($langs)
  62. {
  63. return empty($this->name)?$this->nom:$this->name;
  64. }
  65. /** Return a numbering example
  66. *
  67. * @param Translate $langs Object langs
  68. * @return string Example
  69. */
  70. function getExample($langs)
  71. {
  72. $langs->load("bills");
  73. return $langs->trans("NoExample");
  74. }
  75. /**
  76. * Return next value available
  77. *
  78. * @param Societe $objsoc Object thirdparty
  79. * @param int $type Type
  80. * @return string Value
  81. */
  82. function getNextValue($objsoc=null,$type=-1)
  83. {
  84. global $langs;
  85. return $langs->trans("Function_getNextValue_InModuleNotWorking");
  86. }
  87. /** Return version of module
  88. *
  89. * @return string Version
  90. */
  91. function getVersion()
  92. {
  93. global $langs;
  94. $langs->load("admin");
  95. if ($this->version == 'development') return $langs->trans("VersionDevelopment");
  96. if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
  97. if ($this->version == 'dolibarr') return DOL_VERSION;
  98. if ($this->version) return $this->version;
  99. return $langs->trans("NotAvailable");
  100. }
  101. /**
  102. * Return description of module parameters
  103. *
  104. * @param Translate $langs Output language
  105. * @param Societe $soc Third party object
  106. * @param int $type -1=Nothing, 0=Product, 1=Service
  107. * @return string HTML translated description
  108. */
  109. function getToolTip($langs,$soc,$type)
  110. {
  111. global $conf;
  112. $langs->load("admin");
  113. $s='';
  114. $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
  115. $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
  116. if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
  117. $s.='<br>';
  118. $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
  119. if ($type == 0)
  120. {
  121. $s.=$langs->trans("RequiredIfProduct").': ';
  122. if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
  123. $s.=yn(!$this->code_null,1,2);
  124. if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
  125. $s.='<br>';
  126. }
  127. if ($type == 1)
  128. {
  129. $s.=$langs->trans("RequiredIfService").': ';
  130. if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
  131. $s.=yn(!$this->code_null,1,2);
  132. if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
  133. $s.='<br>';
  134. }
  135. if ($type == -1)
  136. {
  137. $s.=$langs->trans("Required").': ';
  138. if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
  139. $s.=yn(!$this->code_null,1,2);
  140. if (! empty($conf->global->MAIN_BARCODE_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
  141. $s.='<br>';
  142. }
  143. /*$s.=$langs->trans("CanBeModifiedIfOk").': ';
  144. $s.=yn($this->code_modifiable,1,2);
  145. $s.='<br>';
  146. $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
  147. */
  148. $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
  149. $s.='<br>';
  150. $nextval=$this->getNextValue($soc,0);
  151. if (empty($nextval)) $nextval=$langs->trans("Undefined");
  152. $s.=$langs->trans("NextValue").': <b>'.$nextval.'</b><br>';
  153. return $s;
  154. }
  155. }