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