dolibarr  16.0.5
list.php
Go to the documentation of this file.
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 
24 require '../../main.inc.php';
25 require_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');
32 if ($user->socid) {
33  $socid = $user->socid;
34 }
35 $result = restrictedArea($user, 'tax', '', '', 'charges');
36 $ltt = GETPOST("localTaxType", 'int');
37 
38 
39 /*
40  * View
41  */
42 
43 llxHeader();
44 
45 $localtax_static = new Localtax($db);
46 
47 $url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt;
48 if (!empty($socid)) {
49  $url .= '&socid='.$socid;
50 }
51 $newcardbutton = dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
52 
53 print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy');
54 
55 $sql = "SELECT rowid, amount, label, f.datev, f.datep";
56 $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f ";
57 $sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype = ".((int) $ltt);
58 $sql .= " ORDER BY datev DESC";
59 
60 $result = $db->query($sql);
61 if ($result) {
62  $num = $db->num_rows($result);
63  $i = 0;
64  $total = 0;
65 
66  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
67  print '<table class="noborder centpercent">';
68  print '<tr class="liste_titre">';
69  print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
70  print "<td>".$langs->trans("Label")."</td>";
71  print "<td>".$langs->trans("PeriodEndDate")."</td>";
72  print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
73  print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
74  print "</tr>\n";
75  $var = 1;
76  while ($i < $num) {
77  $obj = $db->fetch_object($result);
78 
79  print '<tr class="oddeven">';
80 
81  $localtax_static->id = $obj->rowid;
82  $localtax_static->ref = $obj->rowid;
83  print "<td>".$localtax_static->getNomUrl(1)."</td>\n";
84  print "<td>".dol_trunc($obj->label, 40)."</td>\n";
85  print '<td class="left">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
86  print '<td class="left">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
87  $total = $total + $obj->amount;
88 
89  print '<td class="right nowraponall"><span class="amount">'.price($obj->amount).'</span></td>';
90  print "</tr>\n";
91 
92  $i++;
93  }
94  print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
95  print '<td class="right"><span class="amount">'.price($total).'</span></td></tr>';
96 
97  print "</table>";
98  print '</div>';
99 
100  $db->free($result);
101 } else {
102  dol_print_error($db);
103 }
104 
105 // End of page
106 llxFooter();
107 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
Localtax
Class to manage local tax.
Definition: localtax.class.php:29