modules_facturefournisseur.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  3. * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2013-2016 Philippe Grand <philippe.grand@atoo-net.com>
  5. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. * or see https://www.gnu.org/
  20. */
  21. /**
  22. * \file htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
  23. * \ingroup facture fournisseur
  24. * \brief File that contains parent class for supplier invoices models
  25. * and parent class for supplier invoices numbering models
  26. */
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
  29. /**
  30. * Parent class for supplier invoices models
  31. */
  32. abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
  33. {
  34. /**
  35. * @var string Error code (or message)
  36. */
  37. public $error = '';
  38. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  39. /**
  40. * Return list of active generation models
  41. *
  42. * @param DoliDB $db Database handler
  43. * @param integer $maxfilenamelength Max length of value to show
  44. * @return array List of numbers
  45. */
  46. public static function liste_modeles($db, $maxfilenamelength = 0)
  47. {
  48. // phpcs:enable
  49. global $conf;
  50. $type = 'invoice_supplier';
  51. $list = array();
  52. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  53. $list = getListOfModels($db, $type, $maxfilenamelength);
  54. return $list;
  55. }
  56. }
  57. /**
  58. * Parent Class of numbering models of suppliers invoices references
  59. */
  60. abstract class ModeleNumRefSuppliersInvoices
  61. {
  62. /**
  63. * @var string Error code (or message)
  64. */
  65. public $error = '';
  66. /** Return if a model can be used or not
  67. *
  68. * @return boolean true if model can be used
  69. */
  70. public function isEnabled()
  71. {
  72. return true;
  73. }
  74. /** Returns the default description of the model numbering
  75. *
  76. * @return string Description Text
  77. */
  78. public function info()
  79. {
  80. global $langs;
  81. $langs->load("invoices");
  82. return $langs->trans("NoDescription");
  83. }
  84. /** Returns a numbering example
  85. *
  86. * @return string Example
  87. */
  88. public function getExample()
  89. {
  90. global $langs;
  91. $langs->load("invoices");
  92. return $langs->trans("NoExample");
  93. }
  94. /** Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering.
  95. *
  96. * @return boolean false if conflict, true if ok
  97. */
  98. public function canBeActivated()
  99. {
  100. return true;
  101. }
  102. /** Returns next value assigned
  103. *
  104. * @param Societe $objsoc Object third party
  105. * @param Object $object Object
  106. * @param string $mode 'next' for next value or 'last' for last value
  107. * @return string Value if OK, 0 if KO
  108. */
  109. public function getNextValue($objsoc, $object, $mode = 'next')
  110. {
  111. global $langs;
  112. return $langs->trans("NotAvailable");
  113. }
  114. /** Returns version of the model numbering
  115. *
  116. * @return string Value
  117. */
  118. public function getVersion()
  119. {
  120. global $langs;
  121. $langs->load("admin");
  122. if ($this->version == 'development') {
  123. return $langs->trans("VersionDevelopment");
  124. }
  125. if ($this->version == 'experimental') {
  126. return $langs->trans("VersionExperimental");
  127. }
  128. if ($this->version == 'dolibarr') {
  129. return DOL_VERSION;
  130. }
  131. if ($this->version) {
  132. return $this->version;
  133. }
  134. return $langs->trans("NotAvailable");
  135. }
  136. }