59 $langs->loadLangs(array(
"boxes",
"trips"));
63 include_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
65 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
66 $userstatic =
new User($this->db);
68 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleExpenseReportsToApprove", $max));
70 if ($user->hasRight(
'expensereport',
'lire') && $user->hasRight(
'expensereport',
'approve')) {
71 $childids = $user->getAllChildIds(1);
73 $sql =
"SELECT d.rowid, d.ref, d.date_debut, d.date_fin, d.total_ttc, d.fk_statut as status";
74 $sql .=
", u.rowid as user_id, u.lastname, u.firstname, u.login, u.photo, u.statut as user_status, u.entity as user_entity";
75 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as d";
76 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.fk_user_author = u.rowid";
77 $sql .=
" WHERE d.fk_statut = ".ExpenseReport::STATUS_VALIDATED;
78 $sql .=
" AND d.entity IN (".getEntity(
'expensereport').
")";
79 if (!$user->hasRight(
'expensereport',
'readall')) {
80 $sql .=
" AND (d.fk_user_author IN (".$this->db->sanitize(implode(
',', $childids)).
")";
81 $sql .=
" OR d.fk_user_validator = ".((int) $user->id).
")";
83 $sql .=
" ORDER BY d.date_valid ASC";
84 $sql .= $this->db->plimit($max, 0);
86 $result = $this->db->query($sql);
88 $num = $this->db->num_rows($result);
91 while ($line < $num) {
92 $objp = $this->db->fetch_object($result);
94 $expensereportstatic->id = $objp->rowid;
95 $expensereportstatic->ref = $objp->ref;
96 $expensereportstatic->statut = $objp->status;
97 $expensereportstatic->status = $objp->status;
99 $userstatic->id = $objp->user_id;
100 $userstatic->lastname = $objp->lastname;
101 $userstatic->firstname = $objp->firstname;
102 $userstatic->login = $objp->login;
103 $userstatic->photo = $objp->photo;
104 $userstatic->statut = $objp->user_status;
105 $userstatic->status = $objp->user_status;
106 $userstatic->entity = $objp->user_entity;
108 $this->info_box_contents[$line][] = array(
109 'td' =>
'class="nowraponall"',
110 'text' => $expensereportstatic->getNomUrl(1),
114 $this->info_box_contents[$line][] = array(
115 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
116 'text' => $userstatic->getNomUrl(-1),
120 $this->info_box_contents[$line][] = array(
121 'td' =>
'class="nowraponall right"',
125 $this->info_box_contents[$line][] = array(
126 'td' =>
'class="nowraponall right amount"',
127 'text' =>
price($objp->total_ttc),
134 $this->info_box_contents[$line][] = array(
135 'td' =>
'class="center"',
136 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoExpenseReportToApprove").
'</span>',
140 $this->db->free($result);
142 $this->info_box_contents[0][] = array(
145 'text' => ($this->db->error().
' sql='.$sql),
149 $this->info_box_contents[0][] = array(
150 'td' =>
'class="nohover left"',
151 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'