modules_project.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. /* Copyright (C) 2010-2014 Regis Houssin <regis.houssin@inodbox.com>
  3. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. * or see https://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/modules/project/modules_project.php
  21. * \ingroup project
  22. * \brief File that contain parent class for projects models
  23. * and parent class for projects numbering models
  24. */
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  26. /**
  27. * Parent class for projects models
  28. */
  29. abstract class ModelePDFProjects extends CommonDocGenerator
  30. {
  31. /**
  32. * @var DoliDb Database handler
  33. */
  34. public $db;
  35. /**
  36. * @var string model name
  37. */
  38. public $name;
  39. /**
  40. * @var string model description (short text)
  41. */
  42. public $description;
  43. /**
  44. * @var string document type
  45. */
  46. public $type;
  47. /**
  48. * @var int page_largeur
  49. */
  50. public $page_largeur;
  51. /**
  52. * @var int page_hauteur
  53. */
  54. public $page_hauteur;
  55. /**
  56. * @var array format
  57. */
  58. public $format;
  59. /**
  60. * @var int marge_gauche
  61. */
  62. public $marge_gauche;
  63. /**
  64. * @var int marge_droite
  65. */
  66. public $marge_droite;
  67. /**
  68. * @var int marge_haute
  69. */
  70. public $marge_haute;
  71. /**
  72. * @var int marge_basse
  73. */
  74. public $marge_basse;
  75. /**
  76. * @var string Error code (or message)
  77. */
  78. public $error = '';
  79. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  80. /**
  81. * Return list of active generation modules
  82. *
  83. * @param DoliDB $db Database handler
  84. * @param integer $maxfilenamelength Max length of value to show
  85. * @return array List of templates
  86. */
  87. public static function liste_modeles($db, $maxfilenamelength = 0)
  88. {
  89. // phpcs:enable
  90. global $conf;
  91. $type = 'project';
  92. $list = array();
  93. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  94. $list = getListOfModels($db, $type, $maxfilenamelength);
  95. return $list;
  96. }
  97. }
  98. /**
  99. * Classe mere des modeles de numerotation des references de projets
  100. */
  101. abstract class ModeleNumRefProjects
  102. {
  103. /**
  104. * @var string Error code (or message)
  105. */
  106. public $error = '';
  107. /**
  108. * @var string $version
  109. */
  110. public $version;
  111. /**
  112. * Return if a module can be used or not
  113. *
  114. * @return boolean true if module can be used
  115. */
  116. public function isEnabled()
  117. {
  118. return true;
  119. }
  120. /**
  121. * Renvoi la description par defaut du modele de numerotation
  122. *
  123. * @return string Texte descripif
  124. */
  125. public function info()
  126. {
  127. global $langs;
  128. $langs->load("projects");
  129. return $langs->trans("NoDescription");
  130. }
  131. /**
  132. * Return an example of numbering
  133. *
  134. * @return string Example
  135. */
  136. public function getExample()
  137. {
  138. global $langs;
  139. $langs->load("projects");
  140. return $langs->trans("NoExample");
  141. }
  142. /**
  143. * Checks if the numbers already in the database do not
  144. * cause conflicts that would prevent this numbering working.
  145. *
  146. * @return boolean false if conflict, true if ok
  147. */
  148. public function canBeActivated()
  149. {
  150. return true;
  151. }
  152. /**
  153. * Renvoi prochaine valeur attribuee
  154. *
  155. * @param Societe $objsoc Object third party
  156. * @param Project $project Object project
  157. * @return string Valeur
  158. */
  159. public function getNextValue($objsoc, $project)
  160. {
  161. global $langs;
  162. return $langs->trans("NotAvailable");
  163. }
  164. /**
  165. * Renvoi version du module numerotation
  166. *
  167. * @return string Valeur
  168. */
  169. public function getVersion()
  170. {
  171. global $langs;
  172. $langs->load("admin");
  173. if ($this->version == 'development') {
  174. return $langs->trans("VersionDevelopment");
  175. } elseif ($this->version == 'experimental') {
  176. return $langs->trans("VersionExperimental");
  177. } elseif ($this->version == 'dolibarr') {
  178. return DOL_VERSION;
  179. } elseif ($this->version) {
  180. return $this->version;
  181. } else {
  182. return $langs->trans("NotAvailable");
  183. }
  184. }
  185. }