mod_payment_ant.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. * or see https://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/modules/payment/mod_payment_ant.php
  20. * \ingroup payment
  21. * \brief File containing class for numbering module Ant
  22. */
  23. require_once DOL_DOCUMENT_ROOT.'/core/modules/payment/modules_payment.php';
  24. /**
  25. * Class to manage customer payment numbering rules Ant
  26. */
  27. class mod_payment_ant extends ModeleNumRefPayments
  28. {
  29. /**
  30. * Dolibarr version of the loaded document
  31. * @var string
  32. */
  33. public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
  34. /**
  35. * @var string Error message
  36. */
  37. public $error = '';
  38. /**
  39. * @var string Nom du modele
  40. * @deprecated
  41. * @see $name
  42. */
  43. public $nom = 'Ant';
  44. /**
  45. * @var string model name
  46. */
  47. public $name = 'Ant';
  48. /**
  49. * Returns the description of the numbering model
  50. *
  51. * @return string Texte descripif
  52. */
  53. public function info()
  54. {
  55. global $db, $langs;
  56. $langs->load("bills");
  57. $form = new Form($db);
  58. $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
  59. $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  60. $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
  61. $texte .= '<input type="hidden" name="action" value="updateMask">';
  62. $texte .= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">';
  63. $texte .= '<table class="nobordernopadding" width="100%">';
  64. $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
  65. $tooltip .= $langs->trans("GenericMaskCodes2");
  66. $tooltip .= $langs->trans("GenericMaskCodes3");
  67. $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
  68. $tooltip .= $langs->trans("GenericMaskCodes5");
  69. // Parametrage du prefix
  70. $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
  71. $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskpayment" value="'.getDolGlobalString('PAYMENT_ANT_MASK').'">', $tooltip, 1, 1).'</td>';
  72. $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
  73. $texte .= '</tr>';
  74. $texte .= '</table>';
  75. $texte .= '</form>';
  76. return $texte;
  77. }
  78. /**
  79. * Return an example of numbering
  80. *
  81. * @return string Example
  82. */
  83. public function getExample()
  84. {
  85. global $conf, $langs, $mysoc;
  86. $old_code_client = $mysoc->code_client;
  87. $mysoc->code_client = 'CCCCCCCCCC';
  88. $numExample = $this->getNextValue($mysoc, '');
  89. $mysoc->code_client = $old_code_client;
  90. if (!$numExample) {
  91. $numExample = $langs->trans('NotConfigured');
  92. }
  93. return $numExample;
  94. }
  95. /**
  96. * Return next free value
  97. *
  98. * @param Societe $objsoc Object thirdparty
  99. * @param Object $object Object we need next value for
  100. * @return string Value if KO, <0 if KO
  101. */
  102. public function getNextValue($objsoc, $object)
  103. {
  104. global $db, $conf;
  105. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  106. // We get cursor rule
  107. $mask = getDolGlobalString('PAYMENT_ANT_MASK');
  108. if (!$mask) {
  109. $this->error = 'NotConfigured';
  110. return 0;
  111. }
  112. $numFinal = get_next_value($db, $mask, 'paiement', 'ref', '', $objsoc, $object->datepaye);
  113. return $numFinal;
  114. }
  115. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  116. /**
  117. * Return next free value
  118. *
  119. * @param Societe $objsoc Object third party
  120. * @param string $objforref Object for number to search
  121. * @return string Next free value
  122. */
  123. public function commande_get_num($objsoc, $objforref)
  124. {
  125. // phpcs:enable
  126. return $this->getNextValue($objsoc, $objforref);
  127. }
  128. }