dolibarr 24.0.0-beta
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@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 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
44require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
45require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
46require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
47require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
48require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
51if (isModEnabled('contract')) {
52 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
53}
54if (isModEnabled('intervention')) {
55 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
56}
57
58
59// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
60$hookmanager->initHooks(array('commercialindex'));
61
62// Load translation files required by the page
63$langs->loadLangs(array("boxes", "commercial", "contracts", "orders", "propal", "supplier_proposal"));
64
65$action = GETPOST('action', 'aZ09');
66$bid = GETPOSTINT('bid');
67
68// Securite access client
69$socid = GETPOSTINT('socid');
70if (!empty($user->socid) && $user->socid > 0) {
71 $action = '';
72 $socid = $user->socid;
73}
74
75$total = 0;
76
77$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
78$maxofloop = getDolGlobalInt('MAIN_MAXLIST_OVERLOAD', 500);
79$now = dol_now();
80
81//restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
82if (!$user->hasRight('propal', 'read') && !$user->hasRight('supplier_proposal', 'read') && !$user->hasRight('commande', 'read') && !$user->hasRight('fournisseur', 'commande', 'read')
83 && !$user->hasRight('supplier_order', 'read') && !$user->hasRight('fichinter', 'read') && !$user->hasRight('contrat', 'read')) {
85}
86
87
88
89/*
90 * Actions
91 */
92
93// None
94
95
96/*
97 * View
98 */
99
100$form = new Form($db);
101$formfile = new FormFile($db);
102$companystatic = new Societe($db);
103$propalstatic = null;
104$supplierproposalstatic = null;
105$orderstatic = null;
106$supplierorderstatic = null;
107$fichinterstatic = null;
108if (isModEnabled("propal")) {
109 $propalstatic = new Propal($db);
110}
111if (isModEnabled('supplier_proposal')) {
112 $supplierproposalstatic = new SupplierProposal($db);
113}
114if (isModEnabled('order')) {
115 $orderstatic = new Commande($db);
116}
117if (isModEnabled("supplier_order")) {
118 $supplierorderstatic = new CommandeFournisseur($db);
119}
120
121if (isModEnabled('intervention')) {
122 $fichinterstatic = new Fichinter($db);
123}
124
125llxHeader("", $langs->trans("CommercialArea"));
126
127print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial');
128
129print '<div class="fichecenter">';
130
131print '<div class="twocolumns">';
132
133print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
134
135
136$tmp = getCustomerProposalPieChart($socid);
137if ($tmp) {
138 print $tmp;
139}
140$tmp = getCustomerOrderPieChart($socid);
141if ($tmp) {
142 print $tmp;
143}
144
145/*
146 * Draft customer proposals
147 */
148
149if (isModEnabled("propal") && $user->hasRight("propal", "lire") && is_object($propalstatic)) {
150 $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
151 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
152 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
153 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
154 $sql .= ", s.logo, s.email, s.entity";
155 $sql .= ", s.canvas";
156 $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,";
157 $sql .= " ".MAIN_DB_PREFIX."societe as s";
158 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
159 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
160 }
161 $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
162 $sql .= " AND p.fk_soc = s.rowid";
163 $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT;
164 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
165 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
166 }
167 if ($socid) {
168 $sql .= " AND s.rowid = ".((int) $socid);
169 }
170 // Add where from hooks
171 $parameters = array('socid' => $user->socid);
172 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $propalstatic); // Note that $action and $object may have been modified by hook
173 $sql .= $hookmanager->resPrint;
174
175 $resql = $db->query($sql);
176 if ($resql) {
177 $total = 0;
178 $num = $db->num_rows($resql);
179 $nbofloop = min($num, $maxofloop);
180 startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num);
181
182 if ($num > 0) {
183 $i = 0;
184 $othernb = 0;
185
186 while ($i < $nbofloop) {
187 $obj = $db->fetch_object($resql);
188
189 if ($i >= $max) {
190 $othernb++;
191 $i++;
192 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
193 continue;
194 }
195
196 $propalstatic->id = $obj->rowid;
197 $propalstatic->ref = $obj->ref;
198 $propalstatic->ref_client = $obj->ref_client;
199 $propalstatic->ref_customer = $obj->ref_client;
200 $propalstatic->total_ht = $obj->total_ht;
201 $propalstatic->total_tva = $obj->total_tva;
202 $propalstatic->total_ttc = $obj->total_ttc;
203 $propalstatic->statut = $obj->status; // deprecated
204 $propalstatic->status = $obj->status;
205
206 $companystatic->id = $obj->socid;
207 $companystatic->name = $obj->name;
208 $companystatic->name_alias = $obj->name_alias;
209 $companystatic->code_client = $obj->code_client;
210 $companystatic->code_compta = $obj->code_compta_client;
211 $companystatic->code_compta_client = $obj->code_compta_client;
212 $companystatic->client = $obj->client;
213 $companystatic->code_fournisseur = $obj->code_fournisseur;
214 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
215 $companystatic->fournisseur = $obj->fournisseur;
216 $companystatic->logo = $obj->logo;
217 $companystatic->email = $obj->email;
218 $companystatic->entity = $obj->entity;
219 $companystatic->canvas = $obj->canvas;
220
221 print '<tr class="oddeven">';
222 print '<td class="nowraponall tdoverflowmax125 minwidth75">'.$propalstatic->getNomUrl(1).'</td>';
223 print '<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1, 'customer').'</td>';
224 print '<td class="nowrap right tdamount amount">'.price((getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc)).'</td>';
225 print '</tr>';
226
227 $i++;
228 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
229 }
230
231 if ($othernb) {
232 print '<tr class="oddeven">';
233 print '<td class="nowrap" colspan="5">';
234 print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
235 print '</td>';
236 print "</tr>\n";
237 }
238 }
239
240 addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
241 finishSimpleTable(true);
242
243 $db->free($resql);
244 } else {
246 }
247}
248
249
250/*
251 * Draft supplier proposals
252 */
253
254if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "lire") && is_object($supplierproposalstatic)) {
255 $sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
256 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
257 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
258 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
259 $sql .= ", s.logo, s.email, s.entity";
260 $sql .= ", s.canvas";
261 $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,";
262 $sql .= " ".MAIN_DB_PREFIX."societe as s";
263 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
264 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
265 }
266 $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")";
267 $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
268 $sql .= " AND p.fk_soc = s.rowid";
269 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
270 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
271 }
272 if ($socid) {
273 $sql .= " AND s.rowid = ".((int) $socid);
274 }
275 // Add where from hooks
276 $parameters = array('socid' => $user->socid);
277 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $supplierproposalstatic); // Note that $action and $object may have been modified by hook
278 $sql .= $hookmanager->resPrint;
279 $resql = $db->query($sql);
280 if ($resql) {
281 $total = 0;
282 $num = $db->num_rows($resql);
283 $nbofloop = min($num, $maxofloop);
284 startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=".SupplierProposal::STATUS_DRAFT, 2, $num);
285
286 if ($num > 0) {
287 $i = 0;
288 $othernb = 0;
289
290 while ($i < $nbofloop) {
291 $obj = $db->fetch_object($resql);
292
293 if ($i >= $max) {
294 $othernb += 1;
295 $i++;
296 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
297 continue;
298 }
299
300 $supplierproposalstatic->id = $obj->rowid;
301 $supplierproposalstatic->ref = $obj->ref;
302 $supplierproposalstatic->total_ht = $obj->total_ht;
303 $supplierproposalstatic->total_tva = $obj->total_tva;
304 $supplierproposalstatic->total_ttc = $obj->total_ttc;
305 $supplierproposalstatic->statut = $obj->status;
306 $supplierproposalstatic->status = $obj->status;
307
308 $companystatic->id = $obj->socid;
309 $companystatic->name = $obj->name;
310 $companystatic->name_alias = $obj->name_alias;
311 $companystatic->code_client = $obj->code_client;
312 $companystatic->code_compta_client = $obj->code_compta_client;
313 $companystatic->client = $obj->client;
314 $companystatic->code_fournisseur = $obj->code_fournisseur;
315 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
316 $companystatic->fournisseur = $obj->fournisseur;
317 $companystatic->logo = $obj->logo;
318 $companystatic->email = $obj->email;
319 $companystatic->entity = $obj->entity;
320 $companystatic->canvas = $obj->canvas;
321
322 print '<tr class="oddeven">';
323 print '<td class="nowraponall tdoverflowmax125 minwidth75">'.$supplierproposalstatic->getNomUrl(1).'</td>';
324 print '<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
325 print '<td class="nowrap right tdamount amount">'.price(getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).'</td>';
326 print '</tr>';
327
328 $i++;
329 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
330 }
331
332 if ($othernb) {
333 print '<tr class="oddeven">';
334 print '<td class="nowrap" colspan="5">';
335 print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
336 print '</td>';
337 print "</tr>\n";
338 }
339 }
340
341 addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
342 finishSimpleTable(true);
343
344 $db->free($resql);
345 } else {
347 }
348}
349
350
351/*
352 * Draft sales orders
353 */
354
355if (isModEnabled('order') && $user->hasRight('commande', 'lire') && is_object($orderstatic)) {
356 $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
357 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
358 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
359 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
360 $sql .= ", s.logo, s.email, s.entity";
361 $sql .= ", s.canvas";
362 $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
363 $sql .= " ".MAIN_DB_PREFIX."societe as s";
364 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
365 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
366 }
367 $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
368 $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT;
369 $sql .= " AND c.fk_soc = s.rowid";
370 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
371 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
372 }
373 if ($socid) {
374 $sql .= " AND c.fk_soc = ".((int) $socid);
375 }
376 // Add where from hooks
377 $parameters = array('socid' => $user->socid);
378 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $orderstatic); // Note that $action and $object may have been modified by hook
379 $sql .= $hookmanager->resPrint;
380 $resql = $db->query($sql);
381 if ($resql) {
382 $total = 0;
383 $num = $db->num_rows($resql);
384 $nbofloop = min($num, $maxofloop);
385 startSimpleTable("DraftOrders", "commande/list.php", "search_status=".Commande::STATUS_DRAFT, 2, $num);
386
387 if ($num > 0) {
388 $i = 0;
389 $othernb = 0;
390
391 while ($i < $nbofloop) {
392 $obj = $db->fetch_object($resql);
393
394 if ($i >= $max) {
395 $othernb += 1;
396 $i++;
397 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
398 continue;
399 }
400
401 $orderstatic->id = $obj->rowid;
402 $orderstatic->ref = $obj->ref;
403 $orderstatic->ref_client = $obj->ref_client;
404 $orderstatic->total_ht = $obj->total_ht;
405 $orderstatic->total_tva = $obj->total_tva;
406 $orderstatic->total_ttc = $obj->total_ttc;
407 $orderstatic->statut = $obj->status; // deprecated
408 $orderstatic->status = $obj->status;
409
410 $companystatic->id = $obj->socid;
411 $companystatic->name = $obj->name;
412 $companystatic->name_alias = $obj->name_alias;
413 $companystatic->code_client = $obj->code_client;
414 $companystatic->code_compta = $obj->code_compta_client;
415 $companystatic->code_compta_client = $obj->code_compta_client;
416 $companystatic->client = $obj->client;
417 $companystatic->code_fournisseur = $obj->code_fournisseur;
418 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
419 $companystatic->fournisseur = $obj->fournisseur;
420 $companystatic->logo = $obj->logo;
421 $companystatic->email = $obj->email;
422 $companystatic->entity = $obj->entity;
423 $companystatic->canvas = $obj->canvas;
424
425 print '<tr class="oddeven">';
426 print '<td class="nowraponall tdoverflowmax125 minwidth75">'.$orderstatic->getNomUrl(1).'</td>';
427 print '<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1, 'customer').'</td>';
428 print '<td class="nowrap right tdamount amount">'.price(getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).'</td>';
429 print '</tr>';
430
431 $i++;
432 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
433 }
434
435 if ($othernb) {
436 print '<tr class="oddeven">';
437 print '<td class="nowrap" colspan="5">';
438 print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
439 print '</td>';
440 print "</tr>\n";
441 }
442 }
443
444 addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
445 finishSimpleTable(true);
446
447 $db->free($resql);
448 } else {
450 }
451}
452
453
454/*
455 * Draft purchase orders
456 */
457
458if ((isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "commande", "lire")) || (isModEnabled("supplier_order") && $user->hasRight("supplier_order", "lire"))) {
459 $supplierorderstatic = new CommandeFournisseur($db);
460
461 $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
462 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
463 $sql .= ", s.code_client, s.code_compta, s.client";
464 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
465 $sql .= ", s.logo, s.email, s.entity";
466 $sql .= ", s.canvas";
467 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
468 $sql .= " ".MAIN_DB_PREFIX."societe as s";
469 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
470 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
471 }
472 $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")";
473 $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
474 $sql .= " AND cf.fk_soc = s.rowid";
475 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
476 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
477 }
478 if ($socid) {
479 $sql .= " AND cf.fk_soc = ".((int) $socid);
480 }
481 // Add where from hooks
482 $parameters = array('socid' => $user->socid);
483 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $supplierorderstatic); // Note that $action and $object may have been modified by hook
484 $sql .= $hookmanager->resPrint;
485 $resql = $db->query($sql);
486 if ($resql) {
487 $total = 0;
488 $num = $db->num_rows($resql);
489 $nbofloop = min($num, $maxofloop);
490 startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=".CommandeFournisseur::STATUS_DRAFT, 2, $num);
491
492 if ($num > 0) {
493 $i = 0;
494 $othernb = 0;
495
496 while ($i < $nbofloop) {
497 $obj = $db->fetch_object($resql);
498
499 if ($i >= $max) {
500 $othernb += 1;
501 $i++;
502 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
503 continue;
504 }
505
506 $supplierorderstatic->id = $obj->rowid;
507 $supplierorderstatic->ref = $obj->ref;
508 $supplierorderstatic->ref_supplier = $obj->ref_supplier;
509 $supplierorderstatic->total_ht = $obj->total_ht;
510 $supplierorderstatic->total_tva = $obj->total_tva;
511 $supplierorderstatic->total_ttc = $obj->total_ttc;
512 $supplierorderstatic->statut = $obj->status; // deprecated
513 $supplierorderstatic->status = $obj->status;
514
515 $companystatic->id = $obj->socid;
516 $companystatic->name = $obj->name;
517 $companystatic->name_alias = $obj->name_alias;
518 $companystatic->code_client = $obj->code_client;
519 $companystatic->code_compta = $obj->code_compta;
520 $companystatic->code_compta_client = $obj->code_compta;
521 $companystatic->client = $obj->client;
522 $companystatic->code_fournisseur = $obj->code_fournisseur;
523 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
524 $companystatic->fournisseur = $obj->fournisseur;
525 $companystatic->logo = $obj->logo;
526 $companystatic->email = $obj->email;
527 $companystatic->entity = $obj->entity;
528 $companystatic->canvas = $obj->canvas;
529
530 print '<tr class="oddeven">';
531 print '<td class="nowraponall tdoverflowmax125 minwidth75">'.$supplierorderstatic->getNomUrl(1).'</td>';
532 print '<td class="nowrap tdoverflowmax250">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
533 print '<td class="nowrap right tdamount amount">'.price(getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).'</td>';
534 print '</tr>';
535
536 $i++;
537 $total += (getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
538 }
539
540 if ($othernb) {
541 print '<tr class="oddeven">';
542 print '<td class="nowrap" colspan="5">';
543 print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
544 print '</td>';
545 print "</tr>\n";
546 }
547 }
548
549 addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
550 finishSimpleTable(true);
551
552 $db->free($resql);
553 } else {
555 }
556}
557
558
559/*
560 * Draft interventions
561 */
562if (isModEnabled('intervention') && is_object($fichinterstatic)) {
563 $sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut, f.duree as duration";
564 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
565 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
566 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
567 $sql .= ", s.logo, s.email, s.entity";
568 $sql .= ", s.canvas";
569 $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
570 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
571 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
572 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
573 }
574 $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
575 $sql .= " AND f.fk_soc = s.rowid";
576 $sql .= " AND f.fk_statut = 0";
577 if ($socid) {
578 $sql .= " AND f.fk_soc = ".((int) $socid);
579 }
580 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
581 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
582 }
583
584 // Add where from hooks
585 $parameters = array('socid' => $user->socid);
586 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $fichinterstatic); // Note that $action and $object may have been modified by hook
587 $sql .= $hookmanager->resPrint;
588 $resql = $db->query($sql);
589 if ($resql) {
590 $num = $db->num_rows($resql);
591 $nbofloop = min($num, $maxofloop);
592 startSimpleTable("DraftFichinter", "fichinter/list.php", "search_status=".Fichinter::STATUS_DRAFT, 2, $num);
593
594 //print '<tr class="liste_titre">';
595 //print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
596
597 if ($num > 0) {
598 $i = 0;
599 while ($i < $nbofloop) {
600 $obj = $db->fetch_object($resql);
601
602 $fichinterstatic->id = $obj->rowid;
603 $fichinterstatic->ref = $obj->ref;
604 $fichinterstatic->statut = $obj->fk_statut; // deprecated
605 $fichinterstatic->status = $obj->fk_statut;
606
607 $companystatic->id = $obj->socid;
608 $companystatic->name = $obj->name;
609 $companystatic->name_alias = $obj->name_alias;
610 $companystatic->code_client = $obj->code_client;
611 $companystatic->code_compta = $obj->code_compta_client;
612 $companystatic->code_compta_client = $obj->code_compta_client;
613 $companystatic->client = $obj->client;
614 $companystatic->code_fournisseur = $obj->code_fournisseur;
615 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
616 $companystatic->fournisseur = $obj->fournisseur;
617 $companystatic->logo = $obj->logo;
618 $companystatic->email = $obj->email;
619 $companystatic->entity = $obj->entity;
620 $companystatic->canvas = $obj->canvas;
621
622 print '<tr class="oddeven">';
623 print '<td class="tdoverflowmax125 minwidth75">';
624 print $fichinterstatic->getNomUrl(1);
625 print "</td>";
626 print '<td class="tdoverflowmax250 minwidth100">';
627 print $companystatic->getNomUrl(1, 'customer');
628 print '</td>';
629 print '<td class="nowraponall tdoverflowmax100 right">';
630 print convertSecondToTime($obj->duration);
631 print '</td>';
632 print '</tr>';
633 $i++;
634 }
635 }
636
637 addSummaryTableLine(3, $num, $nbofloop, $total, "NoIntervention");
638 finishSimpleTable(true);
639
640 $db->free($resql);
641 }
642}
643
644
645print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
646
647
648/*
649 * Last modified customers or prospects
650 */
651/* Hidden, already into the menu thirdparty, and it is more relevant in this menu.
652if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) {
653 $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
654 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
655 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
656 $sql .= ", s.logo, s.email, s.entity";
657 $sql .= ", s.canvas";
658 $sql .= ", s.datec, s.tms";
659 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
660 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
661 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
662 }
663 $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
664 $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")";
665 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
666 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
667 }
668 // Add where from hooks
669 $parameters = array('socid' => $socid);
670 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
671 if (empty($reshook)) {
672 if ($socid > 0) {
673 $sql .= " AND s.rowid = ".((int) $socid);
674 }
675 }
676 $sql .= $hookmanager->resPrint;
677 $sql .= " ORDER BY s.tms DESC";
678 $sql .= $db->plimit($max, 0);
679
680 $resql = $db->query($sql);
681 if ($resql) {
682 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
683 $header = "BoxTitleLastCustomersOrProspects";
684 } elseif (getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
685 $header = "BoxTitleLastModifiedProspects";
686 } else {
687 $header = "BoxTitleLastModifiedCustomers";
688 }
689
690 $num = $db->num_rows($resql);
691 startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c&sortfield=s.tms&sortorder=DESC", 1, -1, 'company');
692
693 if ($num) {
694 $i = 0;
695
696 while ($i < $num && $i < $max) {
697 $objp = $db->fetch_object($resql);
698
699 $companystatic->id = $objp->socid;
700 $companystatic->name = $objp->name;
701 $companystatic->name_alias = $objp->name_alias;
702 $companystatic->code_client = $objp->code_client;
703 $companystatic->code_compta = $objp->code_compta_client;
704 $companystatic->code_compta_client = $objp->code_compta_client;
705 $companystatic->client = $objp->client;
706 $companystatic->code_fournisseur = $objp->code_fournisseur;
707 $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
708 $companystatic->fournisseur = $objp->fournisseur;
709 $companystatic->logo = $objp->logo;
710 $companystatic->email = $objp->email;
711 $companystatic->entity = $objp->entity;
712 $companystatic->canvas = $objp->canvas;
713
714 print '<tr class="oddeven">';
715 print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
716 print '<td class="nowrap">';
717 //print $companystatic->getLibCustProspStatut();
718
719 $obj = $companystatic;
720 $s = '';
721 if (($obj->client == 2 || $obj->client == 3) && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
722 $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>';
723 }
724 if (($obj->client == 1 || $obj->client == 3) && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
725 $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>';
726 }
727 print $s;
728
729 print '</td>';
730
731 $datem = $db->jdate($objp->tms);
732 print '<td class="right nowrap tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
733 print dol_print_date($datem, 'day', 'tzuserrel');
734 print '</td>';
735 print '</tr>';
736
737 $i++;
738 }
739 }
740
741 addSummaryTableLine(3, $num);
742 finishSimpleTable(true);
743
744 $db->free($resql);
745 } else {
746 dol_print_error($db);
747 }
748}
749*/
750
751
752/*
753 * Last modified proposals
754 */
755
756if (isModEnabled('propal') && is_object($propalstatic)) {
757 $sql = "SELECT p.rowid, p.entity, p.ref, p.fk_statut as status, p.tms as datem,";
758 $sql .= " s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client";
759 $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,";
760 $sql .= " ".MAIN_DB_PREFIX."societe as s";
761 $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
762 $sql .= " AND p.fk_soc = s.rowid";
763 // If the internal user must only see his customers, force searching by him
764 $search_sale = 0;
765 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
766 $search_sale = $user->id;
767 }
768 // Search on sale representative
769 if ($search_sale && $search_sale != '-1') {
770 if ($search_sale == -2) {
771 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
772 } elseif ($search_sale > 0) {
773 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
774 }
775 }
776 // Search on socid
777 if ($socid) {
778 $sql .= " AND p.fk_soc = ".((int) $socid);
779 }
780 // Add where from hooks
781 $parameters = array('socid' => $user->socid);
782 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $propalstatic); // Note that $action and $object may have been modified by hook
783 $sql .= $hookmanager->resPrint;
784 $sql .= " ORDER BY p.tms DESC";
785
786 $sql .= $db->plimit($max, 0);
787
788 $resql = $db->query($sql);
789 if ($resql) {
790 $num = $db->num_rows($resql);
791
792 startSimpleTable($langs->trans("LastModifiedProposals", $max), "comm/propal/list.php", "sortfield=p.tms&sortorder=DESC", 2, -1, 'propal');
793
794 if ($num) {
795 $i = 0;
796 while ($i < $num) {
797 $obj = $db->fetch_object($resql);
798
799 $propalstatic->id = $obj->rowid;
800 $propalstatic->ref = $obj->ref;
801 $propalstatic->status = $obj->status;
802
803 $companystatic->id = $obj->socid;
804 $companystatic->name = $obj->socname;
805 $companystatic->client = $obj->client;
806 $companystatic->canvas = $obj->canvas;
807 $companystatic->email = $obj->email;
808 $companystatic->code_compta = $obj->code_compta_client;
809 $companystatic->code_compta_client = $obj->code_compta_client;
810
811 $filename = dol_sanitizeFileName($obj->ref);
812 $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
813 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
814
815 print '<tr class="oddeven">';
816
817 print '<td class="nowrap">';
818 print '<table class="nobordernopadding">';
819 print '<tr class="nocellnopadd">';
820 print '<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).'</td>';
821 print '<td width="16" class="nobordernopadding nowrap"></td>';
822 print '<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
823 print '</tr>';
824 print '</table>';
825 print '</td>';
826
827 print '<td class="tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
828
829 $datem = $db->jdate($obj->datem);
830 print '<td class="center" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
831 print dol_print_date($datem, 'day', 'tzuserrel');
832 print '</td>';
833
834 print '<td class="right">'.$propalstatic->LibStatut($obj->status, 3).'</td>';
835
836 print '</tr>';
837
838 $i++;
839 }
840 }
841
842 finishSimpleTable(true);
843 $db->free($resql);
844 } else {
846 }
847}
848
849
850/*
851 * Latest modified orders
852 */
853
854if (isModEnabled('order')) {
855 $commandestatic = new Commande($db);
856
857 $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut as status, c.facture, c.date_cloture as datec, c.tms as datem,";
858 $sql .= " s.nom as name, s.rowid as socid";
859 $sql .= ", s.client";
860 $sql .= ", s.code_client";
861 $sql .= ", s.canvas";
862 $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
863 $sql .= " ".MAIN_DB_PREFIX."societe as s";
864 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
865 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
866 }
867 $sql .= " WHERE c.fk_soc = s.rowid";
868 $sql .= " AND c.entity IN (".getEntity('commande').")";
869 //$sql.= " AND c.fk_statut > 2";
870 if ($socid) {
871 $sql .= " AND c.fk_soc = ".((int) $socid);
872 }
873 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
874 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
875 }
876 // Add where from hooks
877 $parameters = array('socid' => $user->socid);
878 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $orderstatic); // Note that $action and $object may have been modified by hook
879 $sql .= $hookmanager->resPrint;
880 $sql .= " ORDER BY c.tms DESC";
881 $sql .= $db->plimit($max, 0);
882
883 $resql = $db->query($sql);
884 if ($resql) {
885 $num = $db->num_rows($resql);
886
887 startSimpleTable($langs->trans("LastModifiedOrders", $max), "commande/list.php", "sortfield=c.tms&sortorder=DESC", 2, -1, 'order');
888
889 if ($num) {
890 $i = 0;
891 while ($i < $num) {
892 $obj = $db->fetch_object($resql);
893
894 print '<tr class="oddeven">';
895 print '<td width="20%" class="nowrap">';
896
897 $commandestatic->id = $obj->rowid;
898 $commandestatic->ref = $obj->ref;
899
900 $companystatic->id = $obj->socid;
901 $companystatic->name = $obj->name;
902 $companystatic->client = $obj->client;
903 $companystatic->code_client = $obj->code_client;
904 $companystatic->canvas = $obj->canvas;
905
906 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
907 print '<td width="96" class="nobordernopadding nowrap">';
908 print $commandestatic->getNomUrl(1);
909 print '</td>';
910
911 print '<td width="16" class="nobordernopadding nowrap">';
912 print '&nbsp;';
913 print '</td>';
914
915 print '<td width="16" class="nobordernopadding hideonsmartphone right">';
916 $filename = dol_sanitizeFileName($obj->ref);
917 $filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
918 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
919 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
920 print '</td></tr></table>';
921
922 print '</td>';
923
924 print '<td class="nowrap">';
925 print $companystatic->getNomUrl(1, 'company', 16);
926 print '</td>';
927
928 $datem = $db->jdate($obj->datem);
929 print '<td class="center" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
930 print dol_print_date($datem, 'day', 'tzuserrel');
931 print '</td>';
932
933 print '<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).'</td>';
934 print '</tr>';
935 $i++;
936 }
937 }
938 finishSimpleTable(true);
939 } else {
941 }
942}
943
944
945/*
946 * Last suppliers
947 */
948/* Hidden, should be into the Thirdparty menu
949if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) {
950 $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
951 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
952 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
953 $sql .= ", s.logo, s.email, s.entity";
954 $sql .= ", s.canvas";
955 $sql .= ", s.datec as dc, s.tms as dm";
956 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
957 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
958 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
959 }
960 $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
961 $sql .= " AND s.fournisseur = ".Societe::SUPPLIER;
962 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
963 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
964 }
965 // Add where from hooks
966 $parameters = array('socid' => $socid);
967 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
968 if (empty($reshook)) {
969 if ($socid > 0) {
970 $sql .= " AND s.rowid = ".((int) $socid);
971 }
972 }
973 $sql .= $hookmanager->resPrint;
974 $sql .= " ORDER BY s.datec DESC";
975 $sql .= $db->plimit($max, 0);
976
977 $resql = $db->query($sql);
978 if ($resql) {
979 $num = $db->num_rows($resql);
980 startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f", 1, -1, 'company');
981
982 if ($num) {
983 $i = 0;
984 while ($i < $num && $i < $max) {
985 $objp = $db->fetch_object($resql);
986
987 $companystatic->id = $objp->socid;
988 $companystatic->name = $objp->name;
989 $companystatic->name_alias = $objp->name_alias;
990 $companystatic->code_client = $objp->code_client;
991 $companystatic->code_compta = $objp->code_compta_client;
992 $companystatic->code_compta_client = $objp->code_compta_client;
993 $companystatic->client = $objp->client;
994 $companystatic->code_fournisseur = $objp->code_fournisseur;
995 $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
996 $companystatic->fournisseur = $objp->fournisseur;
997 $companystatic->logo = $objp->logo;
998 $companystatic->email = $objp->email;
999 $companystatic->entity = $objp->entity;
1000 $companystatic->canvas = $objp->canvas;
1001
1002 print '<tr class="oddeven">';
1003 print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
1004 print '<td>';
1005
1006 $obj = $companystatic;
1007 $s = '';
1008 if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) {
1009 $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>';
1010 }
1011 print $s;
1012
1013 print '</td>';
1014
1015 $datem = $db->jdate($objp->dm);
1016 print '<td class="right tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
1017 print dol_print_date($datem, 'day', 'tzuserrel');
1018 print '</td>';
1019 print '</tr>';
1020
1021 $i++;
1022 }
1023 }
1024
1025 addSummaryTableLine(3, $num);
1026 finishSimpleTable(true);
1027
1028 $db->free($resql);
1029 } else {
1030 dol_print_error($db);
1031 }
1032}
1033*/
1034
1035
1036/*
1037 * Latest contracts
1038 */
1039if (isModEnabled('contract') && $user->hasRight("contrat", "lire") && 0) { // TODO To redo/reimplement for new contract
1040 $staticcontrat = new Contrat($db);
1041
1042 $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
1043 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
1044 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1045 $sql .= ", s.logo, s.email, s.entity";
1046 $sql .= ", s.canvas";
1047 $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
1048 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
1049 $sql .= ", ".MAIN_DB_PREFIX."contrat as c";
1050 $sql .= ", ".MAIN_DB_PREFIX."product as p";
1051 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
1052 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1053 }
1054 $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")";
1055 $sql .= " AND c.fk_soc = s.rowid";
1056 $sql .= " AND c.fk_product = p.rowid";
1057 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
1058 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1059 }
1060 if ($socid) {
1061 $sql .= " AND s.rowid = ".((int) $socid);
1062 }
1063 // Add where from hooks
1064 $parameters = array('socid' => $user->socid);
1065 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $staticcontrat); // Note that $action and $object may have been modified by hook
1066 $sql .= $hookmanager->resPrint;
1067 $sql .= " ORDER BY c.tms DESC";
1068 $sql .= $db->plimit($max + 1, 0);
1069
1070 $resql = $db->query($sql);
1071 if ($resql) {
1072 $num = $db->num_rows($resql);
1073 startSimpleTable($langs->trans("LastContracts", $max), "", "", 2);
1074
1075 if ($num > 0) {
1076 $i = 0;
1077
1078 while ($i < $num) {
1079 $obj = $db->fetch_object($resql);
1080
1081 $companystatic->id = $obj->socid;
1082 $companystatic->name = $obj->name;
1083 $companystatic->name_alias = $obj->name_alias;
1084 $companystatic->code_client = $obj->code_client;
1085 $companystatic->code_compta = $obj->code_compta_client;
1086 $companystatic->code_compta_client = $obj->code_compta_client;
1087 $companystatic->client = $obj->client;
1088 $companystatic->code_fournisseur = $obj->code_fournisseur;
1089 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1090 $companystatic->fournisseur = $obj->fournisseur;
1091 $companystatic->logo = $obj->logo;
1092 $companystatic->email = $obj->email;
1093 $companystatic->entity = $obj->entity;
1094 $companystatic->canvas = $obj->canvas;
1095
1096 $staticcontrat->id = $obj->contratid;
1097 $staticcontrat->ref = $obj->ref;
1098
1099 print '<tr class="oddeven">';
1100 print '<td class="nowraponall">'.$staticcontrat->getNomUrl(1).'</td>';
1101 print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
1102 print '<td class="right">'.$staticcontrat->LibStatut($obj->statut, 3).'</td>';
1103 print '</tr>';
1104
1105 $i++;
1106 }
1107 }
1108
1109 addSummaryTableLine(2, $num);
1110 finishSimpleTable(true);
1111
1112 $db->free($resql);
1113 } else {
1115 }
1116}
1117
1118
1119/*
1120 * Opened (validated) proposals
1121 */
1122if (isModEnabled("propal") && $user->hasRight("propal", "lire")) {
1123 $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";
1124 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
1125 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
1126 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1127 $sql .= ", s.logo, s.email, s.entity";
1128 $sql .= ", s.canvas";
1129 $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
1130 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
1131 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
1132 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1133 }
1134 $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
1135 $sql .= " AND p.fk_soc = s.rowid";
1136 $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
1137 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
1138 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1139 }
1140 if ($socid) {
1141 $sql .= " AND s.rowid = ".((int) $socid);
1142 }
1143 // Add where from hooks
1144 $parameters = array('socid' => $user->socid);
1145 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $propalstatic); // Note that $action and $object may have been modified by hook
1146 $sql .= $hookmanager->resPrint;
1147 $sql .= " ORDER BY p.rowid DESC";
1148
1149 $resql = $db->query($sql);
1150 if ($resql) {
1151 $total = $total_ttc = 0;
1152 $num = $db->num_rows($resql);
1153 $nbofloop = min($num, getDolGlobalInt('MAIN_MAXLIST_OVERLOAD', 500));
1154 startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num);
1155
1156 if ($num > 0) {
1157 $i = 0;
1158 $othernb = 0;
1159
1160 while ($i < $nbofloop) {
1161 $obj = $db->fetch_object($resql);
1162
1163 if ($i >= $max) {
1164 $othernb += 1;
1165 $i++;
1166 $total += $obj->total_ht;
1167 $total_ttc += $obj->total_ttc;
1168 continue;
1169 }
1170
1171 $propalstatic->id = $obj->propalid;
1172 $propalstatic->ref = $obj->ref;
1173 $propalstatic->ref_client = $obj->ref_client; // deprecated
1174 $propalstatic->ref_customer = $obj->ref_client;
1175 $propalstatic->total_ht = $obj->total_ht;
1176 $propalstatic->total_tva = $obj->total_tva;
1177 $propalstatic->total_ttc = $obj->total_ttc;
1178
1179 $companystatic->id = $obj->socid;
1180 $companystatic->name = $obj->name;
1181 $companystatic->name_alias = $obj->name_alias;
1182 $companystatic->code_client = $obj->code_client;
1183 $companystatic->code_compta = $obj->code_compta_client;
1184 $companystatic->code_compta_client = $obj->code_compta_client;
1185 $companystatic->client = $obj->client;
1186 $companystatic->code_fournisseur = $obj->code_fournisseur;
1187 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1188 $companystatic->fournisseur = $obj->fournisseur;
1189 $companystatic->logo = $obj->logo;
1190 $companystatic->email = $obj->email;
1191 $companystatic->entity = $obj->entity;
1192 $companystatic->canvas = $obj->canvas;
1193
1194 $filename = dol_sanitizeFileName($obj->ref);
1195 $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
1196 //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
1197 $warning = ($db->jdate($obj->dfv) < ($now - getWarningDelay('propal', 'cloture'))) ? img_warning($langs->trans("Late")) : '';
1198
1199 print '<tr class="oddeven">';
1200
1201 print '<td class="nowrap" width="140">';
1202 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1203 print '<td class="nobordernopadding nowraponall">'.$propalstatic->getNomUrl(1).'</td>';
1204 print '<td width="18" class="nobordernopadding nowrap">'.$warning.'</td>';
1205 print '<td width="16" class="nobordernopadding center">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
1206 print '</tr>';
1207 print '</table>';
1208 print '</td>';
1209
1210 print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
1211 $datem = $db->jdate($obj->dp);
1212 print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
1213 print dol_print_date($datem, 'day', 'tzserver');
1214 print '</td>';
1215 print '<td class="right tdamount amount">'.price(getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).'</td>';
1216 print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
1217
1218 print '</tr>';
1219
1220 $i++;
1221 $total += $obj->total_ht;
1222 $total_ttc += $obj->total_ttc;
1223 }
1224
1225 if ($othernb) {
1226 print '<tr class="oddeven">';
1227 print '<td class="nowrap" colspan="5">';
1228 print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
1229 print '</td>';
1230 print "</tr>\n";
1231 }
1232 }
1233
1234 addSummaryTableLine(5, $num, $nbofloop, !getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $total_ttc : $total, "NoProposal", true);
1235 finishSimpleTable(true);
1236
1237 $db->free($resql);
1238 } else {
1240 }
1241}
1242
1243
1244/*
1245 * Opened (validated) order
1246 */
1247if (isModEnabled('order') && $user->hasRight('commande', 'lire') && is_object($orderstatic)) {
1248 $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";
1249 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
1250 $sql .= ", s.code_client, s.code_compta as code_compta_client, s.client";
1251 $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1252 $sql .= ", s.logo, s.email, s.entity";
1253 $sql .= ", s.canvas";
1254 $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
1255 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
1256 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
1257 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1258 }
1259 $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
1260 $sql .= " AND c.fk_soc = s.rowid";
1261 $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
1262 if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
1263 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1264 }
1265 if ($socid) {
1266 $sql .= " AND s.rowid = ".((int) $socid);
1267 }
1268 // Add where from hooks
1269 $parameters = array('socid' => $user->socid);
1270 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $orderstatic); // Note that $action and $object may have been modified by hook
1271 $sql .= $hookmanager->resPrint;
1272 $sql .= " ORDER BY c.rowid DESC";
1273
1274 $resql = $db->query($sql);
1275 if ($resql) {
1276 $total = $total_ttc = 0;
1277 $num = $db->num_rows($resql);
1278 $nbofloop = min($num, getDolGlobalString('MAIN_MAXLIST_OVERLOAD', 500));
1279 startSimpleTable("OrdersOpened", "commande/list.php", "search_status=".Commande::STATUS_VALIDATED, 4, $num);
1280
1281 if ($num > 0) {
1282 $i = 0;
1283 $othernb = 0;
1284
1285 while ($i < $nbofloop) {
1286 $obj = $db->fetch_object($resql);
1287
1288 if ($i >= $max) {
1289 $othernb += 1;
1290 $i++;
1291 $total += $obj->total_ht;
1292 $total_ttc += $obj->total_ttc;
1293 continue;
1294 }
1295
1296 $orderstatic->id = $obj->commandeid;
1297 $orderstatic->ref = $obj->ref;
1298 $orderstatic->ref_client = $obj->ref_client;
1299 $orderstatic->statut = $obj->fk_statut; // deprecated
1300 $orderstatic->status = $obj->fk_statut;
1301 $orderstatic->total_ht = $obj->total_ht;
1302 $orderstatic->total_tva = $obj->total_tva;
1303 $orderstatic->total_ttc = $obj->total_ttc;
1304
1305 $companystatic->id = $obj->socid;
1306 $companystatic->name = $obj->name;
1307 $companystatic->name_alias = $obj->name_alias;
1308 $companystatic->code_client = $obj->code_client;
1309 $companystatic->code_compta = $obj->code_compta_client;
1310 $companystatic->code_compta_client = $obj->code_compta_client;
1311 $companystatic->client = $obj->client;
1312 $companystatic->code_fournisseur = $obj->code_fournisseur;
1313 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1314 $companystatic->fournisseur = $obj->fournisseur;
1315 $companystatic->logo = $obj->logo;
1316 $companystatic->email = $obj->email;
1317 $companystatic->entity = $obj->entity;
1318 $companystatic->canvas = $obj->canvas;
1319
1320 $filename = dol_sanitizeFileName($obj->ref);
1321 $filedir = $conf->order->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1322 //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
1323 //$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
1324
1325 print '<tr class="oddeven">';
1326
1327 print '<td class="nowrap" width="140">';
1328 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1329 print '<td class="nobordernopadding nowraponall">'.$orderstatic->getNomUrl(1).'</td>';
1330 print '<td width="18" class="nobordernopadding nowrap"></td>';
1331 print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).'</td>';
1332 print '</tr>';
1333 print '</table>';
1334 print '</td>';
1335
1336 print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
1337 $datem = $db->jdate($obj->dv);
1338 print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("DateValue").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
1339 print dol_print_date($datem, 'day', 'tzserver');
1340 print '</td>';
1341
1342 print '<td class="right tdamount amount">'.price(getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).'</td>';
1343 print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'</td>';
1344
1345 print '</tr>';
1346
1347 $i++;
1348 $total += $obj->total_ht;
1349 $total_ttc += $obj->total_ttc;
1350 }
1351
1352 if ($othernb) {
1353 print '<tr class="oddeven">';
1354 print '<td class="nowrap" colspan="5">';
1355 print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
1356 print '</td>';
1357 print "</tr>\n";
1358 }
1359 }
1360
1361 addSummaryTableLine(5, $num, $nbofloop, !getDolGlobalString('MAIN_DASHBOARD_USE_TOTAL_HT') ? $total_ttc : $total, "None", true);
1362 finishSimpleTable(true);
1363
1364 $db->free($resql);
1365 } else {
1367 }
1368}
1369
1370print '</div>';
1371print '</div>';
1372print '</div>';
1373
1374$parameters = array('user' => $user);
1375$reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
1376
1377// End of page
1378llxFooter();
1379$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
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.
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 proposals.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
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:248
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
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.