prelevement.lib.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
  3. * Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. * or see https://www.gnu.org/
  19. */
  20. /**
  21. * \file htdocs/core/lib/prelevement.lib.php
  22. * \brief Ensemble de fonctions de base pour le module prelevement
  23. * \ingroup propal
  24. */
  25. /**
  26. * Prepare array with list of tabs
  27. *
  28. * @param BonPrelevement $object Object related to tabs
  29. * @return array Array of tabs to show
  30. */
  31. function prelevement_prepare_head(BonPrelevement $object)
  32. {
  33. global $langs, $conf, $user;
  34. $langs->load("withdrawals");
  35. $h = 0;
  36. $head = array();
  37. $titleoftab = "WithdrawalsReceipts";
  38. if ($object->type == 'bank-transfer') {
  39. $titleoftab = "BankTransferReceipts";
  40. }
  41. $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$object->id;
  42. $head[$h][1] = $langs->trans($titleoftab);
  43. $head[$h][2] = 'prelevement';
  44. $h++;
  45. $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id;
  46. $head[$h][1] = $langs->trans("Bills");
  47. $head[$h][2] = 'invoices';
  48. $h++;
  49. $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php?id='.$object->id;
  50. $head[$h][1] = $langs->trans("Rejects");
  51. $head[$h][2] = 'rejects';
  52. $h++;
  53. $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$object->id;
  54. $head[$h][1] = $langs->trans("Statistics");
  55. $head[$h][2] = 'statistics';
  56. $h++;
  57. // Show more tabs from modules
  58. // Entries must be declared in modules descriptor with line
  59. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  60. // $this->tabs = array('entity:-tabname); to remove a tab
  61. complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
  62. complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
  63. return $head;
  64. }
  65. /**
  66. * Check need data to create standigns orders receipt file
  67. *
  68. * @param string $type 'bank-transfer' or 'direct-debit'
  69. *
  70. * @return int -1 if ko 0 if ok
  71. */
  72. function prelevement_check_config($type = 'direct-debit')
  73. {
  74. global $conf, $db;
  75. if ($type == 'bank-transfer') {
  76. if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) {
  77. return -1;
  78. }
  79. //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
  80. if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) {
  81. return -1;
  82. }
  83. } else {
  84. if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) {
  85. return -1;
  86. }
  87. //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
  88. if (empty($conf->global->PRELEVEMENT_USER)) {
  89. return -1;
  90. }
  91. }
  92. return 0;
  93. }