tovalidate.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/compta/paiement/tovalidate.php
  20. * \ingroup compta
  21. * \brief Page list payment to validate. Visible in menu when option BILL_ADD_PAYMENT_VALIDATION is on.
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. // Load translation files required by the page
  26. $langs->load("bills");
  27. $socid = 0;
  28. if ($user->socid > 0) {
  29. $action = '';
  30. $socid = $user->socid;
  31. }
  32. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  33. $sortfield = GETPOST('sortfield', 'aZ09comma');
  34. $sortorder = GETPOST('sortorder', 'aZ09comma');
  35. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  36. if (empty($page) || $page == -1) {
  37. $page = 0;
  38. } // If $page is not defined, or '' or -1
  39. $offset = $limit * $page;
  40. $pageprev = $page - 1;
  41. $pagenext = $page + 1;
  42. if (!$sortorder) {
  43. $sortorder = "DESC";
  44. }
  45. if (!$sortfield) {
  46. $sortfield = "p.rowid";
  47. }
  48. // Security check
  49. if (empty($user->rights->facture->lire)) {
  50. accessforbidden();
  51. }
  52. /*
  53. * Actions
  54. */
  55. /*
  56. * View
  57. */
  58. llxHeader();
  59. $sql = "SELECT p.rowid, p.datep as dp, p.amount, p.statut";
  60. $sql .= ", c.libelle as paiement_type, p.num_paiement as num_payment";
  61. $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
  62. if ($socid) {
  63. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
  64. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
  65. }
  66. $sql .= " WHERE p.entity IN (".getEntity('invoice').')';
  67. if ($socid) {
  68. $sql .= " AND f.fk_soc = ".((int) $socid);
  69. }
  70. $sql .= " AND p.statut = 0";
  71. $sql .= $db->order($sortfield, $sortorder);
  72. // Count total nb of records
  73. $nbtotalofrecords = '';
  74. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  75. $result = $db->query($sql);
  76. $nbtotalofrecords = $db->num_rows($result);
  77. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  78. $page = 0;
  79. $offset = 0;
  80. }
  81. }
  82. $sql .= $db->plimit($limit + 1, $offset);
  83. $resql = $db->query($sql);
  84. if ($resql) {
  85. $num = $db->num_rows($resql);
  86. $i = 0;
  87. print_barre_liste($langs->trans("ReceivedCustomersPaymentsToValid"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
  88. print '<table class="noborder centpercent">';
  89. print '<tr class="liste_titre">';
  90. print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.rowid", "", "", 'width="60"', $sortfield, $sortorder);
  91. print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "dp", "", "", 'width="80" align="center"', $sortfield, $sortorder);
  92. print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", "", "", $sortfield, $sortorder);
  93. print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "c.libelle", "", "", 'class="right"', $sortfield, $sortorder);
  94. print_liste_field_titre('');
  95. print "</tr>\n";
  96. while ($i < min($num, $limit)) {
  97. $objp = $db->fetch_object($resql);
  98. print '<tr class="oddeven">';
  99. print '<td><a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.'</a></td>';
  100. print '<td width="80" align="center">'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
  101. print "<td>$objp->paiement_type $objp->num_payment</td>\n";
  102. print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
  103. print '<td class="center">';
  104. if ($objp->statut == 0) {
  105. print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">'.$langs->trans("PaymentStatusToValidShort").'</a>';
  106. } else {
  107. print "-";
  108. }
  109. print '</td>';
  110. print "</tr>";
  111. $i++;
  112. }
  113. print "</table>";
  114. }
  115. // End of page
  116. llxFooter();
  117. $db->close();