26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
31 $langs->loadLangs(array(
'companies',
'users',
'trips'));
34 $socid =
GETPOST(
'socid',
'int');
35 if ($user->socid) $socid = $user->socid;
38 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
39 $sortfield =
GETPOST(
"sortfield",
'alpha');
40 $sortorder =
GETPOST(
"sortorder",
'alpha');
42 if (empty($page) || $page == -1) { $page = 0; }
43 $offset = $limit * $page;
44 $pageprev = $page - 1;
45 $pagenext = $page + 1;
46 if (!$sortorder) $sortorder =
"DESC";
47 if (!$sortfield) $sortfield =
"d.dated";
48 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
57 $childids = $user->getAllChildIds();
58 $childids[] = $user->id;
62 llxHeader(
'', $langs->trans(
"ListOfFees"), $help_url);
67 $sql =
"SELECT count(d.rowid) as nb, sum(d.km) as km, d.type";
68 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement as d";
69 $sql .=
" WHERE d.entity = ".$conf->entity;
70 if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .=
' AND d.fk_user IN ('.join(
',', $childids).
')';
71 $sql .=
" GROUP BY d.type";
72 $sql .=
" ORDER BY d.type";
74 $result = $db->query($sql);
77 $num = $db->num_rows($result);
81 $objp = $db->fetch_object($result);
83 $somme[$objp->type] = $objp->km;
84 $nb[$objp->type] = $objp->nb;
85 $totalnb += $objp->nb;
97 print '<div class="fichecenter"><div class="fichethirdleft">';
101 print
'<table class="noborder nohover centpercent">';
102 print
'<tr class="liste_titre">';
103 print
'<td colspan="4">'.$langs->trans(
"Statistics").
'</td>';
106 $listoftype = $tripandexpense_static->listOfTypes();
107 foreach ($listoftype as $code => $label)
109 $dataseries[] = array($label, (isset($nb[$code]) ? (
int) $nb[$code] : 0));
112 if ($conf->use_javascript_ajax)
114 print
'<tr><td align="center" colspan="4">';
116 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
118 $dolgraph->SetData($dataseries);
119 $dolgraph->setShowLegend(2);
120 $dolgraph->setShowPercent(1);
121 $dolgraph->SetType(array(
'pie'));
122 $dolgraph->setHeight(
'200');
123 $dolgraph->draw(
'idgraphstatus');
124 print $dolgraph->show($totalnb ? 0 : 1);
129 print
'<tr class="liste_total">';
130 print
'<td>'.$langs->trans(
"Total").
'</td>';
131 print
'<td class="right">'.$totalnb.
'</td>';
138 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
143 $langs->load(
"boxes");
145 $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";
146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement as d, ".MAIN_DB_PREFIX.
"user as u";
147 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
148 $sql .=
" WHERE u.rowid = d.fk_user";
149 $sql .=
" AND d.entity = ".$conf->entity;
150 if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .=
' AND d.fk_user IN ('.join(
',', $childids).
')';
151 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
152 if ($socid) $sql .=
" AND d.fk_soc = ".$socid;
153 $sql .= $db->order(
"d.tms",
"DESC");
154 $sql .= $db->plimit($max, 0);
156 $result = $db->query($sql);
160 $num = $db->num_rows($result);
164 print
'<table class="noborder centpercent">';
165 print
'<tr class="liste_titre">';
166 print
'<td colspan="2">'.$langs->trans(
"BoxTitleLastModifiedExpenses", min($max, $num)).
'</td>';
167 print
'<td class="right">'.$langs->trans(
"FeesKilometersOrAmout").
'</td>';
168 print
'<td class="right">'.$langs->trans(
"DateModificationShort").
'</td>';
169 print
'<td width="16"> </td>';
173 $total_ttc = $totalam = $total = 0;
176 $userstatic =
new User($db);
177 while ($i < $num && $i < $max)
179 $obj = $db->fetch_object($result);
180 $deplacementstatic->ref = $obj->rowid;
181 $deplacementstatic->id = $obj->rowid;
182 $userstatic->id = $obj->uid;
183 $userstatic->lastname = $obj->lastname;
184 $userstatic->firstname = $obj->firstname;
185 print
'<tr class="oddeven">';
186 print
'<td>'.$deplacementstatic->getNomUrl(1).
'</td>';
187 print
'<td>'.$userstatic->getNomUrl(1).
'</td>';
188 print
'<td class="right">'.$obj->km.
'</td>';
189 print
'<td class="right">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>';
190 print
'<td>'.$deplacementstatic->LibStatut($obj->fk_statut, 3).
'</td>';
196 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
198 print
'</table><br>';
202 print
'</div></div></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage trips and working credit notes.
Class to manage Dolibarr users.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...