dolibarr  19.0.0-dev
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 // Load Dolibarr environment
25 require '../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
27 
28 // Load translation files required by the page
29 $langs->load("compta");
30 
31 $limit = GETPOST('limit', 'int');
32 
33 // Security check
34 $socid = GETPOST('socid', 'int');
35 if ($user->socid) {
36  $socid = $user->socid;
37 }
38 
39 $result = restrictedArea($user, 'tax', '', '', 'charges');
40 $ltt = GETPOST("localTaxType", 'int');
41 $mode = GETPOST('mode', 'alpha');
42 
43 
44 /*
45  * View
46  */
47 
48 llxHeader();
49 
50 $localtax_static = new Localtax($db);
51 
52 $url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt;
53 if (!empty($socid)) {
54  $url .= '&socid='.$socid;
55 }
56 $param = '';
57 if (!empty($mode)) {
58  $param .= '&mode='.urlencode($mode);
59 }
60 $newcardbutton = '';
61 $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'));
62 $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'));
63 $newcardbutton .= dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
64 
65 print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy');
66 
67 $sql = "SELECT rowid, amount, label, f.datev, f.datep";
68 $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f ";
69 $sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype = ".((int) $ltt);
70 $sql .= " ORDER BY datev DESC";
71 
72 $result = $db->query($sql);
73 if ($result) {
74  $num = $db->num_rows($result);
75  $i = 0;
76  $total = 0;
77 
78  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
79  print '<table class="noborder centpercent">';
80  print '<tr class="liste_titre">';
81  print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
82  print "<td>".$langs->trans("Label")."</td>";
83  print "<td>".$langs->trans("PeriodEndDate")."</td>";
84  print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
85  print '<td class="right">'.$langs->trans("PayedByThisPayment").'</td>';
86  print "</tr>\n";
87 
88  $savnbfield = 5;
89 
90  $imaxinloop = ($limit ? min($num, $limit) : $num);
91  while ($i < $imaxinloop) {
92  $obj = $db->fetch_object($result);
93 
94  $localtax_static->label = $obj->label;
95  $localtax_static->id = $obj->rowid;
96  $localtax_static->ref = $obj->rowid;
97  $localtax_static->datev = $obj->datev;
98  $localtax_static->datep = $obj->datep;
99  $localtax_static->amount = $obj->amount;
100 
101  $total = $total + $obj->amount;
102 
103  if ($mode == 'kanban') {
104  if ($i == 0) {
105  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
106  print '<div class="box-flex-container kanban">';
107  }
108  // Output Kanban
109  print $localtax_static->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
110  if ($i == ($imaxinloop - 1)) {
111  print '</div>';
112  print '</td></tr>';
113  }
114  } else {
115  print '<tr class="oddeven">';
116  print "<td>".$localtax_static->getNomUrl(1)."</td>\n";
117  print "<td>".dol_trunc($obj->label, 40)."</td>\n";
118  print '<td class="left">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
119  print '<td class="left">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
120 
121  print '<td class="right nowraponall"><span class="amount">'.price($obj->amount).'</span></td>';
122  print "</tr>\n";
123  }
124  $i++;
125  }
126  print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
127  print '<td class="right"><span class="amount">'.price($total).'</span></td></tr>';
128 
129  print "</table>";
130  print '</div>';
131 
132  $db->free($result);
133 } else {
134  dol_print_error($db);
135 }
136 
137 // End of page
138 llxFooter();
139 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage local tax.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.