modules_stocktransfer.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. * or see https://www.gnu.org/
  24. */
  25. /**
  26. * \file htdocs/core/modules/stocktransfer/modules_stocktransfer.php
  27. * \ingroup stocktransfer
  28. * \brief File that contains parent class for stocktransfers document models and parent class for stocktransfers 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 documents models
  34. */
  35. abstract class ModelePDFStockTransfer 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 = 'stocktransfer';
  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 StockTransfer
  58. */
  59. abstract class ModeleNumRefStockTransfer
  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("stocktransfer@stocktransfer");
  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("stocktransfer@stocktransfer");
  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. * @param Object $object Object we need next value for
  101. * @return boolean false if conflict, true if ok
  102. */
  103. public function canBeActivated($object)
  104. {
  105. return true;
  106. }
  107. /**
  108. * Returns next assigned value
  109. *
  110. * @param Object $object Object we need next value for
  111. * @return string Valeur
  112. */
  113. public function getNextValue($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') return $langs->trans("VersionDevelopment");
  128. if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
  129. if ($this->version == 'dolibarr') return DOL_VERSION;
  130. if ($this->version) return $this->version;
  131. return $langs->trans("NotAvailable");
  132. }
  133. }