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, 5);
192foreach ($listofstatus as $status) {
193 $bool_str = (string) $bool;
194 $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool_str]) ? (int) $nb[$status.$bool_str] : 0));
195 if ($status == ContratLigne::STATUS_INITIAL) {
196 $colorseries[$status.$bool_str] =
'-'.$badgeStatus0;
198 if ($status == ContratLigne::STATUS_OPEN && !$bool) {
199 $colorseries[$status.$bool_str] = $badgeStatus4;
201 if ($status == ContratLigne::STATUS_OPEN && $bool) {
202 $colorseries[$status.$bool_str] = $badgeStatus1;
204 if ($status == ContratLigne::STATUS_CLOSED) {
205 $colorseries[$status.$bool_str] = $badgeStatus6;
208 if (empty(
$conf->use_javascript_ajax)) {
209 print
'<tr class="oddeven">';
210 print
'<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).
'</td>';
211 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>';
214 if ($status == 4 && !$bool) {
220if (!empty(
$conf->use_javascript_ajax)) {
221 print
'<tr class="impair"><td class="center" colspan="2">';
223 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
225 $dolgraph->SetData($dataseries);
226 $dolgraph->SetDataColor(array_values($colorseries));
227 $dolgraph->setShowLegend(2);
228 $dolgraph->setShowPercent(1);
229 $dolgraph->SetType(array(
'pie'));
230 $dolgraph->setHeight(
'200');
231 $dolgraph->draw(
'idgraphstatus');
232 print $dolgraph->show($total ? 0 : 1);
236$listofstatus = array(0, 4, 4, 5);
238foreach ($listofstatus as $status) {
239 $bool_str = (string) $bool;
240 if (empty(
$conf->use_javascript_ajax)) {
241 print
'<tr class="oddeven">';
242 print
'<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).
'</td>';
243 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>';
244 if ($status == 4 && !$bool) {
252print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
253print
"</table></div><br>";
258if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
259 $sql =
"SELECT c.rowid, c.ref,";
260 $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";
261 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c, ".MAIN_DB_PREFIX.
"societe as s";
262 if (!$user->hasRight(
'societe',
'client',
'voir')) {
263 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
265 $sql .=
" WHERE s.rowid = c.fk_soc";
266 $sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
267 $sql .=
" AND c.statut = 0";
268 if (!$user->hasRight(
'societe',
'client',
'voir')) {
269 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
272 $sql .=
" AND c.fk_soc = ".((int) $socid);
275 $resql = $db->query($sql);
278 $num = $db->num_rows($resql);
280 print
'<div class="div-table-responsive-no-min">';
281 print
'<table class="noborder centpercent">';
282 print
'<tr class="liste_titre">';
283 print
'<th colspan="3">'.$langs->trans(
"DraftContracts").($num ?
'<span class="badge marginleftonlyshort">'.$num.
'</span>' :
'').
'</th></tr>';
288 $obj = $db->fetch_object($resql);
290 $staticcontrat->ref = $obj->ref;
291 $staticcontrat->id = $obj->rowid;
293 $staticcompany->id = $obj->socid;
294 $staticcompany->name = $obj->name;
295 $staticcompany->name_alias = $obj->name_alias;
296 $staticcompany->logo = $obj->logo;
297 $staticcompany->code_client = $obj->code_client;
298 $staticcompany->code_fournisseur = $obj->code_fournisseur;
299 $staticcompany->code_compta = $obj->code_compta_client;
300 $staticcompany->code_compta_client = $obj->code_compta_client;
301 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
302 $staticcompany->client = $obj->client;
303 $staticcompany->fournisseur = $obj->fournisseur;
305 print
'<tr class="oddeven"><td class="nowrap">';
306 print $staticcontrat->getNomUrl(1, 0);
309 print $staticcompany->getNomUrl(1,
'', 16);
316 print
'<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"NoContracts").
'</span></td></tr>';
318 print
"</table></div><br>";
326print
'</div><div class="fichetwothirdright">';
331$sql .=
" sum(".$db->ifsql(
"cd.statut=0", 1, 0).
') as nb_initial,';
332$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,';
333$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,';
334$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,';
335$sql .=
" sum(".$db->ifsql(
"cd.statut=5", 1, 0).
') as nb_closed,';
336$sql .=
" c.rowid as cid, c.ref, c.datec, c.tms, c.statut,";
337$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";
338$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
339if (!$user->hasRight(
'societe',
'client',
'voir')) {
340 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
342$sql .=
" ".MAIN_DB_PREFIX.
"contrat as c";
343$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
344$sql .=
" WHERE c.fk_soc = s.rowid";
345$sql .=
" AND c.entity IN (".getEntity(
'contract', 0).
")";
346$sql .=
" AND c.statut > 0";
347if (!$user->hasRight(
'societe',
'client',
'voir')) {
348 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
351 $sql .=
" AND s.rowid = ".((int) $socid);
353$sql .=
" GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut,";
354$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";
355$sql .=
" ORDER BY c.tms DESC";
356$sql .= $db->plimit($max);
359$result = $db->query($sql);
361 $num = $db->num_rows($result);
364 print
'<div class="div-table-responsive-no-min">';
365 print
'<table class="noborder centpercent">';
367 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"LastContracts", $max).
'</th>';
368 print
'<th class="center">'.$langs->trans(
"DateModification").
'</th>';
370 print
'<th class="center" width="80" colspan="4">'.$langs->trans(
"Services").
'</th>';
374 $obj = $db->fetch_object($result);
375 $datem = $db->jdate($obj->tms);
377 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid);
378 $staticcontrat->id = $obj->cid;
380 $staticcompany->id = $obj->socid;
381 $staticcompany->name = $obj->name;
382 $staticcompany->name_alias = $obj->name_alias;
383 $staticcompany->photo = 1;
384 $staticcompany->code_client = $obj->code_client;
385 $staticcompany->code_fournisseur = $obj->code_fournisseur;
386 $staticcompany->code_compta = $obj->code_compta_client;
387 $staticcompany->code_compta_client = $obj->code_compta_client;
388 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
389 $staticcompany->client = $obj->client;
390 $staticcompany->fournisseur = $obj->fournisseur;
392 print
'<tr class="oddeven">';
393 print
'<td class="nowraponall">';
394 print $staticcontrat->getNomUrl(1, 16);
400 print
'<td class="tdoverflowmax150">';
401 print $staticcompany->getNomUrl(1,
'', 20);
403 print
'<td class="center nowraponall" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
407 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>';
408 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>';
409 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>';
410 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>';
416 print
"</table></div>";
424$sql =
"SELECT c.ref, c.fk_soc as socid,";
425$sql .=
" cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,";
426$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,";
427$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
428$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
429$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
430if (!$user->hasRight(
'societe',
'client',
'voir')) {
431 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
433$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
434$sql .=
") LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
435$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
436$sql .=
" AND cd.fk_contrat = c.rowid";
437$sql .=
" AND c.fk_soc = s.rowid";
438if (!$user->hasRight(
'societe',
'client',
'voir')) {
439 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
442 $sql .=
" AND s.rowid = ".((int) $socid);
444$sql .=
" ORDER BY cd.tms DESC";
446$resql = $db->query($sql);
448 $num = $db->num_rows($resql);
451 print
'<div class="div-table-responsive-no-min">';
452 print
'<table class="noborder centpercent">';
454 print
'<tr class="liste_titre"><th colspan="4">'.$langs->trans(
"LastModifiedServices", $max).
'</th>';
457 while ($i < min($num, $max)) {
458 $obj = $db->fetch_object($resql);
460 print
'<tr class="oddeven">';
461 print
'<td class="nowraponall">';
463 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
464 $staticcontrat->id = $obj->fk_contrat;
466 $staticcompany->id = $obj->socid;
467 $staticcompany->name = $obj->name;
468 $staticcompany->name_alias = $obj->name_alias;
469 $staticcompany->photo = 1;
470 $staticcompany->code_client = $obj->code_client;
471 $staticcompany->code_fournisseur = $obj->code_fournisseur;
472 $staticcompany->code_compta = $obj->code_compta_client;
473 $staticcompany->code_compta_client = $obj->code_compta_client;
474 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
475 $staticcompany->client = $obj->client;
476 $staticcompany->fournisseur = $obj->fournisseur;
478 print $staticcontrat->getNomUrl(1, 16);
483 if ($obj->fk_product > 0) {
484 $productstatic->id = $obj->fk_product;
485 $productstatic->type = $obj->ptype;
486 $productstatic->ref = $obj->pref;
487 $productstatic->entity = $obj->pentity;
488 print $productstatic->getNomUrl(1,
'', 20);
490 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
492 print
' '.dol_trunc($obj->label, 20).
'</a>';
494 print
'</a> '.dol_trunc($obj->note, 20);
498 print
'<td class="tdoverflowmax125">';
499 print $staticcompany->getNomUrl(1,
'', 20);
501 print
'<td class="nowrap right"><a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
502 $dateend = $db->jdate($obj->date_fin_validite);
503 print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now) ? 1 : 0);
510 print
"</table></div>";
518$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,";
519$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,";
520$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
521$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
522$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
523if (!$user->hasRight(
'societe',
'client',
'voir')) {
524 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
526$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
527$sql .=
" ) LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
528$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
529$sql .=
" AND c.statut = 1";
530$sql .=
" AND cd.statut = 0";
531$sql .=
" AND cd.fk_contrat = c.rowid";
532$sql .=
" AND c.fk_soc = s.rowid";
533if (!$user->hasRight(
'societe',
'client',
'voir')) {
534 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
537 $sql .=
" AND s.rowid = ".((int) $socid);
539$sql .=
" ORDER BY cd.tms DESC";
541$resql = $db->query($sql);
543 $num = $db->num_rows($resql);
546 print
'<div class="div-table-responsive-no-min">';
547 print
'<table class="noborder centpercent">';
549 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>';
553 $obj = $db->fetch_object($resql);
555 $staticcompany->id = $obj->thirdpartyid;
556 $staticcompany->name = $obj->name;
557 $staticcompany->name_alias = $obj->name_alias;
558 $staticcompany->photo = 1;
559 $staticcompany->code_client = $obj->code_client;
560 $staticcompany->code_fournisseur = $obj->code_fournisseur;
561 $staticcompany->code_compta = $obj->code_compta_client;
562 $staticcompany->code_compta_client = $obj->code_compta_client;
563 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
564 $staticcompany->client = $obj->client;
565 $staticcompany->fournisseur = $obj->fournisseur;
567 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
568 $staticcontrat->id = $obj->fk_contrat;
570 $productstatic->id = $obj->fk_product;
571 $productstatic->type = $obj->ptype;
572 $productstatic->ref = $obj->pref;
573 $productstatic->entity = $obj->pentity;
575 print
'<tr class="oddeven">';
577 print
'<td class="nowraponall">';
578 print $staticcontrat->getNomUrl(1, 16);
580 print
'<td class="nowrap">';
581 if ($obj->fk_product > 0) {
582 print $productstatic->getNomUrl(1,
'', 20);
584 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
586 print
' '.dol_trunc($obj->label, 20).
'</a>';
588 print
'</a> '.dol_trunc($obj->note, 20);
592 print
'<td class="tdoverflowmax125">';
593 print $staticcompany->getNomUrl(1,
'', 20);
595 print
'<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
596 print $staticcontratligne->LibStatut($obj->statut, 3);
604 print
"</table></div>";
612$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,";
613$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,";
614$sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
615$sql .=
" FROM (".MAIN_DB_PREFIX.
"contrat as c";
616$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
617if (!$user->hasRight(
'societe',
'client',
'voir')) {
618 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
620$sql .=
", ".MAIN_DB_PREFIX.
"contratdet as cd";
621$sql .=
" ) LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
622$sql .=
" WHERE c.entity IN (".getEntity(
'contract', 0).
")";
623$sql .=
" AND c.statut = 1";
624$sql .=
" AND cd.statut = 4";
625$sql .=
" AND cd.date_fin_validite < '".$db->idate($now).
"'";
626$sql .=
" AND cd.fk_contrat = c.rowid";
627$sql .=
" AND c.fk_soc = s.rowid";
628if (!$user->hasRight(
'societe',
'client',
'voir')) {
629 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
632 $sql .=
" AND s.rowid = ".((int) $socid);
634$sql .=
" ORDER BY cd.tms DESC";
636$resql = $db->query($sql);
638 $num = $db->num_rows($resql);
641 print
'<div class="div-table-responsive-no-min">';
642 print
'<table class="noborder centpercent">';
644 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>';
648 $obj = $db->fetch_object($resql);
650 $staticcompany->id = $obj->thirdpartyid;
651 $staticcompany->name = $obj->name;
652 $staticcompany->name_alias = $obj->name_alias;
653 $staticcompany->photo = 1;
654 $staticcompany->code_client = $obj->code_client;
655 $staticcompany->code_fournisseur = $obj->code_fournisseur;
656 $staticcompany->code_compta = $obj->code_compta_client;
657 $staticcompany->code_compta_client = $obj->code_compta_client;
658 $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur;
659 $staticcompany->client = $obj->client;
660 $staticcompany->fournisseur = $obj->fournisseur;
662 $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
663 $staticcontrat->id = $obj->fk_contrat;
665 $productstatic->id = $obj->fk_product;
666 $productstatic->type = $obj->ptype;
667 $productstatic->ref = $obj->pref;
668 $productstatic->entity = $obj->pentity;
670 print
'<tr class="oddeven">';
672 print
'<td class="nowraponall">';
673 print $staticcontrat->getNomUrl(1, 16);
675 print
'<td class="nowrap">';
676 if ($obj->fk_product > 0) {
677 print $productstatic->getNomUrl(1,
'', 20);
679 print
'<a href="'.DOL_URL_ROOT.
'/contrat/card.php?id='.$obj->fk_contrat.
'">'.
img_object($langs->trans(
"ShowService"),
"service");
681 print
' '.dol_trunc($obj->label, 20).
'</a>';
683 print
'</a> '.dol_trunc($obj->note, 20);
687 print
'<td class="tdoverflowmax125">';
688 print $staticcompany->getNomUrl(1,
'', 20);
690 print
'<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.
'&ligne='.$obj->cid.
'">';
691 print $staticcontratligne->LibStatut($obj->statut, 3, 1);
698 print
"</table></div>";
706$parameters = array(
'user' => $user);
707$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.
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.