dolibarr  7.0.0-beta
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
6  * Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
36 
37 $langs->load("compta");
38 $langs->load("bills");
39 
40 // Security check
41 if ($user->societe_id) $socid=$user->societe_id;
42 $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|');
43 
44 $mode=GETPOST("mode",'alpha');
45 $year=GETPOST("year",'int');
46 $filtre=GETPOST("filtre",'alpha');
47 if (! $year && $mode != 'sconly') { $year=date("Y", time()); }
48 
49 $search_account = GETPOST('search_account','int');
50 
51 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
52 $sortfield = GETPOST("sortfield",'alpha');
53 $sortorder = GETPOST("sortorder",'alpha');
54 $page = GETPOST("page",'int');
55 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (! $sortfield) $sortfield="cs.date_ech";
60 if (! $sortorder) $sortorder="DESC";
61 
62 
63 /*
64  * View
65  */
66 
67 $tva_static = new Tva($db);
68 $socialcontrib=new ChargeSociales($db);
69 $payment_sc_static=new PaymentSocialContribution($db);
70 $sal_static = new PaymentSalary($db);
71 $accountstatic = new Account($db);
72 
73 llxHeader('',$langs->trans("SpecialExpensesArea"));
74 
75 $title=$langs->trans("SpecialExpensesArea");
76 if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments");
77 
78 $param='';
79 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
80 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
81 if ($mode == 'sconly') $param='&mode=sconly';
82 if ($sortfield) $param.='&sortfield='.$sortfield;
83 if ($sortorder) $param.='&sortorder='.$sortorder;
84 
85 
86 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
87 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
88 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
89 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
90 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
91 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
92 print '<input type="hidden" name="page" value="'.$page.'">';
93 print '<input type="hidden" name="mode" value="'.$mode.'">';
94 
95 if ($mode != 'sconly')
96 {
97  $center=($year?'<a href="index.php?year='.($year-1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="index.php?year='.($year+1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>":"");
98  print_barre_liste($title,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$center,$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit, 1);
99 }
100 else
101 {
102  print_barre_liste($title,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$center,$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit);
103 }
104 
105 if ($year) $param.='&year='.$year;
106 
107 if ($mode != 'sconly')
108 {
109  print $langs->trans("DescTaxAndDividendsArea").'<br>';
110  print "<br>";
111 }
112 
113 if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
114 {
115  // Social contributions only
116  if ($mode != 'sconly')
117  {
118  print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
119  }
120 
121  print '<table class="noborder" width="100%">';
122  print '<tr class="liste_titre">';
123  print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="140px"',$sortfield,$sortorder);
124  print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"c.libelle","",$param,'',$sortfield,$sortorder);
125  print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"cs.fk_type","",$param,'',$sortfield,$sortorder);
126  print_liste_field_titre("ExpectedToPay",$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder);
127  print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],"pc.rowid","",$param,'',$sortfield,$sortorder);
128  print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"pc.datep","",$param,'align="center"',$sortfield,$sortorder);
129  print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder);
130  if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
131  print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"pc.amount","",$param,'align="right"',$sortfield,$sortorder);
132  print "</tr>\n";
133 
134  $sql = "SELECT c.id, c.libelle as lib,";
135  $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,";
136  $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,";
137  $sql.= " pct.code as payment_code,";
138  $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
139  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
140  $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs";
141  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
142  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity IN (".getEntity('c_paiement').")";
143  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid";
144  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
145  $sql.= " WHERE cs.fk_type = c.id";
146  $sql.= " AND cs.entity IN (".getEntity("tax").")";
147  if ($year > 0)
148  {
149  $sql .= " AND (";
150  // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
151  // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
152  $sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
153  $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
154  $sql .= ")";
155  }
156  if (preg_match('/^cs\./',$sortfield) || preg_match('/^c\./',$sortfield) || preg_match('/^pc\./',$sortfield) || preg_match('/^pct\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
157  //$sql.= $db->plimit($limit+1,$offset);
158  //print $sql;
159 
160  dol_syslog("compta/charges/index.php: select payment", LOG_DEBUG);
161  $resql=$db->query($sql);
162  if ($resql)
163  {
164  $num = $db->num_rows($resql);
165  $i = 0;
166  $total = 0;
167  $totalnb = 0;
168  $totalpaye = 0;
169  $var=true;
170 
171  while ($i < min($num, $limit))
172  {
173  $obj = $db->fetch_object($resql);
174  $var = !$var;
175  print '<tr class="oddeven">';
176  // Date
177  $date=$obj->periode;
178  if (empty($date)) $date=$obj->date_ech;
179  print '<td>'.dol_print_date($date,'day').'</td>';
180  // Label
181  print '<td>';
182  $socialcontrib->id=$obj->rowid;
183  $socialcontrib->ref=$obj->libelle;
184  $socialcontrib->lib=$obj->libelle;
185  print $socialcontrib->getNomUrl(1,'20');
186  print '</td>';
187  // Type
188  print '<td><a href="../sociales/index.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
189  // Expected to pay
190  print '<td align="right">'.price($obj->total).'</td>';
191  // Ref payment
192  $payment_sc_static->id=$obj->pid;
193  $payment_sc_static->ref=$obj->pid;
194  print '<td>'.$payment_sc_static->getNomUrl(1)."</td>\n";
195  // Date payment
196  print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day').'</td>';
197  // Type payment
198  print '<td>';
199  if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
200  print $obj->num_payment.'</td>';
201  // Account
202  if (! empty($conf->banque->enabled))
203  {
204  print '<td>';
205  if ($obj->fk_bank > 0)
206  {
207  //$accountstatic->fetch($obj->fk_bank);
208  $accountstatic->id=$obj->bid;
209  $accountstatic->ref=$obj->bref;
210  $accountstatic->number=$obj->bnumber;
211  $accountstatic->accountancy_number=$obj->account_number;
212  $accountstatic->accountancy_journal=$obj->accountancy_journal;
213  $accountstatic->label=$obj->blabel;
214  print $accountstatic->getNomUrl(1);
215  }
216  else print '&nbsp;';
217  print '</td>';
218  }
219  // Paid
220  print '<td align="right">';
221  if ($obj->totalpaye) print price($obj->totalpaye);
222  print '</td>';
223  print '</tr>';
224 
225  $total = $total + $obj->total;
226  $totalnb = $totalnb + $obj->nb;
227  $totalpaye = $totalpaye + $obj->totalpaye;
228  $i++;
229  }
230  print '<tr class="liste_total"><td colspan="3" class="liste_total">'.$langs->trans("Total").'</td>';
231  print '<td align="right" class="liste_total"></td>'; // A total here has no sense
232  print '<td align="center" class="liste_total">&nbsp;</td>';
233  print '<td align="center" class="liste_total">&nbsp;</td>';
234  print '<td align="center" class="liste_total">&nbsp;</td>';
235  if (! empty($conf->banque->enabled)) print '<td></td>';
236  print '<td align="right" class="liste_total">'.price($totalpaye)."</td>";
237  print "</tr>";
238  }
239  else
240  {
241  dol_print_error($db);
242  }
243  print '</table>';
244 }
245 
246 // VAT
247 if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
248 {
249  if (! $mode || $mode != 'sconly')
250  {
251  print "<br>";
252 
253  $tva = new Tva($db);
254 
255  print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
256 
257  $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,";
258  $sql.= " pct.code as payment_code,";
259  $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
260  $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv";
261  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid";
262  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
263  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id AND pct.entity IN (".getEntity('c_paiement').")";
264  $sql.= " WHERE pv.entity IN (".getEntity("tax").")";
265  if ($year > 0)
266  {
267  // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
268  // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
269  $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
270  }
271  if (preg_match('/^pv\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
272 
273  $result = $db->query($sql);
274  if ($result)
275  {
276  $num = $db->num_rows($result);
277  $i = 0;
278  $total = 0 ;
279  print '<table class="noborder" width="100%">';
280  print '<tr class="liste_titre">';
281  print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="140px"',$sortfield,$sortorder);
282  print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder);
283  print_liste_field_titre("ExpectedToPay",$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
284  print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder);
285  print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"pv.datev","",$param,'align="center"',$sortfield,$sortorder);
286  print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder);
287  if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
288  print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
289  print "</tr>\n";
290  $var=1;
291  while ($i < $num)
292  {
293  $obj = $db->fetch_object($result);
294 
295  $total = $total + $obj->amount;
296 
297 
298  print '<tr class="oddeven">';
299  print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
300 
301  print "<td>".$obj->label."</td>\n";
302 
303  print '<td align="right">'.price($obj->amount)."</td>";
304 
305  // Ref payment
306  $tva_static->id=$obj->rowid;
307  $tva_static->ref=$obj->rowid;
308  print '<td align="left">'.$tva_static->getNomUrl(1)."</td>\n";
309 
310  // Date
311  print '<td align="center">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
312 
313  // Type payment
314  print '<td>';
315  if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
316  print $obj->num_payment.'</td>';
317 
318  // Account
319  if (! empty($conf->banque->enabled))
320  {
321  print '<td>';
322  if ($obj->fk_bank > 0)
323  {
324  //$accountstatic->fetch($obj->fk_bank);
325  $accountstatic->id=$obj->bid;
326  $accountstatic->ref=$obj->bref;
327  $accountstatic->number=$obj->bnumber;
328  $accountstatic->accountancy_number=$obj->account_number;
329  $accountstatic->accountancy_journal=$obj->accountancy_journal;
330  $accountstatic->label=$obj->blabel;
331  print $accountstatic->getNomUrl(1);
332  }
333  else print '&nbsp;';
334  print '</td>';
335  }
336 
337  // Paid
338  print '<td align="right">'.price($obj->amount)."</td>";
339  print "</tr>\n";
340 
341  $i++;
342  }
343  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
344  print '<td align="right">'.price($total).'</td>';
345  print '<td>&nbsp;</td>';
346  print '<td>&nbsp;</td>';
347  print '<td>&nbsp;</td>';
348  print '<td>&nbsp;</td>';
349  print '<td align="right">'.price($total)."</td>";
350  print "</tr>";
351 
352  print "</table>";
353  $db->free($result);
354  }
355  else
356  {
357  dol_print_error($db);
358  }
359  }
360 }
361 
362 // Localtax
363 if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
364 {
365  $j=1;
366  $numlt=3;
367 }
368 elseif($mysoc->localtax1_assuj=="1")
369 {
370  $j=1;
371  $numlt=2;
372 }
373 elseif($mysoc->localtax2_assuj=="1")
374 {
375  $j=2;
376  $numlt=3;
377 }
378 else
379 {
380  $j=0;
381  $numlt=0;
382 }
383 
384 while($j<$numlt)
385 {
386  if (! $mode || $mode != 'sconly')
387  {
388  print "<br>";
389 
390  $tva = new Tva($db);
391 
392  print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"),$mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
393 
394 
395  $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
396  $sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv";
397  $sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ;
398  if ($year > 0)
399  {
400  // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
401  // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
402  $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
403  }
404  if (preg_match('/^pv/',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
405 
406  $result = $db->query($sql);
407  if ($result)
408  {
409  $num = $db->num_rows($result);
410  $i = 0;
411  $total = 0 ;
412  print '<table class="noborder" width="100%">';
413  print '<tr class="liste_titre">';
414  print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder);
415  print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder);
416  print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder);
417  print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"pv.datep","",$param,'align="center"',$sortfield,$sortorder);
418  print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
419  print "</tr>\n";
420  $var=1;
421  while ($i < $num)
422  {
423  $obj = $db->fetch_object($result);
424 
425  $total = $total + $obj->amount;
426 
427 
428  print '<tr class="oddeven">';
429  print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
430 
431  print "<td>".$obj->label."</td>\n";
432 
433  // Ref payment
434  $tva_static->id=$obj->rowid;
435  $tva_static->ref=$obj->rowid;
436  print '<td align="left">'.$tva_static->getNomUrl(1)."</td>\n";
437 
438  print '<td align="center">'.dol_print_date($db->jdate($obj->dp),'day')."</td>\n";
439  print '<td align="right">'.price($obj->amount)."</td>";
440  print "</tr>\n";
441 
442  $i++;
443  }
444  print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").'</td>';
445  print '<td align="right">'.price($total)."</td>";
446  print "</tr>";
447 
448  print "</table>";
449  $db->free($result);
450  }
451  else
452  {
453  dol_print_error($db);
454  }
455  }
456  $j++;
457 }
458 
459 
460 // Payment Salary
461 if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
462 {
463  if (! $mode || $mode != 'sconly')
464  {
465  $sal = new PaymentSalary($db);
466 
467  print "<br>";
468 
469  print_fiche_titre( $langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
470 
471  $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,";
472  $sql.= " pct.code as payment_code,";
473  $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
474  $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
475  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
476  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
477  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id AND pct.entity IN (".getEntity('c_paiement').")";
478  $sql.= " , ".MAIN_DB_PREFIX."user as u";
479  $sql.= " WHERE s.entity IN (".getEntity('user').")";
480  $sql.= " AND u.rowid = s.fk_user";
481  if ($year > 0)
482  {
483  $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
484  $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."')";
485  }
486  if (preg_match('/^s\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
487 
488  $result = $db->query($sql);
489  if ($result)
490  {
491  $num = $db->num_rows($result);
492  $i = 0;
493  $total = 0 ;
494  print '<table class="noborder" width="100%">';
495  print '<tr class="liste_titre">';
496  print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"s.dateep","",$param,'width="140px"',$sortfield,$sortorder);
497  print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder);
498  print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder);
499  print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder);
500  print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder);
501  if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
502  print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
503  print "</tr>\n";
504  $var=1;
505  while ($i < $num)
506  {
507  $obj = $db->fetch_object($result);
508 
509  $total = $total + $obj->amount;
510 
511 
512  print '<tr class="oddeven">';
513 
514  print '<td align="left">'.dol_print_date($db->jdate($obj->dateep),'day').'</td>'."\n";
515 
516  print "<td>".$obj->label."</td>\n";
517 
518  // Ref payment
519  $sal_static->id=$obj->rowid;
520  $sal_static->ref=$obj->rowid;
521  print '<td align="left">'.$sal_static->getNomUrl(1)."</td>\n";
522 
523  // Date
524  print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day')."</td>\n";
525 
526  // Type payment
527  print '<td>';
528  if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
529  print $obj->num_payment.'</td>';
530 
531  // Account
532  if (! empty($conf->banque->enabled))
533  {
534  print '<td>';
535  if ($obj->fk_bank > 0)
536  {
537  //$accountstatic->fetch($obj->fk_bank);
538  $accountstatic->id=$obj->bid;
539  $accountstatic->ref=$obj->bref;
540  $accountstatic->number=$obj->bnumber;
541  $accountstatic->accountancy_number=$obj->account_number;
542  $accountstatic->accountancy_journal=$obj->accountancy_journal;
543  $accountstatic->label=$obj->blabel;
544  print $accountstatic->getNomUrl(1);
545  }
546  else print '&nbsp;';
547  print '</td>';
548  }
549 
550  // Paid
551  print '<td align="right">'.price($obj->amount)."</td>";
552  print "</tr>\n";
553 
554  $i++;
555  }
556  print '<tr class="liste_total"><td colspan="6">'.$langs->trans("Total").'</td>';
557  print '<td align="right">'.price($total)."</td>";
558  print "</tr>";
559 
560  print "</table>";
561  $db->free($result);
562 
563  print "<br>";
564  }
565  else
566  {
567  dol_print_error($db);
568  }
569  }
570 }
571 
572 print '</form>';
573 
574 
575 llxFooter();
576 
577 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
Class to manage salary payments.
img_previous($titlealt= 'default', $moreatt='')
Show previous logo.
img_next($titlealt= 'default', $moreatt='')
Show next logo.
Class to manage payments of social contributions.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:445
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage bank accounts.
Put here description of your class.
Definition: tva.class.php:33
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
llxHeader()
Header empty.
Definition: index.php:37
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
getEntity($element, $shared=1, $forceentity=null)
Get list of entity id to use.
print_fiche_titre($title, $mesg='', $picto='title_generic.png', $pictoisfullpath=0, $id='')
Show a title with picto.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:459
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.