dolibarr  9.0.0
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@inodbox.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 // Load translation files required by the page
38 $langs->loadLangs(array('compta', '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','int')?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";
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 
170  while ($i < min($num, $limit))
171  {
172  $obj = $db->fetch_object($resql);
173  print '<tr class="oddeven">';
174  // Date
175  $date=$obj->periode;
176  if (empty($date)) $date=$obj->date_ech;
177  print '<td>'.dol_print_date($date,'day').'</td>';
178  // Label
179  print '<td>';
180  $socialcontrib->id=$obj->rowid;
181  $socialcontrib->ref=$obj->libelle;
182  $socialcontrib->lib=$obj->libelle;
183  print $socialcontrib->getNomUrl(1,'20');
184  print '</td>';
185  // Type
186  print '<td><a href="../sociales/index.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
187  // Expected to pay
188  print '<td align="right">'.price($obj->total).'</td>';
189  // Ref payment
190  $payment_sc_static->id=$obj->pid;
191  $payment_sc_static->ref=$obj->pid;
192  print '<td>'.$payment_sc_static->getNomUrl(1)."</td>\n";
193  // Date payment
194  print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day').'</td>';
195  // Type payment
196  print '<td>';
197  if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
198  print $obj->num_payment.'</td>';
199  // Account
200  if (! empty($conf->banque->enabled))
201  {
202  print '<td>';
203  if ($obj->fk_bank > 0)
204  {
205  //$accountstatic->fetch($obj->fk_bank);
206  $accountstatic->id=$obj->bid;
207  $accountstatic->ref=$obj->bref;
208  $accountstatic->number=$obj->bnumber;
209  $accountstatic->accountancy_number=$obj->account_number;
210  $accountstatic->accountancy_journal=$obj->accountancy_journal;
211  $accountstatic->label=$obj->blabel;
212  print $accountstatic->getNomUrl(1);
213  }
214  else print '&nbsp;';
215  print '</td>';
216  }
217  // Paid
218  print '<td align="right">';
219  if ($obj->totalpaye) print price($obj->totalpaye);
220  print '</td>';
221  print '</tr>';
222 
223  $total = $total + $obj->total;
224  $totalnb = $totalnb + $obj->nb;
225  $totalpaye = $totalpaye + $obj->totalpaye;
226  $i++;
227  }
228  print '<tr class="liste_total"><td colspan="3" class="liste_total">'.$langs->trans("Total").'</td>';
229  print '<td align="right" class="liste_total"></td>'; // A total here has no sense
230  print '<td align="center" class="liste_total">&nbsp;</td>';
231  print '<td align="center" class="liste_total">&nbsp;</td>';
232  print '<td align="center" class="liste_total">&nbsp;</td>';
233  if (! empty($conf->banque->enabled)) print '<td></td>';
234  print '<td align="right" class="liste_total">'.price($totalpaye)."</td>";
235  print "</tr>";
236  }
237  else
238  {
239  dol_print_error($db);
240  }
241  print '</table>';
242 }
243 
244 // VAT
245 if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
246 {
247  if (! $mode || $mode != 'sconly')
248  {
249  print "<br>";
250 
251  $tva = new Tva($db);
252 
253  print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
254 
255  $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,";
256  $sql.= " pct.code as payment_code,";
257  $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
258  $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv";
259  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid";
260  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
261  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id";
262  $sql.= " WHERE pv.entity IN (".getEntity("tax").")";
263  if ($year > 0)
264  {
265  // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
266  // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
267  $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
268  }
269  if (preg_match('/^pv\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
270 
271  $result = $db->query($sql);
272  if ($result)
273  {
274  $num = $db->num_rows($result);
275  $i = 0;
276  $total = 0 ;
277  print '<table class="noborder" width="100%">';
278  print '<tr class="liste_titre">';
279  print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="140px"',$sortfield,$sortorder);
280  print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder);
281  print_liste_field_titre("ExpectedToPay",$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
282  print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder);
283  print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"pv.datev","",$param,'align="center"',$sortfield,$sortorder);
284  print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder);
285  if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
286  print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
287  print "</tr>\n";
288  $var=1;
289  while ($i < $num)
290  {
291  $obj = $db->fetch_object($result);
292 
293  $total = $total + $obj->amount;
294 
295 
296  print '<tr class="oddeven">';
297  print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
298 
299  print "<td>".$obj->label."</td>\n";
300 
301  print '<td align="right">'.price($obj->amount)."</td>";
302 
303  // Ref payment
304  $tva_static->id=$obj->rowid;
305  $tva_static->ref=$obj->rowid;
306  print '<td align="left">'.$tva_static->getNomUrl(1)."</td>\n";
307 
308  // Date
309  print '<td align="center">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
310 
311  // Type payment
312  print '<td>';
313  if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
314  print $obj->num_payment.'</td>';
315 
316  // Account
317  if (! empty($conf->banque->enabled))
318  {
319  print '<td>';
320  if ($obj->fk_bank > 0)
321  {
322  //$accountstatic->fetch($obj->fk_bank);
323  $accountstatic->id=$obj->bid;
324  $accountstatic->ref=$obj->bref;
325  $accountstatic->number=$obj->bnumber;
326  $accountstatic->accountancy_number=$obj->account_number;
327  $accountstatic->accountancy_journal=$obj->accountancy_journal;
328  $accountstatic->label=$obj->blabel;
329  print $accountstatic->getNomUrl(1);
330  }
331  else print '&nbsp;';
332  print '</td>';
333  }
334 
335  // Paid
336  print '<td align="right">'.price($obj->amount)."</td>";
337  print "</tr>\n";
338 
339  $i++;
340  }
341  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
342  print '<td align="right">'.price($total).'</td>';
343  print '<td>&nbsp;</td>';
344  print '<td>&nbsp;</td>';
345  print '<td>&nbsp;</td>';
346  print '<td>&nbsp;</td>';
347  print '<td align="right">'.price($total)."</td>";
348  print "</tr>";
349 
350  print "</table>";
351  $db->free($result);
352  }
353  else
354  {
355  dol_print_error($db);
356  }
357  }
358 }
359 
360 // Localtax
361 if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
362 {
363  $j=1;
364  $numlt=3;
365 }
366 elseif($mysoc->localtax1_assuj=="1")
367 {
368  $j=1;
369  $numlt=2;
370 }
371 elseif($mysoc->localtax2_assuj=="1")
372 {
373  $j=2;
374  $numlt=3;
375 }
376 else
377 {
378  $j=0;
379  $numlt=0;
380 }
381 
382 while($j<$numlt)
383 {
384  if (! $mode || $mode != 'sconly')
385  {
386  print "<br>";
387 
388  $tva = new Tva($db);
389 
390  print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"),$mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
391 
392 
393  $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
394  $sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv";
395  $sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ;
396  if ($year > 0)
397  {
398  // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
399  // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
400  $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
401  }
402  if (preg_match('/^pv/',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
403 
404  $result = $db->query($sql);
405  if ($result)
406  {
407  $num = $db->num_rows($result);
408  $i = 0;
409  $total = 0 ;
410  print '<table class="noborder" width="100%">';
411  print '<tr class="liste_titre">';
412  print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder);
413  print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder);
414  print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder);
415  print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"pv.datep","",$param,'align="center"',$sortfield,$sortorder);
416  print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
417  print "</tr>\n";
418 
419  while ($i < $num)
420  {
421  $obj = $db->fetch_object($result);
422 
423  $total = $total + $obj->amount;
424 
425  print '<tr class="oddeven">';
426  print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
427 
428  print "<td>".$obj->label."</td>\n";
429 
430  // Ref payment
431  $tva_static->id=$obj->rowid;
432  $tva_static->ref=$obj->rowid;
433  print '<td align="left">'.$tva_static->getNomUrl(1)."</td>\n";
434 
435  print '<td align="center">'.dol_print_date($db->jdate($obj->dp),'day')."</td>\n";
436  print '<td align="right">'.price($obj->amount)."</td>";
437  print "</tr>\n";
438 
439  $i++;
440  }
441  print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").'</td>';
442  print '<td align="right">'.price($total)."</td>";
443  print "</tr>";
444 
445  print "</table>";
446  $db->free($result);
447  }
448  else
449  {
450  dol_print_error($db);
451  }
452  }
453  $j++;
454 }
455 
456 
457 // Payment Salary
458 if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
459 {
460  if (! $mode || $mode != 'sconly')
461  {
462  $sal = new PaymentSalary($db);
463 
464  print "<br>";
465 
466  print_fiche_titre( $langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
467 
468  $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,";
469  $sql.= " pct.code as payment_code,";
470  $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
471  $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
472  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
473  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
474  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id";
475  $sql.= " , ".MAIN_DB_PREFIX."user as u";
476  $sql.= " WHERE s.entity IN (".getEntity('user').")";
477  $sql.= " AND u.rowid = s.fk_user";
478  if ($year > 0)
479  {
480  $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
481  $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."')";
482  }
483  if (preg_match('/^s\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
484 
485  $result = $db->query($sql);
486  if ($result)
487  {
488  $num = $db->num_rows($result);
489  $i = 0;
490  $total = 0 ;
491  print '<table class="noborder" width="100%">';
492  print '<tr class="liste_titre">';
493  print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"s.dateep","",$param,'width="140px"',$sortfield,$sortorder);
494  print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder);
495  print_liste_field_titre("RefPayment",$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder);
496  print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder);
497  print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder);
498  if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
499  print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
500  print "</tr>\n";
501 
502  while ($i < $num)
503  {
504  $obj = $db->fetch_object($result);
505 
506  $total = $total + $obj->amount;
507 
508 
509  print '<tr class="oddeven">';
510 
511  print '<td align="left">'.dol_print_date($db->jdate($obj->dateep),'day').'</td>'."\n";
512 
513  print "<td>".$obj->label."</td>\n";
514 
515  // Ref payment
516  $sal_static->id=$obj->rowid;
517  $sal_static->ref=$obj->rowid;
518  print '<td align="left">'.$sal_static->getNomUrl(1)."</td>\n";
519 
520  // Date
521  print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day')."</td>\n";
522 
523  // Type payment
524  print '<td>';
525  if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
526  print $obj->num_payment.'</td>';
527 
528  // Account
529  if (! empty($conf->banque->enabled))
530  {
531  print '<td>';
532  if ($obj->fk_bank > 0)
533  {
534  //$accountstatic->fetch($obj->fk_bank);
535  $accountstatic->id=$obj->bid;
536  $accountstatic->ref=$obj->bref;
537  $accountstatic->number=$obj->bnumber;
538  $accountstatic->accountancy_number=$obj->account_number;
539  $accountstatic->accountancy_journal=$obj->accountancy_journal;
540  $accountstatic->label=$obj->blabel;
541  print $accountstatic->getNomUrl(1);
542  }
543  else print '&nbsp;';
544  print '</td>';
545  }
546 
547  // Paid
548  print '<td align="right">'.price($obj->amount)."</td>";
549  print "</tr>\n";
550 
551  $i++;
552  }
553  print '<tr class="liste_total"><td colspan="6">'.$langs->trans("Total").'</td>';
554  print '<td align="right">'.price($total)."</td>";
555  print "</tr>";
556 
557  print "</table>";
558  $db->free($result);
559 
560  print "<br>";
561  }
562  else
563  {
564  dol_print_error($db);
565  }
566  }
567 }
568 
569 print '</form>';
570 
571 // End of page
572 llxFooter();
573 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:1053
Class to manage salary payments.
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:453
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
img_next($titlealt='default', $moreatt='')
Show next logo.
Class to manage bank accounts.
Put here description of your class.
Definition: tva.class.php:35
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:36
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:467
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
Classe permettant la gestion des paiements des charges La tva collectee n&#39;est calculee que sur les fa...