modules_expedition.php 4.0 KB

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