dolibarr  16.0.5
recruitmentindex.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array("recruitment", "boxes"));
34 
35 $action = GETPOST('action', 'aZ09');
36 
37 
38 // Security check
39 //if (! $user->rights->recruitment->myobject->read) accessforbidden();
40 $socid = GETPOST('socid', 'int');
41 if (isset($user->socid) && $user->socid > 0) {
42  $action = '';
43  $socid = $user->socid;
44 }
45 
46 $max = 5;
47 $now = dol_now();
48 
49 // Security check (enable the most restrictive one)
50 //if ($user->socid > 0) accessforbidden();
51 //if ($user->socid > 0) $socid = $user->socid;
52 // if (! $user->hasRights('mymodule', 'myobject', 'read')) {
53 // accessforbidden();
54 // }
55 restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid');
56 
57 
58 /*
59  * Actions
60  */
61 
62 // None
63 
64 
65 /*
66  * View
67  */
68 
69 $form = new Form($db);
70 $formfile = new FormFile($db);
71 $staticrecruitmentjobposition = new RecruitmentJobPosition($db);
72 $staticrecruitmentcandidature = new RecruitmentCandidature($db);
73 
74 llxHeader("", $langs->trans("RecruitmentArea"));
75 
76 print load_fiche_titre($langs->trans("RecruitmentArea"), '', 'object_recruitmentjobposition');
77 
78 print '<div class="fichecenter"><div class="fichethirdleft">';
79 
80 
81 /*
82  * Statistics
83  */
84 
85 if ($conf->use_javascript_ajax) {
86  $sql = "SELECT COUNT(t.rowid) as nb, status";
87  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as t";
88  $sql .= " GROUP BY t.status";
89  $sql .= " ORDER BY t.status ASC";
90  $resql = $db->query($sql);
91 
92  if ($resql) {
93  $num = $db->num_rows($resql);
94  $i = 0;
95 
96  $totalnb = 0;
97  $dataseries = array();
98  $colorseries = array();
99  $vals = array();
100 
101  include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
102 
103  while ($i < $num) {
104  $obj = $db->fetch_object($resql);
105  if ($obj) {
106  $vals[$obj->status] = $obj->nb;
107 
108  $totalnb += $obj->nb;
109  }
110  $i++;
111  }
112  $db->free($resql);
113 
114  print '<div class="div-table-responsive-no-min">';
115  print '<table class="noborder nohover centpercent">';
116  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("JobPositions").'</th></tr>'."\n";
117  $listofstatus = array(0, 1, 3, 9);
118  foreach ($listofstatus as $status) {
119  $dataseries[] = array(dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
120  if ($status == RecruitmentJobPosition::STATUS_DRAFT) {
121  $colorseries[$status] = '-'.$badgeStatus0;
122  }
123  if ($status == RecruitmentJobPosition::STATUS_VALIDATED) {
124  $colorseries[$status] = $badgeStatus4;
125  }
126  if ($status == RecruitmentJobPosition::STATUS_RECRUITED) {
127  $colorseries[$status] = $badgeStatus6;
128  }
129  if ($status == RecruitmentJobPosition::STATUS_CANCELED) {
130  $colorseries[$status] = $badgeStatus9;
131  }
132 
133  if (empty($conf->use_javascript_ajax)) {
134  print '<tr class="oddeven">';
135  print '<td>'.$staticrecruitmentjobposition->LibStatut($status, 0).'</td>';
136  print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
137  print "</tr>\n";
138  }
139  }
140  if ($conf->use_javascript_ajax) {
141  print '<tr><td class="center" colspan="2">';
142 
143  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
144  $dolgraph = new DolGraph();
145  $dolgraph->SetData($dataseries);
146  $dolgraph->SetDataColor(array_values($colorseries));
147  $dolgraph->setShowLegend(2);
148  $dolgraph->setShowPercent(1);
149  $dolgraph->SetType(array('pie'));
150  $dolgraph->SetHeight('200');
151  $dolgraph->draw('idgraphstatus');
152  print $dolgraph->show($totalnb ? 0 : 1);
153 
154  print '</td></tr>';
155  }
156  print "</table>";
157  print "</div>";
158 
159  print "<br>";
160  } else {
161  dol_print_error($db);
162  }
163 
164  $sql = "SELECT COUNT(t.rowid) as nb, status";
165  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as t";
166  $sql .= " GROUP BY t.status";
167  $sql .= " ORDER BY t.status ASC";
168  $resql = $db->query($sql);
169 
170  if ($resql) {
171  $num = $db->num_rows($resql);
172  $i = 0;
173 
174  $totalnb = 0;
175  $dataseries = array();
176  $colorseries = array();
177  $vals = array();
178 
179  include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
180 
181  while ($i < $num) {
182  $obj = $db->fetch_object($resql);
183  if ($obj) {
184  $vals[$obj->status] = $obj->nb;
185 
186  $totalnb += $obj->nb;
187  }
188  $i++;
189  }
190  $db->free($resql);
191 
192  print '<div class="div-table-responsive-no-min">';
193  print '<table class="noborder nohover centpercent">';
194  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("RecruitmentCandidatures").'</th></tr>'."\n";
195  $listofstatus = array(0, 1, 3, 5, 8, 9);
196  foreach ($listofstatus as $status) {
197  $dataseries[] = array(dol_html_entity_decode($staticrecruitmentcandidature->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
198  if ($status == RecruitmentCandidature::STATUS_DRAFT) {
199  $colorseries[$status] = '-'.$badgeStatus0;
200  }
201  if ($status == RecruitmentCandidature::STATUS_VALIDATED) {
202  $colorseries[$status] = $badgeStatus1;
203  }
204  if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) {
205  $colorseries[$status] = $badgeStatus4;
206  }
207  if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) {
208  $colorseries[$status] = $badgeStatus5;
209  }
210  if ($status == RecruitmentCandidature::STATUS_REFUSED) {
211  $colorseries[$status] = $badgeStatus9;
212  }
213  if ($status == RecruitmentCandidature::STATUS_CANCELED) {
214  $colorseries[$status] = $badgeStatus9;
215  }
216 
217  if (empty($conf->use_javascript_ajax)) {
218  print '<tr class="oddeven">';
219  print '<td>'.$staticrecruitmentcandidature->LibStatut($status, 0).'</td>';
220  print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
221  print "</tr>\n";
222  }
223  }
224  if ($conf->use_javascript_ajax) {
225  print '<tr><td class="center" colspan="2">';
226 
227  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
228  $dolgraph = new DolGraph();
229  $dolgraph->SetData($dataseries);
230  $dolgraph->SetDataColor(array_values($colorseries));
231  $dolgraph->setShowLegend(2);
232  $dolgraph->setShowPercent(1);
233  $dolgraph->SetType(array('pie'));
234  $dolgraph->SetHeight('200');
235  $dolgraph->draw('idgraphstatuscandidature');
236  print $dolgraph->show($totalnb ? 0 : 1);
237 
238  print '</td></tr>';
239  }
240  print "</table>";
241  print "</div>";
242 
243  print "<br>";
244  } else {
245  dol_print_error($db);
246  }
247 }
248 
249 print '<br>';
250 
251 /* BEGIN MODULEBUILDER DRAFT MYOBJECT
252 // Draft MyObject
253 if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->read)
254 {
255  $langs->load("orders");
256 
257  $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
258  $sql.= ", s.code_client";
259  $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c";
260  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
261  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
262  $sql.= " WHERE c.fk_soc = s.rowid";
263  $sql.= " AND c.fk_statut = 0";
264  $sql.= " AND c.entity IN (".getEntity('commande').")";
265  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
266  if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
267 
268  $resql = $db->query($sql);
269  if ($resql)
270  {
271  $total = 0;
272  $num = $db->num_rows($resql);
273 
274  print '<table class="noborder centpercent">';
275  print '<tr class="liste_titre">';
276  print '<th colspan="3">'.$langs->trans("DraftOrders").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
277 
278  $var = true;
279  if ($num > 0)
280  {
281  $i = 0;
282  while ($i < $num)
283  {
284 
285  $obj = $db->fetch_object($resql);
286  print '<tr class="oddeven"><td class="nowrap">';
287  $orderstatic->id=$obj->rowid;
288  $orderstatic->ref=$obj->ref;
289  $orderstatic->ref_client=$obj->ref_client;
290  $orderstatic->total_ht = $obj->total_ht;
291  $orderstatic->total_tva = $obj->total_tva;
292  $orderstatic->total_ttc = $obj->total_ttc;
293  print $orderstatic->getNomUrl(1);
294  print '</td>';
295  print '<td class="nowrap">';
296  $companystatic->id=$obj->socid;
297  $companystatic->name=$obj->name;
298  $companystatic->client=$obj->client;
299  $companystatic->code_client = $obj->code_client;
300  $companystatic->code_fournisseur = $obj->code_fournisseur;
301  $companystatic->canvas=$obj->canvas;
302  print $companystatic->getNomUrl(1,'customer',16);
303  print '</td>';
304  print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
305  $i++;
306  $total += $obj->total_ttc;
307  }
308  if ($total>0)
309  {
310 
311  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
312  }
313  }
314  else
315  {
316 
317  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
318  }
319  print "</table><br>";
320 
321  $db->free($resql);
322  }
323  else
324  {
325  dol_print_error($db);
326  }
327 }
328 END MODULEBUILDER DRAFT MYOBJECT */
329 
330 
331 print '</div><div class="fichetwothirdright">';
332 
333 
334 $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
335 $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
336 
337 // Last modified job position
338 if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) {
339  $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications";
340  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
341  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid";
342  if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
343  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
344  }
345  $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
346  if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
347  $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
348  }
349  if ($socid) {
350  $sql .= " AND s.fk_soc = $socid";
351  }
352  $sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
353  $sql .= $db->order('s.tms', 'DESC');
354  $sql .= $db->plimit($max, 0);
355 
356  $resql = $db->query($sql);
357  if ($resql) {
358  $num = $db->num_rows($resql);
359  $i = 0;
360 
361  print '<div class="div-table-responsive-no-min">';
362  print '<table class="noborder centpercent">';
363  print '<tr class="liste_titre">';
364  print '<th colspan="2">';
365  print $langs->trans("BoxTitleLatestModifiedJobPositions", $max);
366  print '</th>';
367  print '<th class="right">';
368  print $langs->trans("Applications");
369  print '</th>';
370  print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
371  print '</tr>';
372  if ($num) {
373  while ($i < $num) {
374  $objp = $db->fetch_object($resql);
375  $staticrecruitmentjobposition->id = $objp->rowid;
376  $staticrecruitmentjobposition->ref = $objp->ref;
377  $staticrecruitmentjobposition->label = $objp->label;
378  $staticrecruitmentjobposition->status = $objp->status;
379  $staticrecruitmentjobposition->date_creation = $objp->date_creation;
380 
381  print '<tr class="oddeven">';
382  print '<td class="nowrap">'.$staticrecruitmentjobposition->getNomUrl(1, '').'</td>';
383  print '<td class="right nowrap">';
384  print "</td>";
385  print '<td class="right">';
386  print $objp->nbapplications;
387  print '</td>';
388  print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
389  print '<td class="right nowrap" width="16">';
390  print $staticrecruitmentjobposition->getLibStatut(3);
391  print "</td>";
392  print '</tr>';
393  $i++;
394  }
395 
396  $db->free($resql);
397  } else {
398  print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
399  }
400  print "</table>";
401  print "</div>";
402  print "<br>";
403  } else {
404  dol_print_error($db);
405  }
406 }
407 
408 // Last modified job position
409 if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) {
410  $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
411  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
412  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
413  if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
414  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
415  }
416  $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
417  if (isModEnabled('societe') && empty($user->rights->societe->client->voir) && !$socid) {
418  $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
419  }
420  if ($socid) {
421  $sql .= " AND s.fk_soc = $socid";
422  }
423  $sql .= $db->order('rc.tms', 'DESC');
424  $sql .= $db->plimit($max, 0);
425 
426  $resql = $db->query($sql);
427  if ($resql) {
428  $num = $db->num_rows($resql);
429  $i = 0;
430 
431  print '<div class="div-table-responsive-no-min">';
432  print '<table class="noborder centpercent">';
433  print '<tr class="liste_titre">';
434  print '<th colspan="2">';
435  print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
436  print '</th>';
437  print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
438  print '</tr>';
439  if ($num) {
440  while ($i < $num) {
441  $objp = $db->fetch_object($resql);
442  $staticrecruitmentcandidature->id = $objp->rowid;
443  $staticrecruitmentcandidature->ref = $objp->ref;
444  $staticrecruitmentcandidature->email = $objp->email;
445  $staticrecruitmentcandidature->status = $objp->status;
446  $staticrecruitmentcandidature->date_creation = $objp->date_creation;
447  $staticrecruitmentcandidature->firstname = $objp->firstname;
448  $staticrecruitmentcandidature->lastname = $objp->lastname;
449 
450  print '<tr class="oddeven">';
451  print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
452  print '<td class="right nowrap">';
453  print "</td>";
454  print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
455  print '<td class="right nowrap" width="16">';
456  print $staticrecruitmentcandidature->getLibStatut(3);
457  print "</td>";
458  print '</tr>';
459  $i++;
460  }
461 
462  $db->free($resql);
463  } else {
464  print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
465  }
466  print "</table>";
467  print "</div>";
468  print "<br>";
469  } else {
470  dol_print_error($db);
471  }
472 }
473 
474 print '</div></div>';
475 
476 // End of page
477 llxFooter();
478 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
DolGraph
Class to build graphs.
Definition: dolgraph.class.php:40
RecruitmentJobPosition
Class for RecruitmentJobPosition.
Definition: recruitmentjobposition.class.php:32
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
RecruitmentCandidature
Class for RecruitmentCandidature.
Definition: recruitmentcandidature.class.php:32
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
dol_html_entity_decode
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
Definition: functions.lib.php:7052
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59