29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36$langs->loadLangs(array(
'companies',
'users',
'trips'));
41 $socid = $user->socid;
45$search_ref =
GETPOST(
'search_ref',
'alpha');
46$search_name =
GETPOST(
'search_name',
'alpha');
47$search_company =
GETPOST(
'search_company',
'alpha');
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53if (empty($page) || $page == -1) {
56$offset = $limit * $page;
63 $sortfield =
"d.dated";
70if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
86$userstatic =
new User($db);
88$childids = $user->getAllChildIds();
89$childids[] = $user->id;
93$sql =
"SELECT s.nom, d.fk_user, s.rowid as socid,";
94$sql .=
" d.rowid, d.type, d.dated as dd, d.km,";
95$sql .=
" d.fk_statut,";
96$sql .=
" u.lastname, u.firstname";
97$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
98$sql .=
", ".MAIN_DB_PREFIX.
"deplacement as d";
99$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON d.fk_soc = s.rowid";
100$sql .=
" WHERE d.fk_user = u.rowid";
101$sql .=
" AND d.entity = ".$conf->entity;
102if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
103 $sql .=
' AND d.fk_user IN ('.$db->sanitize(implode(
',', $childids)).
')';
107if (!$user->hasRight(
'societe',
'client',
'voir')) {
108 $search_sale = $user->id;
111if ($search_sale && $search_sale !=
'-1') {
112 if ($search_sale == -2) {
113 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc)";
114 } elseif ($search_sale > 0) {
115 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
120 $sql .=
" AND d.fk_soc = ".((int) $socid);
124 $sql .=
" AND d.rowid = ".((int) $search_ref);
129if ($search_company) {
134$sql .= $db->order($sortfield, $sortorder);
135$sql .= $db->plimit($limit + 1, $offset);
138$resql = $db->query($sql);
140 $num = $db->num_rows($resql);
142 print_barre_liste($langs->trans(
"TripsAndExpenses"), $page, $_SERVER[
"PHP_SELF"],
"&socid=$socid", $sortfield, $sortorder,
'', $num);
145 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
146 print
'<table class="noborder centpercent">';
147 print
"<tr class=\"liste_titre\">";
148 print_liste_field_titre(
"Ref", $_SERVER[
"PHP_SELF"],
"d.rowid",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
149 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"d.type",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
150 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.dated",
"",
"&socid=$socid",
'align="center"', $sortfield, $sortorder);
151 print_liste_field_titre(
"Person", $_SERVER[
"PHP_SELF"],
"u.lastname",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
152 print_liste_field_titre(
"Company", $_SERVER[
"PHP_SELF"],
"s.nom",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
153 print_liste_field_titre(
"FeesKilometersOrAmout", $_SERVER[
"PHP_SELF"],
"d.km",
"",
"&socid=$socid",
'class="right"', $sortfield, $sortorder);
158 print
'<tr class="liste_titre">';
159 print
'<td class="liste_titre">';
160 print
'<input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'">';
162 print
'<td class="liste_titre">';
165 print
'<td class="liste_titre" align="center">';
167 print
'<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.
'">';
169 print
'<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.
'">';
170 print $formother->selectyear($year ? $year : -1,
'year', 1, 20, 5);
172 print
'<td class="liste_titre">';
173 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
175 print
'<td class="liste_titre">';
176 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
178 print
'<td class="liste_titre right">';
181 print
'<td class="liste_titre maxwidthsearch">';
182 $searchpicto = $form->showFilterAndCheckAddButtons(0);
187 while ($i < min($num, $limit)) {
188 $obj = $db->fetch_object($resql);
192 $soc->fetch($obj->socid);
195 print
'<tr class="oddeven">';
197 print
'<td><a href="card.php?id='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowTrip"),
"trip").
' '.$obj->rowid.
'</a></td>';
199 print
'<td>'.$langs->trans($obj->type).
'</td>';
201 print
'<td class="center">'.dol_print_date($db->jdate($obj->dd),
'day').
'</td>';
204 $userstatic->id = $obj->fk_user;
205 $userstatic->lastname = $obj->lastname;
206 $userstatic->firstname = $obj->firstname;
207 print $userstatic->getNomUrl(1);
211 print
'<td>'.$soc->getNomUrl(1).
'</td>';
213 print
'<td> </td>';
216 print
'<td class="right">'.$obj->km.
'</td>';
218 $tripandexpense_static->statut = $obj->fk_statut;
219 print
'<td class="right">'.$tripandexpense_static->getLibStatut(5).
'</td>';
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 trips and working credit notes.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
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.