dolibarr 24.0.0-beta
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 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) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
9 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31require "../main.inc.php";
32require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
33require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
34
43// Load translation files required by the page
44$langs->loadLangs(array('products', 'companies', 'contracts'));
45
46// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
47$hookmanager->initHooks(array('contractindex'));
48
49$sortfield = GETPOST('sortfield', 'aZ09comma');
50$sortorder = GETPOST('sortorder', 'aZ09comma');
51$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
52
53$statut = GETPOST('statut') ? GETPOST('statut') : 1;
54
55$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
56
57// Security check
58$socid = 0;
59$id = GETPOSTINT('id');
60if (!empty($user->socid)) {
61 $socid = $user->socid;
62}
63$result = restrictedArea($user, 'contrat', $id);
64
65$staticcompany = new Societe($db);
66$staticcontrat = new Contrat($db);
67$staticcontratligne = new ContratLigne($db);
68$productstatic = new Product($db);
69
70
71
72/*
73 * Action
74 */
75
76// None
77
78
79/*
80 * View
81 */
82
83$now = dol_now();
84
85$title = $langs->trans("ContractsArea");
86$help_url = 'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
87
88llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-contrat page-index');
89
90print load_fiche_titre($langs->trans("ContractsArea"), '', 'contract');
91
92
93print '<div class="fichecenter"><div class="fichethirdleft">';
94
95
96/*
97 * Statistics
98 */
99
100$nb = array();
101$total = 0;
102$totalinprocess = 0;
103$dataseries = array();
104$vals = array();
105
106// Search by status (except expired)
107$sql = "SELECT count(cd.rowid) as nb, cd.statut as status";
108$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
109$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
110if (!$user->hasRight('societe', 'client', 'voir')) {
111 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
112}
113$sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
114$sql .= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))";
115$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
116if ($user->socid) {
117 $sql .= ' AND c.fk_soc = '.((int) $user->socid);
118}
119if (!$user->hasRight('societe', 'client', 'voir')) {
120 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
121}
122$sql .= " GROUP BY cd.statut";
123$resql = $db->query($sql);
124if ($resql) {
125 $num = $db->num_rows($resql);
126 $i = 0;
127 while ($i < $num) {
128 $obj = $db->fetch_object($resql);
129 if ($obj) {
130 $nb[$obj->status] = $obj->nb;
131 if ($obj->status != 5) {
132 $vals[$obj->status] = $obj->nb;
133 $totalinprocess += $obj->nb;
134 }
135 $total += $obj->nb;
136 }
137 $i++;
138 }
139 $db->free($resql);
140} else {
142}
143// Search by status (only expired)
144$sql = "SELECT count(cd.rowid) as nb, cd.statut as status";
145$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
146$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
147if (!$user->hasRight('societe', 'client', 'voir')) {
148 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
149}
150$sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
151$sql .= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')";
152$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
153if ($user->socid) {
154 $sql .= ' AND c.fk_soc = '.((int) $user->socid);
155}
156if (!$user->hasRight('societe', 'client', 'voir')) {
157 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
158}
159$sql .= " GROUP BY cd.statut";
160$resql = $db->query($sql);
161if ($resql) {
162 $num = $db->num_rows($resql);
163
164 // 0 inactive, 4 active, 5 closed
165 $i = 0;
166 while ($i < $num) {
167 $obj = $db->fetch_object($resql);
168 if ($obj) {
169 $nb[$obj->status.((string) true)] = $obj->nb;
170 if ($obj->status != 5) {
171 $vals[$obj->status.((string) true)] = $obj->nb;
172 $totalinprocess += $obj->nb;
173 }
174 $total += $obj->nb;
175 }
176 $i++;
177 }
178 $db->free($resql);
179} else {
181}
182
183$colorseries = array();
184
185include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
193print '<div class="div-table-responsive-no-min">';
194print '<table class="noborder nohover centpercent">';
195print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Services").'</th></tr>'."\n";
196$listofstatus = array(0, 4, 4); // Note: status 5=closed is useless as it increase all the time. We are interesting with 0, 4 expired and 4 non expired only.
197if (!getDolGlobalString('CONTRACT_HIDE_CLOSED_SERVICES_IN_GRAPH')) {
198 $listofstatus[] = 5; // We add this status too (even if useless
199}
200$bool = false;
201foreach ($listofstatus as $status) {
202 $bool_str = (string) $bool;
203 $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool_str]) ? (int) $nb[$status.$bool_str] : 0));
204 if ($status == ContratLigne::STATUS_INITIAL) {
205 $colorseries[$status.$bool_str] = '-'.$badgeStatus0;
206 }
207 if ($status == ContratLigne::STATUS_OPEN && !$bool) {
208 $colorseries[$status.$bool_str] = $badgeStatus4;
209 }
210 if ($status == ContratLigne::STATUS_OPEN && $bool) {
211 $colorseries[$status.$bool_str] = $badgeStatus1;
212 }
213 if ($status == ContratLigne::STATUS_CLOSED) {
214 $colorseries[$status.$bool_str] = $badgeStatus6;
215 }
216
217 if (empty($conf->use_javascript_ajax)) {
218 print '<tr class="oddeven">';
219 print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).'</td>';
220 print '<td class="right"><a href="services_list.php?search_status='.((int) $status).($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool_str] ? $nb[$status.$bool_str] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
221 print "</tr>\n";
222 }
223 if ($status == 4 && !$bool) {
224 $bool = true;
225 } else {
226 $bool = false;
227 }
228}
229if (!empty($conf->use_javascript_ajax)) {
230 print '<tr class="impair"><td class="center" colspan="2">';
231
232 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
233 $dolgraph = new DolGraph();
234 $dolgraph->SetData($dataseries);
235 $dolgraph->SetDataColor(array_values($colorseries));
236 $dolgraph->setShowLegend(2);
237 $dolgraph->setShowPercent(1);
238 $dolgraph->SetType(array('pie'));
239 $dolgraph->setHeight('200');
240 $dolgraph->draw('idgraphstatus');
241 print $dolgraph->show($total ? 0 : 1);
242
243 print '</td></tr>';
244}
245$listofstatus = array(0, 4, 4, 5);
246$bool = false;
247foreach ($listofstatus as $status) {
248 $bool_str = (string) $bool;
249 if (empty($conf->use_javascript_ajax)) {
250 print '<tr class="oddeven">';
251 print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).'</td>';
252 print '<td class="right"><a href="services_list.php?search_status='.((int) $status).($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool_str] ? $nb[$status.$bool_str] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
253 if ($status == 4 && !$bool) {
254 $bool = true;
255 } else {
256 $bool = false;
257 }
258 print "</tr>\n";
259 }
260}
261print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'.$total.'</td></tr>';
262print "</table></div><br>";
263
264
265// Draft contracts
266
267if (isModEnabled('contract') && $user->hasRight('contrat', 'lire')) {
268 $sql = "SELECT c.rowid, c.ref,";
269 $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur";
270 $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
271 if (!$user->hasRight('societe', 'client', 'voir')) {
272 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
273 }
274 $sql .= " WHERE s.rowid = c.fk_soc";
275 $sql .= " AND c.entity IN (".getEntity('contract', 0).")";
276 $sql .= " AND c.statut = 0";
277 if (!$user->hasRight('societe', 'client', 'voir')) {
278 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
279 }
280 if ($socid) {
281 $sql .= " AND c.fk_soc = ".((int) $socid);
282 }
283
284 $resql = $db->query($sql);
285
286 if ($resql) {
287 $num = $db->num_rows($resql);
288
289 print '<div class="div-table-responsive-no-min">';
290 print '<table class="noborder centpercent">';
291 print '<tr class="liste_titre">';
292 print '<th colspan="3">'.$langs->trans("DraftContracts").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
293 if ($num) {
294 $i = 0;
295 //$tot_ttc = 0;
296 while ($i < $num) {
297 $obj = $db->fetch_object($resql);
298
299 $staticcontrat->ref = $obj->ref;
300 $staticcontrat->id = $obj->rowid;
301
302 $staticcompany->id = $obj->socid;
303 $staticcompany->name = $obj->name;
304 $staticcompany->name_alias = $obj->name_alias;
305 $staticcompany->logo = $obj->logo;
306 $staticcompany->code_client = $obj->code_client;
307 $staticcompany->code_fournisseur = $obj->code_fournisseur;
308 $staticcompany->code_compta = $obj->code_compta_client;
309 $staticcompany->code_compta_client = $obj->code_compta_client;
310 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
311 $staticcompany->client = $obj->client;
312 $staticcompany->fournisseur = $obj->fournisseur;
313
314 print '<tr class="oddeven"><td class="nowrap">';
315 print $staticcontrat->getNomUrl(1, 0);
316 print '</td>';
317 print '<td>';
318 print $staticcompany->getNomUrl(1, '', 16);
319 print '</td>';
320 print '</tr>';
321 //$tot_ttc+=$obj->total_ttc;
322 $i++;
323 }
324 } else {
325 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("NoContracts").'</span></td></tr>';
326 }
327 print "</table></div><br>";
328 $db->free($resql);
329 } else {
331 }
332}
333
334
335print '</div><div class="fichetwothirdright">';
336
337
338// Last modified contracts
339$sql = 'SELECT ';
340$sql .= " sum(".$db->ifsql("cd.statut=0", '1', '0').') as nb_initial,';
341$sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", '1', '0').') as nb_running,';
342$sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", '1', '0').') as nb_expired,';
343$sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", '1', '0').') as nb_late,';
344$sql .= " sum(".$db->ifsql("cd.statut=5", '1', '0').') as nb_closed,';
345$sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut,";
346$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur";
347$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,";
348if (!$user->hasRight('societe', 'client', 'voir')) {
349 $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
350}
351$sql .= " ".MAIN_DB_PREFIX."contrat as c";
352$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
353$sql .= " WHERE c.fk_soc = s.rowid";
354$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
355$sql .= " AND c.statut > 0";
356if (!$user->hasRight('societe', 'client', 'voir')) {
357 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
358}
359if ($socid) {
360 $sql .= " AND s.rowid = ".((int) $socid);
361}
362$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut,";
363$sql .= " s.nom, s.name_alias, s.logo, s.rowid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
364$sql .= " ORDER BY c.tms DESC";
365$sql .= $db->plimit($max);
366
367dol_syslog("contrat/index.php", LOG_DEBUG);
368$result = $db->query($sql);
369if ($result) {
370 $num = $db->num_rows($result);
371 $i = 0;
372
373 print '<div class="div-table-responsive-no-min">';
374 print '<table class="noborder centpercent">';
375
376 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastContracts", $max).'</th>';
377 print '<th class="center">'.$langs->trans("DateModification").'</th>';
378 //print '<th class="left">'.$langs->trans("Status").'</th>';
379 print '<th class="center" width="80" colspan="4">'.$langs->trans("Services").'</th>';
380 print "</tr>\n";
381
382 while ($i < $num) {
383 $obj = $db->fetch_object($result);
384 $datem = $db->jdate($obj->tms);
385
386 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid);
387 $staticcontrat->id = $obj->cid;
388
389 $staticcompany->id = $obj->socid;
390 $staticcompany->name = $obj->name;
391 $staticcompany->name_alias = $obj->name_alias;
392 $staticcompany->photo = 1;
393 $staticcompany->code_client = $obj->code_client;
394 $staticcompany->code_fournisseur = $obj->code_fournisseur;
395 $staticcompany->code_compta = $obj->code_compta_client;
396 $staticcompany->code_compta_client = $obj->code_compta_client;
397 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
398 $staticcompany->client = $obj->client;
399 $staticcompany->fournisseur = $obj->fournisseur;
400
401 print '<tr class="oddeven">';
402 print '<td class="nowraponall">';
403 print $staticcontrat->getNomUrl(1, 16);
404 if ($obj->nb_late) {
405 print img_warning($langs->trans("Late"));
406 }
407 print '</td>';
408
409 print '<td class="tdoverflowmax150">';
410 print $staticcompany->getNomUrl(1, '', 20);
411 print '</td>';
412 print '<td class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
413 print dol_print_date($datem, 'dayhour');
414 print '</td>';
415 //print '<td class="left">'.$staticcontrat->LibStatut($obj->statut,2).'</td>';
416 print '<td class="right nowraponall" width="32">'.($obj->nb_initial > 0 ? '<span class="paddingright">'.$obj->nb_initial.'</span>'.$staticcontratligne->LibStatut(0, 3, -1, 'class="paddingleft"') : '').'</td>';
417 print '<td class="right nowraponall" width="32">'.($obj->nb_running > 0 ? '<span class="paddingright">'.$obj->nb_running.'</span>'.$staticcontratligne->LibStatut(4, 3, 0, 'class="marginleft"') : '').'</td>';
418 print '<td class="right nowraponall" width="32">'.($obj->nb_expired > 0 ? '<span class="paddingright">'.$obj->nb_expired.'</span>'.$staticcontratligne->LibStatut(4, 3, 1, 'class="paddingleft"') : '').'</td>';
419 print '<td class="right nowraponall" width="32">'.($obj->nb_closed > 0 ? '<span class="paddingright">'.$obj->nb_closed.'</span>'.$staticcontratligne->LibStatut(5, 3, -1, 'class="paddingleft"') : '').'</td>';
420 print "</tr>\n";
421 $i++;
422 }
423 $db->free($result);
424
425 print "</table></div>";
426} else {
428}
429
430print '<br>';
431
432// Last modified services
433$sql = "SELECT c.ref, c.fk_soc as socid,";
434$sql .= " cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,";
435$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
436$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
437$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
438$sql .= ", ".MAIN_DB_PREFIX."societe as s";
439if (!$user->hasRight('societe', 'client', 'voir')) {
440 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
441}
442$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
443$sql .= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
444$sql .= " WHERE c.entity IN (".getEntity('contract', 0).")";
445$sql .= " AND cd.fk_contrat = c.rowid";
446$sql .= " AND c.fk_soc = s.rowid";
447if (!$user->hasRight('societe', 'client', 'voir')) {
448 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
449}
450if ($socid) {
451 $sql .= " AND s.rowid = ".((int) $socid);
452}
453$sql .= " ORDER BY cd.tms DESC";
454
455$resql = $db->query($sql);
456if ($resql) {
457 $num = $db->num_rows($resql);
458 $i = 0;
459
460 print '<div class="div-table-responsive-no-min">';
461 print '<table class="noborder centpercent">';
462
463 print '<tr class="liste_titre"><th colspan="4">'.$langs->trans("LastModifiedServices", $max).'</th>';
464 print "</tr>\n";
465
466 while ($i < min($num, $max)) {
467 $obj = $db->fetch_object($resql);
468
469 print '<tr class="oddeven">';
470 print '<td class="nowraponall">';
471
472 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
473 $staticcontrat->id = $obj->fk_contrat;
474
475 $staticcompany->id = $obj->socid;
476 $staticcompany->name = $obj->name;
477 $staticcompany->name_alias = $obj->name_alias;
478 $staticcompany->photo = 1;
479 $staticcompany->code_client = $obj->code_client;
480 $staticcompany->code_fournisseur = $obj->code_fournisseur;
481 $staticcompany->code_compta = $obj->code_compta_client;
482 $staticcompany->code_compta_client = $obj->code_compta_client;
483 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
484 $staticcompany->client = $obj->client;
485 $staticcompany->fournisseur = $obj->fournisseur;
486
487 print $staticcontrat->getNomUrl(1, 16);
488
489 //if (1 == 1) print img_warning($langs->trans("Late"));
490 print '</td>';
491 print '<td>';
492 if ($obj->fk_product > 0) {
493 $productstatic->id = $obj->fk_product;
494 $productstatic->type = $obj->ptype;
495 $productstatic->ref = $obj->pref;
496 $productstatic->entity = $obj->pentity;
497 print $productstatic->getNomUrl(1, '', 20);
498 } else {
499 print '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowService"), "service");
500 if ($obj->label) {
501 print ' '.dol_trunc($obj->label, 20).'</a>';
502 } else {
503 print '</a> '.dol_trunc($obj->note, 20);
504 }
505 }
506 print '</td>';
507 print '<td class="tdoverflowmax125">';
508 print $staticcompany->getNomUrl(1, '', 20);
509 print '</td>';
510 print '<td class="nowrap right"><a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'">';
511 $dateend = $db->jdate($obj->date_fin_validite);
512 print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now) ? 1 : 0);
513 print '</a></td>';
514 print "</tr>\n";
515 $i++;
516 }
517 $db->free($resql);
518
519 print "</table></div>";
520} else {
522}
523
524print '<br>';
525
526// Not activated services
527$sql = "SELECT c.ref, c.fk_soc as thirdpartyid, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,";
528$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
529$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
530$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
531$sql .= ", ".MAIN_DB_PREFIX."societe as s";
532if (!$user->hasRight('societe', 'client', 'voir')) {
533 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
534}
535$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
536$sql .= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
537$sql .= " WHERE c.entity IN (".getEntity('contract', 0).")";
538$sql .= " AND c.statut = 1";
539$sql .= " AND cd.statut = 0";
540$sql .= " AND cd.fk_contrat = c.rowid";
541$sql .= " AND c.fk_soc = s.rowid";
542if (!$user->hasRight('societe', 'client', 'voir')) {
543 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
544}
545if ($socid) {
546 $sql .= " AND s.rowid = ".((int) $socid);
547}
548$sql .= " ORDER BY cd.tms DESC";
549
550$resql = $db->query($sql);
551if ($resql) {
552 $num = $db->num_rows($resql);
553 $i = 0;
554
555 print '<div class="div-table-responsive-no-min">';
556 print '<table class="noborder centpercent">';
557
558 print '<tr class="liste_titre"><th colspan="4">'.$langs->trans("NotActivatedServices").' <a href="'.DOL_URL_ROOT.'/contrat/services_list.php?mode=0"><span class="badge">'.$num.'</span></a></th>';
559 print "</tr>\n";
560
561 while ($i < $num) {
562 $obj = $db->fetch_object($resql);
563
564 $staticcompany->id = $obj->thirdpartyid;
565 $staticcompany->name = $obj->name;
566 $staticcompany->name_alias = $obj->name_alias;
567 $staticcompany->photo = 1;
568 $staticcompany->code_client = $obj->code_client;
569 $staticcompany->code_fournisseur = $obj->code_fournisseur;
570 $staticcompany->code_compta = $obj->code_compta_client;
571 $staticcompany->code_compta_client = $obj->code_compta_client;
572 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
573 $staticcompany->client = $obj->client;
574 $staticcompany->fournisseur = $obj->fournisseur;
575
576 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
577 $staticcontrat->id = $obj->fk_contrat;
578
579 $productstatic->id = $obj->fk_product;
580 $productstatic->type = $obj->ptype;
581 $productstatic->ref = $obj->pref;
582 $productstatic->entity = $obj->pentity;
583
584 print '<tr class="oddeven">';
585
586 print '<td class="nowraponall">';
587 print $staticcontrat->getNomUrl(1, 16);
588 print '</td>';
589 print '<td class="nowrap">';
590 if ($obj->fk_product > 0) {
591 print $productstatic->getNomUrl(1, '', 20);
592 } else {
593 print '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowService"), "service");
594 if ($obj->label) {
595 print ' '.dol_trunc($obj->label, 20).'</a>';
596 } else {
597 print '</a> '.dol_trunc($obj->note, 20);
598 }
599 }
600 print '</td>';
601 print '<td class="tdoverflowmax125">';
602 print $staticcompany->getNomUrl(1, '', 20);
603 print '</td>';
604 print '<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'">';
605 print $staticcontratligne->LibStatut($obj->statut, 3);
606 print '</a></td>';
607 print "</tr>\n";
608 $i++;
609 }
610
611 $db->free($resql);
612
613 print "</table></div>";
614} else {
616}
617
618print '<br>';
619
620// Expired services
621$sql = "SELECT c.ref, c.fk_soc as thirdpartyid, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,";
622$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
623$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
624$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
625$sql .= ", ".MAIN_DB_PREFIX."societe as s";
626if (!$user->hasRight('societe', 'client', 'voir')) {
627 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
628}
629$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
630$sql .= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
631$sql .= " WHERE c.entity IN (".getEntity('contract', 0).")";
632$sql .= " AND c.statut = 1";
633$sql .= " AND cd.statut = 4";
634$sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'";
635$sql .= " AND cd.fk_contrat = c.rowid";
636$sql .= " AND c.fk_soc = s.rowid";
637if (!$user->hasRight('societe', 'client', 'voir')) {
638 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
639}
640if ($socid) {
641 $sql .= " AND s.rowid = ".((int) $socid);
642}
643$sql .= " ORDER BY cd.tms DESC";
644
645$resql = $db->query($sql);
646if ($resql) {
647 $num = $db->num_rows($resql);
648 $i = 0;
649
650 print '<div class="div-table-responsive-no-min">';
651 print '<table class="noborder centpercent">';
652
653 print '<tr class="liste_titre"><th colspan="4">'.$langs->trans("ListOfExpiredServices").' <a href="'.DOL_URL_ROOT.'/contrat/services_list.php?search_status=4&amp;filter=expired"><span class="badge">'.$num.'</span></a></th>';
654 print "</tr>\n";
655
656 while ($i < $num) {
657 $obj = $db->fetch_object($resql);
658
659 $staticcompany->id = $obj->thirdpartyid;
660 $staticcompany->name = $obj->name;
661 $staticcompany->name_alias = $obj->name_alias;
662 $staticcompany->photo = 1;
663 $staticcompany->code_client = $obj->code_client;
664 $staticcompany->code_fournisseur = $obj->code_fournisseur;
665 $staticcompany->code_compta = $obj->code_compta_client;
666 $staticcompany->code_compta_client = $obj->code_compta_client;
667 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
668 $staticcompany->client = $obj->client;
669 $staticcompany->fournisseur = $obj->fournisseur;
670
671 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
672 $staticcontrat->id = $obj->fk_contrat;
673
674 $productstatic->id = $obj->fk_product;
675 $productstatic->type = $obj->ptype;
676 $productstatic->ref = $obj->pref;
677 $productstatic->entity = $obj->pentity;
678
679 print '<tr class="oddeven">';
680
681 print '<td class="nowraponall">';
682 print $staticcontrat->getNomUrl(1, 16);
683 print '</td>';
684 print '<td class="nowrap">';
685 if ($obj->fk_product > 0) {
686 print $productstatic->getNomUrl(1, '', 20);
687 } else {
688 print '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowService"), "service");
689 if ($obj->label) {
690 print ' '.dol_trunc($obj->label, 20).'</a>';
691 } else {
692 print '</a> '.dol_trunc($obj->note, 20);
693 }
694 }
695 print '</td>';
696 print '<td class="tdoverflowmax125">';
697 print $staticcompany->getNomUrl(1, '', 20);
698 print '</td>';
699 print '<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'">';
700 print $staticcontratligne->LibStatut($obj->statut, 3, 1);
701 print '</a></td>';
702 print "</tr>\n";
703 $i++;
704 }
705 $db->free($resql);
706
707 print "</table></div>";
708} else {
710}
711
712
713print '</div></div>';
714
715$parameters = array('user' => $user);
716$reshook = $hookmanager->executeHooks('dashboardContracts', $parameters, $object); // Note that $action and $object may have been modified by hook
717
718llxFooter();
719
720$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
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 lines of contracts.
Class to build graphs.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.