dolibarr  17.0.2
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("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || 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->rights->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";
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="nowraponall tdoverflowmax100">';
576  print $fichinterstatic->getNomUrl(1);
577  print "</td>";
578  print '<td class="nowrap tdoverflowmax100">';
579  print $companystatic->getNomUrl(1, 'customer');
580  print '</td></tr>';
581  $i++;
582  }
583  }
584 
585  addSummaryTableLine(3, $num, $nbofloop, $total, "NoIntervention");
586  finishSimpleTable(true);
587 
588  print "</table></div>";
589  }
590 }
591 
592 print '</div><div class="fichetwothirdright">';
593 
594 /*
595  * Last modified customers or prospects
596  */
597 if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) {
598  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
599  $sql .= ", s.code_client, s.code_compta, s.client";
600  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
601  $sql .= ", s.logo, s.email, s.entity";
602  $sql .= ", s.canvas";
603  $sql .= ", s.datec, s.tms";
604  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
605  if (empty($user->rights->societe->client->voir) && !$socid) {
606  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
607  }
608  $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
609  $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")";
610  if (empty($user->rights->societe->client->voir) && !$socid) {
611  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
612  }
613  // Add where from hooks
614  $parameters = array('socid' => $socid);
615  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
616  if (empty($reshook)) {
617  if ($socid > 0) {
618  $sql .= " AND s.rowid = ".((int) $socid);
619  }
620  }
621  $sql .= $hookmanager->resPrint;
622  $sql .= " ORDER BY s.tms DESC";
623  $sql .= $db->plimit($max, 0);
624 
625  $resql = $db->query($sql);
626  if ($resql) {
627  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
628  $header = "BoxTitleLastCustomersOrProspects";
629  } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
630  $header = "BoxTitleLastModifiedProspects";
631  } else {
632  $header = "BoxTitleLastModifiedCustomers";
633  }
634 
635  $num = $db->num_rows($resql);
636  startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c", 1);
637 
638  if ($num) {
639  $i = 0;
640 
641  while ($i < $num && $i < $max) {
642  $objp = $db->fetch_object($resql);
643 
644  $companystatic->id = $objp->socid;
645  $companystatic->name = $objp->name;
646  $companystatic->name_alias = $objp->name_alias;
647  $companystatic->code_client = $objp->code_client;
648  $companystatic->code_compta = $objp->code_compta;
649  $companystatic->client = $objp->client;
650  $companystatic->code_fournisseur = $objp->code_fournisseur;
651  $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
652  $companystatic->fournisseur = $objp->fournisseur;
653  $companystatic->logo = $objp->logo;
654  $companystatic->email = $objp->email;
655  $companystatic->entity = $objp->entity;
656  $companystatic->canvas = $objp->canvas;
657 
658  print '<tr class="oddeven">';
659  print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
660  print '<td class="nowrap">';
661  //print $companystatic->getLibCustProspStatut();
662 
663  $obj = $companystatic;
664  $s = '';
665  if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
666  $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>';
667  }
668  if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
669  $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>';
670  }
671  /*
672  if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur)
673  {
674  $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>';
675  }*/
676  print $s;
677 
678  print '</td>';
679 
680  $datem = $db->jdate($objp->tms);
681  print '<td class="right nowrap tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
682  print dol_print_date($datem, 'day', 'tzuserrel');
683  print '</td>';
684  print '</tr>';
685 
686  $i++;
687  }
688  }
689 
690  addSummaryTableLine(3, $num);
691  finishSimpleTable(true);
692 
693  $db->free($resql);
694  } else {
695  dol_print_error($db);
696  }
697 }
698 
699 
700 /*
701  * Last suppliers
702  */
703 if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) {
704  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
705  $sql .= ", s.code_client, s.code_compta, s.client";
706  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
707  $sql .= ", s.logo, s.email, s.entity";
708  $sql .= ", s.canvas";
709  $sql .= ", s.datec as dc, s.tms as dm";
710  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
711  if (empty($user->rights->societe->client->voir) && !$user->socid) {
712  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
713  }
714  $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
715  $sql .= " AND s.fournisseur = ".Societe::SUPPLIER;
716  if (empty($user->rights->societe->client->voir) && !$user->socid) {
717  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
718  }
719  // Add where from hooks
720  $parameters = array('socid' => $socid);
721  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
722  if (empty($reshook)) {
723  if ($socid > 0) {
724  $sql .= " AND s.rowid = ".((int) $socid);
725  }
726  }
727  $sql .= $hookmanager->resPrint;
728  $sql .= " ORDER BY s.datec DESC";
729  $sql .= $db->plimit($max, 0);
730 
731  $resql = $db->query($sql);
732  if ($resql) {
733  $num = $db->num_rows($resql);
734  startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f", 1);
735 
736  if ($num) {
737  $i = 0;
738  while ($i < $num && $i < $max) {
739  $objp = $db->fetch_object($resql);
740 
741  $companystatic->id = $objp->socid;
742  $companystatic->name = $objp->name;
743  $companystatic->name_alias = $objp->name_alias;
744  $companystatic->code_client = $objp->code_client;
745  $companystatic->code_compta = $objp->code_compta;
746  $companystatic->client = $objp->client;
747  $companystatic->code_fournisseur = $objp->code_fournisseur;
748  $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
749  $companystatic->fournisseur = $objp->fournisseur;
750  $companystatic->logo = $objp->logo;
751  $companystatic->email = $objp->email;
752  $companystatic->entity = $objp->entity;
753  $companystatic->canvas = $objp->canvas;
754 
755  print '<tr class="oddeven">';
756  print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
757  print '<td>';
758 
759  $obj = $companystatic;
760  $s = '';
761  /*if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
762  $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>';
763  }
764  if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
765  {
766  $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>';
767  }*/
768  if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) {
769  $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>';
770  }
771  print $s;
772 
773  print '</td>';
774 
775  $datem = $db->jdate($objp->dm);
776  print '<td class="right tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
777  print dol_print_date($datem, 'day', 'tzuserrel');
778  print '</td>';
779  print '</tr>';
780 
781  $i++;
782  }
783  }
784 
785  addSummaryTableLine(3, $num);
786  finishSimpleTable(true);
787 
788  $db->free($resql);
789  } else {
790  dol_print_error($db);
791  }
792 }
793 
794 
795 /*
796  * Last actions
797  */
798 /*if ($user->rights->agenda->myactions->read) {
799  show_array_last_actions_done($max);
800 }*/
801 
802 
803 /*
804  * Actions to do
805  */
806 /*if ($user->rights->agenda->myactions->read) {
807  show_array_actions_to_do($max);
808 }*/
809 
810 
811 /*
812  * Latest contracts
813  */
814 if (isModEnabled('contrat') && $user->hasRight("contrat", "lire") && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
815  $staticcontrat = new Contrat($db);
816 
817  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
818  $sql .= ", s.code_client, s.code_compta, s.client";
819  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
820  $sql .= ", s.logo, s.email, s.entity";
821  $sql .= ", s.canvas";
822  $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
823  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
824  $sql .= ", ".MAIN_DB_PREFIX."contrat as c";
825  $sql .= ", ".MAIN_DB_PREFIX."product as p";
826  if (empty($user->rights->societe->client->voir) && !$socid) {
827  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
828  }
829  $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")";
830  $sql .= " AND c.fk_soc = s.rowid";
831  $sql .= " AND c.fk_product = p.rowid";
832  if (empty($user->rights->societe->client->voir) && !$socid) {
833  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
834  }
835  if ($socid) {
836  $sql .= " AND s.rowid = ".((int) $socid);
837  }
838  $sql .= " ORDER BY c.tms DESC";
839  $sql .= $db->plimit($max + 1, 0);
840 
841  $resql = $db->query($sql);
842  if ($resql) {
843  $num = $db->num_rows($resql);
844  startSimpleTable($langs->trans("LastContracts", $max), "", "", 2);
845 
846  if ($num > 0) {
847  $i = 0;
848 
849  while ($i < $num) {
850  $obj = $db->fetch_object($resql);
851 
852  $companystatic->id = $obj->socid;
853  $companystatic->name = $obj->name;
854  $companystatic->name_alias = $obj->name_alias;
855  $companystatic->code_client = $obj->code_client;
856  $companystatic->code_compta = $obj->code_compta;
857  $companystatic->client = $obj->client;
858  $companystatic->code_fournisseur = $obj->code_fournisseur;
859  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
860  $companystatic->fournisseur = $obj->fournisseur;
861  $companystatic->logo = $obj->logo;
862  $companystatic->email = $obj->email;
863  $companystatic->entity = $obj->entity;
864  $companystatic->canvas = $obj->canvas;
865 
866  $staticcontrat->id = $obj->contratid;
867  $staticcontrat->ref = $obj->ref;
868 
869  print '<tr class="oddeven">';
870  print '<td class="nowraponall">'.$staticcontrat->getNomUrl(1).'</td>';
871  print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
872  print '<td class="right">'.$staticcontrat->LibStatut($obj->statut, 3).'</td>';
873  print '</tr>';
874 
875  $i++;
876  }
877  }
878 
879  addSummaryTableLine(2, $num);
880  finishSimpleTable(true);
881 
882  $db->free($resql);
883  } else {
884  dol_print_error($db);
885  }
886 }
887 
888 
889 /*
890  * Opened (validated) proposals
891  */
892 if (isModEnabled("propal") && $user->hasRight("propal", "lire")) {
893  $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";
894  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
895  $sql .= ", s.code_client, s.code_compta, s.client";
896  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
897  $sql .= ", s.logo, s.email, s.entity";
898  $sql .= ", s.canvas";
899  $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
900  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
901  if (empty($user->rights->societe->client->voir) && !$socid) {
902  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
903  }
904  $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
905  $sql .= " AND p.fk_soc = s.rowid";
906  $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
907  if (empty($user->rights->societe->client->voir) && !$socid) {
908  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
909  }
910  if ($socid) {
911  $sql .= " AND s.rowid = ".((int) $socid);
912  }
913  $sql .= " ORDER BY p.rowid DESC";
914 
915  $resql = $db->query($sql);
916  if ($resql) {
917  $total = $total_ttc = 0;
918  $num = $db->num_rows($resql);
919  $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
920  startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num);
921 
922  if ($num > 0) {
923  $i = 0;
924  $othernb = 0;
925 
926  while ($i < $nbofloop) {
927  $obj = $db->fetch_object($resql);
928 
929  if ($i >= $max) {
930  $othernb += 1;
931  $i++;
932  $total += $obj->total_ht;
933  $total_ttc += $obj->total_ttc;
934  continue;
935  }
936 
937  $propalstatic->id = $obj->propalid;
938  $propalstatic->ref = $obj->ref;
939  $propalstatic->ref_client = $obj->ref_client;
940  $propalstatic->total_ht = $obj->total_ht;
941  $propalstatic->total_tva = $obj->total_tva;
942  $propalstatic->total_ttc = $obj->total_ttc;
943 
944  $companystatic->id = $obj->socid;
945  $companystatic->name = $obj->name;
946  $companystatic->name_alias = $obj->name_alias;
947  $companystatic->code_client = $obj->code_client;
948  $companystatic->code_compta = $obj->code_compta;
949  $companystatic->client = $obj->client;
950  $companystatic->code_fournisseur = $obj->code_fournisseur;
951  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
952  $companystatic->fournisseur = $obj->fournisseur;
953  $companystatic->logo = $obj->logo;
954  $companystatic->email = $obj->email;
955  $companystatic->entity = $obj->entity;
956  $companystatic->canvas = $obj->canvas;
957 
958  $filename = dol_sanitizeFileName($obj->ref);
959  $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
960  //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
961  $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
962 
963  print '<tr class="oddeven">';
964 
965  print '<td class="nowrap" width="140">';
966  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
967  print '<td class="nobordernopadding nowraponall">'.$propalstatic->getNomUrl(1).'</td>';
968  print '<td width="18" class="nobordernopadding nowrap">'.$warning.'</td>';
969  print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
970  print '</tr>';
971  print '</table>';
972  print '</td>';
973 
974  print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
975  $datem = $db->jdate($obj->dp);
976  print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
977  print dol_print_date($datem, 'day', 'tzserver');
978  print '</td>';
979  print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
980  print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
981 
982  print '</tr>';
983 
984  $i++;
985  $total += $obj->total_ht;
986  $total_ttc += $obj->total_ttc;
987  }
988 
989  if ($othernb) {
990  print '<tr class="oddeven">';
991  print '<td class="nowrap" colspan="5">';
992  print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
993  print '</td>';
994  print "</tr>\n";
995  }
996  }
997 
998  addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "NoProposal", true);
999  finishSimpleTable(true);
1000 
1001  $db->free($resql);
1002  } else {
1003  dol_print_error($db);
1004  }
1005 }
1006 
1007 
1008 /*
1009  * Opened (validated) order
1010  */
1011 if (isModEnabled('commande') && $user->rights->commande->lire) {
1012  $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";
1013  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
1014  $sql .= ", s.code_client, s.code_compta, s.client";
1015  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1016  $sql .= ", s.logo, s.email, s.entity";
1017  $sql .= ", s.canvas";
1018  $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
1019  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
1020  if (empty($user->rights->societe->client->voir) && !$socid) {
1021  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1022  }
1023  $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
1024  $sql .= " AND c.fk_soc = s.rowid";
1025  $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
1026  if (empty($user->rights->societe->client->voir) && !$socid) {
1027  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1028  }
1029  if ($socid) {
1030  $sql .= " AND s.rowid = ".((int) $socid);
1031  }
1032  $sql .= " ORDER BY c.rowid DESC";
1033 
1034  $resql = $db->query($sql);
1035  if ($resql) {
1036  $total = $total_ttc = 0;
1037  $num = $db->num_rows($resql);
1038  $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
1039  startSimpleTable("OrdersOpened", "commande/list.php", "search_status=".Commande::STATUS_VALIDATED, 4, $num);
1040 
1041  if ($num > 0) {
1042  $i = 0;
1043  $othernb = 0;
1044 
1045  while ($i < $nbofloop) {
1046  $obj = $db->fetch_object($resql);
1047 
1048  if ($i >= $max) {
1049  $othernb += 1;
1050  $i++;
1051  $total += $obj->total_ht;
1052  $total_ttc += $obj->total_ttc;
1053  continue;
1054  }
1055 
1056  $orderstatic->id = $obj->commandeid;
1057  $orderstatic->ref = $obj->ref;
1058  $orderstatic->ref_client = $obj->ref_client;
1059  $orderstatic->statut = $obj->fk_statut;
1060  $orderstatic->total_ht = $obj->total_ht;
1061  $orderstatic->total_tva = $obj->total_tva;
1062  $orderstatic->total_ttc = $obj->total_ttc;
1063 
1064  $companystatic->id = $obj->socid;
1065  $companystatic->name = $obj->name;
1066  $companystatic->name_alias = $obj->name_alias;
1067  $companystatic->code_client = $obj->code_client;
1068  $companystatic->code_compta = $obj->code_compta;
1069  $companystatic->client = $obj->client;
1070  $companystatic->code_fournisseur = $obj->code_fournisseur;
1071  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1072  $companystatic->fournisseur = $obj->fournisseur;
1073  $companystatic->logo = $obj->logo;
1074  $companystatic->email = $obj->email;
1075  $companystatic->entity = $obj->entity;
1076  $companystatic->canvas = $obj->canvas;
1077 
1078  $filename = dol_sanitizeFileName($obj->ref);
1079  $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1080  //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
1081  //$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
1082 
1083  print '<tr class="oddeven">';
1084 
1085  print '<td class="nowrap" width="140">';
1086  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1087  print '<td class="nobordernopadding nowraponall">'.$orderstatic->getNomUrl(1).'</td>';
1088  print '<td width="18" class="nobordernopadding nowrap"></td>';
1089  print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).'</td>';
1090  print '</tr>';
1091  print '</table>';
1092  print '</td>';
1093 
1094  print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
1095  $datem = $db->jdate($obj->dv);
1096  print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("DateValue").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
1097  print dol_print_date($datem, 'day', 'tzserver');
1098  print '</td>';
1099 
1100  print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
1101  print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'</td>';
1102 
1103  print '</tr>';
1104 
1105  $i++;
1106  $total += $obj->total_ht;
1107  $total_ttc += $obj->total_ttc;
1108  }
1109 
1110  if ($othernb) {
1111  print '<tr class="oddeven">';
1112  print '<td class="nowrap" colspan="5">';
1113  print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
1114  print '</td>';
1115  print "</tr>\n";
1116  }
1117  }
1118 
1119  addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "None", true);
1120  finishSimpleTable(true);
1121 
1122  $db->free($resql);
1123  } else {
1124  dol_print_error($db);
1125  }
1126 }
1127 
1128 print '</div>';
1129 print '</div>';
1130 
1131 $parameters = array('user' => $user);
1132 $reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
1133 
1134 // End of page
1135 llxFooter();
1136 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:49
Societe\PROSPECT
const PROSPECT
Third party type is a prospect.
Definition: societe.class.php:824
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1225
dol_substr
dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0)
Make a substring.
Definition: functions.lib.php:3910
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5360
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:520
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:4993
Societe\CUSTOMER_AND_PROSPECT
const CUSTOMER_AND_PROSPECT
Third party type is a customer and a prospect.
Definition: societe.class.php:829
Commande\STATUS_SHIPMENTONPROCESS
const STATUS_SHIPMENTONPROCESS
Shipment on process.
Definition: commande.class.php:382
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4670
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:11415
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
finishSimpleTable
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
Definition: functions.lib.php:11394
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:2550
Propal\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: propal.class.php:357
Commande\STATUS_VALIDATED
const STATUS_VALIDATED
Validated status.
Definition: commande.class.php:378
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 sales orders.
Definition: order.lib.php:197
$resql
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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)) $resql
Social contributions to pay.
Definition: index.php:745
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:374
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:137
Contrat
Class to manage contracts.
Definition: contrat.class.php:43
CommandeFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.commande.class.php:48
CommandeFournisseur\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: fournisseur.commande.class.php:269
Fichinter\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: fichinter.class.php:169
getCustomerProposalPieChart
getCustomerProposalPieChart($socid=0)
Return a HTML table that contains a pie chart of customer proposals.
Definition: propal.lib.php:178
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
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:11334
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2951
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1117
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