30require
"../main.inc.php";
31require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
32require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
37$hookmanager->initHooks(array(
'contractindex'));
40$langs->loadLangs(array(
'products',
'companies',
'contracts'));
42$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53if (!empty($user->socid)) {
54 $socid = $user->socid;
58$staticcompany =
new Societe($db);
59$staticcontrat =
new Contrat($db);
61$productstatic =
new Product($db);
78$title = $langs->trans(
"ContractsArea");
79$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
81llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-index');
86print
'<div class="fichecenter"><div class="fichethirdleft">';
100$sql =
"SELECT count(cd.rowid) as nb, cd.statut as status";
101$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
102$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd, ".MAIN_DB_PREFIX.
"contrat as c";
103if (!$user->hasRight(
'societe',
'client',
'voir')) {
104 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
106$sql .=
" WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
107$sql .=
" AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now).
"')))";
108$sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
110 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
112if (!$user->hasRight(
'societe',
'client',
'voir')) {
113 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
115$sql .=
" GROUP BY cd.statut";
116$resql = $db->query($sql);
118 $num = $db->num_rows($resql);
121 $obj = $db->fetch_object($resql);
123 $nb[$obj->status] = $obj->nb;
124 if ($obj->status != 5) {
125 $vals[$obj->status] = $obj->nb;
126 $totalinprocess += $obj->nb;
137$sql =
"SELECT count(cd.rowid) as nb, cd.statut as status";
138$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
139$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd, ".MAIN_DB_PREFIX.
"contrat as c";
140if (!$user->hasRight(
'societe',
'client',
'voir')) {
141 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
143$sql .=
" WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
144$sql .=
" AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"')";
145$sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
147 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
149if (!$user->hasRight(
'societe',
'client',
'voir')) {
150 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
152$sql .=
" GROUP BY cd.statut";
153$resql = $db->query($sql);
155 $num = $db->num_rows($resql);
160 $obj = $db->fetch_object($resql);
162 $nb[$obj->status.((string)
true)] = $obj->nb;
163 if ($obj->status != 5) {
164 $vals[$obj->status.((string)
true)] = $obj->nb;
165 $totalinprocess += $obj->nb;
176$colorseries = array();
178include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
180print
'<div class="div-table-responsive-no-min">';
181print
'<table class="noborder nohover centpercent">';
182print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"Services").
'</th></tr>'.
"\n";
183$listofstatus = array(0, 4, 4, 5);
185foreach ($listofstatus as $status) {
186 $bool_str = (string) $bool;
187 $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool_str]) ? (int) $nb[$status.$bool_str] : 0));
188 if ($status == ContratLigne::STATUS_INITIAL) {
189 $colorseries[$status.$bool_str] =
'-'.$badgeStatus0;
191 if ($status == ContratLigne::STATUS_OPEN && !$bool) {
192 $colorseries[$status.$bool_str] = $badgeStatus4;
194 if ($status == ContratLigne::STATUS_OPEN && $bool) {
195 $colorseries[$status.$bool_str] = $badgeStatus1;
197 if ($status == ContratLigne::STATUS_CLOSED) {
198 $colorseries[$status.$bool_str] = $badgeStatus6;
201 if (empty($conf->use_javascript_ajax)) {
202 print
'<tr class="oddeven">';
203 print
'<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).
'</td>';
204 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>';
207 if ($status == 4 && !$bool) {
213if (!empty($conf->use_javascript_ajax)) {
214 print
'<tr class="impair"><td class="center" colspan="2">';
216 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
218 $dolgraph->SetData($dataseries);
219 $dolgraph->SetDataColor(array_values($colorseries));
220 $dolgraph->setShowLegend(2);
221 $dolgraph->setShowPercent(1);
222 $dolgraph->SetType(array(
'pie'));
223 $dolgraph->setHeight(
'200');
224 $dolgraph->draw(
'idgraphstatus');
225 print $dolgraph->show($total ? 0 : 1);
229$listofstatus = array(0, 4, 4, 5);
231foreach ($listofstatus as $status) {
232 $bool_str = (string) $bool;
233 if (empty($conf->use_javascript_ajax)) {
234 print
'<tr class="oddeven">';
235 print
'<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).
'</td>';
236 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>';
237 if ($status == 4 && !$bool) {
245print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
246print
"</table></div><br>";
251if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
252 $sql =
"SELECT c.rowid, c.ref,";
253 $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";
254 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c, ".MAIN_DB_PREFIX.
"societe as s";
255 if (!$user->hasRight(
'societe',
'client',
'voir')) {
256 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
258 $sql .=
" WHERE s.rowid = c.fk_soc";
259 $sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
260 $sql .=
" AND c.statut = 0";
261 if (!$user->hasRight(
'societe',
'client',
'voir')) {
262 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
265 $sql .=
" AND c.fk_soc = ".((int) $socid);
268 $resql = $db->query($sql);
271 $num = $db->num_rows($resql);
273 print
'<div class="div-table-responsive-no-min">';
274 print
'<table class="noborder centpercent">';
275 print
'<tr class="liste_titre">';
276 print
'<th colspan="3">'.$langs->trans(
"DraftContracts").($num ?
'<span class="badge marginleftonlyshort">'.$num.
'</span>' :
'').
'</th></tr>';
281 $obj = $db->fetch_object($resql);
283 $staticcontrat->ref = $obj->ref;
284 $staticcontrat->id = $obj->rowid;
286 $staticcompany->id = $obj->socid;
287 $staticcompany->name = $obj->name;
288 $staticcompany->name_alias = $obj->name_alias;
289 $staticcompany->logo = $obj->logo;
290 $staticcompany->code_client = $obj->code_client;
291 $staticcompany->code_fournisseur = $obj->code_fournisseur;
292 $staticcompany->code_compta = $obj->code_compta_client;
293 $staticcompany->code_compta_client = $obj->code_compta_client;
294 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
295 $staticcompany->client = $obj->client;
296 $staticcompany->fournisseur = $obj->fournisseur;
298 print
'<tr class="oddeven"><td class="nowrap">';
299 print $staticcontrat->getNomUrl(1, 0);
302 print $staticcompany->getNomUrl(1,
'', 16);
309 print
'<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"NoContracts").
'</span></td></tr>';
311 print
"</table></div><br>";
319print
'</div><div class="fichetwothirdright">';
324$sql .=
" sum(".$db->ifsql(
"cd.statut=0", 1, 0).
') as nb_initial,';
325$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,';
326$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,';
327$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,';
328$sql .=
" sum(".$db->ifsql(
"cd.statut=5", 1, 0).
') as nb_closed,';
329$sql .=
" c.rowid as cid, c.ref, c.datec, c.tms, c.statut,";
330$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, s.code_compta_fournisseur";
331$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
332if (!$user->hasRight(
'societe',
'client',
'voir')) {
333 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
335$sql .=
" ".MAIN_DB_PREFIX.
"contrat as c";
336$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
337$sql .=
" WHERE c.fk_soc = s.rowid";
338$sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
339$sql .=
" AND c.statut > 0";
340if (!$user->hasRight(
'societe',
'client',
'voir')) {
341 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
344 $sql .=
" AND s.rowid = ".((int) $socid);
346$sql .=
" GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut,";
347$sql .=
" s.nom, s.name_alias, s.logo, s.rowid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur";
348$sql .=
" ORDER BY c.tms DESC";
349$sql .= $db->plimit($max);
352$result = $db->query($sql);
354 $num = $db->num_rows($result);
357 print
'<div class="div-table-responsive-no-min">';
358 print
'<table class="noborder centpercent">';
360 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"LastContracts", $max).
'</th>';
361 print
'<th class="center">'.$langs->trans(
"DateModification").
'</th>';
363 print
'<th class="center" width="80" colspan="4">'.$langs->trans(
"Services").
'</th>';
367 $obj = $db->fetch_object($result);
368 $datem = $db->jdate($obj->tms);
370 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid);
371 $staticcontrat->id = $obj->cid;
373 $staticcompany->id = $obj->socid;
374 $staticcompany->name = $obj->name;
375 $staticcompany->name_alias = $obj->name_alias;
376 $staticcompany->photo = 1;
377 $staticcompany->code_client = $obj->code_client;
378 $staticcompany->code_fournisseur = $obj->code_fournisseur;
379 $staticcompany->code_compta = $obj->code_compta_client;
380 $staticcompany->code_compta_client = $obj->code_compta_client;
381 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
382 $staticcompany->client = $obj->client;
383 $staticcompany->fournisseur = $obj->fournisseur;
385 print
'<tr class="oddeven">';
386 print
'<td class="nowraponall">';
387 print $staticcontrat->getNomUrl(1, 16);
393 print
'<td class="tdoverflowmax150">';
394 print $staticcompany->getNomUrl(1,
'', 20);
396 print
'<td class="center nowraponall" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
400 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>';
401 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>';
402 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>';
403 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>';
409 print
"</table></div>";
417$sql =
"SELECT c.ref, c.fk_soc as socid,";
418$sql .=
" cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,";
419$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,";
420$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
421$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
422$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
423if (!$user->hasRight(
'societe',
'client',
'voir')) {
424 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
426$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
427$sql .=
") LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
428$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
429$sql .=
" AND cd.fk_contrat = c.rowid";
430$sql .=
" AND c.fk_soc = s.rowid";
431if (!$user->hasRight(
'societe',
'client',
'voir')) {
432 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
435 $sql .=
" AND s.rowid = ".((int) $socid);
437$sql .=
" ORDER BY cd.tms DESC";
439$resql = $db->query($sql);
441 $num = $db->num_rows($resql);
444 print
'<div class="div-table-responsive-no-min">';
445 print
'<table class="noborder centpercent">';
447 print
'<tr class="liste_titre"><th colspan="4">'.$langs->trans(
"LastModifiedServices", $max).
'</th>';
450 while ($i < min($num, $max)) {
451 $obj = $db->fetch_object($resql);
453 print
'<tr class="oddeven">';
454 print
'<td class="nowraponall">';
456 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
457 $staticcontrat->id = $obj->fk_contrat;
459 $staticcompany->id = $obj->socid;
460 $staticcompany->name = $obj->name;
461 $staticcompany->name_alias = $obj->name_alias;
462 $staticcompany->photo = 1;
463 $staticcompany->code_client = $obj->code_client;
464 $staticcompany->code_fournisseur = $obj->code_fournisseur;
465 $staticcompany->code_compta = $obj->code_compta_client;
466 $staticcompany->code_compta_client = $obj->code_compta_client;
467 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
468 $staticcompany->client = $obj->client;
469 $staticcompany->fournisseur = $obj->fournisseur;
471 print $staticcontrat->getNomUrl(1, 16);
476 if ($obj->fk_product > 0) {
477 $productstatic->id = $obj->fk_product;
478 $productstatic->type = $obj->ptype;
479 $productstatic->ref = $obj->pref;
480 $productstatic->entity = $obj->pentity;
481 print $productstatic->getNomUrl(1,
'', 20);
483 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
485 print
' '.dol_trunc($obj->label, 20).
'</a>';
487 print
'</a> '.dol_trunc($obj->note, 20);
491 print
'<td class="tdoverflowmax125">';
492 print $staticcompany->getNomUrl(1,
'', 20);
494 print
'<td class="nowrap right"><a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
495 $dateend = $db->jdate($obj->date_fin_validite);
496 print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now) ? 1 : 0);
503 print
"</table></div>";
511$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,";
512$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,";
513$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
514$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
515$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
516if (!$user->hasRight(
'societe',
'client',
'voir')) {
517 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
519$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
520$sql .=
" ) LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
521$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
522$sql .=
" AND c.statut = 1";
523$sql .=
" AND cd.statut = 0";
524$sql .=
" AND cd.fk_contrat = c.rowid";
525$sql .=
" AND c.fk_soc = s.rowid";
526if (!$user->hasRight(
'societe',
'client',
'voir')) {
527 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
530 $sql .=
" AND s.rowid = ".((int) $socid);
532$sql .=
" ORDER BY cd.tms DESC";
534$resql = $db->query($sql);
536 $num = $db->num_rows($resql);
539 print
'<div class="div-table-responsive-no-min">';
540 print
'<table class="noborder centpercent">';
542 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>';
546 $obj = $db->fetch_object($resql);
548 $staticcompany->id = $obj->thirdpartyid;
549 $staticcompany->name = $obj->name;
550 $staticcompany->name_alias = $obj->name_alias;
551 $staticcompany->photo = 1;
552 $staticcompany->code_client = $obj->code_client;
553 $staticcompany->code_fournisseur = $obj->code_fournisseur;
554 $staticcompany->code_compta = $obj->code_compta_client;
555 $staticcompany->code_compta_client = $obj->code_compta_client;
556 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
557 $staticcompany->client = $obj->client;
558 $staticcompany->fournisseur = $obj->fournisseur;
560 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
561 $staticcontrat->id = $obj->fk_contrat;
563 $productstatic->id = $obj->fk_product;
564 $productstatic->type = $obj->ptype;
565 $productstatic->ref = $obj->pref;
566 $productstatic->entity = $obj->pentity;
568 print
'<tr class="oddeven">';
570 print
'<td class="nowraponall">';
571 print $staticcontrat->getNomUrl(1, 16);
573 print
'<td class="nowrap">';
574 if ($obj->fk_product > 0) {
575 print $productstatic->getNomUrl(1,
'', 20);
577 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
579 print
' '.dol_trunc($obj->label, 20).
'</a>';
581 print
'</a> '.dol_trunc($obj->note, 20);
585 print
'<td class="tdoverflowmax125">';
586 print $staticcompany->getNomUrl(1,
'', 20);
588 print
'<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
589 print $staticcontratligne->LibStatut($obj->statut, 3);
597 print
"</table></div>";
605$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,";
606$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,";
607$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
608$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
609$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
610if (!$user->hasRight(
'societe',
'client',
'voir')) {
611 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
613$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
614$sql .=
" ) LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
615$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
616$sql .=
" AND c.statut = 1";
617$sql .=
" AND cd.statut = 4";
618$sql .=
" AND cd.date_fin_validite < '".$db->idate($now).
"'";
619$sql .=
" AND cd.fk_contrat = c.rowid";
620$sql .=
" AND c.fk_soc = s.rowid";
621if (!$user->hasRight(
'societe',
'client',
'voir')) {
622 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
625 $sql .=
" AND s.rowid = ".((int) $socid);
627$sql .=
" ORDER BY cd.tms DESC";
629$resql = $db->query($sql);
631 $num = $db->num_rows($resql);
634 print
'<div class="div-table-responsive-no-min">';
635 print
'<table class="noborder centpercent">';
637 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>';
641 $obj = $db->fetch_object($resql);
643 $staticcompany->id = $obj->thirdpartyid;
644 $staticcompany->name = $obj->name;
645 $staticcompany->name_alias = $obj->name_alias;
646 $staticcompany->photo = 1;
647 $staticcompany->code_client = $obj->code_client;
648 $staticcompany->code_fournisseur = $obj->code_fournisseur;
649 $staticcompany->code_compta = $obj->code_compta_client;
650 $staticcompany->code_compta_client = $obj->code_compta_client;
651 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
652 $staticcompany->client = $obj->client;
653 $staticcompany->fournisseur = $obj->fournisseur;
655 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
656 $staticcontrat->id = $obj->fk_contrat;
658 $productstatic->id = $obj->fk_product;
659 $productstatic->type = $obj->ptype;
660 $productstatic->ref = $obj->pref;
661 $productstatic->entity = $obj->pentity;
663 print
'<tr class="oddeven">';
665 print
'<td class="nowraponall">';
666 print $staticcontrat->getNomUrl(1, 16);
668 print
'<td class="nowrap">';
669 if ($obj->fk_product > 0) {
670 print $productstatic->getNomUrl(1,
'', 20);
672 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
674 print
' '.dol_trunc($obj->label, 20).
'</a>';
676 print
'</a> '.dol_trunc($obj->note, 20);
680 print
'<td class="tdoverflowmax125">';
681 print $staticcompany->getNomUrl(1,
'', 20);
683 print
'<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
684 print $staticcontratligne->LibStatut($obj->statut, 3, 1);
691 print
"</table></div>";
699$parameters = array(
'user' => $user);
700$reshook = $hookmanager->executeHooks(
'dashboardContracts', $parameters, $object);
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_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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_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...
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.