28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
41$langs->loadLangs(array(
'companies',
'users',
'trips'));
46 $socid = $user->socid;
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54if (empty($page) || $page == -1) {
57$offset = $limit * $page;
64 $sortfield =
"d.dated";
75$childids = $user->getAllChildIds();
76$childids[] = $user->id;
80llxHeader(
'', $langs->trans(
"TripsAndExpenses"), $help_url);
85$sql =
"SELECT count(d.rowid) as nb, sum(d.km) as km, d.type";
86$sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement as d";
87$sql .=
" WHERE d.entity = ".$conf->entity;
88if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
89 $sql .=
' AND d.fk_user IN ('.$db->sanitize(implode(
',', $childids)).
')';
91$sql .=
" GROUP BY d.type";
92$sql .=
" ORDER BY d.type";
94$result = $db->query($sql);
98 $num = $db->num_rows($result);
101 $objp = $db->fetch_object($result);
103 $somme[$objp->type] = $objp->km;
104 $nb[$objp->type] = $objp->nb;
105 $totalnb += $objp->nb;
117print
'<div class="fichecenter"><div class="fichethirdleft">';
121print
'<table class="noborder nohover centpercent">';
122print
'<tr class="liste_titre">';
123print
'<td colspan="4">'.$langs->trans(
"Statistics").
'</td>';
126$listoftype = $tripandexpense_static->listOfTypes();
127$dataseries = array();
128foreach ($listoftype as $code => $label) {
129 $dataseries[] = array($label, (isset($nb[$code]) ? (
int) $nb[$code] : 0));
132if (
$conf->use_javascript_ajax) {
133 print
'<tr><td align="center" colspan="4">';
135 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
137 $dolgraph->SetData($dataseries);
138 $dolgraph->setShowLegend(2);
139 $dolgraph->setShowPercent(1);
140 $dolgraph->SetType(array(
'pie'));
141 $dolgraph->setHeight(
'200');
142 $dolgraph->draw(
'idgraphstatus');
143 print $dolgraph->show($totalnb ? 0 : 1);
148print
'<tr class="liste_total">';
149print
'<td>'.$langs->trans(
"Total").
'</td>';
150print
'<td class="right">'.$totalnb.
'</td>';
157print
'</div><div class="fichetwothirdright">';
162$langs->load(
"boxes");
164$sql =
"SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut";
165$sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement as d, ".MAIN_DB_PREFIX.
"user as u";
166$sql .=
" WHERE u.rowid = d.fk_user";
167$sql .=
" AND d.entity = ".$conf->entity;
168if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
169 $sql .=
' AND d.fk_user IN ('.$db->sanitize(implode(
',', $childids)).
')';
173if (!$user->hasRight(
'societe',
'client',
'voir')) {
174 $search_sale = $user->id;
177if ($search_sale && $search_sale !=
'-1') {
178 if ($search_sale == -2) {
179 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc)";
180 } elseif ($search_sale > 0) {
181 $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).
")";
186 $sql .=
" AND d.fk_soc = ".((int) $socid);
188$sql .= $db->order(
"d.tms",
"DESC");
189$sql .= $db->plimit($max, 0);
191$result = $db->query($sql);
194 $num = $db->num_rows($result);
198 print
'<table class="noborder centpercent">';
199 print
'<tr class="liste_titre">';
200 print
'<td colspan="2">'.$langs->trans(
"BoxTitleLastModifiedExpenses", min($max, $num)).
'</td>';
201 print
'<td class="right">'.$langs->trans(
"FeesKilometersOrAmout").
'</td>';
202 print
'<td class="right">'.$langs->trans(
"DateModificationShort").
'</td>';
203 print
'<td width="16"> </td>';
206 $total_ttc = $totalam = $total = 0;
209 $userstatic =
new User($db);
210 while ($i < $num && $i < $max) {
211 $obj = $db->fetch_object($result);
212 $deplacementstatic->ref = $obj->rowid;
213 $deplacementstatic->id = $obj->rowid;
214 $userstatic->id = $obj->uid;
215 $userstatic->lastname = $obj->lastname;
216 $userstatic->firstname = $obj->firstname;
217 print
'<tr class="oddeven">';
218 print
'<td>'.$deplacementstatic->getNomUrl(1).
'</td>';
219 print
'<td>'.$userstatic->getNomUrl(1).
'</td>';
220 print
'<td class="right">'.$obj->km.
'</td>';
221 print
'<td class="right">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>';
222 print
'<td>'.$deplacementstatic->LibStatut($obj->fk_statut, 3).
'</td>';
228 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
230 print
'</table><br>';
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 Dolibarr users.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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...
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.