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-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
32 if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
33 if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
34 if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
35 if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
36 if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
37 
38 if (! $user->rights->societe->lire) accessforbidden();
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array("commercial", "propal"));
42 
43 $action=GETPOST('action', 'alpha');
44 $bid=GETPOST('bid', 'int');
45 
46 // Securite acces client
47 $socid=GETPOST('socid','int');
48 if (isset($user->societe_id) && $user->societe_id > 0)
49 {
50  $action = '';
51  $socid = $user->societe_id;
52 }
53 
54 $max=5;
55 $now=dol_now();
56 
57 /*
58  * Actions
59  */
60 
61 
62 /*
63  * View
64  */
65 
66 $form = new Form($db);
67 $formfile = new FormFile($db);
68 $companystatic=new Societe($db);
69 if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db);
70 if (! empty($conf->supplier_proposal->enabled)) $supplierproposalstatic=new SupplierProposal($db);
71 if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db);
72 if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db);
73 
74 llxHeader("",$langs->trans("CommercialArea"));
75 
76 print load_fiche_titre($langs->trans("CommercialArea"),'','title_commercial.png');
77 
78 print '<div class="fichecenter"><div class="fichethirdleft">';
79 
80 if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
81 {
82  // Search proposal
83  if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
84  {
85  $listofsearchfields['search_proposal']=array('text'=>'Proposal');
86  }
87  // Search customer order
88  if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
89  {
90  $listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder');
91  }
92  // Search supplier proposal
93  if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
94  {
95  $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort');
96  }
97  // Search supplier order
98  if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
99  {
100  $listofsearchfields['search_supplier_order']=array('text'=>'SupplierOrder');
101  }
102  // Search intervention
103  if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
104  {
105  $listofsearchfields['search_intervention']=array('text'=>'Intervention');
106  }
107  // Search contract
108  if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
109  {
110  $listofsearchfields['search_contract']=array('text'=>'Contract');
111  }
112 
113  if (count($listofsearchfields))
114  {
115  print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
116  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
117  print '<table class="noborder nohover centpercent">';
118  $i=0;
119  foreach($listofsearchfields as $key => $value)
120  {
121  if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
122  print '<tr '.$bc[false].'>';
123  print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
124  if ($i == 0) print '<td class="noborderbottom" rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button "></td>';
125  print '</tr>';
126  $i++;
127  }
128  print '</table>';
129  print '</form>';
130  print '<br>';
131  }
132 }
133 
134 
135 /*
136  * Draft proposals
137  */
138 if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
139 {
140  $langs->load("propal");
141 
142  $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
143  $sql.= ", s.code_client";
144  $sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
145  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
146  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
147  $sql.= " WHERE p.fk_statut = 0";
148  $sql.= " AND p.fk_soc = s.rowid";
149  $sql.= " AND p.entity IN (".getEntity('propal').")";
150  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
151  if ($socid) $sql.= " AND s.rowid = ".$socid;
152 
153  $resql=$db->query($sql);
154  if ($resql)
155  {
156  $total = 0;
157  $num = $db->num_rows($resql);
158 
159  print '<div class="div-table-responsive-no-min">';
160  print '<table class="noborder" width="100%">';
161  print '<tr class="liste_titre">';
162  print '<th colspan="3">'.$langs->trans("ProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
163 
164  if ($num > 0)
165  {
166  $i = 0;
167  while ($i < $num)
168  {
169  $obj = $db->fetch_object($resql);
170 
171  print '<tr class="oddeven"><td class="nowrap">';
172  $propalstatic->id=$obj->rowid;
173  $propalstatic->ref=$obj->ref;
174  $propalstatic->ref_client=$obj->ref_client;
175  $propalstatic->total_ht = $obj->total_ht;
176  $propalstatic->total_tva = $obj->total_tva;
177  $propalstatic->total_ttc = $obj->total_ttc;
178  print $propalstatic->getNomUrl(1);
179  print '</td>';
180  print '<td class="nowrap">';
181  $companystatic->id=$obj->socid;
182  $companystatic->name=$obj->name;
183  $companystatic->client=$obj->client;
184  $companystatic->code_client = $obj->code_client;
185  $companystatic->code_fournisseur = $obj->code_fournisseur;
186  $companystatic->canvas=$obj->canvas;
187  print $companystatic->getNomUrl(1,'customer',16);
188  print '</td>';
189  print '<td align="right" class="nowrap">'.price($obj->total_ht).'</td></tr>';
190  $i++;
191  $total += $obj->total_ht;
192  }
193  if ($total>0)
194  {
195 
196  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
197  }
198  }
199  else
200  {
201 
202  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoProposal").'</td></tr>';
203  }
204  print "</table></div><br>";
205 
206  $db->free($resql);
207  }
208  else
209  {
210  dol_print_error($db);
211  }
212 }
213 
214 
215 
216 /*
217  * Draft supplier proposals
218  */
219 if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
220 {
221  $langs->load("supplier_proposal");
222 
223  $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
224  $sql.= ", s.code_client";
225  $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p";
226  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
227  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
228  $sql.= " WHERE p.fk_statut = 0";
229  $sql.= " AND p.fk_soc = s.rowid";
230  $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")";
231  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
232  if ($socid) $sql.= " AND s.rowid = ".$socid;
233 
234  $resql=$db->query($sql);
235  if ($resql)
236  {
237  $total = 0;
238  $num = $db->num_rows($resql);
239 
240  print '<div class="div-table-responsive-no-min">';
241  print '<table class="noborder" width="100%">';
242  print '<tr class="liste_titre">';
243  print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
244 
245  if ($num > 0)
246  {
247  $i = 0;
248  while ($i < $num)
249  {
250  $obj = $db->fetch_object($resql);
251 
252  print '<tr class="oddeven"><td class="nowrap">';
253  $supplierproposalstatic->id=$obj->rowid;
254  $supplierproposalstatic->ref=$obj->ref;
255  $supplierproposalstatic->total_ht = $obj->total_ht;
256  $supplierproposalstatic->total_tva = $obj->total_tva;
257  $supplierproposalstatic->total_ttc = $obj->total_ttc;
258  print $supplierproposalstatic->getNomUrl(1);
259  print '</td>';
260  print '<td class="nowrap">';
261  $companystatic->id=$obj->socid;
262  $companystatic->name=$obj->name;
263  $companystatic->client=$obj->client;
264  $companystatic->code_client = $obj->code_client;
265  $companystatic->code_fournisseur = $obj->code_fournisseur;
266  $companystatic->canvas=$obj->canvas;
267  print $companystatic->getNomUrl(1,'supplier',16);
268  print '</td>';
269  print '<td align="right" class="nowrap">'.price($obj->total_ht).'</td></tr>';
270  $i++;
271  $total += $obj->total_ht;
272  }
273  if ($total>0)
274  {
275  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
276  }
277  }
278  else
279  {
280  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoProposal").'</td></tr>';
281  }
282  print "</table></div><br>";
283 
284  $db->free($resql);
285  }
286  else
287  {
288  dol_print_error($db);
289  }
290 }
291 
292 
293 /*
294  * Draft orders
295  */
296 if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
297 {
298  $langs->load("orders");
299 
300  $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
301  $sql.= ", s.code_client";
302  $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
303  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
304  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
305  $sql.= " WHERE c.fk_soc = s.rowid";
306  $sql.= " AND c.fk_statut = 0";
307  $sql.= " AND c.entity IN (".getEntity('commande').")";
308  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
309  if ($socid) $sql.= " AND c.fk_soc = ".$socid;
310 
311  $resql = $db->query($sql);
312  if ($resql)
313  {
314  $total = 0;
315  $num = $db->num_rows($resql);
316 
317  print '<div class="div-table-responsive-no-min">';
318  print '<table class="noborder" width="100%">';
319  print '<tr class="liste_titre">';
320  print '<th colspan="3">'.$langs->trans("DraftOrders").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
321 
322  if ($num > 0)
323  {
324  $i = 0;
325  while ($i < $num)
326  {
327 
328  $obj = $db->fetch_object($resql);
329  print '<tr class="oddeven"><td class="nowrap">';
330  $orderstatic->id=$obj->rowid;
331  $orderstatic->ref=$obj->ref;
332  $orderstatic->ref_client=$obj->ref_client;
333  $orderstatic->total_ht = $obj->total_ht;
334  $orderstatic->total_tva = $obj->total_tva;
335  $orderstatic->total_ttc = $obj->total_ttc;
336  print $orderstatic->getNomUrl(1);
337  print '</td>';
338  print '<td class="nowrap">';
339  $companystatic->id=$obj->socid;
340  $companystatic->name=$obj->name;
341  $companystatic->client=$obj->client;
342  $companystatic->code_client = $obj->code_client;
343  $companystatic->code_fournisseur = $obj->code_fournisseur;
344  $companystatic->canvas=$obj->canvas;
345  print $companystatic->getNomUrl(1,'customer',16);
346  print '</td>';
347  if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
348  print '<td align="right" class="nowrap">'.price($obj->total_ht).'</td></tr>';
349  }
350  else {
351  print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
352  }
353  $i++;
354  $total += $obj->total_ttc;
355  }
356  if ($total>0)
357  {
358 
359  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
360  }
361  }
362  else
363  {
364 
365  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
366  }
367  print "</table>";
368  print "</div><br>";
369 
370  $db->free($resql);
371  }
372  else
373  {
374  dol_print_error($db);
375  }
376 }
377 
378 
379 /*
380  * Draft suppliers orders
381  */
382 if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
383 {
384  $langs->load("orders");
385 
386  $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
387  $sql.= ", s.code_client";
388  $sql.= ", s.code_fournisseur";
389  $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
390  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
391  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
392  $sql.= " WHERE cf.fk_soc = s.rowid";
393  $sql.= " AND cf.fk_statut = 0";
394  $sql.= " AND cf.entity IN (".getEntity('supplier_order').")";
395  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
396  if ($socid) $sql.= " AND cf.fk_soc = ".$socid;
397 
398  $resql = $db->query($sql);
399  if ($resql)
400  {
401  $total = 0;
402  $num = $db->num_rows($resql);
403 
404  print '<div class="div-table-responsive-no-min">';
405  print '<table class="noborder" width="100%">';
406  print '<tr class="liste_titre">';
407  print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
408 
409  if ($num > 0)
410  {
411  $i = 0;
412  while ($i < $num)
413  {
414 
415  $obj = $db->fetch_object($resql);
416  print '<tr class="oddeven"><td class="nowrap">';
417  $supplierorderstatic->id=$obj->rowid;
418  $supplierorderstatic->ref=$obj->ref;
419  $supplierorderstatic->ref_supplier=$obj->ref_suppliert;
420  $supplierorderstatic->total_ht = $obj->total_ht;
421  $supplierorderstatic->total_tva = $obj->total_tva;
422  $supplierorderstatic->total_ttc = $obj->total_ttc;
423  print $supplierorderstatic->getNomUrl(1);
424  print '</td>';
425  print '<td class="nowrap">';
426  $companystatic->id=$obj->socid;
427  $companystatic->name=$obj->name;
428  $companystatic->client=$obj->client;
429  $companystatic->code_client = $obj->code_client;
430  $companystatic->code_fournisseur = $obj->code_fournisseur;
431  $companystatic->canvas=$obj->canvas;
432  print $companystatic->getNomUrl(1,'supplier',16);
433  print '</td>';
434  if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
435  print '<td align="right" class="nowrap">'.price($obj->total_ht).'</td></tr>';
436  }
437  else {
438  print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
439  }
440  $i++;
441  $total += $obj->total_ttc;
442  }
443  if ($total>0)
444  {
445 
446  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
447  }
448  }
449  else
450  {
451 
452  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoSupplierOrder").'</td></tr>';
453  }
454  print "</table>";
455  print "</div><br>";
456 
457  $db->free($resql);
458  } else {
459  dol_print_error($db);
460  }
461 }
462 
463 
464 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
465 
466 
467 $NBMAX=3;
468 $max=3;
469 
470 
471 /*
472  * Last modified customers or prospects
473  */
474 if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
475 {
476  $langs->load("boxes");
477 
478  $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas";
479  $sql.= ", s.code_client";
480  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
481  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
482  $sql.= " WHERE s.client IN (1, 2, 3)";
483  $sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
484  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
485  if ($socid) $sql.= " AND s.rowid = $socid";
486  $sql .= " ORDER BY s.tms DESC";
487  $sql .= $db->plimit($max, 0);
488 
489  $resql = $db->query($sql);
490  if ($resql)
491  {
492  $num = $db->num_rows($resql);
493  $i = 0;
494 
495  print '<div class="div-table-responsive-no-min">';
496  print '<table class="noborder" width="100%">';
497  print '<tr class="liste_titre">';
498  print '<th colspan="2">';
499  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max);
500  else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max);
501  else print $langs->trans("BoxTitleLastModifiedCustomers",$max);
502  print '</th>';
503  print '<th align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/societe/list.php?type=p,c">'.$langs->trans("FullList").'</a></th>';
504  print '</tr>';
505  if ($num)
506  {
507  while ($i < $num)
508  {
509  $objp = $db->fetch_object($resql);
510  $companystatic->id=$objp->rowid;
511  $companystatic->name=$objp->name;
512  $companystatic->client=$objp->client;
513  $companystatic->code_client = $objp->code_client;
514  $companystatic->code_fournisseur = $objp->code_fournisseur;
515  $companystatic->canvas=$objp->canvas;
516  print '<tr class="oddeven">';
517  print '<td class="nowrap">'.$companystatic->getNomUrl(1,'customer',48).'</td>';
518  print '<td align="right" nowrap>';
519  print $companystatic->getLibCustProspStatut();
520  print "</td>";
521  print '<td align="right" nowrap>'.dol_print_date($db->jdate($objp->tms),'day')."</td>";
522  print '</tr>';
523  $i++;
524  }
525 
526  $db->free($resql);
527  }
528  else
529  {
530  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
531  }
532  print "</table>";
533  print "</div><br>";
534  }
535 }
536 
537 // Last suppliers
538 if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire)
539 {
540  $langs->load("boxes");
541 
542  $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm";
543  $sql.= ", s.code_fournisseur";
544  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
545  if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
546  $sql.= " WHERE s.fournisseur = 1";
547  $sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
548  if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
549  if ($socid) $sql.= " AND s.rowid = ".$socid;
550  $sql.= " ORDER BY s.datec DESC";
551  $sql.= $db->plimit($max, 0);
552 
553  $result = $db->query($sql);
554  if ($result)
555  {
556  $num = $db->num_rows($result);
557  $i = 0;
558 
559  print '<div class="div-table-responsive-no-min">';
560  print '<table class="noborder" width="100%">';
561  print '<tr class="liste_titre">';
562  print '<th>'.$langs->trans("BoxTitleLastModifiedSuppliers",min($max,$num)).'</th>';
563  print '<th align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("FullList").'</a></th>';
564  print '</tr>';
565  if ($num)
566  {
567  while ($i < $num && $i < $max)
568  {
569  $objp = $db->fetch_object($result);
570  $companystatic->id=$objp->rowid;
571  $companystatic->name=$objp->name;
572  $companystatic->code_client = $objp->code_client;
573  $companystatic->code_fournisseur = $objp->code_fournisseur;
574  $companystatic->canvas=$objp->canvas;
575  print '<tr class="oddeven">';
576  print '<td class="nowrap">'.$companystatic->getNomUrl(1,'supplier',44).'</td>';
577  print '<td align="right">'.dol_print_date($db->jdate($objp->dm),'day').'</td>';
578  print '</tr>';
579 
580  $i++;
581  }
582  }
583  else
584  {
585  print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
586  }
587  print '</table>';
588  print '</div><br>';
589  }
590 }
591 
592 
593 /*
594  * Last actions
595  */
596 if ($user->rights->agenda->myactions->read)
597 {
599 }
600 
601 
602 /*
603  * Actions to do
604  */
605 if ($user->rights->agenda->myactions->read)
606 {
608 }
609 
610 
611 /*
612  * Last contracts
613  */
614 if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
615 {
616  $langs->load("contracts");
617 
618  $sql = "SELECT s.nom as name, s.rowid, s.canvas, ";
619  $sql.= ", s.code_client";
620  $sql.= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo";
621  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
622  $sql.= ", ".MAIN_DB_PREFIX."contrat as c";
623  $sql.= ", ".MAIN_DB_PREFIX."product as p";
624  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
625  $sql.= " WHERE c.fk_soc = s.rowid";
626  $sql.= " AND c.entity IN (".getEntity('contract').")";
627  $sql.= " AND c.fk_product = p.rowid";
628  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
629  if ($socid) $sql.= " AND s.rowid = ".$socid;
630  $sql.= " ORDER BY c.tms DESC";
631  $sql.= $db->plimit(5, 0);
632 
633  $resql=$db->query($sql);
634  if ($resql)
635  {
636  $num = $db->num_rows($resql);
637 
638  if ($num > 0)
639  {
640  print '<div class="div-table-responsive-no-min">';
641  print '<table class="noborder" width="100%">';
642  print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("LastContracts",5).'</th></tr>';
643  $i = 0;
644 
645  $staticcontrat=new Contrat($db);
646 
647  while ($i < $num)
648  {
649  $obj = $db->fetch_object($resql);
650  print '<tr class="oddeven"><td><a href=\"../contrat/card.php?id=".$obj->contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."</a></td>';
651  print '<td>';
652  $companystatic->id=$objp->rowid;
653  $companystatic->name=$objp->name;
654  $companystatic->code_client = $objp->code_client;
655  $companystatic->code_fournisseur = $objp->code_fournisseur;
656  $companystatic->canvas=$objp->canvas;
657  print $companystatic->getNomUrl(1,'customer',44);
658  print '</td>'."\n";
659  print "<td align=\"right\">".$staticcontrat->LibStatut($obj->statut,3)."</td></tr>\n";
660 
661  $i++;
662  }
663  print "</table>";
664  print "</div><br>";
665  }
666  }
667  else
668  {
669  dol_print_error($db);
670  }
671 }
672 
673 /*
674  * Opened proposals
675  */
676 if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
677 {
678  $langs->load("propal");
679 
680  $sql = "SELECT s.nom as name, s.rowid, s.code_client";
681  $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
682  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
683  $sql.= ", ".MAIN_DB_PREFIX."propal as p";
684  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
685  $sql.= " WHERE p.fk_soc = s.rowid";
686  $sql.= " AND p.entity IN (".getEntity('propal').")";
687  $sql.= " AND p.fk_statut = 1";
688  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
689  if ($socid) $sql.= " AND s.rowid = ".$socid;
690  $sql.= " ORDER BY p.rowid DESC";
691 
692  $result=$db->query($sql);
693  if ($result)
694  {
695  $total = 0;
696  $num = $db->num_rows($result);
697  $i = 0;
698  if ($num > 0)
699  {
700  print '<div class="div-table-responsive-no-min">';
701  print '<table class="noborder" width="100%">';
702  print '<tr class="liste_titre"><th colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></th></tr>';
703 
704  $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
705  while ($i < $nbofloop)
706  {
707  $obj = $db->fetch_object($result);
708 
709  print '<tr class="oddeven">';
710 
711  // Ref
712  print '<td class="nowrap" width="140">';
713 
714  $propalstatic->id=$obj->propalid;
715  $propalstatic->ref=$obj->ref;
716  $propalstatic->ref_client=$obj->ref_client;
717  $propalstatic->total_ht = $obj->total_ht;
718  $propalstatic->total_tva = $obj->total_tva;
719  $propalstatic->total_ttc = $obj->total_ttc;
720 
721  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
722  print '<td class="nobordernopadding nowrap">';
723  print $propalstatic->getNomUrl(1);
724  print '</td>';
725  print '<td width="18" class="nobordernopadding nowrap">';
726  if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
727  print '</td>';
728  print '<td width="16" align="center" class="nobordernopadding">';
729  $filename=dol_sanitizeFileName($obj->ref);
730  $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
731  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
732  print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
733  print '</td></tr></table>';
734 
735  print "</td>";
736 
737  print '<td class="nowrap">';
738  $companystatic->id=$obj->rowid;
739  $companystatic->name=$obj->name;
740  $companystatic->client=$obj->client;
741  $companystatic->code_client = $obj->code_client;
742  $companystatic->code_fournisseur = $obj->code_fournisseur;
743  $companystatic->canvas=$obj->canvas;
744  print $companystatic->getNomUrl(1, 'customer', 44);
745  print '</td>';
746  print '<td align="right">';
747  print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n";
748  if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
749  print '<td align="right">'.price($obj->total_ht).'</td>';
750  }
751  else {
752  print '<td align="right">'.price($obj->total_ttc).'</td>';
753  }
754  print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n";
755  print '</tr>'."\n";
756  $i++;
757  $total += $obj->total_ttc;
758  }
759  if ($num > $nbofloop)
760  {
761  print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
762  }
763  else if ($total>0)
764  {
765  print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
766  }
767  print "</table>";
768  print "</div><br>";
769  }
770  }
771  else
772  {
773  dol_print_error($db);
774  }
775 }
776 
777 /*
778  * Opened Order
779  */
780 if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
781 {
782  $langs->load("orders");
783 
784  $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
785  $sql.= ", s.code_client";
786  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
787  $sql.= ", ".MAIN_DB_PREFIX."commande as c";
788  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
789  $sql.= " WHERE c.fk_soc = s.rowid";
790  $sql.= " AND c.entity IN (".getEntity('commande').")";
791  $sql.= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")";
792  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
793  if ($socid) $sql.= " AND s.rowid = ".$socid;
794  $sql.= " ORDER BY c.rowid DESC";
795 
796  $result=$db->query($sql);
797  if ($result)
798  {
799  $total = 0;
800  $num = $db->num_rows($result);
801  $i = 0;
802  if ($num > 0)
803  {
804  print '<div class="div-table-responsive-no-min">';
805  print '<table class="noborder" width="100%">';
806  print '<tr class="liste_titre"><th class="liste_titre" colspan="5">'.$langs->trans("OrdersOpened").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1"><span class="badge">'.$num.'</span></th></tr>';
807 
808  $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
809  while ($i < $nbofloop)
810  {
811  $obj = $db->fetch_object($result);
812 
813  print '<tr class="oddeven">';
814 
815  // Ref
816  print '<td class="nowrap" width="140">';
817 
818  $orderstatic->id=$obj->commandeid;
819  $orderstatic->ref=$obj->ref;
820  $orderstatic->ref_client=$obj->ref_client;
821  $orderstatic->total_ht = $obj->total_ht;
822  $orderstatic->total_tva = $obj->total_tva;
823  $orderstatic->total_ttc = $obj->total_ttc;
824 
825  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
826  print '<td class="nobordernopadding nowrap">';
827  print $orderstatic->getNomUrl(1);
828  print '</td>';
829  print '<td width="18" class="nobordernopadding nowrap">';
830  //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
831  print '</td>';
832  print '<td width="16" align="center" class="nobordernopadding">';
833  $filename=dol_sanitizeFileName($obj->ref);
834  $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
835  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
836  print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir);
837  print '</td></tr></table>';
838 
839  print "</td>";
840 
841  print '<td class="nowrap">';
842  $companystatic->id=$obj->rowid;
843  $companystatic->name=$obj->name;
844  $companystatic->client=$obj->client;
845  $companystatic->code_client = $obj->code_client;
846  $companystatic->code_fournisseur = $obj->code_fournisseur;
847  $companystatic->canvas=$obj->canvas;
848  print $companystatic->getNomUrl(1, 'customer', 44);
849  print '</td>';
850  print '<td align="right">';
851  print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n";
852  if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) {
853  print '<td align="right">'.price($obj->total_ht).'</td>';
854  }
855  else {
856  print '<td align="right">'.price($obj->total_ttc).'</td>';
857  }
858  print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut,$obj->billed,3).'</td>'."\n";
859  print '</tr>'."\n";
860  $i++;
861  $total += $obj->total_ttc;
862  }
863  if ($num > $nbofloop)
864  {
865  print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
866  }
867  else if ($total>0)
868  {
869  print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
870  }
871  print "</table>";
872  print "</div><br>";
873  }
874  }
875  else
876  {
877  dol_print_error($db);
878  }
879 }
880 
881 
882 
883 print '</div></div></div>';
884 
885 // End of page
886 llxFooter();
887 $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.
Class to manage contracts.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
const STATUS_SHIPMENTONPROCESS
Shipment on process.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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.
show_array_last_actions_done($max=5)
Show last actions array.
Definition: agenda.lib.php:312
dol_now($mode='gmt')
Return date for now.
Class to manage predefined suppliers products.
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...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage price ask supplier.
show_array_actions_to_do($max=5)
Show actions to do array.
Definition: agenda.lib.php:212
Class to manage proposals.