list.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /* Copyright (C) 2011-2014 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. */
  17. /**
  18. * \file htdocs/compta/localtax/list.php
  19. * \ingroup tax
  20. * \brief List of IRPF payments
  21. */
  22. // Load Dolibarr environment
  23. require '../../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
  25. // Load translation files required by the page
  26. $langs->load("compta");
  27. // Security check
  28. $socid = GETPOST('socid', 'int');
  29. if ($user->socid) {
  30. $socid = $user->socid;
  31. }
  32. $result = restrictedArea($user, 'tax', '', '', 'charges');
  33. $ltt = GETPOST("localTaxType", 'int');
  34. /*
  35. * View
  36. */
  37. llxHeader();
  38. $localtax_static = new Localtax($db);
  39. $url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt;
  40. if (!empty($socid)) {
  41. $url .= '&socid='.$socid;
  42. }
  43. $newcardbutton = dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
  44. print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy');
  45. $sql = "SELECT rowid, amount, label, f.datev, f.datep";
  46. $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f ";
  47. $sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype = ".((int) $ltt);
  48. $sql .= " ORDER BY datev DESC";
  49. $result = $db->query($sql);
  50. if ($result) {
  51. $num = $db->num_rows($result);
  52. $i = 0;
  53. $total = 0;
  54. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  55. print '<table class="noborder centpercent">';
  56. print '<tr class="liste_titre">';
  57. print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
  58. print "<td>".$langs->trans("Label")."</td>";
  59. print "<td>".$langs->trans("PeriodEndDate")."</td>";
  60. print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
  61. print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
  62. print "</tr>\n";
  63. $var = 1;
  64. while ($i < $num) {
  65. $obj = $db->fetch_object($result);
  66. print '<tr class="oddeven">';
  67. $localtax_static->id = $obj->rowid;
  68. $localtax_static->ref = $obj->rowid;
  69. print "<td>".$localtax_static->getNomUrl(1)."</td>\n";
  70. print "<td>".dol_trunc($obj->label, 40)."</td>\n";
  71. print '<td class="left">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
  72. print '<td class="left">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
  73. $total = $total + $obj->amount;
  74. print '<td class="right nowraponall"><span class="amount">'.price($obj->amount).'</span></td>';
  75. print "</tr>\n";
  76. $i++;
  77. }
  78. print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
  79. print '<td class="right"><span class="amount">'.price($total).'</span></td></tr>';
  80. print "</table>";
  81. print '</div>';
  82. $db->free($result);
  83. } else {
  84. dol_print_error($db);
  85. }
  86. // End of page
  87. llxFooter();
  88. $db->close();