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';
187print
'<div class="div-table-responsive-no-min">';
188print
'<table class="noborder nohover centpercent">';
189print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"Services").
'</th></tr>'.
"\n";
190$listofstatus = array(0, 4, 4);
195foreach ($listofstatus as $status) {
196 $bool_str = (string) $bool;
197 $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool_str]) ? (int) $nb[$status.$bool_str] : 0));
198 if ($status == ContratLigne::STATUS_INITIAL) {
199 $colorseries[$status.$bool_str] =
'-'.$badgeStatus0;
201 if ($status == ContratLigne::STATUS_OPEN && !$bool) {
202 $colorseries[$status.$bool_str] = $badgeStatus4;
204 if ($status == ContratLigne::STATUS_OPEN && $bool) {
205 $colorseries[$status.$bool_str] = $badgeStatus1;
207 if ($status == ContratLigne::STATUS_CLOSED) {
208 $colorseries[$status.$bool_str] = $badgeStatus6;
211 if (empty(
$conf->use_javascript_ajax)) {
212 print
'<tr class="oddeven">';
213 print
'<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).
'</td>';
214 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>';
217 if ($status == 4 && !$bool) {
223if (!empty(
$conf->use_javascript_ajax)) {
224 print
'<tr class="impair"><td class="center" colspan="2">';
226 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
228 $dolgraph->SetData($dataseries);
229 $dolgraph->SetDataColor(array_values($colorseries));
230 $dolgraph->setShowLegend(2);
231 $dolgraph->setShowPercent(1);
232 $dolgraph->SetType(array(
'pie'));
233 $dolgraph->setHeight(
'200');
234 $dolgraph->draw(
'idgraphstatus');
235 print $dolgraph->show($total ? 0 : 1);
239$listofstatus = array(0, 4, 4, 5);
241foreach ($listofstatus as $status) {
242 $bool_str = (string) $bool;
243 if (empty(
$conf->use_javascript_ajax)) {
244 print
'<tr class="oddeven">';
245 print
'<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).
'</td>';
246 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>';
247 if ($status == 4 && !$bool) {
255print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
256print
"</table></div><br>";
261if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
262 $sql =
"SELECT c.rowid, c.ref,";
263 $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";
264 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c, ".MAIN_DB_PREFIX.
"societe as s";
265 if (!$user->hasRight(
'societe',
'client',
'voir')) {
266 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
268 $sql .=
" WHERE s.rowid = c.fk_soc";
269 $sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
270 $sql .=
" AND c.statut = 0";
271 if (!$user->hasRight(
'societe',
'client',
'voir')) {
272 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
275 $sql .=
" AND c.fk_soc = ".((int) $socid);
278 $resql = $db->query($sql);
281 $num = $db->num_rows($resql);
283 print
'<div class="div-table-responsive-no-min">';
284 print
'<table class="noborder centpercent">';
285 print
'<tr class="liste_titre">';
286 print
'<th colspan="3">'.$langs->trans(
"DraftContracts").($num ?
'<span class="badge marginleftonlyshort">'.$num.
'</span>' :
'').
'</th></tr>';
291 $obj = $db->fetch_object($resql);
293 $staticcontrat->ref = $obj->ref;
294 $staticcontrat->id = $obj->rowid;
296 $staticcompany->id = $obj->socid;
297 $staticcompany->name = $obj->name;
298 $staticcompany->name_alias = $obj->name_alias;
299 $staticcompany->logo = $obj->logo;
300 $staticcompany->code_client = $obj->code_client;
301 $staticcompany->code_fournisseur = $obj->code_fournisseur;
302 $staticcompany->code_compta = $obj->code_compta_client;
303 $staticcompany->code_compta_client = $obj->code_compta_client;
304 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
305 $staticcompany->client = $obj->client;
306 $staticcompany->fournisseur = $obj->fournisseur;
308 print
'<tr class="oddeven"><td class="nowrap">';
309 print $staticcontrat->getNomUrl(1, 0);
312 print $staticcompany->getNomUrl(1,
'', 16);
319 print
'<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"NoContracts").
'</span></td></tr>';
321 print
"</table></div><br>";
329print
'</div><div class="fichetwothirdright">';
334$sql .=
" sum(".$db->ifsql(
"cd.statut=0",
'1',
'0').
') as nb_initial,';
335$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,';
336$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,';
337$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,';
338$sql .=
" sum(".$db->ifsql(
"cd.statut=5",
'1',
'0').
') as nb_closed,';
339$sql .=
" c.rowid as cid, c.ref, c.datec, c.tms, c.statut,";
340$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";
341$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
342if (!$user->hasRight(
'societe',
'client',
'voir')) {
343 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
345$sql .=
" ".MAIN_DB_PREFIX.
"contrat as c";
346$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
347$sql .=
" WHERE c.fk_soc = s.rowid";
348$sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
349$sql .=
" AND c.statut > 0";
350if (!$user->hasRight(
'societe',
'client',
'voir')) {
351 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
354 $sql .=
" AND s.rowid = ".((int) $socid);
356$sql .=
" GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut,";
357$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";
358$sql .=
" ORDER BY c.tms DESC";
359$sql .= $db->plimit($max);
362$result = $db->query($sql);
364 $num = $db->num_rows($result);
367 print
'<div class="div-table-responsive-no-min">';
368 print
'<table class="noborder centpercent">';
370 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"LastContracts", $max).
'</th>';
371 print
'<th class="center">'.$langs->trans(
"DateModification").
'</th>';
373 print
'<th class="center" width="80" colspan="4">'.$langs->trans(
"Services").
'</th>';
377 $obj = $db->fetch_object($result);
378 $datem = $db->jdate($obj->tms);
380 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid);
381 $staticcontrat->id = $obj->cid;
383 $staticcompany->id = $obj->socid;
384 $staticcompany->name = $obj->name;
385 $staticcompany->name_alias = $obj->name_alias;
386 $staticcompany->photo = 1;
387 $staticcompany->code_client = $obj->code_client;
388 $staticcompany->code_fournisseur = $obj->code_fournisseur;
389 $staticcompany->code_compta = $obj->code_compta_client;
390 $staticcompany->code_compta_client = $obj->code_compta_client;
391 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
392 $staticcompany->client = $obj->client;
393 $staticcompany->fournisseur = $obj->fournisseur;
395 print
'<tr class="oddeven">';
396 print
'<td class="nowraponall">';
397 print $staticcontrat->getNomUrl(1, 16);
403 print
'<td class="tdoverflowmax150">';
404 print $staticcompany->getNomUrl(1,
'', 20);
406 print
'<td class="center nowraponall" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
410 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>';
411 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>';
412 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>';
413 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>';
419 print
"</table></div>";
427$sql =
"SELECT c.ref, c.fk_soc as socid,";
428$sql .=
" cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,";
429$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,";
430$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
431$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
432$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
433if (!$user->hasRight(
'societe',
'client',
'voir')) {
434 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
436$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
437$sql .=
") LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
438$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
439$sql .=
" AND cd.fk_contrat = c.rowid";
440$sql .=
" AND c.fk_soc = s.rowid";
441if (!$user->hasRight(
'societe',
'client',
'voir')) {
442 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
445 $sql .=
" AND s.rowid = ".((int) $socid);
447$sql .=
" ORDER BY cd.tms DESC";
449$resql = $db->query($sql);
451 $num = $db->num_rows($resql);
454 print
'<div class="div-table-responsive-no-min">';
455 print
'<table class="noborder centpercent">';
457 print
'<tr class="liste_titre"><th colspan="4">'.$langs->trans(
"LastModifiedServices", $max).
'</th>';
460 while ($i < min($num, $max)) {
461 $obj = $db->fetch_object($resql);
463 print
'<tr class="oddeven">';
464 print
'<td class="nowraponall">';
466 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
467 $staticcontrat->id = $obj->fk_contrat;
469 $staticcompany->id = $obj->socid;
470 $staticcompany->name = $obj->name;
471 $staticcompany->name_alias = $obj->name_alias;
472 $staticcompany->photo = 1;
473 $staticcompany->code_client = $obj->code_client;
474 $staticcompany->code_fournisseur = $obj->code_fournisseur;
475 $staticcompany->code_compta = $obj->code_compta_client;
476 $staticcompany->code_compta_client = $obj->code_compta_client;
477 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
478 $staticcompany->client = $obj->client;
479 $staticcompany->fournisseur = $obj->fournisseur;
481 print $staticcontrat->getNomUrl(1, 16);
486 if ($obj->fk_product > 0) {
487 $productstatic->id = $obj->fk_product;
488 $productstatic->type = $obj->ptype;
489 $productstatic->ref = $obj->pref;
490 $productstatic->entity = $obj->pentity;
491 print $productstatic->getNomUrl(1,
'', 20);
493 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
495 print
' '.dol_trunc($obj->label, 20).
'</a>';
497 print
'</a> '.dol_trunc($obj->note, 20);
501 print
'<td class="tdoverflowmax125">';
502 print $staticcompany->getNomUrl(1,
'', 20);
504 print
'<td class="nowrap right"><a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
505 $dateend = $db->jdate($obj->date_fin_validite);
506 print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now) ? 1 : 0);
513 print
"</table></div>";
521$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,";
522$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,";
523$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
524$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
525$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
526if (!$user->hasRight(
'societe',
'client',
'voir')) {
527 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
529$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
530$sql .=
" ) LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
531$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
532$sql .=
" AND c.statut = 1";
533$sql .=
" AND cd.statut = 0";
534$sql .=
" AND cd.fk_contrat = c.rowid";
535$sql .=
" AND c.fk_soc = s.rowid";
536if (!$user->hasRight(
'societe',
'client',
'voir')) {
537 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
540 $sql .=
" AND s.rowid = ".((int) $socid);
542$sql .=
" ORDER BY cd.tms DESC";
544$resql = $db->query($sql);
546 $num = $db->num_rows($resql);
549 print
'<div class="div-table-responsive-no-min">';
550 print
'<table class="noborder centpercent">';
552 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>';
556 $obj = $db->fetch_object($resql);
558 $staticcompany->id = $obj->thirdpartyid;
559 $staticcompany->name = $obj->name;
560 $staticcompany->name_alias = $obj->name_alias;
561 $staticcompany->photo = 1;
562 $staticcompany->code_client = $obj->code_client;
563 $staticcompany->code_fournisseur = $obj->code_fournisseur;
564 $staticcompany->code_compta = $obj->code_compta_client;
565 $staticcompany->code_compta_client = $obj->code_compta_client;
566 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
567 $staticcompany->client = $obj->client;
568 $staticcompany->fournisseur = $obj->fournisseur;
570 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
571 $staticcontrat->id = $obj->fk_contrat;
573 $productstatic->id = $obj->fk_product;
574 $productstatic->type = $obj->ptype;
575 $productstatic->ref = $obj->pref;
576 $productstatic->entity = $obj->pentity;
578 print
'<tr class="oddeven">';
580 print
'<td class="nowraponall">';
581 print $staticcontrat->getNomUrl(1, 16);
583 print
'<td class="nowrap">';
584 if ($obj->fk_product > 0) {
585 print $productstatic->getNomUrl(1,
'', 20);
587 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
589 print
' '.dol_trunc($obj->label, 20).
'</a>';
591 print
'</a> '.dol_trunc($obj->note, 20);
595 print
'<td class="tdoverflowmax125">';
596 print $staticcompany->getNomUrl(1,
'', 20);
598 print
'<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
599 print $staticcontratligne->LibStatut($obj->statut, 3);
607 print
"</table></div>";
615$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,";
616$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,";
617$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
618$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
619$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
620if (!$user->hasRight(
'societe',
'client',
'voir')) {
621 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
623$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
624$sql .=
" ) LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
625$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
626$sql .=
" AND c.statut = 1";
627$sql .=
" AND cd.statut = 4";
628$sql .=
" AND cd.date_fin_validite < '".$db->idate($now).
"'";
629$sql .=
" AND cd.fk_contrat = c.rowid";
630$sql .=
" AND c.fk_soc = s.rowid";
631if (!$user->hasRight(
'societe',
'client',
'voir')) {
632 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
635 $sql .=
" AND s.rowid = ".((int) $socid);
637$sql .=
" ORDER BY cd.tms DESC";
639$resql = $db->query($sql);
641 $num = $db->num_rows($resql);
644 print
'<div class="div-table-responsive-no-min">';
645 print
'<table class="noborder centpercent">';
647 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>';
651 $obj = $db->fetch_object($resql);
653 $staticcompany->id = $obj->thirdpartyid;
654 $staticcompany->name = $obj->name;
655 $staticcompany->name_alias = $obj->name_alias;
656 $staticcompany->photo = 1;
657 $staticcompany->code_client = $obj->code_client;
658 $staticcompany->code_fournisseur = $obj->code_fournisseur;
659 $staticcompany->code_compta = $obj->code_compta_client;
660 $staticcompany->code_compta_client = $obj->code_compta_client;
661 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
662 $staticcompany->client = $obj->client;
663 $staticcompany->fournisseur = $obj->fournisseur;
665 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
666 $staticcontrat->id = $obj->fk_contrat;
668 $productstatic->id = $obj->fk_product;
669 $productstatic->type = $obj->ptype;
670 $productstatic->ref = $obj->pref;
671 $productstatic->entity = $obj->pentity;
673 print
'<tr class="oddeven">';
675 print
'<td class="nowraponall">';
676 print $staticcontrat->getNomUrl(1, 16);
678 print
'<td class="nowrap">';
679 if ($obj->fk_product > 0) {
680 print $productstatic->getNomUrl(1,
'', 20);
682 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
684 print
' '.dol_trunc($obj->label, 20).
'</a>';
686 print
'</a> '.dol_trunc($obj->note, 20);
690 print
'<td class="tdoverflowmax125">';
691 print $staticcompany->getNomUrl(1,
'', 20);
693 print
'<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
694 print $staticcontratligne->LibStatut($obj->statut, 3, 1);
701 print
"</table></div>";
709$parameters = array(
'user' => $user);
710$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...)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.