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