modules_contract.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  7. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
  9. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  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/contract/modules_contract.php
  27. * \ingroup contract
  28. * \brief File with parent class for generating contracts to PDF and File of class to manage contract numbering
  29. */
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  31. /**
  32. * Parent class to manage intervention document templates
  33. */
  34. abstract class ModelePDFContract extends CommonDocGenerator
  35. {
  36. /**
  37. * @var string Error code (or message)
  38. */
  39. public $error = '';
  40. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  41. /**
  42. * Return list of active generation modules
  43. *
  44. * @param DoliDB $db Database handler
  45. * @param integer $maxfilenamelength Max length of value to show
  46. * @return array List of templates
  47. */
  48. public static function liste_modeles($db, $maxfilenamelength = 0)
  49. {
  50. // phpcs:enable
  51. global $conf;
  52. $type = 'contract';
  53. $list = array();
  54. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  55. $list = getListOfModels($db, $type, $maxfilenamelength);
  56. return $list;
  57. }
  58. }
  59. /**
  60. * Parent class for all contract numbering modules
  61. */
  62. class ModelNumRefContracts
  63. {
  64. /**
  65. * @var string Error code (or message)
  66. */
  67. public $error = '';
  68. /**
  69. * Return if a module can be used or not
  70. *
  71. * @return boolean true if module can be used
  72. */
  73. public function isEnabled()
  74. {
  75. return true;
  76. }
  77. /**
  78. * Return default description of numbering model
  79. *
  80. * @return string text description
  81. */
  82. public function info()
  83. {
  84. global $langs;
  85. $langs->load("contracts");
  86. return $langs->trans("NoDescription");
  87. }
  88. /**
  89. * Return numbering example
  90. *
  91. * @return string Example
  92. */
  93. public function getExample()
  94. {
  95. global $langs;
  96. $langs->load("contracts");
  97. return $langs->trans("NoExample");
  98. }
  99. /**
  100. * Test if existing numbers make problems with numbering
  101. *
  102. * @return boolean false if conflict, true if ok
  103. */
  104. public function canBeActivated()
  105. {
  106. return true;
  107. }
  108. /**
  109. * Return next value
  110. *
  111. * @param Societe $objsoc third party object
  112. * @param Object $contract contract object
  113. * @return string Value
  114. */
  115. public function getNextValue($objsoc, $contract)
  116. {
  117. global $langs;
  118. return $langs->trans("NotAvailable");
  119. }
  120. /**
  121. * Return numbering version module
  122. *
  123. * @return string Value
  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. }