mod_payment_ant.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. * @param Translate $langs Lang object to use for output
  52. * @return string Descriptive text
  53. */
  54. public function info($langs)
  55. {
  56. global $db, $langs;
  57. $langs->load("bills");
  58. $form = new Form($db);
  59. $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
  60. $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  61. $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
  62. $texte .= '<input type="hidden" name="action" value="updateMask">';
  63. $texte .= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">';
  64. $texte .= '<table class="nobordernopadding" width="100%">';
  65. $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
  66. $tooltip .= $langs->trans("GenericMaskCodes2");
  67. $tooltip .= $langs->trans("GenericMaskCodes3");
  68. $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
  69. $tooltip .= $langs->trans("GenericMaskCodes5");
  70. // Parametrage du prefix
  71. $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
  72. $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskpayment" value="'.getDolGlobalString('PAYMENT_ANT_MASK').'">', $tooltip, 1, 1).'</td>';
  73. $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
  74. $texte .= '</tr>';
  75. $texte .= '</table>';
  76. $texte .= '</form>';
  77. return $texte;
  78. }
  79. /**
  80. * Return an example of numbering
  81. *
  82. * @return string Example
  83. */
  84. public function getExample()
  85. {
  86. global $conf, $langs, $mysoc;
  87. $old_code_client = $mysoc->code_client;
  88. $mysoc->code_client = 'CCCCCCCCCC';
  89. $numExample = $this->getNextValue($mysoc, '');
  90. $mysoc->code_client = $old_code_client;
  91. if (!$numExample) {
  92. $numExample = $langs->trans('NotConfigured');
  93. }
  94. return $numExample;
  95. }
  96. /**
  97. * Return next free value
  98. *
  99. * @param Societe $objsoc Object thirdparty
  100. * @param Object $object Object we need next value for
  101. * @return string Value if KO, <0 if KO
  102. */
  103. public function getNextValue($objsoc, $object)
  104. {
  105. global $db, $conf;
  106. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  107. // We get cursor rule
  108. $mask = getDolGlobalString('PAYMENT_ANT_MASK');
  109. if (!$mask) {
  110. $this->error = 'NotConfigured';
  111. return 0;
  112. }
  113. $numFinal = get_next_value($db, $mask, 'paiement', 'ref', '', $objsoc, $object->datepaye);
  114. return $numFinal;
  115. }
  116. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  117. /**
  118. * Return next free value
  119. *
  120. * @param Societe $objsoc Object third party
  121. * @param string $objforref Object for number to search
  122. * @return string Next free value
  123. */
  124. public function commande_get_num($objsoc, $objforref)
  125. {
  126. // phpcs:enable
  127. return $this->getNextValue($objsoc, $objforref);
  128. }
  129. }