modules_propale.php 4.0 KB

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