dolibarr  16.0.5
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  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7  * Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
8  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.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 <https://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.'/core/lib/agenda.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
42 if (!empty($conf->ficheinter->enabled)) {
43  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
44 }
45 
46 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
47 $hookmanager = new HookManager($db);
48 $hookmanager->initHooks(array('commercialindex'));
49 
50 // Load translation files required by the page
51 $langs->loadLangs(array("boxes", "commercial", "contracts", "orders", "propal", "supplier_proposal"));
52 
53 $action = GETPOST('action', 'aZ09');
54 $bid = GETPOST('bid', 'int');
55 
56 // Securite acces client
57 $socid = GETPOST('socid', 'int');
58 if (isset($user->socid) && $user->socid > 0) {
59  $action = '';
60  $socid = $user->socid;
61 }
62 
63 restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
64 
65 $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
66 $now = dol_now();
67 
68 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
69 
70 
71 /*
72  * Actions
73  */
74 
75 // None
76 
77 
78 /*
79  * View
80  */
81 
82 $form = new Form($db);
83 $formfile = new FormFile($db);
84 $companystatic = new Societe($db);
85 if (!empty($conf->propal->enabled)) {
86  $propalstatic = new Propal($db);
87 }
88 if (!empty($conf->supplier_proposal->enabled)) {
89  $supplierproposalstatic = new SupplierProposal($db);
90 }
91 if (!empty($conf->commande->enabled)) {
92  $orderstatic = new Commande($db);
93 }
94 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
95  $supplierorderstatic = new CommandeFournisseur($db);
96 }
97 
98 if (!empty($conf->ficheinter->enabled)) {
99  $fichinterstatic = new Fichinter($db);
100 }
101 
102 llxHeader("", $langs->trans("CommercialArea"));
103 
104 print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial');
105 
106 print '<div class="fichecenter"><div class="fichethirdleft">';
107 
108 $tmp = getCustomerProposalPieChart($socid);
109 if ($tmp) {
110  print $tmp;
111  print '<br>';
112 }
113 $tmp = getCustomerOrderPieChart($socid);
114 if ($tmp) {
115  print $tmp;
116  print '<br>';
117 }
118 
119 /*
120  * Draft customer proposals
121  */
122 
123 if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
124  $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
125  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
126  $sql .= ", s.code_client, s.code_compta, s.client";
127  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
128  $sql .= ", s.logo, s.email, s.entity";
129  $sql .= ", s.canvas";
130  $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,";
131  $sql .= " ".MAIN_DB_PREFIX."societe as s";
132  if (empty($user->rights->societe->client->voir) && !$socid) {
133  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
134  }
135  $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
136  $sql .= " AND p.fk_soc = s.rowid";
137  $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT;
138  if (empty($user->rights->societe->client->voir) && !$socid) {
139  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
140  }
141  if ($socid) {
142  $sql .= " AND s.rowid = ".((int) $socid);
143  }
144 
145  $resql = $db->query($sql);
146  if ($resql) {
147  $total = 0;
148  $num = $db->num_rows($resql);
149  $nbofloop = min($num, $maxofloop);
150  startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num);
151 
152  if ($num > 0) {
153  $i = 0;
154  $othernb = 0;
155 
156  while ($i < $nbofloop) {
157  $obj = $db->fetch_object($resql);
158 
159  if ($i >= $max) {
160  $othernb += 1;
161  $i++;
162  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
163  continue;
164  }
165 
166  $propalstatic->id = $obj->rowid;
167  $propalstatic->ref = $obj->ref;
168  $propalstatic->ref_client = $obj->ref_client;
169  $propalstatic->total_ht = $obj->total_ht;
170  $propalstatic->total_tva = $obj->total_tva;
171  $propalstatic->total_ttc = $obj->total_ttc;
172  $propalstatic->statut = $obj->status;
173 
174  $companystatic->id = $obj->socid;
175  $companystatic->name = $obj->name;
176  $companystatic->name_alias = $obj->name_alias;
177  $companystatic->code_client = $obj->code_client;
178  $companystatic->code_compta = $obj->code_compta;
179  $companystatic->client = $obj->client;
180  $companystatic->code_fournisseur = $obj->code_fournisseur;
181  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
182  $companystatic->fournisseur = $obj->fournisseur;
183  $companystatic->logo = $obj->logo;
184  $companystatic->email = $obj->email;
185  $companystatic->entity = $obj->entity;
186  $companystatic->canvas = $obj->canvas;
187 
188  print '<tr class="oddeven">';
189  print '<td class="nowraponall tdoverflowmax100">'.$propalstatic->getNomUrl(1).'</td>';
190  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
191  print '<td class="nowrap right tdamount amount">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'</td>';
192  print '</tr>';
193 
194  $i++;
195  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
196  }
197 
198  if ($othernb) {
199  print '<tr class="oddeven">';
200  print '<td class="nowrap" colspan="5">';
201  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
202  print '</td>';
203  print "</tr>\n";
204  }
205  }
206 
207  addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
208  finishSimpleTable(true);
209 
210  $db->free($resql);
211  } else {
212  dol_print_error($db);
213  }
214 }
215 
216 
217 /*
218  * Draft supplier proposals
219  */
220 
221 if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
222  $sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
223  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
224  $sql .= ", s.code_client, s.code_compta, s.client";
225  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
226  $sql .= ", s.logo, s.email, s.entity";
227  $sql .= ", s.canvas";
228  $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,";
229  $sql .= " ".MAIN_DB_PREFIX."societe as s";
230  if (empty($user->rights->societe->client->voir) && !$socid) {
231  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
232  }
233  $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")";
234  $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
235  $sql .= " AND p.fk_soc = s.rowid";
236  if (empty($user->rights->societe->client->voir) && !$socid) {
237  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
238  }
239  if ($socid) {
240  $sql .= " AND s.rowid = ".((int) $socid);
241  }
242 
243  $resql = $db->query($sql);
244  if ($resql) {
245  $total = 0;
246  $num = $db->num_rows($resql);
247  $nbofloop = min($num, $maxofloop);
248  startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=".SupplierProposal::STATUS_DRAFT, 2, $num);
249 
250  if ($num > 0) {
251  $i = 0;
252  $othernb = 0;
253 
254  while ($i < $nbofloop) {
255  $obj = $db->fetch_object($resql);
256 
257  if ($i >= $max) {
258  $othernb += 1;
259  $i++;
260  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
261  continue;
262  }
263 
264  $supplierproposalstatic->id = $obj->rowid;
265  $supplierproposalstatic->ref = $obj->ref;
266  $supplierproposalstatic->total_ht = $obj->total_ht;
267  $supplierproposalstatic->total_tva = $obj->total_tva;
268  $supplierproposalstatic->total_ttc = $obj->total_ttc;
269  $supplierproposalstatic->statut = $obj->status;
270 
271  $companystatic->id = $obj->socid;
272  $companystatic->name = $obj->name;
273  $companystatic->name_alias = $obj->name_alias;
274  $companystatic->code_client = $obj->code_client;
275  $companystatic->code_compta = $obj->code_compta;
276  $companystatic->client = $obj->client;
277  $companystatic->code_fournisseur = $obj->code_fournisseur;
278  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
279  $companystatic->fournisseur = $obj->fournisseur;
280  $companystatic->logo = $obj->logo;
281  $companystatic->email = $obj->email;
282  $companystatic->entity = $obj->entity;
283  $companystatic->canvas = $obj->canvas;
284 
285  print '<tr class="oddeven">';
286  print '<td class="nowraponall tdoverflowmax100">'.$supplierproposalstatic->getNomUrl(1).'</td>';
287  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
288  print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
289  print '</tr>';
290 
291  $i++;
292  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
293  }
294 
295  if ($othernb) {
296  print '<tr class="oddeven">';
297  print '<td class="nowrap" colspan="5">';
298  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
299  print '</td>';
300  print "</tr>\n";
301  }
302  }
303 
304  addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
305  finishSimpleTable(true);
306 
307  $db->free($resql);
308  } else {
309  dol_print_error($db);
310  }
311 }
312 
313 
314 /*
315  * Draft customer orders
316  */
317 
318 if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
319  $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
320  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
321  $sql .= ", s.code_client, s.code_compta, s.client";
322  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
323  $sql .= ", s.logo, s.email, s.entity";
324  $sql .= ", s.canvas";
325  $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
326  $sql .= " ".MAIN_DB_PREFIX."societe as s";
327  if (empty($user->rights->societe->client->voir) && !$socid) {
328  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
329  }
330  $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
331  $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT;
332  $sql .= " AND c.fk_soc = s.rowid";
333  if (empty($user->rights->societe->client->voir) && !$socid) {
334  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
335  }
336  if ($socid) {
337  $sql .= " AND c.fk_soc = ".((int) $socid);
338  }
339 
340  $resql = $db->query($sql);
341  if ($resql) {
342  $total = 0;
343  $num = $db->num_rows($resql);
344  $nbofloop = min($num, $maxofloop);
345  startSimpleTable("DraftOrders", "commande/list.php", "search_status=".Commande::STATUS_DRAFT, 2, $num);
346 
347  if ($num > 0) {
348  $i = 0;
349  $othernb = 0;
350 
351  while ($i < $nbofloop) {
352  $obj = $db->fetch_object($resql);
353 
354  if ($i >= $max) {
355  $othernb += 1;
356  $i++;
357  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
358  continue;
359  }
360 
361  $orderstatic->id = $obj->rowid;
362  $orderstatic->ref = $obj->ref;
363  $orderstatic->ref_client = $obj->ref_client;
364  $orderstatic->total_ht = $obj->total_ht;
365  $orderstatic->total_tva = $obj->total_tva;
366  $orderstatic->total_ttc = $obj->total_ttc;
367  $orderstatic->statut = $obj->status;
368 
369  $companystatic->id = $obj->socid;
370  $companystatic->name = $obj->name;
371  $companystatic->name_alias = $obj->name_alias;
372  $companystatic->code_client = $obj->code_client;
373  $companystatic->code_compta = $obj->code_compta;
374  $companystatic->client = $obj->client;
375  $companystatic->code_fournisseur = $obj->code_fournisseur;
376  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
377  $companystatic->fournisseur = $obj->fournisseur;
378  $companystatic->logo = $obj->logo;
379  $companystatic->email = $obj->email;
380  $companystatic->entity = $obj->entity;
381  $companystatic->canvas = $obj->canvas;
382 
383  print '<tr class="oddeven">';
384  print '<td class="nowraponall tdoverflowmax100">'.$orderstatic->getNomUrl(1).'</td>';
385  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
386  print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
387  print '</tr>';
388 
389  $i++;
390  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
391  }
392 
393  if ($othernb) {
394  print '<tr class="oddeven">';
395  print '<td class="nowrap" colspan="5">';
396  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
397  print '</td>';
398  print "</tr>\n";
399  }
400  }
401 
402  addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
403  finishSimpleTable(true);
404 
405  $db->free($resql);
406  } else {
407  dol_print_error($db);
408  }
409 }
410 
411 
412 /*
413  * Draft purchase orders
414  */
415 
416 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) {
417  $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
418  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
419  $sql .= ", s.code_client, s.code_compta, s.client";
420  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
421  $sql .= ", s.logo, s.email, s.entity";
422  $sql .= ", s.canvas";
423  $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
424  $sql .= " ".MAIN_DB_PREFIX."societe as s";
425  if (empty($user->rights->societe->client->voir) && !$socid) {
426  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
427  }
428  $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")";
429  $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
430  $sql .= " AND cf.fk_soc = s.rowid";
431  if (empty($user->rights->societe->client->voir) && !$socid) {
432  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
433  }
434  if ($socid) {
435  $sql .= " AND cf.fk_soc = ".((int) $socid);
436  }
437 
438  $resql = $db->query($sql);
439  if ($resql) {
440  $total = 0;
441  $num = $db->num_rows($resql);
442  $nbofloop = min($num, $maxofloop);
443  startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=".CommandeFournisseur::STATUS_DRAFT, 2, $num);
444 
445  if ($num > 0) {
446  $i = 0;
447  $othernb = 0;
448 
449  while ($i < $nbofloop) {
450  $obj = $db->fetch_object($resql);
451 
452  if ($i >= $max) {
453  $othernb += 1;
454  $i++;
455  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
456  continue;
457  }
458 
459  $supplierorderstatic->id = $obj->rowid;
460  $supplierorderstatic->ref = $obj->ref;
461  $supplierorderstatic->ref_supplier = $obj->ref_supplier;
462  $supplierorderstatic->total_ht = $obj->total_ht;
463  $supplierorderstatic->total_tva = $obj->total_tva;
464  $supplierorderstatic->total_ttc = $obj->total_ttc;
465  $supplierorderstatic->statut = $obj->status;
466 
467  $companystatic->id = $obj->socid;
468  $companystatic->name = $obj->name;
469  $companystatic->name_alias = $obj->name_alias;
470  $companystatic->code_client = $obj->code_client;
471  $companystatic->code_compta = $obj->code_compta;
472  $companystatic->client = $obj->client;
473  $companystatic->code_fournisseur = $obj->code_fournisseur;
474  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
475  $companystatic->fournisseur = $obj->fournisseur;
476  $companystatic->logo = $obj->logo;
477  $companystatic->email = $obj->email;
478  $companystatic->entity = $obj->entity;
479  $companystatic->canvas = $obj->canvas;
480 
481  print '<tr class="oddeven">';
482  print '<td class="nowraponall tdoverflowmax100">'.$supplierorderstatic->getNomUrl(1).'</td>';
483  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
484  print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
485  print '</tr>';
486 
487  $i++;
488  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
489  }
490 
491  if ($othernb) {
492  print '<tr class="oddeven">';
493  print '<td class="nowrap" colspan="5">';
494  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
495  print '</td>';
496  print "</tr>\n";
497  }
498  }
499 
500  addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
501  finishSimpleTable(true);
502 
503  $db->free($resql);
504  } else {
505  dol_print_error($db);
506  }
507 }
508 
509 
510 /*
511  * Draft interventionals
512  */
513 if (!empty($conf->ficheinter->enabled)) {
514  $sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut";
515  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
516  $sql .= ", s.code_client, s.code_compta, s.client";
517  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
518  $sql .= ", s.logo, s.email, s.entity";
519  $sql .= ", s.canvas";
520  $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
521  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
522  if (empty($user->rights->societe->client->voir) && !$socid) {
523  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
524  }
525  $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
526  $sql .= " AND f.fk_soc = s.rowid";
527  $sql .= " AND f.fk_statut = 0";
528  if ($socid) {
529  $sql .= " AND f.fk_soc = ".((int) $socid);
530  }
531  if (empty($user->rights->societe->client->voir) && !$socid) {
532  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
533  }
534 
535 
536  $resql = $db->query($sql);
537  if ($resql) {
538  $num = $db->num_rows($resql);
539  $nbofloop = min($num, $maxofloop);
540 
541  print '<div class="div-table-responsive-no-min">';
542  print '<table class="noborder centpercent">';
543  print '<tr class="liste_titre">';
544  print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
545 
546  if ($num) {
547  $i = 0;
548  while ($i < $nbofloop) {
549  $obj = $db->fetch_object($resql);
550 
551  $fichinterstatic->id=$obj->rowid;
552  $fichinterstatic->ref=$obj->ref;
553  $fichinterstatic->statut=$obj->fk_statut;
554 
555  $companystatic->id = $obj->socid;
556  $companystatic->name = $obj->name;
557  $companystatic->name_alias = $obj->name_alias;
558  $companystatic->code_client = $obj->code_client;
559  $companystatic->code_compta = $obj->code_compta;
560  $companystatic->client = $obj->client;
561  $companystatic->code_fournisseur = $obj->code_fournisseur;
562  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
563  $companystatic->fournisseur = $obj->fournisseur;
564  $companystatic->logo = $obj->logo;
565  $companystatic->email = $obj->email;
566  $companystatic->entity = $obj->entity;
567  $companystatic->canvas = $obj->canvas;
568 
569  print '<tr class="oddeven">';
570  print '<td class="nowraponall tdoverflowmax100">';
571  print $fichinterstatic->getNomUrl(1);
572  print "</td>";
573  print '<td class="nowrap tdoverflowmax100">';
574  print $companystatic->getNomUrl(1, 'customer');
575  print '</td></tr>';
576  $i++;
577  }
578  }
579  print "</table></div>";
580  }
581 }
582 
583 print '</div><div class="fichetwothirdright">';
584 
585 /*
586  * Last modified customers or prospects
587  */
588 if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
589  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
590  $sql .= ", s.code_client, s.code_compta, s.client";
591  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
592  $sql .= ", s.logo, s.email, s.entity";
593  $sql .= ", s.canvas";
594  $sql .= ", s.datec, s.tms";
595  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
596  if (empty($user->rights->societe->client->voir) && !$socid) {
597  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
598  }
599  $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
600  $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")";
601  if (empty($user->rights->societe->client->voir) && !$socid) {
602  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
603  }
604  // Add where from hooks
605  $parameters = array('socid' => $socid);
606  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
607  if (empty($reshook)) {
608  if ($socid > 0) {
609  $sql .= " AND s.rowid = ".((int) $socid);
610  }
611  }
612  $sql .= $hookmanager->resPrint;
613  $sql .= " ORDER BY s.tms DESC";
614  $sql .= $db->plimit($max, 0);
615 
616  $resql = $db->query($sql);
617  if ($resql) {
618  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
619  $header = "BoxTitleLastCustomersOrProspects";
620  } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
621  $header = "BoxTitleLastModifiedProspects";
622  } else {
623  $header = "BoxTitleLastModifiedCustomers";
624  }
625 
626  $num = $db->num_rows($resql);
627  startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c", 1);
628 
629  if ($num) {
630  $i = 0;
631 
632  while ($i < $num && $i < $max) {
633  $objp = $db->fetch_object($resql);
634 
635  $companystatic->id = $objp->socid;
636  $companystatic->name = $objp->name;
637  $companystatic->name_alias = $objp->name_alias;
638  $companystatic->code_client = $objp->code_client;
639  $companystatic->code_compta = $objp->code_compta;
640  $companystatic->client = $objp->client;
641  $companystatic->code_fournisseur = $objp->code_fournisseur;
642  $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
643  $companystatic->fournisseur = $objp->fournisseur;
644  $companystatic->logo = $objp->logo;
645  $companystatic->email = $objp->email;
646  $companystatic->entity = $objp->entity;
647  $companystatic->canvas = $objp->canvas;
648 
649  print '<tr class="oddeven">';
650  print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
651  print '<td class="nowrap">';
652  //print $companystatic->getLibCustProspStatut();
653 
654  $obj = $companystatic;
655  $s = '';
656  if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
657  $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
658  }
659  if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
660  $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
661  }
662  /*
663  if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur)
664  {
665  $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
666  }*/
667  print $s;
668 
669  print '</td>';
670 
671  $datem = $db->jdate($objp->tms);
672  print '<td class="right nowrap tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
673  print dol_print_date($datem, 'day', 'tzuserrel');
674  print '</td>';
675  print '</tr>';
676 
677  $i++;
678  }
679  }
680 
681  addSummaryTableLine(3, $num);
682  finishSimpleTable(true);
683 
684  $db->free($resql);
685  } else {
686  dol_print_error($db);
687  }
688 }
689 
690 
691 /*
692  * Last suppliers
693  */
694 if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) {
695  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
696  $sql .= ", s.code_client, s.code_compta, s.client";
697  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
698  $sql .= ", s.logo, s.email, s.entity";
699  $sql .= ", s.canvas";
700  $sql .= ", s.datec as dc, s.tms as dm";
701  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
702  if (empty($user->rights->societe->client->voir) && !$user->socid) {
703  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
704  }
705  $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
706  $sql .= " AND s.fournisseur = ".Societe::SUPPLIER;
707  if (empty($user->rights->societe->client->voir) && !$user->socid) {
708  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
709  }
710  // Add where from hooks
711  $parameters = array('socid' => $socid);
712  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
713  if (empty($reshook)) {
714  if ($socid > 0) {
715  $sql .= " AND s.rowid = ".((int) $socid);
716  }
717  }
718  $sql .= $hookmanager->resPrint;
719  $sql .= " ORDER BY s.datec DESC";
720  $sql .= $db->plimit($max, 0);
721 
722  $resql = $db->query($sql);
723  if ($resql) {
724  $num = $db->num_rows($resql);
725  startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f", 1);
726 
727  if ($num) {
728  $i = 0;
729  while ($i < $num && $i < $max) {
730  $objp = $db->fetch_object($resql);
731 
732  $companystatic->id = $objp->socid;
733  $companystatic->name = $objp->name;
734  $companystatic->name_alias = $objp->name_alias;
735  $companystatic->code_client = $objp->code_client;
736  $companystatic->code_compta = $objp->code_compta;
737  $companystatic->client = $objp->client;
738  $companystatic->code_fournisseur = $objp->code_fournisseur;
739  $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
740  $companystatic->fournisseur = $objp->fournisseur;
741  $companystatic->logo = $objp->logo;
742  $companystatic->email = $objp->email;
743  $companystatic->entity = $objp->entity;
744  $companystatic->canvas = $objp->canvas;
745 
746  print '<tr class="oddeven">';
747  print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
748  print '<td>';
749 
750  $obj = $companystatic;
751  $s = '';
752  /*if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
753  $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
754  }
755  if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
756  {
757  $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
758  }*/
759  if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) {
760  $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
761  }
762  print $s;
763 
764  print '</td>';
765 
766  $datem = $db->jdate($objp->dm);
767  print '<td class="right tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
768  print dol_print_date($datem, 'day', 'tzuserrel');
769  print '</td>';
770  print '</tr>';
771 
772  $i++;
773  }
774  }
775 
776  addSummaryTableLine(3, $num);
777  finishSimpleTable(true);
778 
779  $db->free($resql);
780  } else {
781  dol_print_error($db);
782  }
783 }
784 
785 
786 /*
787  * Last actions
788  */
789 /*if ($user->rights->agenda->myactions->read) {
790  show_array_last_actions_done($max);
791 }*/
792 
793 
794 /*
795  * Actions to do
796  */
797 /*if ($user->rights->agenda->myactions->read) {
798  show_array_actions_to_do($max);
799 }*/
800 
801 
802 /*
803  * Latest contracts
804  */
805 if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
806  $staticcontrat = new Contrat($db);
807 
808  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
809  $sql .= ", s.code_client, s.code_compta, s.client";
810  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
811  $sql .= ", s.logo, s.email, s.entity";
812  $sql .= ", s.canvas";
813  $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
814  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
815  $sql .= ", ".MAIN_DB_PREFIX."contrat as c";
816  $sql .= ", ".MAIN_DB_PREFIX."product as p";
817  if (empty($user->rights->societe->client->voir) && !$socid) {
818  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
819  }
820  $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")";
821  $sql .= " AND c.fk_soc = s.rowid";
822  $sql .= " AND c.fk_product = p.rowid";
823  if (empty($user->rights->societe->client->voir) && !$socid) {
824  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
825  }
826  if ($socid) {
827  $sql .= " AND s.rowid = ".((int) $socid);
828  }
829  $sql .= " ORDER BY c.tms DESC";
830  $sql .= $db->plimit($max + 1, 0);
831 
832  $resql = $db->query($sql);
833  if ($resql) {
834  $num = $db->num_rows($resql);
835  startSimpleTable($langs->trans("LastContracts", $max), "", "", 2);
836 
837  if ($num > 0) {
838  $i = 0;
839 
840  while ($i < $num) {
841  $obj = $db->fetch_object($resql);
842 
843  $companystatic->id = $obj->socid;
844  $companystatic->name = $obj->name;
845  $companystatic->name_alias = $obj->name_alias;
846  $companystatic->code_client = $obj->code_client;
847  $companystatic->code_compta = $obj->code_compta;
848  $companystatic->client = $obj->client;
849  $companystatic->code_fournisseur = $obj->code_fournisseur;
850  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
851  $companystatic->fournisseur = $obj->fournisseur;
852  $companystatic->logo = $obj->logo;
853  $companystatic->email = $obj->email;
854  $companystatic->entity = $obj->entity;
855  $companystatic->canvas = $obj->canvas;
856 
857  $staticcontrat->id = $obj->contratid;
858  $staticcontrat->ref = $obj->ref;
859 
860  print '<tr class="oddeven">';
861  print '<td class="nowraponall">'.$staticcontrat->getNomUrl(1).'</td>';
862  print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
863  print '<td class="right">'.$staticcontrat->LibStatut($obj->statut, 3).'</td>';
864  print '</tr>';
865 
866  $i++;
867  }
868  }
869 
870  addSummaryTableLine(2, $num);
871  finishSimpleTable(true);
872 
873  $db->free($resql);
874  } else {
875  dol_print_error($db);
876  }
877 }
878 
879 
880 /*
881  * Opened (validated) proposals
882  */
883 if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
884  $sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
885  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
886  $sql .= ", s.code_client, s.code_compta, s.client";
887  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
888  $sql .= ", s.logo, s.email, s.entity";
889  $sql .= ", s.canvas";
890  $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
891  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
892  if (empty($user->rights->societe->client->voir) && !$socid) {
893  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
894  }
895  $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
896  $sql .= " AND p.fk_soc = s.rowid";
897  $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
898  if (empty($user->rights->societe->client->voir) && !$socid) {
899  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
900  }
901  if ($socid) {
902  $sql .= " AND s.rowid = ".((int) $socid);
903  }
904  $sql .= " ORDER BY p.rowid DESC";
905 
906  $resql = $db->query($sql);
907  if ($resql) {
908  $total = $total_ttc = 0;
909  $num = $db->num_rows($resql);
910  $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
911  startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num);
912 
913  if ($num > 0) {
914  $i = 0;
915  $othernb = 0;
916 
917  while ($i < $nbofloop) {
918  $obj = $db->fetch_object($resql);
919 
920  if ($i >= $max) {
921  $othernb += 1;
922  $i++;
923  $total += $obj->total_ht;
924  $total_ttc += $obj->total_ttc;
925  continue;
926  }
927 
928  $propalstatic->id = $obj->propalid;
929  $propalstatic->ref = $obj->ref;
930  $propalstatic->ref_client = $obj->ref_client;
931  $propalstatic->total_ht = $obj->total_ht;
932  $propalstatic->total_tva = $obj->total_tva;
933  $propalstatic->total_ttc = $obj->total_ttc;
934 
935  $companystatic->id = $obj->socid;
936  $companystatic->name = $obj->name;
937  $companystatic->name_alias = $obj->name_alias;
938  $companystatic->code_client = $obj->code_client;
939  $companystatic->code_compta = $obj->code_compta;
940  $companystatic->client = $obj->client;
941  $companystatic->code_fournisseur = $obj->code_fournisseur;
942  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
943  $companystatic->fournisseur = $obj->fournisseur;
944  $companystatic->logo = $obj->logo;
945  $companystatic->email = $obj->email;
946  $companystatic->entity = $obj->entity;
947  $companystatic->canvas = $obj->canvas;
948 
949  $filename = dol_sanitizeFileName($obj->ref);
950  $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
951  //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
952  $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
953 
954  print '<tr class="oddeven">';
955 
956  print '<td class="nowrap" width="140">';
957  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
958  print '<td class="nobordernopadding nowraponall">'.$propalstatic->getNomUrl(1).'</td>';
959  print '<td width="18" class="nobordernopadding nowrap">'.$warning.'</td>';
960  print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
961  print '</tr>';
962  print '</table>';
963  print '</td>';
964 
965  print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
966  $datem = $db->jdate($obj->dp);
967  print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
968  print dol_print_date($datem, 'day', 'tzserver');
969  print '</td>';
970  print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
971  print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
972 
973  print '</tr>';
974 
975  $i++;
976  $total += $obj->total_ht;
977  $total_ttc += $obj->total_ttc;
978  }
979 
980  if ($othernb) {
981  print '<tr class="oddeven">';
982  print '<td class="nowrap" colspan="5">';
983  print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
984  print '</td>';
985  print "</tr>\n";
986  }
987  }
988 
989  addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "NoProposal", true);
990  finishSimpleTable(true);
991 
992  $db->free($resql);
993  } else {
994  dol_print_error($db);
995  }
996 }
997 
998 
999 /*
1000  * Opened (validated) order
1001  */
1002 if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
1003  $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
1004  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
1005  $sql .= ", s.code_client, s.code_compta, s.client";
1006  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1007  $sql .= ", s.logo, s.email, s.entity";
1008  $sql .= ", s.canvas";
1009  $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
1010  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
1011  if (empty($user->rights->societe->client->voir) && !$socid) {
1012  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1013  }
1014  $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
1015  $sql .= " AND c.fk_soc = s.rowid";
1016  $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
1017  if (empty($user->rights->societe->client->voir) && !$socid) {
1018  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1019  }
1020  if ($socid) {
1021  $sql .= " AND s.rowid = ".((int) $socid);
1022  }
1023  $sql .= " ORDER BY c.rowid DESC";
1024 
1025  $resql = $db->query($sql);
1026  if ($resql) {
1027  $total = $total_ttc = 0;
1028  $num = $db->num_rows($resql);
1029  $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
1030  startSimpleTable("OrdersOpened", "commande/list.php", "search_status=".Commande::STATUS_VALIDATED, 4, $num);
1031 
1032  if ($num > 0) {
1033  $i = 0;
1034  $othernb = 0;
1035 
1036  while ($i < $nbofloop) {
1037  $obj = $db->fetch_object($resql);
1038 
1039  if ($i >= $max) {
1040  $othernb += 1;
1041  $i++;
1042  $total += $obj->total_ht;
1043  $total_ttc += $obj->total_ttc;
1044  continue;
1045  }
1046 
1047  $orderstatic->id = $obj->commandeid;
1048  $orderstatic->ref = $obj->ref;
1049  $orderstatic->ref_client = $obj->ref_client;
1050  $orderstatic->statut = $obj->fk_statut;
1051  $orderstatic->total_ht = $obj->total_ht;
1052  $orderstatic->total_tva = $obj->total_tva;
1053  $orderstatic->total_ttc = $obj->total_ttc;
1054 
1055  $companystatic->id = $obj->socid;
1056  $companystatic->name = $obj->name;
1057  $companystatic->name_alias = $obj->name_alias;
1058  $companystatic->code_client = $obj->code_client;
1059  $companystatic->code_compta = $obj->code_compta;
1060  $companystatic->client = $obj->client;
1061  $companystatic->code_fournisseur = $obj->code_fournisseur;
1062  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1063  $companystatic->fournisseur = $obj->fournisseur;
1064  $companystatic->logo = $obj->logo;
1065  $companystatic->email = $obj->email;
1066  $companystatic->entity = $obj->entity;
1067  $companystatic->canvas = $obj->canvas;
1068 
1069  $filename = dol_sanitizeFileName($obj->ref);
1070  $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1071  //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
1072  //$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
1073 
1074  print '<tr class="oddeven">';
1075 
1076  print '<td class="nowrap" width="140">';
1077  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1078  print '<td class="nobordernopadding nowraponall">'.$orderstatic->getNomUrl(1).'</td>';
1079  print '<td width="18" class="nobordernopadding nowrap"></td>';
1080  print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).'</td>';
1081  print '</tr>';
1082  print '</table>';
1083  print '</td>';
1084 
1085  print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
1086  $datem = $db->jdate($obj->dv);
1087  print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("DateValue").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
1088  print dol_print_date($datem, 'day', 'tzserver');
1089  print '</td>';
1090 
1091  print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
1092  print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'</td>';
1093 
1094  print '</tr>';
1095 
1096  $i++;
1097  $total += $obj->total_ht;
1098  $total_ttc += $obj->total_ttc;
1099  }
1100 
1101  if ($othernb) {
1102  print '<tr class="oddeven">';
1103  print '<td class="nowrap" colspan="5">';
1104  print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
1105  print '</td>';
1106  print "</tr>\n";
1107  }
1108  }
1109 
1110  addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "None", true);
1111  finishSimpleTable(true);
1112 
1113  $db->free($resql);
1114  } else {
1115  dol_print_error($db);
1116  }
1117 }
1118 
1119 print '</div>';
1120 print '</div>';
1121 
1122 $parameters = array('user' => $user);
1123 $reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
1124 
1125 // End of page
1126 llxFooter();
1127 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
Societe\PROSPECT
const PROSPECT
Third party is a prospect.
Definition: societe.class.php:819
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
dol_substr
dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0)
Make a substring.
Definition: functions.lib.php:3766
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
Societe\CUSTOMER_AND_PROSPECT
const CUSTOMER_AND_PROSPECT
Third party is a customer and a prospect.
Definition: societe.class.php:824
Commande\STATUS_SHIPMENTONPROCESS
const STATUS_SHIPMENTONPROCESS
Shipment on process.
Definition: commande.class.php:389
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
addSummaryTableLine
addSummaryTableLine($tableColumnCount, $num, $nbofloop=0, $total=0, $noneWord="None", $extraRightColumn=false)
Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx")
Definition: functions.lib.php:10987
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
finishSimpleTable
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
Definition: functions.lib.php:10966
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
Propal\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: propal.class.php:352
Commande\STATUS_VALIDATED
const STATUS_VALIDATED
Validated status.
Definition: commande.class.php:385
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
getCustomerOrderPieChart
getCustomerOrderPieChart($socid=0)
Return a HTML table that contains a pie chart of customer orders.
Definition: order.lib.php:183
Commande
Class to manage customers orders.
Definition: commande.class.php:46
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
Fichinter
Class to manage interventions.
Definition: fichinter.class.php:37
Commande\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: commande.class.php:381
Contrat
Class to manage contracts.
Definition: contrat.class.php:43
CommandeFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.commande.class.php:47
CommandeFournisseur\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: fournisseur.commande.class.php:268
getCustomerProposalPieChart
getCustomerProposalPieChart($socid=0)
Return a HTML table that contains a pie chart of customer proposals.
Definition: propal.lib.php:164
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
startSimpleTable
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
Definition: functions.lib.php:10906
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
Propal
Class to manage proposals.
Definition: propal.class.php:52
SupplierProposal
Class to manage price ask supplier.
Definition: supplier_proposal.class.php:50
SupplierProposal\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: supplier_proposal.class.php:200
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30