rejets.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
  5. * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/compta/prelevement/rejets.php
  22. * \ingroup prelevement
  23. * \brief Reject page
  24. */
  25. // Load Dolibarr environment
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  31. // Load translation files required by the page
  32. $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
  33. $type = GETPOST('type', 'aZ09');
  34. // Get supervariables
  35. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  36. $sortorder = GETPOST('sortorder', 'aZ09comma');
  37. $sortfield = GETPOST('sortfield', 'aZ09comma');
  38. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  39. if (empty($page) || $page == -1) {
  40. $page = 0;
  41. } // If $page is not defined, or '' or -1
  42. $offset = $limit * $page;
  43. $pageprev = $page - 1;
  44. $pagenext = $page + 1;
  45. // Security check
  46. $socid = GETPOST('socid', 'int');
  47. if ($user->socid) {
  48. $socid = $user->socid;
  49. }
  50. if ($type == 'bank-transfer') {
  51. $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
  52. } else {
  53. $result = restrictedArea($user, 'prelevement', '', '', 'bons');
  54. }
  55. /*
  56. * View
  57. */
  58. $title = $langs->trans("WithdrawsRefused");
  59. if ($type == 'bank-transfer') {
  60. $title = $langs->trans("CreditTransfersRefused");
  61. }
  62. llxHeader('', $title);
  63. if ($sortorder == "") {
  64. $sortorder = "DESC";
  65. }
  66. if ($sortfield == "") {
  67. $sortfield = "p.datec";
  68. }
  69. $rej = new RejetPrelevement($db, $user, $type);
  70. $line = new LignePrelevement($db);
  71. $hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
  72. /*
  73. * Liste des factures
  74. *
  75. */
  76. $sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut";
  77. $sql .= " , s.rowid as socid, s.nom";
  78. $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
  79. $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
  80. $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
  81. $sql .= " , ".MAIN_DB_PREFIX."societe as s";
  82. $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
  83. $sql .= " AND pl.fk_prelevement_bons = p.rowid";
  84. $sql .= " AND pl.fk_soc = s.rowid";
  85. $sql .= " AND p.entity = ".$conf->entity;
  86. if ($type == 'bank-transfer') {
  87. $sql .= " AND p.type = 'bank-transfer'";
  88. } else {
  89. $sql .= " AND p.type = 'debit-order'";
  90. }
  91. if ($socid) {
  92. $sql .= " AND s.rowid = ".((int) $socid);
  93. }
  94. $sql .= $db->order($sortfield, $sortorder);
  95. $sql .= $db->plimit($limit + 1, $offset);
  96. $result = $db->query($sql);
  97. if ($result) {
  98. $num = $db->num_rows($result);
  99. $i = 0;
  100. $param = '';
  101. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
  102. print"\n<!-- debut table -->\n";
  103. print '<table class="noborder tagtable liste" width="100%" cellpadding="4">';
  104. print '<tr class="liste_titre">';
  105. print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param);
  106. print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param);
  107. print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
  108. print "</tr>\n";
  109. if ($num) {
  110. while ($i < min($num, $limit)) {
  111. $obj = $db->fetch_object($result);
  112. print '<tr class="oddeven">';
  113. print '<td>';
  114. print $line->LibStatut($obj->statut, 2).'&nbsp;';
  115. print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
  116. print substr('000000'.$obj->rowid, -6)."</a></td>";
  117. print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->nom."</a></td>\n";
  118. print '<td>'.$rej->motifs[$obj->motif].'</td>';
  119. print "</tr>\n";
  120. $i++;
  121. }
  122. } else {
  123. print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
  124. }
  125. print "</table>";
  126. $db->free($result);
  127. } else {
  128. dol_print_error($db);
  129. }
  130. // End of page
  131. llxFooter();
  132. $db->close();