32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
39 $hookmanager->initHooks(array(
'expensereportindex'));
42 $langs->loadLangs(array(
'companies',
'users',
'trips'));
45 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
46 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
48 if (empty($page) || $page == -1) {
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
67 $socid = $user->socid;
78 $childids = $user->getAllChildIds();
79 $childids[] = $user->id;
81 $help_url =
"EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
83 llxHeader(
'', $langs->trans(
"TripsAndExpenses"), $help_url);
86 $label = $somme = $nb = array();
88 $totalnb = $totalsum = 0;
89 $sql =
"SELECT tf.code, tf.label, count(de.rowid) as nb, sum(de.total_ht) as km";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as d, ".MAIN_DB_PREFIX.
"expensereport_det as de, ".MAIN_DB_PREFIX.
"c_type_fees as tf";
91 $sql .=
" WHERE de.fk_expensereport = d.rowid AND d.entity IN (".getEntity(
'expensereport').
") AND de.fk_c_type_fees = tf.id";
93 if (!$user->hasRight(
'expensereport',
'readall') && !$user->hasRight(
'expensereport',
'lire_tous')
94 && (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance'))) {
95 $childids = $user->getAllChildIds();
96 $childids[] = $user->id;
97 $sql .=
" AND d.fk_user_author IN (".$db->sanitize(implode(
',', $childids)).
")\n";
100 $sql .=
" GROUP BY tf.code, tf.label";
102 $result = $db->query(
$sql);
104 $num = $db->num_rows($result);
107 $objp = $db->fetch_object($result);
109 $somme[$objp->code] = $objp->km;
110 $nb[$objp->code] = $objp->nb;
111 $label[$objp->code] = $objp->label;
112 $totalnb += $objp->nb;
113 $totalsum += $objp->km;
125 print
'<div class="fichecenter"><div class="fichethirdleft">';
127 print
'<div class="div-table-responsive-no-min">';
128 print
'<table class="noborder nohover centpercent">';
129 print
'<tr class="liste_titre">';
130 print
'<th colspan="4">'.$langs->trans(
"Statistics").
'</th>';
133 $listoftype = $tripandexpense_static->listOfTypes();
134 $dataseries = array();
135 foreach ($listoftype as $code => $label) {
136 $dataseries[] = array($label, (isset($somme[$code]) ? (
int) $somme[$code] : 0));
145 if (count($dataseries) > ($KEEPNFIRST + 1)) {
146 foreach ($dataseries as $key => $val) {
147 if ($i < $KEEPNFIRST) {
152 $dataseries[$KEEPNFIRST][0] = $langs->trans(
"Others").
'...';
153 if ($key == $KEEPNFIRST) {
157 $dataseries[$KEEPNFIRST][1] += $dataseries[$key][1];
158 unset($dataseries[$key]);
163 if ($conf->use_javascript_ajax) {
164 print
'<tr><td class="center" colspan="4">';
166 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
168 $dolgraph->SetData($dataseries);
169 $dolgraph->setHeight(350);
170 $dolgraph->combine = !
getDolGlobalString(
'MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT') ? 0.05 : $conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT;
171 $dolgraph->setShowLegend(2);
172 $dolgraph->setShowPercent(1);
173 $dolgraph->SetType(array(
'pie'));
174 $dolgraph->setHeight(
'200');
175 $dolgraph->draw(
'idgraphstatus');
176 print $dolgraph->show($totalnb ? 0 : 1);
181 print
'<tr class="liste_total">';
182 print
'<td>'.$langs->trans(
"Total").
'</td>';
183 print
'<td class="right" colspan="3">'.price($totalsum, 1, $langs, 0, 0, 0, $conf->currency).
'</td>';
192 print
'</div><div class="fichetwothirdright">';
195 $langs->load(
"boxes");
197 $sql =
"SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo, u.email, u.admin,";
198 $sql .=
" d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as status";
199 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as d, ".MAIN_DB_PREFIX.
"user as u";
200 $sql .=
" WHERE u.rowid = d.fk_user_author";
202 if (!$user->hasRight(
'expensereport',
'readall') && !$user->hasRight(
'expensereport',
'lire_tous')
203 && (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || !$user->hasRight(
'expensereport',
'writeall_advance'))) {
204 $childids = $user->getAllChildIds();
205 $childids[] = $user->id;
206 $sql .=
" AND d.fk_user_author IN (".$db->sanitize(implode(
',', $childids)).
")\n";
208 $sql .=
' AND d.entity IN ('.getEntity(
'expensereport').
')';
209 $sql .= $db->order($sortfield, $sortorder);
210 $sql .= $db->plimit($max, 0);
212 $result = $db->query(
$sql);
215 $num = $db->num_rows($result);
219 print
'<div class="div-table-responsive-no-min">';
220 print
'<table class="noborder centpercent">';
221 print
'<tr class="liste_titre">';
222 print
'<th colspan="2">'.$langs->trans(
"BoxTitleLastModifiedExpenses", min($max, $num)).
'</th>';
223 print
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
224 print
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
225 print
'<th class="right">'.$langs->trans(
"DateModificationShort").
'</th>';
227 print
'<a href="'.DOL_URL_ROOT.
'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">';
228 print
img_picto($langs->trans(
"FullList"),
'expensereport');
233 $total_ttc = $totalam = $total = 0;
236 $userstatic =
new User($db);
237 while ($i < $num && $i < $max) {
238 $obj = $db->fetch_object($result);
240 $expensereportstatic->id = $obj->rowid;
241 $expensereportstatic->ref = $obj->ref;
242 $expensereportstatic->status = $obj->status;
244 $userstatic->id = $obj->uid;
245 $userstatic->admin = $obj->admin;
246 $userstatic->email = $obj->email;
247 $userstatic->lastname = $obj->lastname;
248 $userstatic->firstname = $obj->firstname;
249 $userstatic->login = $obj->login;
250 $userstatic->status = $obj->user_status;
251 $userstatic->photo = $obj->photo;
253 print
'<tr class="oddeven">';
254 print
'<td class="tdoverflowmax200">'.$expensereportstatic->getNomUrl(1).
'</td>';
255 print
'<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1).
'</td>';
256 print
'<td class="right amount">'.price($obj->total_ht).
'</td>';
257 print
'<td class="right amount">'.price($obj->total_ttc).
'</td>';
258 print
'<td class="right">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>';
259 print
'<td class="right">';
260 print $expensereportstatic->getLibStatut(3);
267 print
'<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
269 print
'</table></div><br>';
274 print
'</div></div>';
276 $parameters = array(
'user' => $user);
277 $reshook = $hookmanager->executeHooks(
'dashboardExpenseReport', $parameters,
$object);
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage Trips and Expenses.
Class to manage Dolibarr users.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
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.