dolibarr  7.0.0-beta
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@capnetworks.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 $langs->load("commercial");
41 $langs->load("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 '<table class="noborder" width="100%">';
160  print '<tr class="liste_titre">';
161  print '<th colspan="3">'.$langs->trans("ProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
162 
163  $var=true;
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><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('propal').")";
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 '<table class="noborder" width="100%">';
241  print '<tr class="liste_titre">';
242  print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
243 
244  $var=true;
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,'customer',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 
276  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
277  }
278  }
279  else
280  {
281 
282  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoProposal").'</td></tr>';
283  }
284  print "</table><br>";
285 
286  $db->free($resql);
287  }
288  else
289  {
290  dol_print_error($db);
291  }
292 }
293 
294 
295 /*
296  * Draft orders
297  */
298 if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
299 {
300  $langs->load("orders");
301 
302  $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";
303  $sql.= ", s.code_client";
304  $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
305  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
306  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
307  $sql.= " WHERE c.fk_soc = s.rowid";
308  $sql.= " AND c.fk_statut = 0";
309  $sql.= " AND c.entity IN (".getEntity('commande').")";
310  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
311  if ($socid) $sql.= " AND c.fk_soc = ".$socid;
312 
313  $resql = $db->query($sql);
314  if ($resql)
315  {
316  $total = 0;
317  $num = $db->num_rows($resql);
318 
319  print '<table class="noborder" width="100%">';
320  print '<tr class="liste_titre">';
321  print '<th colspan="3">'.$langs->trans("DraftOrders").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
322 
323  $var = true;
324  if ($num > 0)
325  {
326  $i = 0;
327  while ($i < $num)
328  {
329 
330  $obj = $db->fetch_object($resql);
331  print '<tr class="oddeven"><td class="nowrap">';
332  $orderstatic->id=$obj->rowid;
333  $orderstatic->ref=$obj->ref;
334  $orderstatic->ref_client=$obj->ref_client;
335  $orderstatic->total_ht = $obj->total_ht;
336  $orderstatic->total_tva = $obj->total_tva;
337  $orderstatic->total_ttc = $obj->total_ttc;
338  print $orderstatic->getNomUrl(1);
339  print '</td>';
340  print '<td class="nowrap">';
341  $companystatic->id=$obj->socid;
342  $companystatic->name=$obj->name;
343  $companystatic->client=$obj->client;
344  $companystatic->code_client = $obj->code_client;
345  $companystatic->code_fournisseur = $obj->code_fournisseur;
346  $companystatic->canvas=$obj->canvas;
347  print $companystatic->getNomUrl(1,'customer',16);
348  print '</td>';
349  print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
350  $i++;
351  $total += $obj->total_ttc;
352  }
353  if ($total>0)
354  {
355 
356  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
357  }
358  }
359  else
360  {
361 
362  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
363  }
364  print "</table><br>";
365 
366  $db->free($resql);
367  }
368  else
369  {
370  dol_print_error($db);
371  }
372 }
373 
374 
375 /*
376  * Draft suppliers orders
377  */
378 if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
379 {
380  $langs->load("orders");
381 
382  $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
383  $sql.= ", s.code_client";
384  $sql.= ", s.code_fournisseur";
385  $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf";
386  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
387  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
388  $sql.= " WHERE cf.fk_soc = s.rowid";
389  $sql.= " AND cf.fk_statut = 0";
390  $sql.= " AND cf.entity IN (".getEntity('supplier_order').")";
391  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
392  if ($socid) $sql.= " AND cf.fk_soc = ".$socid;
393 
394  $resql = $db->query($sql);
395  if ($resql)
396  {
397  $total = 0;
398  $num = $db->num_rows($resql);
399 
400  print '<table class="noborder" width="100%">';
401  print '<tr class="liste_titre">';
402  print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
403 
404  $var = true;
405  if ($num > 0)
406  {
407  $i = 0;
408  while ($i < $num)
409  {
410 
411  $obj = $db->fetch_object($resql);
412  print '<tr class="oddeven"><td class="nowrap">';
413  $supplierorderstatic->id=$obj->rowid;
414  $supplierorderstatic->ref=$obj->ref;
415  $supplierorderstatic->ref_supplier=$obj->ref_suppliert;
416  $supplierorderstatic->total_ht = $obj->total_ht;
417  $supplierorderstatic->total_tva = $obj->total_tva;
418  $supplierorderstatic->total_ttc = $obj->total_ttc;
419  print $supplierorderstatic->getNomUrl(1);
420  print '</td>';
421  print '<td class="nowrap">';
422  $companystatic->id=$obj->socid;
423  $companystatic->name=$obj->name;
424  $companystatic->client=$obj->client;
425  $companystatic->code_client = $obj->code_client;
426  $companystatic->code_fournisseur = $obj->code_fournisseur;
427  $companystatic->canvas=$obj->canvas;
428  print $companystatic->getNomUrl(1,'supplier',16);
429  print '</td>';
430  print '<td align="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
431  $i++;
432  $total += $obj->total_ttc;
433  }
434  if ($total>0)
435  {
436 
437  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" align="right">'.price($total)."</td></tr>";
438  }
439  }
440  else
441  {
442 
443  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoSupplierOrder").'</td></tr>';
444  }
445  print "</table><br>";
446 
447  $db->free($resql);
448  } else {
449  dol_print_error($db);
450  }
451 }
452 
453 
454 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
455 
456 
457 $NBMAX=3;
458 $max=3;
459 
460 
461 /*
462  * Last modified customers or prospects
463  */
464 if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
465 {
466  $langs->load("boxes");
467 
468  $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas";
469  $sql.= ", s.code_client";
470  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
471  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
472  $sql.= " WHERE s.client IN (1, 2, 3)";
473  $sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")";
474  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
475  if ($socid) $sql.= " AND s.rowid = $socid";
476  $sql .= " ORDER BY s.tms DESC";
477  $sql .= $db->plimit($max, 0);
478 
479  $resql = $db->query($sql);
480  if ($resql)
481  {
482  $num = $db->num_rows($resql);
483  $i = 0;
484 
485  print '<table class="noborder" width="100%">';
486  print '<tr class="liste_titre">';
487  print '<th colspan="2">';
488  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max);
489  else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max);
490  else print $langs->trans("BoxTitleLastModifiedCustomers",$max);
491  print '</th>';
492  print '<th align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/societe/list.php?type=p,c">'.$langs->trans("FullList").'</a></th>';
493  print '</tr>';
494  if ($num)
495  {
496  while ($i < $num)
497  {
498  $objp = $db->fetch_object($resql);
499  $companystatic->id=$objp->rowid;
500  $companystatic->name=$objp->name;
501  $companystatic->client=$objp->client;
502  $companystatic->code_client = $objp->code_client;
503  $companystatic->code_fournisseur = $objp->code_fournisseur;
504  $companystatic->canvas=$objp->canvas;
505  print '<tr class="oddeven">';
506  print '<td class="nowrap">'.$companystatic->getNomUrl(1,'customer',48).'</td>';
507  print '<td align="right" nowrap>';
508  print $companystatic->getLibCustProspStatut();
509  print "</td>";
510  print '<td align="right" nowrap>'.dol_print_date($db->jdate($objp->tms),'day')."</td>";
511  print '</tr>';
512  $i++;
513 
514 
515  }
516 
517  $db->free($resql);
518  }
519  else
520  {
521  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
522  }
523  print "</table><br>";
524  }
525 }
526 
527 // Last suppliers
528 if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire)
529 {
530  $langs->load("boxes");
531 
532  $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm";
533  $sql.= ", s.code_fournisseur";
534  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
535  if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
536  $sql.= " WHERE s.fournisseur = 1";
537  $sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")";
538  if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
539  if ($socid) $sql.= " AND s.rowid = ".$socid;
540  $sql.= " ORDER BY s.datec DESC";
541  $sql.= $db->plimit($max, 0);
542 
543  $result = $db->query($sql);
544  if ($result)
545  {
546  $num = $db->num_rows($result);
547  $i = 0;
548 
549  print '<table class="noborder" width="100%">';
550  print '<tr class="liste_titre">';
551  print '<th>'.$langs->trans("BoxTitleLastModifiedSuppliers",min($max,$num)).'</th>';
552  print '<th align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("FullList").'</a></th>';
553  print '</tr>';
554  if ($num)
555  {
556  while ($i < $num && $i < $max)
557  {
558  $objp = $db->fetch_object($result);
559  $companystatic->id=$objp->rowid;
560  $companystatic->name=$objp->name;
561  $companystatic->code_client = $objp->code_client;
562  $companystatic->code_fournisseur = $objp->code_fournisseur;
563  $companystatic->canvas=$objp->canvas;
564  print '<tr class="oddeven">';
565  print '<td class="nowrap">'.$companystatic->getNomUrl(1,'supplier',44).'</td>';
566  print '<td align="right">'.dol_print_date($db->jdate($objp->dm),'day').'</td>';
567  print '</tr>';
568 
569  $i++;
570  }
571 
572  }
573  else
574  {
575  print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
576  }
577  print '</table><br>';
578  }
579 }
580 
581 
582 /*
583  * Last actions
584  */
585 if ($user->rights->agenda->myactions->read)
586 {
588 }
589 
590 
591 /*
592  * Actions to do
593  */
594 if ($user->rights->agenda->myactions->read)
595 {
597 }
598 
599 
600 /*
601  * Last contracts
602  */
603 if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
604 {
605  $langs->load("contracts");
606 
607  $sql = "SELECT s.nom as name, s.rowid, s.canvas, ";
608  $sql.= ", s.code_client";
609  $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";
610  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
611  $sql.= ", ".MAIN_DB_PREFIX."contrat as c";
612  $sql.= ", ".MAIN_DB_PREFIX."product as p";
613  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
614  $sql.= " WHERE c.fk_soc = s.rowid";
615  $sql.= " AND c.entity IN (".getEntity('contract').")";
616  $sql.= " AND c.fk_product = p.rowid";
617  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
618  if ($socid) $sql.= " AND s.rowid = ".$socid;
619  $sql.= " ORDER BY c.tms DESC";
620  $sql.= $db->plimit(5, 0);
621 
622  $resql=$db->query($sql);
623  if ($resql)
624  {
625  $num = $db->num_rows($resql);
626 
627  if ($num > 0)
628  {
629  print '<table class="noborder" width="100%">';
630  print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("LastContracts",5).'</th></tr>';
631  $i = 0;
632 
633  $staticcontrat=new Contrat($db);
634 
635  while ($i < $num)
636  {
637  $obj = $db->fetch_object($resql);
638  print '<tr class="oddeven"><td><a href=\"../contrat/card.php?id=".$obj->contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."</a></td>';
639  print '<td>';
640  $companystatic->id=$objp->rowid;
641  $companystatic->name=$objp->name;
642  $companystatic->code_client = $objp->code_client;
643  $companystatic->code_fournisseur = $objp->code_fournisseur;
644  $companystatic->canvas=$objp->canvas;
645  print $companystatic->getNomUrl(1,'customer',44);
646  print '</td>'."\n";
647  print "<td align=\"right\">".$staticcontrat->LibStatut($obj->statut,3)."</td></tr>\n";
648 
649  $i++;
650  }
651  print "</table><br>";
652  }
653  }
654  else
655  {
656  dol_print_error($db);
657  }
658 }
659 
660 /*
661  * Opened proposals
662  */
663 if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
664 {
665  $langs->load("propal");
666 
667  $sql = "SELECT s.nom as name, s.rowid, p.rowid as propalid, 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";
668  $sql.= ", s.code_client";
669  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
670  $sql.= ", ".MAIN_DB_PREFIX."propal as p";
671  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
672  $sql.= " WHERE p.fk_soc = s.rowid";
673  $sql.= " AND p.entity IN (".getEntity('propal').")";
674  $sql.= " AND p.fk_statut = 1";
675  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
676  if ($socid) $sql.= " AND s.rowid = ".$socid;
677  $sql.= " ORDER BY p.rowid DESC";
678 
679  $result=$db->query($sql);
680  if ($result)
681  {
682  $total = 0;
683  $num = $db->num_rows($result);
684  $i = 0;
685  if ($num > 0)
686  {
687  print '<table class="noborder" width="100%">';
688  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>';
689 
690  $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
691  while ($i < $nbofloop)
692  {
693  $obj = $db->fetch_object($result);
694 
695  print '<tr class="oddeven">';
696 
697  // Ref
698  print '<td class="nowrap" width="140">';
699 
700  $propalstatic->id=$obj->propalid;
701  $propalstatic->ref=$obj->ref;
702  $propalstatic->ref_client=$obj->ref_client;
703  $propalstatic->total_ht = $obj->total_ht;
704  $propalstatic->total_tva = $obj->total_tva;
705  $propalstatic->total_ttc = $obj->total_ttc;
706 
707  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
708  print '<td class="nobordernopadding nowrap">';
709  print $propalstatic->getNomUrl(1);
710  print '</td>';
711  print '<td width="18" class="nobordernopadding nowrap">';
712  if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
713  print '</td>';
714  print '<td width="16" align="center" class="nobordernopadding">';
715  $filename=dol_sanitizeFileName($obj->ref);
716  $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
717  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
718  print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
719  print '</td></tr></table>';
720 
721  print "</td>";
722 
723  print '<td class="nowrap">';
724  $companystatic->id=$obj->rowid;
725  $companystatic->name=$obj->name;
726  $companystatic->client=$obj->client;
727  $companystatic->code_client = $obj->code_client;
728  $companystatic->code_fournisseur = $obj->code_fournisseur;
729  $companystatic->canvas=$obj->canvas;
730  print $companystatic->getNomUrl(1, 'customer', 44);
731  print '</td>';
732  print '<td align="right">';
733  print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n";
734  print '<td align="right">'.price($obj->total_ttc).'</td>';
735  print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n";
736  print '</tr>'."\n";
737  $i++;
738  $total += $obj->total_ttc;
739  }
740  if ($num > $nbofloop)
741  {
742  print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
743  }
744  else if ($total>0)
745  {
746  print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
747  }
748  print "</table><br>";
749  }
750  }
751  else
752  {
753  dol_print_error($db);
754  }
755 }
756 
757 /*
758  * Opened Order
759  */
760 if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
761 {
762  $langs->load("orders");
763 
764  $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";
765  $sql.= ", s.code_client";
766  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
767  $sql.= ", ".MAIN_DB_PREFIX."commande as c";
768  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
769  $sql.= " WHERE c.fk_soc = s.rowid";
770  $sql.= " AND c.entity IN (".getEntity('commande').")";
771  $sql.= " AND c.fk_statut = 1";
772  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
773  if ($socid) $sql.= " AND s.rowid = ".$socid;
774  $sql.= " ORDER BY c.rowid DESC";
775 
776  $result=$db->query($sql);
777  if ($result)
778  {
779  $total = 0;
780  $num = $db->num_rows($result);
781  $i = 0;
782  if ($num > 0)
783  {
784  print '<table class="noborder" width="100%">';
785  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>';
786 
787  $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
788  while ($i < $nbofloop)
789  {
790  $obj = $db->fetch_object($result);
791 
792  print '<tr class="oddeven">';
793 
794  // Ref
795  print '<td class="nowrap" width="140">';
796 
797  $orderstatic->id=$obj->commandeid;
798  $orderstatic->ref=$obj->ref;
799  $orderstatic->ref_client=$obj->ref_client;
800  $orderstatic->total_ht = $obj->total_ht;
801  $orderstatic->total_tva = $obj->total_tva;
802  $orderstatic->total_ttc = $obj->total_ttc;
803 
804  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
805  print '<td class="nobordernopadding nowrap">';
806  print $orderstatic->getNomUrl(1);
807  print '</td>';
808  print '<td width="18" class="nobordernopadding nowrap">';
809  //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
810  print '</td>';
811  print '<td width="16" align="center" class="nobordernopadding">';
812  $filename=dol_sanitizeFileName($obj->ref);
813  $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
814  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
815  print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir);
816  print '</td></tr></table>';
817 
818  print "</td>";
819 
820  print '<td class="nowrap">';
821  $companystatic->id=$obj->rowid;
822  $companystatic->name=$obj->name;
823  $companystatic->client=$obj->client;
824  $companystatic->code_client = $obj->code_client;
825  $companystatic->code_fournisseur = $obj->code_fournisseur;
826  $companystatic->canvas=$obj->canvas;
827  print $companystatic->getNomUrl(1, 'customer', 44);
828  print '</td>';
829  print '<td align="right">';
830  print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n";
831  print '<td align="right">'.price($obj->total_ttc).'</td>';
832  print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut,$obj->billed,3).'</td>'."\n";
833  print '</tr>'."\n";
834  $i++;
835  $total += $obj->total_ttc;
836  }
837  if ($num > $nbofloop)
838  {
839  print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
840  }
841  else if ($total>0)
842  {
843  print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
844  }
845  print "</table><br>";
846  }
847  }
848  else
849  {
850  dol_print_error($db);
851  }
852 }
853 
854 
855 
856 print '</div></div></div>';
857 
858 llxFooter();
859 
860 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
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...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...)
img_warning($titlealt= 'default', $moreatt= '')
Show warning logo.
llxHeader()
Header empty.
Definition: index.php:37
Class to manage customers orders.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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).
print
Draft customers invoices.
Definition: index.php:91
Class to manage price ask supplier.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
show_array_actions_to_do($max=5)
Show actions to do array.
Definition: agenda.lib.php:212
Class to manage proposals.