dolibarr  9.0.0
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015-2016 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
7  * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8  * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
34 if (! empty($conf->commande->enabled))
35  require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
36 if (! empty($conf->commande->enabled))
37  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
38 if (! empty($conf->tax->enabled))
39  require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
40 
41 // L'espace compta/treso doit toujours etre actif car c'est un espace partage
42 // par de nombreux modules (banque, facture, commande a facturer, etc...) independamment
43 // de l'utilisation de la compta ou non. C'est au sein de cet espace que chaque sous fonction
44 // est protegee par le droit qui va bien du module concerne.
45 //if (!$user->rights->compta->general->lire)
46 // accessforbidden();
47 
48 // Load translation files required by the page
49 $langs->loadLangs(array('compta', 'bills'));
50 if (! empty($conf->commande->enabled))
51  $langs->load("orders");
52 
53 $action=GETPOST('action', 'alpha');
54 $bid=GETPOST('bid', 'int');
55 
56 // Security check
57 $socid='';
58 if ($user->societe_id > 0)
59 {
60  $action = '';
61  $socid = $user->societe_id;
62 }
63 
64 $max=3;
65 
66 $hookmanager->initHooks(array('invoiceindex'));
67 
68 /*
69  * Actions
70  */
71 
72 
73 /*
74  * View
75  */
76 
77 $now=dol_now();
78 
79 $facturestatic=new Facture($db);
80 $facturesupplierstatic=new FactureFournisseur($db);
81 
82 $form = new Form($db);
83 $formfile = new FormFile($db);
84 $thirdpartystatic = new Societe($db);
85 
86 llxHeader("",$langs->trans("AccountancyTreasuryArea"));
87 
88 print load_fiche_titre($langs->trans("AccountancyTreasuryArea"),'','title_accountancy.png');
89 
90 
91 print '<div class="fichecenter"><div class="fichethirdleft">';
92 
93 
94 if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
95 {
96  // Search customer invoices
97  if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
98  {
99  $listofsearchfields['search_invoice']=array('text'=>'CustomerInvoice');
100  }
101  // Search supplier invoices
102  if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
103  {
104  $listofsearchfields['search_supplier_invoice']=array('text'=>'SupplierInvoice');
105  }
106  if (! empty($conf->don->enabled) && $user->rights->don->lire)
107  {
108  $langs->load("donations");
109  $listofsearchfields['search_donation']=array('text'=>'Donation');
110  }
111 
112  if (count($listofsearchfields))
113  {
114  print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
115  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
116  print '<table class="noborder nohover centpercent">';
117  $i=0;
118  foreach($listofsearchfields as $key => $value)
119  {
120  if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
121  print '<tr '.$bc[false].'>';
122  print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'"></td>';
123  if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
124  print '</tr>';
125  $i++;
126  }
127  print '</table>';
128  print '</form>';
129  print '<br>';
130  }
131 }
132 
133 
137 if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
138 {
139  $sql = "SELECT f.facnumber";
140  $sql.= ", f.rowid, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client";
141  $sql.= ", f.type";
142  $sql.= ", s.nom as name";
143  $sql.= ", s.rowid as socid, s.email";
144  $sql.= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
145  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
146  $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
147  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
148  $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
149  $sql.= " AND f.entity = ".$conf->entity;
150  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
151 
152  if ($socid)
153  {
154  $sql .= " AND f.fk_soc = $socid";
155  }
156  // Add where from hooks
157  $parameters=array();
158  $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerDraft',$parameters);
159  $sql.=$hookmanager->resPrint;
160 
161  $resql = $db->query($sql);
162 
163  if ( $resql )
164  {
165  $num = $db->num_rows($resql);
166 
167  print '<table class="noborder" width="100%">';
168  print '<tr class="liste_titre">';
169  print '<th colspan="3">'.$langs->trans("CustomersDraftInvoices").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
170  if ($num)
171  {
172  $companystatic=new Societe($db);
173 
174  $i = 0;
175  $tot_ttc = 0;
176  while ($i < $num)
177  {
178  $obj = $db->fetch_object($resql);
179 
180  $facturestatic->ref=$obj->facnumber;
181  $facturestatic->id=$obj->rowid;
182  $facturestatic->total_ht=$obj->total_ht;
183  $facturestatic->total_tva=$obj->total_tva;
184  $facturestatic->total_ttc=$obj->total_ttc;
185  $facturestatic->ref_client=$obj->ref_client;
186  $facturestatic->type=$obj->type;
187 
188  $companystatic->id=$obj->socid;
189  $companystatic->name=$obj->name;
190  $companystatic->email=$obj->email;
191  $companystatic->client = 1;
192  $companystatic->code_client = $obj->code_client;
193  $companystatic->code_fournisseur = $obj->code_fournisseur;
194  $companystatic->code_compta = $obj->code_compta;
195  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
196 
197  print '<tr class="oddeven"><td class="nowrap">';
198  print $facturestatic->getNomUrl(1,'');
199  print '</td>';
200  print '<td class="nowrap">';
201  print $companystatic->getNomUrl(1,'customer',16);
202  print '</td>';
203  print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td>';
204  print '</tr>';
205  $tot_ttc+=$obj->total_ttc;
206  $i++;
207  }
208 
209  print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>';
210  print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
211  print '</tr>';
212  }
213  else
214  {
215  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>';
216  }
217  print "</table><br>";
218  $db->free($resql);
219  }
220  else
221  {
222  dol_print_error($db);
223  }
224 }
225 
229 if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
230 {
231  $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier";
232  $sql.= ", s.nom as name";
233  $sql.= ", s.rowid as socid, s.email";
234  $sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
235  $sql.= ", cc.rowid as country_id, cc.code as country_code";
236  $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
237  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
238  $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
239  $sql.= " AND f.entity = ".$conf->entity;
240  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
241  if ($socid) $sql.= " AND f.fk_soc = ".$socid;
242  // Add where from hooks
243  $parameters=array();
244  $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierDraft',$parameters);
245  $sql.=$hookmanager->resPrint;
246  $resql = $db->query($sql);
247 
248  if ( $resql )
249  {
250  $num = $db->num_rows($resql);
251 
252  print '<table class="noborder" width="100%">';
253  print '<tr class="liste_titre">';
254  print '<th colspan="3">'.$langs->trans("SuppliersDraftInvoices").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
255  if ($num)
256  {
257  $companystatic=new Societe($db);
258 
259  $i = 0;
260  $tot_ttc = 0;
261  while ($i < $num)
262  {
263  $obj = $db->fetch_object($resql);
264 
265  $facturesupplierstatic->ref=$obj->ref;
266  $facturesupplierstatic->id=$obj->rowid;
267  $facturesupplierstatic->total_ht=$obj->total_ht;
268  $facturesupplierstatic->total_tva=$obj->total_tva;
269  $facturesupplierstatic->total_ttc=$obj->total_ttc;
270  $facturesupplierstatic->ref_supplier=$obj->ref_supplier;
271  $facturesupplierstatic->type=$obj->type;
272 
273  $companystatic->id=$obj->socid;
274  $companystatic->name=$obj->name;
275  $companystatic->email=$obj->email;
276  $companystatic->country_id=$obj->country_id;
277  $companystatic->country_code=$obj->country_code;
278  $companystatic->fournisseur = 1;
279  $companystatic->code_client = $obj->code_client;
280  $companystatic->code_fournisseur = $obj->code_fournisseur;
281  $companystatic->code_compta = $obj->code_compta;
282  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
283 
284  print '<tr class="oddeven"><td class="nowrap">';
285  print $facturesupplierstatic->getNomUrl(1,'',16);
286  print '</td>';
287  print '<td>';
288  print $companystatic->getNomUrl(1,'supplier',16);
289  print '</td>';
290  print '<td align="right">'.price($obj->total_ttc).'</td>';
291  print '</tr>';
292  $tot_ttc+=$obj->total_ttc;
293  $i++;
294  }
295 
296  print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>';
297  print '<td colspan="2" align="right">'.price($tot_ttc).'</td>';
298  print '</tr>';
299  }
300  else
301  {
302  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>';
303  }
304  print "</table><br>";
305  $db->free($resql);
306  }
307  else
308  {
309  dol_print_error($db);
310  }
311 }
312 
313 
314 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
315 
316 
317 // Latest modified customer invoices
318 if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
319 {
320  $langs->load("boxes");
321  $facstatic=new Facture($db);
322 
323  $sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms";
324  $sql.= ", f.date_lim_reglement as datelimite";
325  $sql.= ", s.nom as name";
326  $sql.= ", s.rowid as socid";
327  $sql.= ", s.code_client, s.code_compta, s.email";
328  $sql.= ", cc.rowid as country_id, cc.code as country_code";
329  $sql.= ", sum(pf.amount) as am";
330  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f";
331  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
332  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
333  $sql.= " WHERE s.rowid = f.fk_soc";
334  $sql.= " AND f.entity = ".$conf->entity;
335  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
336  if ($socid) $sql.= " AND f.fk_soc = ".$socid;
337  // Add where from hooks
338  $parameters=array();
339  $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerLastModified',$parameters);
340  $sql.=$hookmanager->resPrint;
341 
342  $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
343  $sql.= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,";
344  $sql.= " cc.rowid, cc.code";
345  $sql.= " ORDER BY f.tms DESC ";
346  $sql.= $db->plimit($max, 0);
347 
348  $resql = $db->query($sql);
349  if ($resql)
350  {
351  $num = $db->num_rows($resql);
352  $i = 0;
353 
354  print '<table class="noborder" width="100%">';
355  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BoxTitleLastCustomerBills",$max).'</th>';
356  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th align="right">'.$langs->trans("AmountHT").'</th>';
357  print '<th align="right">'.$langs->trans("AmountTTC").'</th>';
358  print '<th align="right">'.$langs->trans("DateModificationShort").'</th>';
359  print '<th width="16">&nbsp;</th>';
360  print '</tr>';
361  if ($num)
362  {
363  $total_ttc = $totalam = $total = 0;
364  while ($i < $num && $i < $conf->liste_limit)
365  {
366  $obj = $db->fetch_object($resql);
367 
368  $facturestatic->ref=$obj->facnumber;
369  $facturestatic->id=$obj->rowid;
370  $facturestatic->total_ht=$obj->total_ht;
371  $facturestatic->total_tva=$obj->total_tva;
372  $facturestatic->total_ttc=$obj->total_ttc;
373  $facturestatic->statut = $obj->fk_statut;
374  $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
375  $facturestatic->type=$obj->type;
376 
377  $thirdpartystatic->id=$obj->socid;
378  $thirdpartystatic->name=$obj->name;
379  $thirdpartystatic->email=$obj->email;
380  $thirdpartystatic->country_id=$obj->country_id;
381  $thirdpartystatic->country_code=$obj->country_code;
382  $thirdpartystatic->email=$obj->email;
383  $thirdpartystatic->client=1;
384  $thirdpartystatic->code_client = $obj->code_client;
385  //$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
386  $thirdpartystatic->code_compta = $obj->code_compta;
387  //$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
388 
389  print '<tr class="oddeven">';
390  print '<td class="nowrap">';
391 
392  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
393  print '<td width="110" class="nobordernopadding nowrap">';
394  print $facturestatic->getNomUrl(1,'');
395  print '</td>';
396  print '<td width="20" class="nobordernopadding nowrap">';
397  if ($facturestatic->hasDelay()) {
398  print img_warning($langs->trans("Late"));
399  }
400  print '</td>';
401  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
402  $filename=dol_sanitizeFileName($obj->facnumber);
403  $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber);
404  $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid;
405  print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
406  print '</td></tr></table>';
407 
408  print '</td>';
409  print '<td align="left">';
410  print $thirdpartystatic->getNomUrl(1,'customer',44);
411  print '</td>';
412  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
413  print '<td align="right">'.price($obj->total_ttc).'</td>';
414  print '<td align="right">'.dol_print_date($db->jdate($obj->tms),'day').'</td>';
415  print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).'</td>';
416  print '</tr>';
417 
418  $total_ttc += $obj->total_ttc;
419  $total += $obj->total_ht;
420  $totalam += $obj->am;
421 
422  $i++;
423  }
424  }
425  else
426  {
427  $colspan=5;
428  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
429  print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>';
430  }
431  print '</table><br>';
432  $db->free($resql);
433  }
434  else
435  {
436  dol_print_error($db);
437  }
438 }
439 
440 
441 
442 // Last modified supplier invoices
443 if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
444 {
445  $langs->load("boxes");
446  $facstatic=new FactureFournisseur($db);
447 
448  $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye";
449  $sql.= ", s.nom as name";
450  $sql.= ", s.rowid as socid";
451  $sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
452  $sql.= ", SUM(pf.amount) as am";
453  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
454  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
455  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
456  $sql.= " WHERE s.rowid = ff.fk_soc";
457  $sql.= " AND ff.entity = ".$conf->entity;
458  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
459  if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
460  // Add where from hooks
461  $parameters=array();
462  $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierLastModified',$parameters);
463  $sql.=$hookmanager->resPrint;
464 
465  $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,";
466  $sql.= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur";
467  $sql.= " ORDER BY ff.tms DESC ";
468  $sql.= $db->plimit($max, 0);
469 
470  $resql=$db->query($sql);
471  if ($resql)
472  {
473  $num = $db->num_rows($resql);
474 
475  print '<table class="noborder" width="100%">';
476  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BoxTitleLastSupplierBills",$max).'</th>';
477  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th align="right">'.$langs->trans("AmountHT").'</th>';
478  print '<th align="right">'.$langs->trans("AmountTTC").'</th>';
479  print '<th align="right">'.$langs->trans("DateModificationShort").'</th>';
480  print '<th width="16">&nbsp;</th>';
481  print "</tr>\n";
482  if ($num)
483  {
484  $i = 0;
485  $total = $total_ttc = $totalam = 0;
486  while ($i < $num)
487  {
488  $obj = $db->fetch_object($resql);
489 
490  $facstatic->ref=$obj->ref;
491  $facstatic->id = $obj->rowid;
492  $facstatic->total_ht = $obj->total_ht;
493  $facstatic->total_tva = $obj->total_tva;
494  $facstatic->total_ttc = $obj->total_ttc;
495 
496  $thirdpartystatic->id=$obj->socid;
497  $thirdpartystatic->name=$obj->name;
498  $thirdpartystatic->fournisseur=1;
499  //$thirdpartystatic->code_client = $obj->code_client;
500  $thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
501  //$thirdpartystatic->code_compta = $obj->code_compta;
502  $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
503 
504  print '<tr class="oddeven"><td>';
505  print $facstatic->getNomUrl(1,'');
506  print '</td>';
507  print '<td>';
508  print $thirdpartystatic->getNomUrl(1,'supplier',44);
509  print '</td>';
510  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
511  print '<td align="right">'.price($obj->total_ttc).'</td>';
512  print '<td align="right">'.dol_print_date($db->jdate($obj->tms),'day').'</td>';
513  print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3).'</td>';
514  print '</tr>';
515  $total += $obj->total_ht;
516  $total_ttc += $obj->total_ttc;
517  $totalam += $obj->am;
518  $i++;
519  }
520  }
521  else
522  {
523  $colspan=5;
524  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
525  print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>';
526  }
527  print '</table><br>';
528  }
529  else
530  {
531  dol_print_error($db);
532  }
533 }
534 
535 
536 
537 // Last donations
538 if (! empty($conf->don->enabled) && $user->rights->societe->lire)
539 {
540  include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
541 
542  $langs->load("boxes");
543  $donationstatic=new Don($db);
544 
545  $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut";
546  $sql.= " FROM ".MAIN_DB_PREFIX."don as d";
547  $sql.= " WHERE d.entity IN (".getEntity('donation').")";
548  // Add where from hooks
549  $parameters=array();
550  $reshook=$hookmanager->executeHooks('printFieldListWhereLastDonations',$parameters);
551  $sql.=$hookmanager->resPrint;
552 
553  $sql.= $db->order("d.tms","DESC");
554  $sql.= $db->plimit($max, 0);
555 
556  $result = $db->query($sql);
557  if ($result)
558  {
559  $var=false;
560  $num = $db->num_rows($result);
561 
562  $i = 0;
563 
564  print '<table class="noborder" width="100%">';
565  print '<tr class="liste_titre">';
566  print '<th>'.$langs->trans("BoxTitleLastModifiedDonations",$max).'</th>';
567  print '<th></th>';
568  print '<th align="right">'.$langs->trans("AmountTTC").'</th>';
569  print '<th align="right">'.$langs->trans("DateModificationShort").'</th>';
570  print '<th width="16">&nbsp;</th>';
571  print '</tr>';
572  if ($num)
573  {
574  $total_ttc = $totalam = $total = 0;
575 
576  while ($i < $num && $i < $max)
577  {
578  $objp = $db->fetch_object($result);
579 
580  $donationstatic->id=$objp->rowid;
581  $donationstatic->ref=$objp->rowid;
582  $donationstatic->lastname=$objp->lastname;
583  $donationstatic->firstname=$objp->firstname;
584 
585  $label=$donationstatic->getFullName($langs);
586  if ($objp->societe) $label.=($label?' - ':'').$objp->societe;
587 
588  print '<tr class="oddeven">';
589  print '<td>'.$donationstatic->getNomUrl(1).'</td>';
590  print '<td>'.$label.'</td>';
591  print '<td align="right">'.price($objp->amount).'</td>';
592  print '<td align="right">'.dol_print_date($db->jdate($objp->dm),'day').'</td>';
593  print '<td>'.$donationstatic->LibStatut($objp->fk_statut,3).'</td>';
594  print '</tr>';
595 
596  $i++;
597  }
598  }
599  else
600  {
601  print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
602  }
603  print '</table><br>';
604  }
605  else dol_print_error($db);
606 }
607 
611 if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
612 {
613  if (!$socid)
614  {
615  $chargestatic=new ChargeSociales($db);
616 
617  $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,";
618  $sql.= " cc.libelle,";
619  $sql.= " SUM(pc.amount) as sumpaid";
620  $sql.= " FROM (".MAIN_DB_PREFIX."c_chargesociales as cc, ".MAIN_DB_PREFIX."chargesociales as c)";
621  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = c.rowid";
622  $sql.= " WHERE c.fk_type = cc.id";
623  $sql.= " AND c.entity = ".$conf->entity;
624  $sql.= " AND c.paye = 0";
625  // Add where from hooks
626  $parameters=array();
627  $reshook=$hookmanager->executeHooks('printFieldListWhereSocialContributions',$parameters);
628  $sql.=$hookmanager->resPrint;
629 
630  $sql.= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle";
631 
632  $resql = $db->query($sql);
633  if ( $resql )
634  {
635  $num = $db->num_rows($resql);
636 
637  print '<table class="noborder" width="100%">';
638  print '<tr class="liste_titre">';
639  print '<th>'.$langs->trans("ContributionsToPay").($num?' <a href="'.DOL_URL_ROOT.'/compta/sociales/list.php?status=0"><span class="badge">'.$num.'</span></a>':'').'</th>';
640  print '<th align="center">'.$langs->trans("DateDue").'</th>';
641  print '<th align="right">'.$langs->trans("AmountTTC").'</th>';
642  print '<th align="right">'.$langs->trans("Paid").'</th>';
643  print '<th align="center" width="16">&nbsp;</th>';
644  print '</tr>';
645  if ($num)
646  {
647  $i = 0;
648  $tot_ttc=0;
649  while ($i < $num)
650  {
651  $obj = $db->fetch_object($resql);
652 
653  $chargestatic->id=$obj->rowid;
654  $chargestatic->ref=$obj->libelle;
655  $chargestatic->lib=$obj->libelle;
656  $chargestatic->paye=$obj->paye;
657 
658  print '<tr class="oddeven">';
659  print '<td>'.$chargestatic->getNomUrl(1).'</td>';
660  print '<td align="center">'.dol_print_date($db->jdate($obj->date_ech),'day').'</td>';
661  print '<td align="right">'.price($obj->amount).'</td>';
662  print '<td align="right">'.price($obj->sumpaid).'</td>';
663  print '<td align="center">'.$chargestatic->getLibStatut(3).'</td>';
664  print '</tr>';
665  $tot_ttc+=$obj->amount;
666  $i++;
667  }
668 
669  print '<tr class="liste_total"><td align="left" colspan="2">'.$langs->trans("Total").'</td>';
670  print '<td align="right">'.price($tot_ttc).'</td>';
671  print '<td align="right"></td>';
672  print '<td align="right">&nbsp;</td>';
673  print '</tr>';
674  }
675  else
676  {
677  print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
678  }
679  print "</table><br>";
680  $db->free($resql);
681  }
682  else
683  {
684  dol_print_error($db);
685  }
686  }
687 }
688 
689 /*
690  * Customers orders to be billed
691  */
692 if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER))
693 {
694  $commandestatic=new Commande($db);
695  $langs->load("orders");
696 
697  $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc";
698  $sql.= ", s.nom as name, s.email";
699  $sql.= ", s.rowid as socid";
700  $sql.= ", s.code_client, s.code_compta";
701  $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,";
702  $sql.= " cc.rowid as country_id, cc.code as country_code";
703  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
704  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
705  $sql.= ", ".MAIN_DB_PREFIX."commande as c";
706  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'";
707  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'";
708  $sql.= " WHERE c.fk_soc = s.rowid";
709  $sql.= " AND c.entity = ".$conf->entity;
710  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
711  if ($socid) $sql.= " AND c.fk_soc = ".$socid;
712  $sql.= " AND c.fk_statut = 3";
713  $sql.= " AND c.facture = 0";
714  // Add where from hooks
715  $parameters=array();
716  $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill',$parameters);
717  $sql.=$hookmanager->resPrint;
718 
719  $sql.= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code";
720 
721  $resql = $db->query($sql);
722  if ( $resql )
723  {
724  $num = $db->num_rows($resql);
725 
726  if ($num)
727  {
728  $i = 0;
729  print '<table class="noborder" width="100%">';
730  print "<tr class=\"liste_titre\">";
731  print '<th colspan="2">'.$langs->trans("OrdersDeliveredToBill").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=3&amp;billed=0"><span class="badge">'.$num.'</span></a></th>';
732  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th align="right">'.$langs->trans("AmountHT").'</th>';
733  print '<th align="right">'.$langs->trans("AmountTTC").'</th>';
734  print '<th align="right">'.$langs->trans("ToBill").'</th>';
735  print '<th align="center" width="16">&nbsp;</th>';
736  print '</tr>';
737 
738  $tot_ht=$tot_ttc=$tot_tobill=0;
739  $societestatic = new Societe($db);
740  while ($i < $num)
741  {
742  $obj = $db->fetch_object($resql);
743 
744  $societestatic->id=$obj->socid;
745  $societestatic->name=$obj->name;
746  $societestatic->email=$obj->email;
747  $societestatic->country_id=$obj->country_id;
748  $societestatic->country_code=$obj->country_code;
749  $societestatic->client=1;
750  $societestatic->code_client = $obj->code_client;
751  //$societestatic->code_fournisseur = $obj->code_fournisseur;
752  $societestatic->code_compta = $obj->code_compta;
753  //$societestatic->code_fournisseur = $obj->code_fournisseur;
754 
755  $commandestatic->id=$obj->rowid;
756  $commandestatic->ref=$obj->ref;
757 
758  print '<tr class="oddeven">';
759  print '<td class="nowrap">';
760 
761  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
762  print '<td width="110" class="nobordernopadding nowrap">';
763  print $commandestatic->getNomUrl(1);
764  print '</td>';
765  print '<td width="20" class="nobordernopadding nowrap">';
766  print '&nbsp;';
767  print '</td>';
768  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
769  $filename=dol_sanitizeFileName($obj->ref);
770  $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
771  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
772  print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
773  print '</td></tr></table>';
774 
775  print '</td>';
776 
777  print '<td align="left">';
778  print $societestatic->getNomUrl(1,'customer',44);
779  print '</td>';
780  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
781  print '<td align="right">'.price($obj->total_ttc).'</td>';
782  print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td>';
783  print '<td>'.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,3).'</td>';
784  print '</tr>';
785  $tot_ht += $obj->total_ht;
786  $tot_ttc += $obj->total_ttc;
787  //print "x".$tot_ttc."z".$obj->tot_fttc;
788  $tot_tobill += ($obj->total_ttc-$obj->tot_fttc);
789  $i++;
790  }
791 
792  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' &nbsp; <font style="font-weight: normal">('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</font> </td>';
793  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($tot_ht).'</td>';
794  print '<td align="right">'.price($tot_ttc).'</td>';
795  print '<td align="right">'.price($tot_tobill).'</td>';
796  print '<td>&nbsp;</td>';
797  print '</tr>';
798  print '</table><br>';
799  }
800  $db->free($resql);
801  }
802  else
803  {
804  dol_print_error($db);
805  }
806 }
807 
808 /*
809  * Unpaid customers invoices
810  */
811 if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
812 {
813  $facstatic=new Facture($db);
814 
815  $sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms";
816  $sql.= ", f.date_lim_reglement as datelimite";
817  $sql.= ", s.nom as name";
818  $sql.= ", s.rowid as socid, s.email";
819  $sql.= ", s.code_client, s.code_compta";
820  $sql.= ", cc.rowid as country_id, cc.code as country_code";
821  $sql.= ", sum(pf.amount) as am";
822  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f";
823  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
824  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
825  $sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
826  $sql.= " AND f.entity = ".$conf->entity;
827  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
828  if ($socid) $sql.= " AND f.fk_soc = ".$socid;
829  // Add where from hooks
830  $parameters=array();
831  $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerUnpaid',$parameters);
832  $sql.=$hookmanager->resPrint;
833 
834  $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
835  $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
836  $sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
837 
838  $resql = $db->query($sql);
839  if ($resql)
840  {
841  $num = $db->num_rows($resql);
842  $i = 0;
843 
844  print '<div class="div-table-responsive-no-min">';
845  print '<table class="noborder" width="100%">';
846  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BillsCustomersUnpaid",$num).' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th>';
847  print '<th align="right">'.$langs->trans("DateDue").'</th>';
848  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th align="right">'.$langs->trans("AmountHT").'</th>';
849  print '<th align="right">'.$langs->trans("AmountTTC").'</th>';
850  print '<th align="right">'.$langs->trans("Received").'</th>';
851  print '<th width="16">&nbsp;</th>';
852  print '</tr>';
853  if ($num)
854  {
855  $societestatic = new Societe($db);
856  $total_ttc = $totalam = $total = 0;
857  while ($i < $num && $i < $conf->liste_limit)
858  {
859  $obj = $db->fetch_object($resql);
860 
861  $facturestatic->ref=$obj->facnumber;
862  $facturestatic->id=$obj->rowid;
863  $facturestatic->total_ht=$obj->total_ht;
864  $facturestatic->total_tva=$obj->total_tva;
865  $facturestatic->total_ttc=$obj->total_ttc;
866  $facturestatic->type=$obj->type;
867  $facturestatic->statut = $obj->fk_statut;
868  $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
869 
870  $societestatic->id=$obj->socid;
871  $societestatic->name=$obj->name;
872  $societestatic->email=$obj->email;
873  $societestatic->country_id=$obj->country_id;
874  $societestatic->country_code=$obj->country_code;
875  $societestatic->client=1;
876  $societestatic->code_client = $obj->code_client;
877  $societestatic->code_fournisseur = $obj->code_fournisseur;
878  $societestatic->code_compta = $obj->code_compta;
879  $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
880 
881  print '<tr class="oddeven">';
882  print '<td class="nowrap">';
883 
884  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
885  print '<td width="110" class="nobordernopadding nowrap">';
886  print $facturestatic->getNomUrl(1,'');
887  print '</td>';
888  print '<td width="20" class="nobordernopadding nowrap">';
889  if ($facturestatic->hasDelay()) {
890  print img_warning($langs->trans("Late"));
891  }
892  print '</td>';
893  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
894  $filename=dol_sanitizeFileName($obj->facnumber);
895  $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber);
896  $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid;
897  print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
898  print '</td></tr></table>';
899 
900  print '</td>';
901  print '<td align="left">' ;
902  print $societestatic->getNomUrl(1,'customer',44);
903  print '</td>';
904  print '<td align="right">'.dol_print_date($db->jdate($obj->datelimite),'day').'</td>';
905  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
906  print '<td align="right">'.price($obj->total_ttc).'</td>';
907  print '<td align="right">'.price($obj->am).'</td>';
908  print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3,$obj->am).'</td>';
909  print '</tr>';
910 
911  $total_ttc += $obj->total_ttc;
912  $total += $obj->total_ht;
913  $totalam += $obj->am;
914 
915  $i++;
916  }
917 
918  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' &nbsp; <font style="font-weight: normal">('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</font> </td>';
919  print '<td>&nbsp;</td>';
920  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($total).'</td>';
921  print '<td align="right">'.price($total_ttc).'</td>';
922  print '<td align="right">'.price($totalam).'</td>';
923  print '<td>&nbsp;</td>';
924  print '</tr>';
925  }
926  else
927  {
928  $colspan=6;
929  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
930  print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>';
931  }
932  print '</table></div><br>';
933  $db->free($resql);
934  }
935  else
936  {
937  dol_print_error($db);
938  }
939 }
940 
941 /*
942  * Unpayed supplier invoices
943  */
944 if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
945 {
946  $facstatic=new FactureFournisseur($db);
947 
948  $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye";
949  $sql.= ", ff.date_lim_reglement";
950  $sql.= ", s.nom as name";
951  $sql.= ", s.rowid as socid, s.email";
952  $sql.= ", s.code_client, s.code_compta";
953  $sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
954  $sql.= ", sum(pf.amount) as am";
955  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
956  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
957  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
958  $sql.= " WHERE s.rowid = ff.fk_soc";
959  $sql.= " AND ff.entity = ".$conf->entity;
960  $sql.= " AND ff.paye = 0";
961  $sql.= " AND ff.fk_statut = 1";
962  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
963  if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
964  // Add where from hooks
965  $parameters=array();
966  $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierUnpaid',$parameters);
967  $sql.=$hookmanager->resPrint;
968 
969  $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,";
970  $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
971  $sql.= " ORDER BY ff.date_lim_reglement ASC";
972 
973  $resql=$db->query($sql);
974  if ($resql)
975  {
976  $num = $db->num_rows($resql);
977 
978  print '<div class="div-table-responsive-no-min">';
979  print '<table class="noborder" width="100%">';
980  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("BillsSuppliersUnpaid",$num).' <a href="'.DOL_URL_ROOT.'/fourn/facture/impayees.php"><span class="badge">'.$num.'</span></a></th>';
981  print '<th align="right">'.$langs->trans("DateDue").'</th>';
982  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<th align="right">'.$langs->trans("AmountHT").'</th>';
983  print '<th align="right">'.$langs->trans("AmountTTC").'</th>';
984  print '<th align="right">'.$langs->trans("Paid").'</th>';
985  print '<th width="16">&nbsp;</th>';
986  print "</tr>\n";
987  $societestatic = new Societe($db);
988  if ($num)
989  {
990  $i = 0;
991  $total = $total_ttc = $totalam = 0;
992  while ($i < $num)
993  {
994  $obj = $db->fetch_object($resql);
995 
996  $facstatic->ref=$obj->ref;
997  $facstatic->id = $obj->rowid;
998  $facstatic->total_ht = $obj->total_ht;
999  $facstatic->total_tva = $obj->total_tva;
1000  $facstatic->total_ttc = $obj->total_ttc;
1001 
1002  $societestatic->id=$obj->socid;
1003  $societestatic->name=$obj->name;
1004  $societestatic->email=$obj->email;
1005  $societestatic->client=0;
1006  $societestatic->fournisseur=1;
1007  $societestatic->code_client = $obj->code_client;
1008  $societestatic->code_fournisseur = $obj->code_fournisseur;
1009  $societestatic->code_compta = $obj->code_compta;
1010  $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1011 
1012  print '<tr class="oddeven"><td>';
1013  print $facstatic->getNomUrl(1,'');
1014  print '</td>';
1015  print '<td>'.$societestatic->getNomUrl(1, 'supplier', 44).'</td>';
1016  print '<td align="right">'.dol_print_date($db->jdate($obj->date_lim_reglement),'day').'</td>';
1017  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($obj->total_ht).'</td>';
1018  print '<td align="right">'.price($obj->total_ttc).'</td>';
1019  print '<td align="right">'.price($obj->am).'</td>';
1020  print '<td>'.$facstatic->LibStatut($obj->paye,$obj->fk_statut,3).'</td>';
1021  print '</tr>';
1022  $total += $obj->total_ht;
1023  $total_ttc += $obj->total_ttc;
1024  $totalam += $obj->am;
1025  $i++;
1026  }
1027 
1028  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").' &nbsp; <font style="font-weight: normal">('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</font> </td>';
1029  print '<td>&nbsp;</td>';
1030  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.price($total).'</td>';
1031  print '<td align="right">'.price($total_ttc).'</td>';
1032  print '<td align="right">'.price($totalam).'</td>';
1033  print '<td>&nbsp;</td>';
1034  print '</tr>';
1035  }
1036  else
1037  {
1038  $colspan=6;
1039  if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
1040  print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoInvoice").'</td></tr>';
1041  }
1042  print '</table></div><br>';
1043  }
1044  else
1045  {
1046  dol_print_error($db);
1047  }
1048 }
1049 
1050 
1051 
1052 // TODO Mettre ici recup des actions en rapport avec la compta
1054 if ($resql)
1055 {
1056  print '<table class="noborder" width="100%">';
1057  print '<tr class="liste_titre"><thcolspan="2">'.$langs->trans("TasksToDo").'</th>';
1058  print "</tr>\n";
1059  $i = 0;
1060  while ($i < $db->num_rows($resql))
1061  {
1062  $obj = $db->fetch_object($resql);
1063 
1064 
1065  print '<tr class="oddeven"><td>'.dol_print_date($db->jdate($obj->da),"day").'</td>';
1066  print '<td><a href="action/card.php">'.$obj->libelle.' '.$obj->label.'</a></td></tr>';
1067  $i++;
1068  }
1069  $db->free($resql);
1070  print "</table><br>";
1071 }
1072 
1073 
1074 print '</div></div></div>';
1075 
1076 // End of page
1077 llxFooter();
1078 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
img_warning($titlealt='default', $moreatt='')
Show warning logo.
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
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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 suppliers invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
llxHeader()
Header empty.
Definition: index.php:36
Class to manage customers orders.
dol_now($mode='gmt')
Return date for now.
Class to offer components to list and upload files.
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...
Class to manage donations.
Definition: don.class.php:35
Class to manage invoices.
Classe permettant la gestion des paiements des charges La tva collectee n&#39;est calculee que sur les fa...