modules_asset.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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/asset/modules_asset.php
  26. * \ingroup asset
  27. * \brief File that contains parent class for assets document models and parent class for assets numbering models
  28. */
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
  31. /**
  32. * Parent class for documents models
  33. */
  34. abstract class ModelePDFAsset extends CommonDocGenerator
  35. {
  36. /**
  37. * @var int page_largeur
  38. */
  39. public $page_largeur;
  40. /**
  41. * @var int page_hauteur
  42. */
  43. public $page_hauteur;
  44. /**
  45. * @var array format
  46. */
  47. public $format;
  48. /**
  49. * @var int marge_gauche
  50. */
  51. public $marge_gauche;
  52. /**
  53. * @var int marge_droite
  54. */
  55. public $marge_droite;
  56. /**
  57. * @var int marge_haute
  58. */
  59. public $marge_haute;
  60. /**
  61. * @var int marge_basse
  62. */
  63. public $marge_basse;
  64. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  65. /**
  66. * Return list of active generation modules
  67. *
  68. * @param DoliDB $db Database handler
  69. * @param integer $maxfilenamelength Max length of value to show
  70. * @return array List of templates
  71. */
  72. public static function liste_modeles($db, $maxfilenamelength = 0)
  73. {
  74. // phpcs:enable
  75. global $conf;
  76. $type = 'asset';
  77. $list = array();
  78. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  79. $list = getListOfModels($db, $type, $maxfilenamelength);
  80. return $list;
  81. }
  82. }
  83. /**
  84. * Parent class to manage numbering of Asset
  85. */
  86. abstract class ModeleNumRefAsset
  87. {
  88. /**
  89. * @var string Error code (or message)
  90. */
  91. public $error = '';
  92. /**
  93. * Return if a module can be used or not
  94. *
  95. * @return boolean true if module can be used
  96. */
  97. public function isEnabled()
  98. {
  99. return true;
  100. }
  101. /**
  102. * Returns the default description of the numbering template
  103. *
  104. * @return string Texte descripif
  105. */
  106. public function info()
  107. {
  108. global $langs;
  109. $langs->load("asset@asset");
  110. return $langs->trans("NoDescription");
  111. }
  112. /**
  113. * Returns an example of numbering
  114. *
  115. * @return string Example
  116. */
  117. public function getExample()
  118. {
  119. global $langs;
  120. $langs->load("asset@asset");
  121. return $langs->trans("NoExample");
  122. }
  123. /**
  124. * Checks if the numbers already in the database do not
  125. * cause conflicts that would prevent this numbering working.
  126. *
  127. * @param Object $object Object we need next value for
  128. * @return boolean false if conflict, true if ok
  129. */
  130. public function canBeActivated($object)
  131. {
  132. return true;
  133. }
  134. /**
  135. * Returns next assigned value
  136. *
  137. * @param Object $object Object we need next value for
  138. * @return string Valeur
  139. */
  140. public function getNextValue($object)
  141. {
  142. global $langs;
  143. return $langs->trans("NotAvailable");
  144. }
  145. /**
  146. * Returns version of numbering module
  147. *
  148. * @return string Valeur
  149. */
  150. public function getVersion()
  151. {
  152. global $langs;
  153. $langs->load("admin");
  154. if ($this->version == 'development') {
  155. return $langs->trans("VersionDevelopment");
  156. }
  157. if ($this->version == 'experimental') {
  158. return $langs->trans("VersionExperimental");
  159. }
  160. if ($this->version == 'dolibarr') {
  161. return DOL_VERSION;
  162. }
  163. if ($this->version) {
  164. return $this->version;
  165. }
  166. return $langs->trans("NotAvailable");
  167. }
  168. }