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'));
37 $socid = $user->socid;
42$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
45if (empty($page) || $page == -1) {
48$offset = $limit * $page;
55 $sortfield =
"d.dated";
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 (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
80 $sql .=
' AND d.fk_user IN ('.$db->sanitize(implode(
',', $childids)).
')';
82$sql .=
" GROUP BY d.type";
83$sql .=
" ORDER BY d.type";
85$result = $db->query($sql);
89 $num = $db->num_rows($result);
92 $objp = $db->fetch_object($result);
94 $somme[$objp->type] = $objp->km;
95 $nb[$objp->type] = $objp->nb;
96 $totalnb += $objp->nb;
108print
'<div class="fichecenter"><div class="fichethirdleft">';
112print
'<table class="noborder nohover centpercent">';
113print
'<tr class="liste_titre">';
114print
'<td colspan="4">'.$langs->trans(
"Statistics").
'</td>';
117$listoftype = $tripandexpense_static->listOfTypes();
118$dataseries = array();
119foreach ($listoftype as $code => $label) {
120 $dataseries[] = array($label, (isset($nb[$code]) ? (
int) $nb[$code] : 0));
123if ($conf->use_javascript_ajax) {
124 print
'<tr><td align="center" colspan="4">';
126 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
128 $dolgraph->SetData($dataseries);
129 $dolgraph->setShowLegend(2);
130 $dolgraph->setShowPercent(1);
131 $dolgraph->SetType(array(
'pie'));
132 $dolgraph->setHeight(
'200');
133 $dolgraph->draw(
'idgraphstatus');
134 print $dolgraph->show($totalnb ? 0 : 1);
139print
'<tr class="liste_total">';
140print
'<td>'.$langs->trans(
"Total").
'</td>';
141print
'<td class="right">'.$totalnb.
'</td>';
148print
'</div><div class="fichetwothirdright">';
153$langs->load(
"boxes");
155$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";
156$sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement as d, ".MAIN_DB_PREFIX.
"user as u";
157$sql .=
" WHERE u.rowid = d.fk_user";
158$sql .=
" AND d.entity = ".$conf->entity;
159if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
160 $sql .=
' AND d.fk_user IN ('.$db->sanitize(implode(
',', $childids)).
')';
164if (!$user->hasRight(
'societe',
'client',
'voir')) {
165 $search_sale = $user->id;
168if ($search_sale && $search_sale !=
'-1') {
169 if ($search_sale == -2) {
170 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc)";
171 } elseif ($search_sale > 0) {
172 $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).
")";
177 $sql .=
" AND d.fk_soc = ".((int) $socid);
179$sql .= $db->order(
"d.tms",
"DESC");
180$sql .= $db->plimit($max, 0);
182$result = $db->query($sql);
185 $num = $db->num_rows($result);
189 print
'<table class="noborder centpercent">';
190 print
'<tr class="liste_titre">';
191 print
'<td colspan="2">'.$langs->trans(
"BoxTitleLastModifiedExpenses", min($max, $num)).
'</td>';
192 print
'<td class="right">'.$langs->trans(
"FeesKilometersOrAmout").
'</td>';
193 print
'<td class="right">'.$langs->trans(
"DateModificationShort").
'</td>';
194 print
'<td width="16"> </td>';
197 $total_ttc = $totalam = $total = 0;
200 $userstatic =
new User($db);
201 while ($i < $num && $i < $max) {
202 $obj = $db->fetch_object($result);
203 $deplacementstatic->ref = $obj->rowid;
204 $deplacementstatic->id = $obj->rowid;
205 $userstatic->id = $obj->uid;
206 $userstatic->lastname = $obj->lastname;
207 $userstatic->firstname = $obj->firstname;
208 print
'<tr class="oddeven">';
209 print
'<td>'.$deplacementstatic->getNomUrl(1).
'</td>';
210 print
'<td>'.$userstatic->getNomUrl(1).
'</td>';
211 print
'<td class="right">'.$obj->km.
'</td>';
212 print
'<td class="right">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>';
213 print
'<td>'.$deplacementstatic->LibStatut($obj->fk_statut, 3).
'</td>';
219 print
'<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
221 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($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...
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.