modules_facture.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /* Copyright (C) 2003-2005 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) 2014 Marcos García <marcosgdf@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. * or see https://www.gnu.org/
  21. */
  22. /**
  23. * \file htdocs/core/modules/facture/modules_facture.php
  24. * \ingroup facture
  25. * \brief File that contains parent class for invoices models
  26. * and parent class for invoices numbering models
  27. */
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit
  31. /**
  32. * Parent class of invoice document generators
  33. */
  34. abstract class ModelePDFFactures extends CommonDocGenerator
  35. {
  36. /**
  37. * @var string Error code (or message)
  38. */
  39. public $error = '';
  40. public $tva;
  41. public $tva_array;
  42. public $localtax1;
  43. public $localtax2;
  44. public $atleastonediscount = 0;
  45. public $atleastoneratenotnull = 0;
  46. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  47. /**
  48. * Return list of active generation modules
  49. *
  50. * @param DoliDB $db Database handler
  51. * @param integer $maxfilenamelength Max length of value to show
  52. * @return array List of templates
  53. */
  54. public static function liste_modeles($db, $maxfilenamelength = 0)
  55. {
  56. // phpcs:enable
  57. global $conf;
  58. $type = 'invoice';
  59. $list = array();
  60. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  61. $list = getListOfModels($db, $type, $maxfilenamelength);
  62. return $list;
  63. }
  64. }
  65. /**
  66. * Parent class of invoice reference numbering templates
  67. */
  68. abstract class ModeleNumRefFactures
  69. {
  70. /**
  71. * @var string Error code (or message)
  72. */
  73. public $error = '';
  74. /**
  75. * Return if a module can be used or not
  76. *
  77. * @return boolean true if module can be used
  78. */
  79. public function isEnabled()
  80. {
  81. return true;
  82. }
  83. /**
  84. * Renvoi la description par defaut du modele de numerotation
  85. *
  86. * @return string Texte descripif
  87. */
  88. public function info()
  89. {
  90. global $langs;
  91. $langs->load("bills");
  92. return $langs->trans("NoDescription");
  93. }
  94. /**
  95. * Return an example of numbering
  96. *
  97. * @return string Example
  98. */
  99. public function getExample()
  100. {
  101. global $langs;
  102. $langs->load("bills");
  103. return $langs->trans("NoExample");
  104. }
  105. /**
  106. * Checks if the numbers already in the database do not
  107. * cause conflicts that would prevent this numbering working.
  108. *
  109. * @return boolean false if conflict, true if ok
  110. */
  111. public function canBeActivated()
  112. {
  113. return true;
  114. }
  115. /**
  116. * Renvoi prochaine valeur attribuee
  117. *
  118. * @param Societe $objsoc Objet societe
  119. * @param Facture $invoice Objet facture
  120. * @param string $mode 'next' for next value or 'last' for last value
  121. * @return string Value
  122. */
  123. public function getNextValue($objsoc, $invoice, $mode = 'next')
  124. {
  125. global $langs;
  126. return $langs->trans("NotAvailable");
  127. }
  128. /**
  129. * Renvoi version du modele de numerotation
  130. *
  131. * @return string Valeur
  132. */
  133. public function getVersion()
  134. {
  135. global $langs;
  136. $langs->load("admin");
  137. if ($this->version == 'development') {
  138. return $langs->trans("VersionDevelopment");
  139. } elseif ($this->version == 'experimental') {
  140. return $langs->trans("VersionExperimental");
  141. } elseif ($this->version == 'dolibarr') {
  142. return DOL_VERSION;
  143. } elseif ($this->version) {
  144. return $this->version;
  145. } else {
  146. return $langs->trans("NotAvailable");
  147. }
  148. }
  149. }