30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
46$langs->loadLangs(array(
'companies',
'users',
'trips'));
51 $socid = $user->socid;
55$search_ref =
GETPOST(
'search_ref',
'alpha');
56$search_name =
GETPOST(
'search_name',
'alpha');
57$search_company =
GETPOST(
'search_company',
'alpha');
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63if (empty($page) || $page == -1) {
66$offset = $limit * $page;
73 $sortfield =
"d.dated";
80if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
96$userstatic =
new User($db);
98$childids = $user->getAllChildIds();
99$childids[] = $user->id;
103$sql =
"SELECT s.nom, d.fk_user, s.rowid as socid,";
104$sql .=
" d.rowid, d.type, d.dated as dd, d.km,";
105$sql .=
" d.fk_statut,";
106$sql .=
" u.lastname, u.firstname";
107$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
108$sql .=
", ".MAIN_DB_PREFIX.
"deplacement as d";
109$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON d.fk_soc = s.rowid";
110$sql .=
" WHERE d.fk_user = u.rowid";
111$sql .=
" AND d.entity = ".$conf->entity;
112if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
113 $sql .=
' AND d.fk_user IN ('.$db->sanitize(implode(
',', $childids)).
')';
117if (!$user->hasRight(
'societe',
'client',
'voir')) {
118 $search_sale = $user->id;
121if ($search_sale && $search_sale !=
'-1') {
122 if ($search_sale == -2) {
123 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc)";
124 } elseif ($search_sale > 0) {
125 $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).
")";
130 $sql .=
" AND d.fk_soc = ".((int) $socid);
134 $sql .=
" AND d.rowid = ".((int) $search_ref);
139if ($search_company) {
144$sql .= $db->order($sortfield, $sortorder);
145$sql .= $db->plimit($limit + 1, $offset);
148$resql = $db->query($sql);
150 $num = $db->num_rows($resql);
152 print_barre_liste($langs->trans(
"TripsAndExpenses"), $page, $_SERVER[
"PHP_SELF"],
"&socid=$socid", $sortfield, $sortorder,
'', $num);
155 print
'<form method="get" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
156 print
'<table class="noborder centpercent">';
157 print
"<tr class=\"liste_titre\">";
158 print_liste_field_titre(
"Ref", $_SERVER[
"PHP_SELF"],
"d.rowid",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
159 print_liste_field_titre(
"Type", $_SERVER[
"PHP_SELF"],
"d.type",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
160 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.dated",
"",
"&socid=$socid",
'align="center"', $sortfield, $sortorder);
161 print_liste_field_titre(
"Person", $_SERVER[
"PHP_SELF"],
"u.lastname",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
162 print_liste_field_titre(
"Company", $_SERVER[
"PHP_SELF"],
"s.nom",
"",
"&socid=$socid",
'', $sortfield, $sortorder);
163 print_liste_field_titre(
"FeesKilometersOrAmout", $_SERVER[
"PHP_SELF"],
"d.km",
"",
"&socid=$socid",
'class="right"', $sortfield, $sortorder);
168 print
'<tr class="liste_titre">';
169 print
'<td class="liste_titre">';
170 print
'<input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.
'">';
172 print
'<td class="liste_titre">';
175 print
'<td class="liste_titre" align="center">';
177 print
'<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.
'">';
179 print
'<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.
'">';
180 print $formother->selectyear($year ? $year : -1,
'year', 1, 20, 5);
182 print
'<td class="liste_titre">';
183 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
185 print
'<td class="liste_titre">';
186 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
188 print
'<td class="liste_titre right">';
191 print
'<td class="liste_titre maxwidthsearch">';
192 $searchpicto = $form->showFilterAndCheckAddButtons(0);
197 while ($i < min($num, $limit)) {
198 $obj = $db->fetch_object($resql);
202 $soc->fetch($obj->socid);
205 print
'<tr class="oddeven">';
207 print
'<td><a href="card.php?id='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowTrip"),
"trip").
' '.$obj->rowid.
'</a></td>';
209 print
'<td>'.$langs->trans($obj->type).
'</td>';
211 print
'<td class="center">'.dol_print_date($db->jdate($obj->dd),
'day').
'</td>';
214 $userstatic->id = $obj->fk_user;
215 $userstatic->lastname = $obj->lastname;
216 $userstatic->firstname = $obj->firstname;
217 print $userstatic->getNomUrl(1);
221 print
'<td>'.$soc->getNomUrl(1).
'</td>';
223 print
'<td> </td>';
226 print
'<td class="right">'.$obj->km.
'</td>';
228 $tripandexpense_static->statut = $obj->fk_statut;
229 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.
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.