modules_facturefournisseur.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  3. * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.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 <http://www.gnu.org/licenses/>.
  19. * or see http://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. var $error='';
  35. /**
  36. * Return list of active generation models
  37. *
  38. * @param DoliDB $db Database handler
  39. * @param integer $maxfilenamelength Max length of value to show
  40. * @return array List of numbers
  41. */
  42. static function liste_modeles($db,$maxfilenamelength=0)
  43. {
  44. global $conf;
  45. $type='invoice_supplier';
  46. $liste=array();
  47. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  48. $liste=getListOfModels($db,$type,$maxfilenamelength);
  49. return $liste;
  50. }
  51. }
  52. /**
  53. * Parent Class of numbering models of suppliers invoices references
  54. */
  55. abstract class ModeleNumRefSuppliersInvoices
  56. {
  57. var $error='';
  58. /** Return if a model can be used or not
  59. *
  60. * @return boolean true if model can be used
  61. */
  62. function isEnabled()
  63. {
  64. return true;
  65. }
  66. /** Returns the default description of the model numbering
  67. *
  68. * @return string Description Text
  69. */
  70. function info()
  71. {
  72. global $langs;
  73. $langs->load("invoices");
  74. return $langs->trans("NoDescription");
  75. }
  76. /** Returns a numbering example
  77. *
  78. * @return string Example
  79. */
  80. function getExample()
  81. {
  82. global $langs;
  83. $langs->load("invoices");
  84. return $langs->trans("NoExample");
  85. }
  86. /** Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering.
  87. *
  88. * @return boolean false if conflict, true if ok
  89. */
  90. function canBeActivated()
  91. {
  92. return true;
  93. }
  94. /** Returns next value assigned
  95. *
  96. * @param Societe $objsoc Object third party
  97. * @param Object $object Object
  98. * @param string $mode 'next' for next value or 'last' for last value
  99. * @return string Value if OK, 0 if KO
  100. */
  101. function getNextValue($objsoc,$object,$mode)
  102. {
  103. global $langs;
  104. return $langs->trans("NotAvailable");
  105. }
  106. /** Returns version of the model numbering
  107. *
  108. * @return string Value
  109. */
  110. function getVersion()
  111. {
  112. global $langs;
  113. $langs->load("admin");
  114. if ($this->version == 'development') return $langs->trans("VersionDevelopment");
  115. if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
  116. if ($this->version == 'dolibarr') return DOL_VERSION;
  117. if ($this->version) return $this->version;
  118. return $langs->trans("NotAvailable");
  119. }
  120. }
  121. /**
  122. * Create a document onto disk according to template model.
  123. *
  124. * @param DoliDB $db Database handler
  125. * @param Object $object Object supplier invoice
  126. * @param string $modele Force template to use ('' to not force)
  127. * @param Translate $outputlangs Object lang a utiliser pour traduction
  128. * @param int $hidedetails Hide details of lines
  129. * @param int $hidedesc Hide description
  130. * @param int $hideref Hide ref
  131. * @return int 0 if KO, 1 if OK
  132. *
  133. */
  134. function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
  135. {
  136. return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
  137. }