modules_commande.php 4.1 KB

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