modules_holiday.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. * or see https://www.gnu.org/
  25. */
  26. /**
  27. * \file htdocs/core/modules/holiday/modules_holiday.php
  28. * \ingroup contract
  29. * \brief File with parent class for generating holiday to PDF and File of class to manage contract numbering
  30. */
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  32. /**
  33. * Parent class to manage holidays document templates
  34. */
  35. abstract class ModelePDFHoliday extends CommonDocGenerator
  36. {
  37. /**
  38. * @var string Error code (or message)
  39. */
  40. public $error = '';
  41. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  42. /**
  43. * Return list of active generation modules
  44. *
  45. * @param DoliDB $db Database handler
  46. * @param integer $maxfilenamelength Max length of value to show
  47. * @return array List of templates
  48. */
  49. public static function liste_modeles($db, $maxfilenamelength = 0)
  50. {
  51. // phpcs:enable
  52. global $conf;
  53. $type = 'holiday';
  54. $list = array();
  55. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  56. $list = getListOfModels($db, $type, $maxfilenamelength);
  57. return $list;
  58. }
  59. }
  60. /**
  61. * Parent class for all holidays numbering modules
  62. */
  63. class ModelNumRefHolidays
  64. {
  65. /**
  66. * @var string Error code (or message)
  67. */
  68. public $error = '';
  69. /**
  70. * Return if a module can be used or not
  71. *
  72. * @return boolean true if module can be used
  73. */
  74. public function isEnabled()
  75. {
  76. return true;
  77. }
  78. /**
  79. * Return default description of numbering model
  80. *
  81. * @return string text description
  82. */
  83. public function info()
  84. {
  85. global $langs;
  86. $langs->load("holiday");
  87. return $langs->trans("NoDescription");
  88. }
  89. /**
  90. * Return numbering example
  91. *
  92. * @return string Example
  93. */
  94. public function getExample()
  95. {
  96. global $langs;
  97. $langs->load("holiday");
  98. return $langs->trans("NoExample");
  99. }
  100. /**
  101. * Test if existing numbers make problems with numbering
  102. *
  103. * @return boolean false if conflict, true if ok
  104. */
  105. public function canBeActivated()
  106. {
  107. return true;
  108. }
  109. /**
  110. * Return next value
  111. *
  112. * @param Societe $objsoc third party object
  113. * @param Object $holiday Holiday object
  114. * @return string Value if OK, 0 if KO
  115. */
  116. public function getNextValue($objsoc, $holiday)
  117. {
  118. global $langs;
  119. return $langs->trans("NotAvailable");
  120. }
  121. /**
  122. * Return numbering version module
  123. *
  124. * @return string Value
  125. */
  126. public function getVersion()
  127. {
  128. global $langs;
  129. $langs->load("admin");
  130. if ($this->version == 'development') {
  131. return $langs->trans("VersionDevelopment");
  132. } elseif ($this->version == 'experimental') {
  133. return $langs->trans("VersionExperimental");
  134. } elseif ($this->version == 'dolibarr') {
  135. return DOL_VERSION;
  136. } elseif ($this->version) {
  137. return $this->version;
  138. } else {
  139. return $langs->trans("NotAvailable");
  140. }
  141. }
  142. }