modules_don.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005 Regis Houssin <regis.houssin@inodbox.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. * or see https://www.gnu.org/
  20. */
  21. /**
  22. * \file htdocs/core/modules/dons/modules_don.php
  23. * \ingroup donations
  24. * \brief File of class to manage donation document generation
  25. */
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  28. /**
  29. * Parent class of subscription templates
  30. */
  31. abstract class ModeleDon extends CommonDocGenerator
  32. {
  33. /**
  34. * @var string Error code (or message)
  35. */
  36. public $error = '';
  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 = 'donation';
  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 of donation numbering templates
  58. */
  59. abstract class ModeleNumRefDons
  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. * Renvoi la description par defaut du modele de numerotation
  76. *
  77. * @return string Texte descripif
  78. */
  79. public function info()
  80. {
  81. global $langs;
  82. $langs->load("bills");
  83. return $langs->trans("NoDescription");
  84. }
  85. /**
  86. * Return an example of numbering
  87. *
  88. * @return string Example
  89. */
  90. public function getExample()
  91. {
  92. global $langs;
  93. $langs->load("bills");
  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. * Renvoi prochaine valeur attribuee
  108. *
  109. * @return string Valeur
  110. */
  111. public function getNextValue()
  112. {
  113. global $langs;
  114. return $langs->trans("NotAvailable");
  115. }
  116. /**
  117. * Renvoi version du module numerotation
  118. *
  119. * @return string Valeur
  120. */
  121. public function getVersion()
  122. {
  123. global $langs;
  124. $langs->load("admin");
  125. if ($this->version == 'development') {
  126. return $langs->trans("VersionDevelopment");
  127. }
  128. if ($this->version == 'experimental') {
  129. return $langs->trans("VersionExperimental");
  130. }
  131. if ($this->version == 'dolibarr') {
  132. return DOL_VERSION;
  133. }
  134. if ($this->version) {
  135. return $this->version;
  136. }
  137. return $langs->trans("NotAvailable");
  138. }
  139. }