* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin * * 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 2 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/compta/deplacement/list.php * \brief Page list of expenses */ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/tva/class/tva.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/class/deplacement.class.php"); $langs->load("companies"); $langs->load("users"); $langs->load("trips"); // Security check $socid = GETPOST('socid'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'deplacement','',''); $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) $sortfield="d.dated"; $limit = $conf->liste_limit; $search_ref=GETPOST('search_ref'); /* * View */ $tripandexpense_static=new Deplacement($db); llxHeader(); $sql = "SELECT s.nom, s.rowid as socid,"; // Ou $sql.= " d.rowid, d.type, d.dated as dd, d.km,"; // Comment $sql.= " u.name, u.firstname"; // Qui $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= ", ".MAIN_DB_PREFIX."deplacement as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON d.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE d.fk_user = u.rowid"; $sql.= " AND d.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if (trim($search_ref) != '') { $sql.= ' AND d.rowid LIKE \'%'.$db->escape(trim($search_ref)) . '%\''; } $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1 ,$offset); //print $sql; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"],"&socid=$socid",$sortfield,$sortorder,'',$num); $i = 0; print '
'."\n"; print ''; print ""; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","","&socid=$socid",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"d.type","","&socid=$socid",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"d.dated","","&socid=$socid",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.name","","&socid=$socid",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socid=$socid",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("FeesKilometersOrAmout"),$_SERVER["PHP_SELF"],"d.km","","&socid=$socid",'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"], ''); print "\n"; // Filters lines print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '\n"; $var=true; while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); $soc = new Societe($db); if ($objp->socid) $soc->fetch($objp->socid); $var=!$var; print ''; print ''; print ''; print ''; print ''; if ($objp->socid) print ''; else print ''; print ''; print ''; print "\n"; $i++; } print "
'; print ''; print ''; //print ''; print ''; //print ''; print ''; print ' '; print ''; print ' '; print ''; print ' '; print ''; print "
'.img_object($langs->trans("ShowTrip"),"trip").' '.$objp->rowid.''.$langs->trans($objp->type).''.dol_print_date($db->jdate($objp->dd),'day').''.img_object($langs->trans("ShowUser"),"user").' '.$objp->firstname.' '.$objp->name.''.$soc->getNomUrl(1).' '.$objp->km.''.$tripandexpense_static->getLibStatut(5).'
"; print "
\n"; $db->free($resql); } else { dol_print_error($db); } $db->close(); llxFooter(); ?>