29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 $langs->loadLangs(array(
'companies',
'users',
'trips'));
39 $socid =
GETPOST(
'socid',
'int');
41 $socid = $user->socid;
45 $search_ref =
GETPOST(
'search_ref',
'int');
46 $search_name =
GETPOST(
'search_name',
'alpha');
47 $search_company =
GETPOST(
'search_company',
'alpha');
49 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
53 if (empty($page) || $page == -1) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
63 $sortfield =
"d.dated";
70 if (
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 if (empty($user->rights->societe->client->voir) && !$socid) {
101 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
103 $sql .=
" WHERE d.fk_user = u.rowid";
104 $sql .=
" AND d.entity = ".$conf->entity;
105 if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) {
106 $sql .=
' AND d.fk_user IN ('.$db->sanitize(join(
',', $childids)).
')';
108 if (empty($user->rights->societe->client->voir) && !$socid) {
109 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR d.fk_soc IS NULL) ";
112 $sql .=
" AND s.rowid = ".((int) $socid);
116 $sql .=
" AND d.rowid = ".((int) $search_ref);
121 if ($search_company) {
126 $sql .= $db->order($sortfield, $sortorder);
127 $sql .= $db->plimit($limit + 1, $offset);
130 $resql = $db->query($sql);
132 $num = $db->num_rows(
$resql);
134 print_barre_liste($langs->trans(
"TripsAndExpenses"), $page, $_SERVER[
"PHP_SELF"],
"&socid=$socid", $sortfield, $sortorder,
'', $num);
137 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
138 print
'<table class="noborder centpercent">';
139 print
"<tr class=\"liste_titre\">";
140 print_liste_field_titre(
"Ref", $_SERVER[
"PHP_SELF"],
"d.rowid",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
141 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"d.type",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
142 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.dated",
"",
"&socid=$socid",
'align="center"', $sortfield, $sortorder);
143 print_liste_field_titre(
"Person", $_SERVER[
"PHP_SELF"],
"u.lastname",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
144 print_liste_field_titre(
"Company", $_SERVER[
"PHP_SELF"],
"s.nom",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
145 print_liste_field_titre(
"FeesKilometersOrAmout", $_SERVER[
"PHP_SELF"],
"d.km",
"",
"&socid=$socid",
'class="right"', $sortfield, $sortorder);
150 print
'<tr class="liste_titre">';
151 print
'<td class="liste_titre">';
152 print
'<input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'">';
154 print
'<td class="liste_titre">';
157 print
'<td class="liste_titre" align="center">';
158 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
159 print
'<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.
'">';
161 print
'<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.
'">';
162 print $formother->selectyear($year ? $year : -1,
'year', 1, 20, 5);
164 print
'<td class="liste_titre">';
165 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
167 print
'<td class="liste_titre">';
168 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
170 print
'<td class="liste_titre right">';
173 print
'<td class="liste_titre maxwidthsearch">';
174 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
179 while ($i < min($num, $limit)) {
180 $obj = $db->fetch_object(
$resql);
184 $soc->fetch($obj->socid);
187 print
'<tr class="oddeven">';
189 print
'<td><a href="card.php?id='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowTrip"),
"trip").
' '.$obj->rowid.
'</a></td>';
191 print
'<td>'.$langs->trans($obj->type).
'</td>';
193 print
'<td class="center">'.dol_print_date($db->jdate($obj->dd),
'day').
'</td>';
196 $userstatic->id = $obj->fk_user;
197 $userstatic->lastname = $obj->lastname;
198 $userstatic->firstname = $obj->firstname;
199 print $userstatic->getNomUrl(1);
203 print
'<td>'.$soc->getNomUrl(1).
'</td>';
205 print
'<td> </td>';
208 print
'<td class="right">'.$obj->km.
'</td>';
210 $tripandexpense_static->statut = $obj->fk_statut;
211 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()
Empty header.
Class to manage trips and working credit notes.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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).
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.