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