modules_reception.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. * or see https://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/modules/reception/modules_reception.php
  20. * \ingroup reception
  21. * \brief File that contains parent class for sending receipts models
  22. * and parent class for sending receipts numbering models
  23. */
  24. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  25. /**
  26. * Parent class of sending receipts models
  27. */
  28. abstract class ModelePdfReception extends CommonDocGenerator
  29. {
  30. public $error = '';
  31. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  32. /**
  33. * Return list of active generation modules
  34. *
  35. * @param DoliDB $db Database handler
  36. * @param integer $maxfilenamelength Max length of value to show
  37. * @return array List of templates
  38. */
  39. public static function liste_modeles($db, $maxfilenamelength = 0)
  40. {
  41. // phpcs:enable
  42. global $conf;
  43. $type = 'reception';
  44. $list = array();
  45. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  46. $list = getListOfModels($db, $type, $maxfilenamelength);
  47. return $list;
  48. }
  49. }
  50. /**
  51. * Parent Class of numbering models of sending receipts references
  52. */
  53. abstract class ModelNumRefReception
  54. {
  55. public $error = '';
  56. /** Return if a model can be used or not
  57. *
  58. * @return boolean true if model can be used
  59. */
  60. public function isEnabled()
  61. {
  62. return true;
  63. }
  64. /**
  65. * Return default description of numbering model
  66. *
  67. * @return string text description
  68. */
  69. public function info()
  70. {
  71. global $langs;
  72. $langs->load("reception");
  73. return $langs->trans("NoDescription");
  74. }
  75. /**
  76. * Returns numbering example
  77. *
  78. * @return string Example
  79. */
  80. public function getExample()
  81. {
  82. global $langs;
  83. $langs->load("reception");
  84. return $langs->trans("NoExample");
  85. }
  86. /**
  87. * Test if existing numbers make problems with numbering
  88. *
  89. * @return boolean false if conflit, true if ok
  90. */
  91. public function canBeActivated()
  92. {
  93. return true;
  94. }
  95. /**
  96. * Returns next value assigned
  97. *
  98. * @param Societe $objsoc Third party object
  99. * @param Object $reception Reception object
  100. * @return string Value
  101. */
  102. public function getNextValue($objsoc, $reception)
  103. {
  104. global $langs;
  105. return $langs->trans("NotAvailable");
  106. }
  107. /**
  108. * Returns version of the numbering model
  109. *
  110. * @return string Value
  111. */
  112. public function getVersion()
  113. {
  114. global $langs;
  115. $langs->load("admin");
  116. if ($this->version == 'development') {
  117. return $langs->trans("VersionDevelopment");
  118. } elseif ($this->version == 'experimental') {
  119. return $langs->trans("VersionExperimental");
  120. } elseif ($this->version == 'dolibarr') {
  121. return DOL_VERSION;
  122. } elseif ($this->version) {
  123. return $this->version;
  124. }
  125. return $langs->trans("NotAvailable");
  126. }
  127. }