modules_bom.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  7. * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. * or see https://www.gnu.org/
  23. */
  24. /**
  25. * \file htdocs/core/modules/bom/modules_bom.php
  26. * \ingroup bom
  27. * \brief File that contains parent class for boms models
  28. * and parent class for boms numbering models
  29. */
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
  32. /**
  33. * Parent class for boms models
  34. */
  35. abstract class ModelePDFBom extends CommonDocGenerator
  36. {
  37. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  38. /**
  39. * Return list of active generation modules
  40. *
  41. * @param DoliDB $db Database handler
  42. * @param integer $maxfilenamelength Max length of value to show
  43. * @return array List of templates
  44. */
  45. public static function liste_modeles($db, $maxfilenamelength = 0)
  46. {
  47. // phpcs:enable
  48. global $conf;
  49. $type = 'bom';
  50. $list = array();
  51. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  52. $list = getListOfModels($db, $type, $maxfilenamelength);
  53. return $list;
  54. }
  55. }
  56. /**
  57. * Parent class to manage numbering of BOMs
  58. */
  59. abstract class ModeleNumRefBoms
  60. {
  61. /**
  62. * @var string Error code (or message)
  63. */
  64. public $error = '';
  65. /**
  66. * Return if a module can be used or not
  67. *
  68. * @return boolean true if module can be used
  69. */
  70. public function isEnabled()
  71. {
  72. return true;
  73. }
  74. /**
  75. * Returns the default description of the numbering template
  76. *
  77. * @return string Texte descripif
  78. */
  79. public function info()
  80. {
  81. global $langs;
  82. $langs->load("mrp");
  83. return $langs->trans("NoDescription");
  84. }
  85. /**
  86. * Returns an example of numbering
  87. *
  88. * @return string Example
  89. */
  90. public function getExample()
  91. {
  92. global $langs;
  93. $langs->load("mrp");
  94. return $langs->trans("NoExample");
  95. }
  96. /**
  97. * Checks if the numbers already in the database do not
  98. * cause conflicts that would prevent this numbering working.
  99. *
  100. * @return boolean false if conflict, true if ok
  101. */
  102. public function canBeActivated()
  103. {
  104. return true;
  105. }
  106. /**
  107. * Returns next assigned value
  108. *
  109. * @param Societe $objsoc Object thirdparty
  110. * @param Object $object Object we need next value for
  111. * @return string Valeur
  112. */
  113. public function getNextValue($objsoc, $object)
  114. {
  115. global $langs;
  116. return $langs->trans("NotAvailable");
  117. }
  118. /**
  119. * Returns version of numbering module
  120. *
  121. * @return string Valeur
  122. */
  123. public function getVersion()
  124. {
  125. global $langs;
  126. $langs->load("admin");
  127. if ($this->version == 'development') {
  128. return $langs->trans("VersionDevelopment");
  129. }
  130. if ($this->version == 'experimental') {
  131. return $langs->trans("VersionExperimental");
  132. }
  133. if ($this->version == 'dolibarr') {
  134. return DOL_VERSION;
  135. }
  136. if ($this->version) {
  137. return $this->version;
  138. }
  139. return $langs->trans("NotAvailable");
  140. }
  141. }