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