dolibarr  13.0.2
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 {
43  $action = '';
44  $socid = $user->socid;
45 }
46 
47 $max = 5;
48 $now = dol_now();
49 
50 
51 /*
52  * Actions
53  */
54 
55 // None
56 
57 
58 /*
59  * View
60  */
61 
62 $form = new Form($db);
63 $formfile = new FormFile($db);
64 $staticrecruitmentjobposition = new RecruitmentJobPosition($db);
65 $staticrecruitmentcandidature = new RecruitmentCandidature($db);
66 
67 llxHeader("", $langs->trans("RecruitmentArea"));
68 
69 print load_fiche_titre($langs->trans("RecruitmentArea"), '', 'object_recruitmentjobposition');
70 
71 print '<div class="fichecenter"><div class="fichethirdleft">';
72 
73 
74 /*
75  * Statistics
76  */
77 
78 if ($conf->use_javascript_ajax)
79 {
80  $sql = "SELECT COUNT(t.rowid) as nb, status";
81  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as t";
82  $sql .= " GROUP BY t.status";
83  $sql .= " ORDER BY t.status ASC";
84  $resql = $db->query($sql);
85 
86  if ($resql)
87  {
88  $num = $db->num_rows($resql);
89  $i = 0;
90 
91  $totalnb = 0;
92  $dataseries = array();
93  $colorseries = array();
94  $vals = array();
95 
96  include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
97 
98  while ($i < $num)
99  {
100  $obj = $db->fetch_object($resql);
101  if ($obj)
102  {
103  $vals[$obj->status] = $obj->nb;
104 
105  $totalnb += $obj->nb;
106  }
107  $i++;
108  }
109  $db->free($resql);
110 
111  print '<div class="div-table-responsive-no-min">';
112  print '<table class="noborder nohover centpercent">';
113  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("JobPositions").'</th></tr>'."\n";
114  $listofstatus = array(0, 1, 3, 9);
115  foreach ($listofstatus as $status)
116  {
117  $dataseries[] = array(dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
118  if ($status == RecruitmentJobPosition::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
119  if ($status == RecruitmentJobPosition::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus4;
120  if ($status == RecruitmentJobPosition::STATUS_RECRUITED) $colorseries[$status] = $badgeStatus6;
121  if ($status == RecruitmentJobPosition::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9;
122 
123  if (empty($conf->use_javascript_ajax))
124  {
125  print '<tr class="oddeven">';
126  print '<td>'.$staticrecruitmentjobposition->LibStatut($status, 0).'</td>';
127  print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
128  print "</tr>\n";
129  }
130  }
131  if ($conf->use_javascript_ajax)
132  {
133  print '<tr><td class="center" colspan="2">';
134 
135  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
136  $dolgraph = new DolGraph();
137  $dolgraph->SetData($dataseries);
138  $dolgraph->SetDataColor(array_values($colorseries));
139  $dolgraph->setShowLegend(2);
140  $dolgraph->setShowPercent(1);
141  $dolgraph->SetType(array('pie'));
142  $dolgraph->SetHeight('200');
143  $dolgraph->draw('idgraphstatus');
144  print $dolgraph->show($totalnb ? 0 : 1);
145 
146  print '</td></tr>';
147  }
148  print "</table>";
149  print "</div>";
150 
151  print "<br>";
152  } else {
153  dol_print_error($db);
154  }
155 
156  $sql = "SELECT COUNT(t.rowid) as nb, status";
157  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as t";
158  $sql .= " GROUP BY t.status";
159  $sql .= " ORDER BY t.status ASC";
160  $resql = $db->query($sql);
161 
162  if ($resql)
163  {
164  $num = $db->num_rows($resql);
165  $i = 0;
166 
167  $totalnb = 0;
168  $dataseries = array();
169  $colorseries = array();
170  $vals = array();
171 
172  include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
173 
174  while ($i < $num)
175  {
176  $obj = $db->fetch_object($resql);
177  if ($obj)
178  {
179  $vals[$obj->status] = $obj->nb;
180 
181  $totalnb += $obj->nb;
182  }
183  $i++;
184  }
185  $db->free($resql);
186 
187  print '<div class="div-table-responsive-no-min">';
188  print '<table class="noborder nohover centpercent">';
189  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Candidatures").'</th></tr>'."\n";
190  $listofstatus = array(0, 1, 3, 5, 8, 9);
191  foreach ($listofstatus as $status)
192  {
193  $dataseries[] = array(dol_html_entity_decode($staticrecruitmentcandidature->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
194  if ($status == RecruitmentCandidature::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
195  if ($status == RecruitmentCandidature::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
196  if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) $colorseries[$status] = $badgeStatus4;
197  if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) $colorseries[$status] = $badgeStatus5;
198  if ($status == RecruitmentCandidature::STATUS_REFUSED) $colorseries[$status] = $badgeStatus9;
199  if ($status == RecruitmentCandidature::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9;
200 
201  if (empty($conf->use_javascript_ajax))
202  {
203  print '<tr class="oddeven">';
204  print '<td>'.$staticrecruitmentcandidature->LibStatut($status, 0).'</td>';
205  print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
206  print "</tr>\n";
207  }
208  }
209  if ($conf->use_javascript_ajax)
210  {
211  print '<tr><td class="center" colspan="2">';
212 
213  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
214  $dolgraph = new DolGraph();
215  $dolgraph->SetData($dataseries);
216  $dolgraph->SetDataColor(array_values($colorseries));
217  $dolgraph->setShowLegend(2);
218  $dolgraph->setShowPercent(1);
219  $dolgraph->SetType(array('pie'));
220  $dolgraph->SetHeight('200');
221  $dolgraph->draw('idgraphstatuscandidature');
222  print $dolgraph->show($totalnb ? 0 : 1);
223 
224  print '</td></tr>';
225  }
226  print "</table>";
227  print "</div>";
228 
229  print "<br>";
230  } else {
231  dol_print_error($db);
232  }
233 }
234 
235 print '<br>';
236 
237 /* BEGIN MODULEBUILDER DRAFT MYOBJECT
238 // Draft MyObject
239 if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->read)
240 {
241  $langs->load("orders");
242 
243  $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
244  $sql.= ", s.code_client";
245  $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c";
246  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
247  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
248  $sql.= " WHERE c.fk_soc = s.rowid";
249  $sql.= " AND c.fk_statut = 0";
250  $sql.= " AND c.entity IN (".getEntity('commande').")";
251  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
252  if ($socid) $sql.= " AND c.fk_soc = ".$socid;
253 
254  $resql = $db->query($sql);
255  if ($resql)
256  {
257  $total = 0;
258  $num = $db->num_rows($resql);
259 
260  print '<table class="noborder centpercent">';
261  print '<tr class="liste_titre">';
262  print '<th colspan="3">'.$langs->trans("DraftOrders").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
263 
264  $var = true;
265  if ($num > 0)
266  {
267  $i = 0;
268  while ($i < $num)
269  {
270 
271  $obj = $db->fetch_object($resql);
272  print '<tr class="oddeven"><td class="nowrap">';
273  $orderstatic->id=$obj->rowid;
274  $orderstatic->ref=$obj->ref;
275  $orderstatic->ref_client=$obj->ref_client;
276  $orderstatic->total_ht = $obj->total_ht;
277  $orderstatic->total_tva = $obj->total_tva;
278  $orderstatic->total_ttc = $obj->total_ttc;
279  print $orderstatic->getNomUrl(1);
280  print '</td>';
281  print '<td class="nowrap">';
282  $companystatic->id=$obj->socid;
283  $companystatic->name=$obj->name;
284  $companystatic->client=$obj->client;
285  $companystatic->code_client = $obj->code_client;
286  $companystatic->code_fournisseur = $obj->code_fournisseur;
287  $companystatic->canvas=$obj->canvas;
288  print $companystatic->getNomUrl(1,'customer',16);
289  print '</td>';
290  print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
291  $i++;
292  $total += $obj->total_ttc;
293  }
294  if ($total>0)
295  {
296 
297  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
298  }
299  }
300  else
301  {
302 
303  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
304  }
305  print "</table><br>";
306 
307  $db->free($resql);
308  }
309  else
310  {
311  dol_print_error($db);
312  }
313 }
314 END MODULEBUILDER DRAFT MYOBJECT */
315 
316 
317 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
318 
319 
320 $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
321 $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
322 
323 // Last modified job position
324 if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
325 {
326  $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications";
327  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
328  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid";
329  if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
330  $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
331  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
332  if ($socid) $sql .= " AND s.fk_soc = $socid";
333  $sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
334  $sql .= " ORDER BY s.tms DESC";
335  $sql .= $db->plimit($max, 0);
336 
337  $resql = $db->query($sql);
338  if ($resql)
339  {
340  $num = $db->num_rows($resql);
341  $i = 0;
342 
343  print '<div class="div-table-responsive-no-min">';
344  print '<table class="noborder centpercent">';
345  print '<tr class="liste_titre">';
346  print '<th colspan="2">';
347  print $langs->trans("BoxTitleLatestModifiedJobPositions", $max);
348  print '</th>';
349  print '<th class="right">';
350  print $langs->trans("Applications");
351  print '</th>';
352  print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentjobposition_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  $staticrecruitmentjobposition->id = $objp->rowid;
360  $staticrecruitmentjobposition->ref = $objp->ref;
361  $staticrecruitmentjobposition->label = $objp->label;
362  $staticrecruitmentjobposition->status = $objp->status;
363  $staticrecruitmentjobposition->date_creation = $objp->date_creation;
364 
365  print '<tr class="oddeven">';
366  print '<td class="nowrap">'.$staticrecruitmentjobposition->getNomUrl(1, '').'</td>';
367  print '<td class="right nowrap">';
368  print "</td>";
369  print '<td class="right">';
370  print $objp->nbapplications;
371  print '</td>';
372  print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
373  print '<td class="right nowrap" width="16">';
374  print $staticrecruitmentjobposition->getLibStatut(3);
375  print "</td>";
376  print '</tr>';
377  $i++;
378  }
379 
380  $db->free($resql);
381  } else {
382  print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
383  }
384  print "</table>";
385  print "</div>";
386  print "<br>";
387  } else {
388  dol_print_error($db);
389  }
390 }
391 
392 // Last modified job position
393 if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
394 {
395  $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
396  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
397  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
398  if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
399  $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
400  if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
401  if ($socid) $sql .= " AND s.fk_soc = $socid";
402  $sql .= " ORDER BY rc.tms DESC";
403  $sql .= $db->plimit($max, 0);
404 
405  $resql = $db->query($sql);
406  if ($resql)
407  {
408  $num = $db->num_rows($resql);
409  $i = 0;
410 
411  print '<div class="div-table-responsive-no-min">';
412  print '<table class="noborder centpercent">';
413  print '<tr class="liste_titre">';
414  print '<th colspan="2">';
415  print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
416  print '</th>';
417  print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
418  print '</tr>';
419  if ($num)
420  {
421  while ($i < $num)
422  {
423  $objp = $db->fetch_object($resql);
424  $staticrecruitmentcandidature->id = $objp->rowid;
425  $staticrecruitmentcandidature->ref = $objp->ref;
426  $staticrecruitmentcandidature->email = $objp->email;
427  $staticrecruitmentcandidature->status = $objp->status;
428  $staticrecruitmentcandidature->date_creation = $objp->date_creation;
429  $staticrecruitmentcandidature->firstname = $objp->firstname;
430  $staticrecruitmentcandidature->lastname = $objp->lastname;
431 
432  print '<tr class="oddeven">';
433  print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
434  print '<td class="right nowrap">';
435  print "</td>";
436  print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
437  print '<td class="right nowrap" width="16">';
438  print $staticrecruitmentcandidature->getLibStatut(3);
439  print "</td>";
440  print '</tr>';
441  $i++;
442  }
443 
444  $db->free($resql);
445  } else {
446  print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
447  }
448  print "</table>";
449  print "</div>";
450  print "<br>";
451  } else {
452  dol_print_error($db);
453  }
454 }
455 
456 print '</div></div></div>';
457 
458 // End of page
459 llxFooter();
460 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_html_entity_decode($a, $b, $c= 'UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_now($mode= 'auto')
Return date for now.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class for RecruitmentJobPosition.
Class to offer components to list and upload files.
Class for RecruitmentCandidature.
print
Draft customers invoices.
Definition: index.php:89
Class to build graphs.
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