* Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/fichinter/list.php * \brief List of all interventions * \ingroup ficheinter */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("companies"); $langs->load("bills"); $langs->load("interventions"); $socid=GETPOST('socid','int'); // Security check $fichinterid = GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $fichinterid,'fichinter'); $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) { if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sortfield="fd.date"; else $sortfield="f.ref"; } $limit = $conf->liste_limit; $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha'); $search_company=GETPOST('search_company','alpha'); $search_desc=GETPOST('search_desc','alpha'); $search_status=GETPOST('search_status'); $sall=GETPOST('sall'); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_company=""; $search_desc=""; $search_status=""; } /* * View */ $form = new Form($db); $interventionstatic=new Fichinter($db); llxHeader('', $langs->trans("Intervention")); $sql = "SELECT"; $sql.= " f.ref, f.rowid as fichid, f.fk_statut, f.description,"; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " fd.description as descriptiondetail, fd.date as dp, fd.duree,"; $sql.= " s.nom as name, s.rowid as socid, s.client"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && empty($socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f)"; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; $sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " AND f.entity = ".$conf->entity; if ($search_ref) { $sql .= natural_search('f.ref', $search_ref); } if ($search_company) { $sql .= natural_search('s.nom', $search_company); } if ($search_desc) { if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql .= natural_search(array('f.description', 'fd.description'), $search_desc); else $sql .= natural_search(array('f.description'), $search_desc); } if ($search_status != '' && $search_status >= 0) { $sql .= ' AND f.fk_statut = '.$search_status; } if (! $user->rights->societe->client->voir && empty($socid)) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = " . $socid; if ($sall) { $arraytosearch=array('f.ref', 'f.description', 's.nom'); if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $arraytosearch=array('f.ref', 'f.description', 's.nom', 'fd.description'); $sql .= natural_search($arraytosearch, $sall); } $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); //print $sql; $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); $urlparam=''; if ($socid) $urlparam.="&socid=".$socid; if ($search_ref) $urlparam.="&search_ref=".urlencode($search_ref); if ($search_company) $urlparam.="&search_company=".urlencode($search_company); if ($search_desc) $urlparam.="&search_desc=".urlencode($search_desc); if ($search_status != '' && $search_status > -1) $urlparam.="&search_status=".urlencode($search_status); print_barre_liste($langs->trans("ListOfInterventions"), $page, $_SERVER['PHP_SELF'], $urlparam, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_commercial.png'); print '
'."\n"; print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.ref","",$urlparam,'width="15%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$urlparam,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"f.description","",$urlparam,'',$sortfield,$sortorder); if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { print_liste_field_titre('',$_SERVER["PHP_SELF"],''); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fd.date","",$urlparam,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],"fd.duree","",$urlparam,'align="right"',$sortfield,$sortorder); } print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$urlparam,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; print ''; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { // Desc of line print ''; print ''; print ''; } print ''; print '\n"; $companystatic=new Societe($db); $var=True; $total = 0; $i = 0; while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $var=!$var; print ""; print "\n"; print ''; print ''; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { print ''; print '\n"; print ''; } print ''; print ''; print "\n"; $total += $objp->duree; $i++; } $rowspan=3; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { print ''; print ''; print ''; } print '
'; print ''; print ''; print ''; print ''; print ''; print '   '; $liststatus=$interventionstatic->statuts_short; print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); print ''; print ''; print "
"; $interventionstatic->id=$objp->fichid; $interventionstatic->ref=$objp->ref; print $interventionstatic->getNomUrl(1); print "'; $companystatic->name=$objp->name; $companystatic->id=$objp->socid; $companystatic->client=$objp->client; print $companystatic->getNomUrl(1,'',44); print ''.dol_htmlentitiesbr(dol_trunc($objp->description,20)).''.dol_htmlentitiesbr(dol_trunc($objp->descriptiondetail,20)).''.dol_print_date($db->jdate($objp->dp),'dayhour')."'.convertSecondToTime($objp->duree).''.$interventionstatic->LibStatut($objp->fk_statut,5).' 
'.$langs->trans("Total").''.convertSecondToTime($total).'  
'; print "
\n"; $db->free($result); } else { dol_print_error($db); } llxFooter(); $db->close();