31require
"../main.inc.php";
32require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
33require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
44$langs->loadLangs(array(
'products',
'companies',
'contracts'));
47$hookmanager->initHooks(array(
'contractindex'));
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60if (!empty($user->socid)) {
61 $socid = $user->socid;
65$staticcompany =
new Societe($db);
66$staticcontrat =
new Contrat($db);
68$productstatic =
new Product($db);
85$title = $langs->trans(
"ContractsArea");
86$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
88llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-index');
93print
'<div class="fichecenter"><div class="fichethirdleft">';
103$dataseries = array();
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";
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).
")";
117 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
119if (!$user->hasRight(
'societe',
'client',
'voir')) {
120 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
122$sql .=
" GROUP BY cd.statut";
123$resql = $db->query($sql);
125 $num = $db->num_rows($resql);
128 $obj = $db->fetch_object($resql);
130 $nb[$obj->status] = $obj->nb;
131 if ($obj->status != 5) {
132 $vals[$obj->status] = $obj->nb;
133 $totalinprocess += $obj->nb;
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";
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).
")";
154 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
156if (!$user->hasRight(
'societe',
'client',
'voir')) {
157 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
159$sql .=
" GROUP BY cd.statut";
160$resql = $db->query($sql);
162 $num = $db->num_rows($resql);
167 $obj = $db->fetch_object($resql);
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;
183$colorseries = array();
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);
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;
207 if ($status == ContratLigne::STATUS_OPEN && !$bool) {
208 $colorseries[$status.$bool_str] = $badgeStatus4;
210 if ($status == ContratLigne::STATUS_OPEN && $bool) {
211 $colorseries[$status.$bool_str] = $badgeStatus1;
213 if ($status == ContratLigne::STATUS_CLOSED) {
214 $colorseries[$status.$bool_str] = $badgeStatus6;
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>';
223 if ($status == 4 && !$bool) {
229if (!empty($conf->use_javascript_ajax)) {
230 print
'<tr class="impair"><td class="center" colspan="2">';
232 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
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);
245$listofstatus = array(0, 4, 4, 5);
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) {
261print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
262print
"</table></div><br>";
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";
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);
281 $sql .=
" AND c.fk_soc = ".((int) $socid);
284 $resql = $db->query($sql);
287 $num = $db->num_rows($resql);
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>';
297 $obj = $db->fetch_object($resql);
299 $staticcontrat->ref = $obj->ref;
300 $staticcontrat->id = $obj->rowid;
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;
314 print
'<tr class="oddeven"><td class="nowrap">';
315 print $staticcontrat->getNomUrl(1, 0);
318 print $staticcompany->getNomUrl(1,
'', 16);
325 print
'<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"NoContracts").
'</span></td></tr>';
327 print
"</table></div><br>";
335print
'</div><div class="fichetwothirdright">';
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,";
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);
360 $sql .=
" AND s.rowid = ".((int) $socid);
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);
368$result = $db->query($sql);
370 $num = $db->num_rows($result);
373 print
'<div class="div-table-responsive-no-min">';
374 print
'<table class="noborder centpercent">';
376 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"LastContracts", $max).
'</th>';
377 print
'<th class="center">'.$langs->trans(
"DateModification").
'</th>';
379 print
'<th class="center" width="80" colspan="4">'.$langs->trans(
"Services").
'</th>';
383 $obj = $db->fetch_object($result);
384 $datem = $db->jdate($obj->tms);
386 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid);
387 $staticcontrat->id = $obj->cid;
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;
401 print
'<tr class="oddeven">';
402 print
'<td class="nowraponall">';
403 print $staticcontrat->getNomUrl(1, 16);
409 print
'<td class="tdoverflowmax150">';
410 print $staticcompany->getNomUrl(1,
'', 20);
412 print
'<td class="center nowraponall" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
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>';
425 print
"</table></div>";
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";
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);
451 $sql .=
" AND s.rowid = ".((int) $socid);
453$sql .=
" ORDER BY cd.tms DESC";
455$resql = $db->query($sql);
457 $num = $db->num_rows($resql);
460 print
'<div class="div-table-responsive-no-min">';
461 print
'<table class="noborder centpercent">';
463 print
'<tr class="liste_titre"><th colspan="4">'.$langs->trans(
"LastModifiedServices", $max).
'</th>';
466 while ($i < min($num, $max)) {
467 $obj = $db->fetch_object($resql);
469 print
'<tr class="oddeven">';
470 print
'<td class="nowraponall">';
472 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
473 $staticcontrat->id = $obj->fk_contrat;
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;
487 print $staticcontrat->getNomUrl(1, 16);
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);
499 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
501 print
' '.dol_trunc($obj->label, 20).
'</a>';
503 print
'</a> '.dol_trunc($obj->note, 20);
507 print
'<td class="tdoverflowmax125">';
508 print $staticcompany->getNomUrl(1,
'', 20);
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);
519 print
"</table></div>";
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";
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);
546 $sql .=
" AND s.rowid = ".((int) $socid);
548$sql .=
" ORDER BY cd.tms DESC";
550$resql = $db->query($sql);
552 $num = $db->num_rows($resql);
555 print
'<div class="div-table-responsive-no-min">';
556 print
'<table class="noborder centpercent">';
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>';
562 $obj = $db->fetch_object($resql);
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;
576 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
577 $staticcontrat->id = $obj->fk_contrat;
579 $productstatic->id = $obj->fk_product;
580 $productstatic->type = $obj->ptype;
581 $productstatic->ref = $obj->pref;
582 $productstatic->entity = $obj->pentity;
584 print
'<tr class="oddeven">';
586 print
'<td class="nowraponall">';
587 print $staticcontrat->getNomUrl(1, 16);
589 print
'<td class="nowrap">';
590 if ($obj->fk_product > 0) {
591 print $productstatic->getNomUrl(1,
'', 20);
593 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
595 print
' '.dol_trunc($obj->label, 20).
'</a>';
597 print
'</a> '.dol_trunc($obj->note, 20);
601 print
'<td class="tdoverflowmax125">';
602 print $staticcompany->getNomUrl(1,
'', 20);
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);
613 print
"</table></div>";
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";
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);
641 $sql .=
" AND s.rowid = ".((int) $socid);
643$sql .=
" ORDER BY cd.tms DESC";
645$resql = $db->query($sql);
647 $num = $db->num_rows($resql);
650 print
'<div class="div-table-responsive-no-min">';
651 print
'<table class="noborder centpercent">';
653 print
'<tr class="liste_titre"><th colspan="4">'.$langs->trans(
"ListOfExpiredServices").
' <a href="'.DOL_URL_ROOT.
'/contrat/services_list.php?search_status=4&filter=expired"><span class="badge">'.$num.
'</span></a></th>';
657 $obj = $db->fetch_object($resql);
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;
671 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
672 $staticcontrat->id = $obj->fk_contrat;
674 $productstatic->id = $obj->fk_product;
675 $productstatic->type = $obj->ptype;
676 $productstatic->ref = $obj->pref;
677 $productstatic->entity = $obj->pentity;
679 print
'<tr class="oddeven">';
681 print
'<td class="nowraponall">';
682 print $staticcontrat->getNomUrl(1, 16);
684 print
'<td class="nowrap">';
685 if ($obj->fk_product > 0) {
686 print $productstatic->getNomUrl(1,
'', 20);
688 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
690 print
' '.dol_trunc($obj->label, 20).
'</a>';
692 print
'</a> '.dol_trunc($obj->note, 20);
696 print
'<td class="tdoverflowmax125">';
697 print $staticcompany->getNomUrl(1,
'', 20);
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);
707 print
"</table></div>";
715$parameters = array(
'user' => $user);
716$reshook = $hookmanager->executeHooks(
'dashboardContracts', $parameters, $object);
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage lines of contracts.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
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.