27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
32$langs->loadLangs(array(
'companies',
'users',
'trips'));
35$socid =
GETPOST(
'socid',
'int');
37 $socid = $user->socid;
41$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
42$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
44$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
45if (empty($page) || $page == -1) {
48$offset = $limit * $page;
55 $sortfield =
"d.dated";
57$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
66$childids = $user->getAllChildIds();
67$childids[] = $user->id;
71llxHeader(
'', $langs->trans(
"TripsAndExpenses"), $help_url);
76$sql =
"SELECT count(d.rowid) as nb, sum(d.km) as km, d.type";
77$sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement as d";
78$sql .=
" WHERE d.entity = ".$conf->entity;
79if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) {
80 $sql .=
' AND d.fk_user IN ('.$db->sanitize(join(
',', $childids)).
')';
82$sql .=
" GROUP BY d.type";
83$sql .=
" ORDER BY d.type";
85$result = $db->query($sql);
87 $num = $db->num_rows($result);
90 $objp = $db->fetch_object($result);
92 $somme[$objp->type] = $objp->km;
93 $nb[$objp->type] = $objp->nb;
94 $totalnb += $objp->nb;
106print
'<div class="fichecenter"><div class="fichethirdleft">';
110print
'<table class="noborder nohover centpercent">';
111print
'<tr class="liste_titre">';
112print
'<td colspan="4">'.$langs->trans(
"Statistics").
'</td>';
115$listoftype = $tripandexpense_static->listOfTypes();
116foreach ($listoftype as $code => $label) {
117 $dataseries[] = array($label, (isset($nb[$code]) ? (
int) $nb[$code] : 0));
120if ($conf->use_javascript_ajax) {
121 print
'<tr><td align="center" colspan="4">';
123 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
125 $dolgraph->SetData($dataseries);
126 $dolgraph->setShowLegend(2);
127 $dolgraph->setShowPercent(1);
128 $dolgraph->SetType(array(
'pie'));
129 $dolgraph->setHeight(
'200');
130 $dolgraph->draw(
'idgraphstatus');
131 print $dolgraph->show($totalnb ? 0 : 1);
136print
'<tr class="liste_total">';
137print
'<td>'.$langs->trans(
"Total").
'</td>';
138print
'<td class="right">'.$totalnb.
'</td>';
145print
'</div><div class="fichetwothirdright">';
150$langs->load(
"boxes");
152$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";
153$sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement as d, ".MAIN_DB_PREFIX.
"user as u";
154if (empty($user->rights->societe->client->voir) && !$user->socid) {
155 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
157$sql .=
" WHERE u.rowid = d.fk_user";
158$sql .=
" AND d.entity = ".$conf->entity;
159if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) {
160 $sql .=
' AND d.fk_user IN ('.$db->sanitize(join(
',', $childids)).
')';
162if (empty($user->rights->societe->client->voir) && !$user->socid) {
163 $sql .=
" AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
166 $sql .=
" AND d.fk_soc = ".((int) $socid);
168$sql .= $db->order(
"d.tms",
"DESC");
169$sql .= $db->plimit($max, 0);
171$result = $db->query($sql);
174 $num = $db->num_rows($result);
178 print
'<table class="noborder centpercent">';
179 print
'<tr class="liste_titre">';
180 print
'<td colspan="2">'.$langs->trans(
"BoxTitleLastModifiedExpenses", min($max, $num)).
'</td>';
181 print
'<td class="right">'.$langs->trans(
"FeesKilometersOrAmout").
'</td>';
182 print
'<td class="right">'.$langs->trans(
"DateModificationShort").
'</td>';
183 print
'<td width="16"> </td>';
186 $total_ttc = $totalam = $total = 0;
189 $userstatic =
new User($db);
190 while ($i < $num && $i < $max) {
191 $obj = $db->fetch_object($result);
192 $deplacementstatic->ref = $obj->rowid;
193 $deplacementstatic->id = $obj->rowid;
194 $userstatic->id = $obj->uid;
195 $userstatic->lastname = $obj->lastname;
196 $userstatic->firstname = $obj->firstname;
197 print
'<tr class="oddeven">';
198 print
'<td>'.$deplacementstatic->getNomUrl(1).
'</td>';
199 print
'<td>'.$userstatic->getNomUrl(1).
'</td>';
200 print
'<td class="right">'.$obj->km.
'</td>';
201 print
'<td class="right">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>';
202 print
'<td>'.$deplacementstatic->LibStatut($obj->fk_statut, 3).
'</td>';
208 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
210 print
'</table><br>';
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 Dolibarr users.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.