dolibarr 21.0.0-beta
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
29
39// Load translation files required by the page
40$langs->load("compta");
41
42$limit = GETPOSTINT('limit');
43
44// Security check
45$socid = GETPOSTINT('socid');
46if ($user->socid) {
47 $socid = $user->socid;
48}
49
50$result = restrictedArea($user, 'tax', '', '', 'charges');
51$ltt = GETPOSTINT("localTaxType");
52$mode = GETPOST('mode', 'alpha');
53
54
55/*
56 * View
57 */
58
59llxHeader();
60
61$localtax_static = new Localtax($db);
62
63$url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt;
64if (!empty($socid)) {
65 $url .= '&socid='.$socid;
66}
67$param = '';
68if (!empty($mode)) {
69 $param .= '&mode='.urlencode($mode);
70}
71$newcardbutton = '';
72$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?localTaxType='.$ltt.'&mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
73$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?localTaxType='.$ltt.'&mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
74$newcardbutton .= dolGetButtonTitleSeparator();
75$newcardbutton .= dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->hasRight('tax', 'charges', 'creer'));
76
77print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy');
78
79$sql = "SELECT rowid, amount, label, f.datev, f.datep";
80$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f ";
81$sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype = ".((int) $ltt);
82$sql .= " ORDER BY datev DESC";
83
84$result = $db->query($sql);
85if ($result) {
86 $num = $db->num_rows($result);
87 $i = 0;
88 $total = 0;
89
90 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
91 print '<table class="noborder centpercent">';
92 print '<tr class="liste_titre">';
93 print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
94 print "<td>".$langs->trans("Label")."</td>";
95 print "<td>".$langs->trans("PeriodEndDate")."</td>";
96 print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
97 print '<td class="right">'.$langs->trans("PayedByThisPayment").'</td>';
98 print "</tr>\n";
99
100 $savnbfield = 5;
101
102 $imaxinloop = ($limit ? min($num, $limit) : $num);
103 while ($i < $imaxinloop) {
104 $obj = $db->fetch_object($result);
105
106 $localtax_static->label = $obj->label;
107 $localtax_static->id = $obj->rowid;
108 $localtax_static->ref = $obj->rowid;
109 $localtax_static->datev = $obj->datev;
110 $localtax_static->datep = $obj->datep;
111 $localtax_static->amount = $obj->amount;
112
113 $total += $obj->amount;
114
115 if ($mode == 'kanban') {
116 if ($i == 0) {
117 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
118 print '<div class="box-flex-container kanban">';
119 }
120 // Output Kanban
121 print $localtax_static->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
122 if ($i == ($imaxinloop - 1)) {
123 print '</div>';
124 print '</td></tr>';
125 }
126 } else {
127 print '<tr class="oddeven">';
128 print "<td>".$localtax_static->getNomUrl(1)."</td>\n";
129 print "<td>".dol_trunc($obj->label, 40)."</td>\n";
130 print '<td class="left">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
131 print '<td class="left">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
132
133 print '<td class="right nowraponall"><span class="amount">'.price($obj->amount).'</span></td>';
134 print "</tr>\n";
135 }
136 $i++;
137 }
138 print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
139 print '<td class="right"><span class="amount">'.price($total).'</span></td></tr>';
140
141 print "</table>";
142 print '</div>';
143
144 $db->free($result);
145} else {
146 dol_print_error($db);
147}
148
149// End of page
150llxFooter();
151$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage local tax.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
restrictedArea(User $user, $features, $object=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.