dolibarr  13.0.2
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
3  * Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2012-2014 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
6  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
36 if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
37 if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
40 
41 $hookmanager = new HookManager($db);
42 $hookmanager->initHooks('hrmindex');
43 
44 // Load translation files required by the page
45 $langs->loadLangs(array('users', 'holidays', 'trips', 'boxes'));
46 
47 $socid = GETPOST("socid", "int");
48 
49 // Protection if external user
50 if ($user->socid > 0) accessforbidden();
51 
52 if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1;
53 
54 $holiday = new Holiday($db);
55 $holidaystatic = new Holiday($db);
56 $staticrecruitmentcandidature = new RecruitmentCandidature($db);
57 
58 $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
59 
60 
61 /*
62  * Actions
63  */
64 
65 // Update sold
66 if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete))
67 {
68  $result = $holiday->updateBalance();
69 }
70 
71 
72 /*
73  * View
74  */
75 
76 $childids = $user->getAllChildIds();
77 $childids[] = $user->id;
78 
79 llxHeader('', $langs->trans('HRMArea'));
80 
81 print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm');
82 
83 
84 if (!empty($setupcompanynotcomplete))
85 {
86  $langs->load("errors");
87  $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
88  print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
89 
90  llxFooter();
91  exit;
92 }
93 
94 
95 print '<div class="fichecenter"><div class="fichethirdleft">';
96 
97 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
98 {
99  if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
100  {
101  $langs->load("holiday");
102  $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP');
103  }
104  if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
105  {
106  $langs->load("trips");
107  $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport');
108  }
109  if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
110  {
111  $langs->load("trips");
112  $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport');
113  }
114  if (count($listofsearchfields))
115  {
116  print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
117  print '<input type="hidden" name="token" value="'.newToken().'">';
118  print '<div class="div-table-responsive-no-min">';
119  print '<table class="noborder nohover centpercent">';
120  $i = 0;
121  foreach ($listofsearchfields as $key => $value)
122  {
123  if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
124  print '<tr '.$bc[false].'>';
125  print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
126  if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
127  print '</tr>';
128  $i++;
129  }
130  print '</table>';
131  print '</div>';
132  print '</form>';
133  print '<br>';
134  }
135 }
136 
137 
138 if (!empty($conf->holiday->enabled))
139 {
140  if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
141  {
142  $user_id = $user->id;
143 
144  print '<div class="div-table-responsive-no-min">';
145  print '<table class="noborder nohover centpercent">';
146  print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Holidays").'</th></tr>';
147  print '<tr class="oddeven">';
148  print '<td colspan="3">';
149 
150  $out = '';
151  $typeleaves = $holiday->getTypes(1, 1);
152  foreach ($typeleaves as $key => $val)
153  {
154  $nb_type = $holiday->getCPforUser($user->id, $val['rowid']);
155  $nb_holiday += $nb_type;
156  $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': <strong>'.($nb_type ? price2num($nb_type) : 0).'</strong><br>';
157  }
158  print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'<br>';
159  print $out;
160 
161  print '</td>';
162  print '</tr>';
163  print '</table></div><br>';
164  } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE))
165  {
166  print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>';
167  }
168 }
169 
170 
171 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
172 
173 
174 
175 // Latest leave requests
176 if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
177 {
178  $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,";
179  $sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
180  $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
181  $sql .= " WHERE u.rowid = x.fk_user";
182  $sql .= " AND x.entity = ".$conf->entity;
183  if (empty($user->rights->holiday->readall)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')';
184  //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
185  //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
186  $sql .= $db->order("x.tms", "DESC");
187  $sql .= $db->plimit($max, 0);
188 
189  $result = $db->query($sql);
190  if ($result)
191  {
192  $var = false;
193  $num = $db->num_rows($result);
194 
195  $holidaystatic = new Holiday($db);
196  $userstatic = new User($db);
197 
198  $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
199  $typeleaves = $holidaystatic->getTypes(1, -1);
200 
201  $i = 0;
202 
203  print '<div class="div-table-responsive-no-min">';
204  print '<table class="noborder centpercent">';
205  print '<tr class="liste_titre">';
206  print '<th colspan="3">'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).'</th>';
207  print '<th>'.$langs->trans("from").'</th>';
208  print '<th>'.$langs->trans("to").'</th>';
209  print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
210  print '</tr>';
211  if ($num)
212  {
213  while ($i < $num && $i < $max)
214  {
215  $obj = $db->fetch_object($result);
216 
217  $holidaystatic->id = $obj->rowid;
218  $holidaystatic->ref = $obj->ref;
219  $holidaystatic->statut = $obj->status;
220 
221  $userstatic->id = $obj->uid;
222  $userstatic->lastname = $obj->lastname;
223  $userstatic->firstname = $obj->firstname;
224  $userstatic->login = $obj->login;
225  $userstatic->photo = $obj->photo;
226  $userstatic->email = $obj->email;
227  $userstatic->statut = $obj->user_status;
228 
229  print '<tr class="oddeven">';
230  print '<td class="nowraponall">'.$holidaystatic->getNomUrl(1).'</td>';
231  print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1, 'leave').'</td>';
232  print '<td>'.$typeleaves[$obj->fk_type]['label'].'</td>';
233 
234  $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
235  $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
236 
237  print '<td>'.dol_print_date($db->jdate($obj->date_start), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
238  print '<td>'.dol_print_date($db->jdate($obj->date_end), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
239  print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
240  print '<td class="right nowrap" width="16">'.$holidaystatic->LibStatut($obj->status, 3).'</td>';
241  print '</tr>';
242 
243  $i++;
244  }
245  } else {
246  print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
247  }
248  print '</table>';
249  print '</div>';
250  print '<br>';
251  } else dol_print_error($db);
252 }
253 
254 
255 // Latest expense report
256 if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
257 {
258  $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,";
259  $sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
260  $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
261  //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
262  $sql .= " WHERE u.rowid = x.fk_user_author";
263  $sql .= " AND x.entity = ".$conf->entity;
264  if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')';
265  //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
266  //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
267  $sql .= $db->order("x.tms", "DESC");
268  $sql .= $db->plimit($max, 0);
269 
270  $result = $db->query($sql);
271  if ($result)
272  {
273  $num = $db->num_rows($result);
274 
275  $i = 0;
276 
277  print '<div class="div-table-responsive-no-min">';
278  print '<table class="noborder centpercent">';
279  print '<tr class="liste_titre">';
280  print '<th colspan="2">'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).'</th>';
281  print '<th class="right">'.$langs->trans("TotalTTC").'</th>';
282  print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
283  print '</tr>';
284  if ($num)
285  {
286  $total_ttc = $totalam = $total = 0;
287 
288  $expensereportstatic = new ExpenseReport($db);
289  $userstatic = new User($db);
290  while ($i < $num && $i < $max)
291  {
292  $obj = $db->fetch_object($result);
293 
294  $expensereportstatic->id = $obj->rowid;
295  $expensereportstatic->ref = $obj->ref;
296  $expensereportstatic->statut = $obj->status;
297  $expensereportstatic->status = $obj->status;
298 
299  $userstatic->id = $obj->uid;
300  $userstatic->lastname = $obj->lastname;
301  $userstatic->firstname = $obj->firstname;
302  $userstatic->email = $obj->email;
303  $userstatic->login = $obj->login;
304  $userstatic->statut = $obj->user_status;
305  $userstatic->photo = $obj->photo;
306 
307  print '<tr class="oddeven">';
308  print '<td class="nowraponall">'.$expensereportstatic->getNomUrl(1).'</td>';
309  print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1).'</td>';
310  print '<td class="right">'.price($obj->total_ttc).'</td>';
311  print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
312  print '<td class="right nowrap" width="16">'.$expensereportstatic->LibStatut($obj->status, 3).'</td>';
313  print '</tr>';
314 
315  $i++;
316  }
317  } else {
318  print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
319  }
320  print '</table>';
321  print '</div>';
322  print '<br>';
323  } else dol_print_error($db);
324 }
325 
326 
327 // Last modified job position
328 if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
329 {
330  $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
331  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
332  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
333  if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
334  $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
335  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
336  if ($socid) $sql .= " AND s.fk_soc = $socid";
337  $sql .= " ORDER BY rc.tms DESC";
338  $sql .= $db->plimit($max, 0);
339 
340  $resql = $db->query($sql);
341  if ($resql)
342  {
343  $num = $db->num_rows($resql);
344  $i = 0;
345 
346  print '<div class="div-table-responsive-no-min">';
347  print '<table class="noborder centpercent">';
348  print '<tr class="liste_titre">';
349  print '<th colspan="2">';
350  print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
351  print '</th>';
352  print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
353  print '</tr>';
354  if ($num)
355  {
356  while ($i < $num)
357  {
358  $objp = $db->fetch_object($resql);
359  $staticrecruitmentcandidature->id = $objp->rowid;
360  $staticrecruitmentcandidature->ref = $objp->ref;
361  $staticrecruitmentcandidature->email = $objp->email;
362  $staticrecruitmentcandidature->status = $objp->status;
363  $staticrecruitmentcandidature->date_creation = $objp->date_creation;
364  $staticrecruitmentcandidature->firstname = $objp->firstname;
365  $staticrecruitmentcandidature->lastname = $objp->lastname;
366 
367  print '<tr class="oddeven">';
368  print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
369  print '<td class="right nowrap">';
370  print "</td>";
371  print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
372  print '<td class="right nowrap" width="16">';
373  print $staticrecruitmentcandidature->getLibStatut(3);
374  print "</td>";
375  print '</tr>';
376  $i++;
377  }
378 
379  $db->free($resql);
380  } else {
381  print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
382  }
383  print "</table>";
384  print "</div>";
385  print "<br>";
386  } else {
387  dol_print_error($db);
388  }
389 }
390 
391 print '</div></div></div>';
392 
393 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
394 $parameters = array('user' => $user);
395 $reshook = $hookmanager->executeHooks('dashboardHRM', $parameters, $object); // Note that $action and $object may have been modified by hook
396 
397 // End of page
398 llxFooter();
399 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
Class to manage Dolibarr users.
Definition: user.class.php:44
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage hooks.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage Trips and Expenses.
Class for RecruitmentCandidature.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59