dolibarr  13.0.2
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Jean-François FERRY <jfefe@aternatik.fr>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
24 if (!defined('NOCSRFCHECK')) {
25  define('NOCSRFCHECK', '1');
26 }
27 // Do not check anti CSRF attack test
28 if (!defined('NOREQUIREMENU')) {
29  define('NOREQUIREMENU', '1');
30 }
31 // If there is no need to load and show top and left menu
32 if (!defined("NOLOGIN")) {
33  define("NOLOGIN", '1');
34 }
35 if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
36 if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1');
37 // If this page is public (can be called outside logged session)
38 
39 require '../../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
44 
45 // Load translation files required by the page
46 $langs->loadLangs(array("companies", "other", "recruitment"));
47 
48 // Get parameters
49 $action = GETPOST('action', 'aZ09');
50 $email = GETPOST('email', 'alpha');
51 
52 $object = new RecruitmentJobPosition($db);
53 
54 
55 
56 
57 /*
58  * Actions
59  */
60 
61 // None
62 
63 
64 
65 /*
66  * View
67  */
68 
69 $form = new Form($db);
70 $user_assign = new User($db);
71 $user_create = new User($db);
72 
73 if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
74  $langs->load("errors");
75  print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
76  $db->close();
77  exit();
78 }
79 
80 $arrayofjs = array();
81 $arrayofcss = array();
82 
83 llxHeaderTicket($langs->trans("Jobs"), "", 0, 0, $arrayofjs, $arrayofcss);
84 
85 
86 print '<div class="ticketpublicarealist">';
87 
88 $display_ticket_list = 1;
89 
90 print '<br>';
91 if ($display_ticket_list) {
92  // Filters
93  $search_fk_status = GETPOST("search_fk_status", 'alpha');
94  $search_subject = GETPOST("search_subject", 'alpha');
95  $search_type = GETPOST("search_type", 'alpha');
96  $search_category = GETPOST("search_category", 'alpha');
97  $search_severity = GETPOST("search_severity", 'alpha');
98  $search_fk_user_create = GETPOST("search_fk_user_create", 'int');
99  $search_fk_user_assign = GETPOST("search_fk_user_assign", 'int');
100 
101  // Store current page url
102  $url_page_current = dol_buildpath('/public/ticket/list.php', 1);
103 
104  // Do we click on purge search criteria ?
105  if (GETPOST("button_removefilter_x")) {
106  $search_fk_status = '';
107  $search_subject = '';
108  $search_type = '';
109  $search_category = '';
110  $search_severity = '';
111  $search_fk_user_create = '';
112  $search_fk_user_assign = '';
113  }
114 
115  // fetch optionals attributes and labels
116  $extrafields = new ExtraFields($db);
117  $extrafields->fetch_name_optionals_label($object->table_element);
118 
119  $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
120 
121  $filter = array();
122  $param = 'action=viewlist';
123 
124  // Definition of fields for list
125  $arrayfields = array(
126  't.datec' => array('label' => $langs->trans("Date"), 'checked' => 1),
127  't.date_read' => array('label' => $langs->trans("TicketReadOn"), 'checked' => 0),
128  't.date_close' => array('label' => $langs->trans("TicketCloseOn"), 'checked' => 0),
129  't.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1),
130  //'t.track_id' => array('label' => $langs->trans("IDTracking"), 'checked' => 0),
131  't.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => 1),
132  't.subject' => array('label' => $langs->trans("Subject"), 'checked' => 1),
133  'type.code' => array('label' => $langs->trans("Type"), 'checked' => 1),
134  'category.code' => array('label' => $langs->trans("Category"), 'checked' => 1),
135  'severity.code' => array('label' => $langs->trans("Severity"), 'checked' => 1),
136  't.progress' => array('label' => $langs->trans("Progression"), 'checked' => 0),
137  //'t.fk_contract' => array('label' => $langs->trans("Contract"), 'checked' => 0),
138  't.fk_user_create' => array('label' => $langs->trans("Author"), 'checked' => 1),
139  't.fk_user_assign' => array('label' => $langs->trans("AssignedTo"), 'checked' => 0),
140 
141  //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
142  //'t.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
143  //'t.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 2)
144  //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
145  );
146 
147  // Extra fields
148  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
149  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
150  if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') {
151  $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => ($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1, 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' =>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3) && $extrafields->attributes[$object->table_element]['perms'][$key]);
152  }
153  }
154  }
155  if (!empty($search_subject)) {
156  $filter['t.subject'] = $search_subject;
157  $param .= '&search_subject='.urlencode($search_subject);
158  }
159  if (!empty($search_type)) {
160  $filter['t.type_code'] = $search_type;
161  $param .= '&search_type='.urlencode($search_type);
162  }
163  if (!empty($search_category)) {
164  $filter['t.category_code'] = $search_category;
165  $param .= '&search_category='.urlencode($search_category);
166  }
167  if (!empty($search_severity)) {
168  $filter['t.severity_code'] = $search_severity;
169  $param .= '&search_severity='.urlencode($search_severity);
170  }
171  if (!empty($search_fk_user_assign)) {
172  // -1 value = all so no filter
173  if ($search_fk_user_assign > 0) {
174  $filter['t.fk_user_assign'] = $search_fk_user_assign;
175  $param .= '&search_fk_user_assign='.urlencode($search_fk_user_assign);
176  }
177  }
178  if (!empty($search_fk_user_create)) {
179  // -1 value = all so no filter
180  if ($search_fk_user_create > 0) {
181  $filter['t.fk_user_create'] = $search_fk_user_create;
182  $param .= '&search_fk_user_create='.urlencode($search_fk_user_create);
183  }
184  }
185  if ((isset($search_fk_status) && $search_fk_status != '') && $search_fk_status != '-1' && $search_fk_status != 'non_closed') {
186  $filter['t.fk_statut'] = $search_fk_status;
187  $param .= '&search_fk_status='.urlencode($search_fk_status);
188  }
189  if (isset($search_fk_status) && $search_fk_status == 'non_closed') {
190  $filter['t.fk_statut'] = array(0, 1, 3, 4, 5, 6);
191  $param .= '&search_fk_status=non_closed';
192  }
193 
194  require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
195 
196  $sortfield = GETPOST("sortfield", 'alpha');
197  $sortorder = GETPOST("sortorder", 'alpha');
198 
199  if (!$sortfield) {
200  $sortfield = 't.datec';
201  }
202  if (!$sortorder) {
203  $sortorder = 'DESC';
204  }
205 
206  $limit = $conf->liste_limit;
207 
208  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
209  if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
210  $offset = $limit * $page;
211  $pageprev = $page - 1;
212  $pagenext = $page + 1;
213 
214  // Request SQL
215  $sql = "SELECT DISTINCT";
216  $sql .= " t.rowid,";
217  $sql .= " t.ref,";
218  $sql .= " t.track_id,";
219  $sql .= " t.fk_soc,";
220  $sql .= " t.fk_project,";
221  $sql .= " t.origin_email,";
222  $sql .= " t.fk_user_create, uc.lastname as user_create_lastname, uc.firstname as user_create_firstname,";
223  $sql .= " t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,";
224  $sql .= " t.subject,";
225  $sql .= " t.message,";
226  $sql .= " t.fk_statut,";
227  $sql .= " t.resolution,";
228  $sql .= " t.progress,";
229  $sql .= " t.timing,";
230  $sql .= " t.type_code,";
231  $sql .= " t.category_code,";
232  $sql .= " t.severity_code,";
233  $sql .= " t.datec,";
234  $sql .= " t.date_read,";
235  $sql .= " t.date_close,";
236  $sql .= " t.tms,";
237  $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
238  // Add fields for extrafields
239  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
240  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
241  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
242  }
243  $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as t";
244  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc";
245  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid=t.fk_user_create";
246  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
247  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition_extrafields as ef on (t.rowid = ef.fk_object)";
248  }
249  $sql .= " WHERE t.entity IN (".getEntity('recruitmentjobposition').")";
250  // Manage filter
251  if (!empty($filter)) {
252  foreach ($filter as $key => $value) {
253  if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year
254  $sql .= ' AND '.$key.' = \''.$value.'\'';
255  } elseif ($key == 't.fk_statut') {
256  if (is_array($value) && count($value) > 0) {
257  $sql .= 'AND '.$key.' IN ('.implode(',', $value).')';
258  } else {
259  $sql .= ' AND '.$key.' = '.$db->escape($value);
260  }
261  } else {
262  $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\'';
263  }
264  }
265  }
266  $sql .= " ORDER BY ".$sortfield.' '.$sortorder;
267 
268  $resql = $db->query($sql);
269  if ($resql) {
270  $num_total = $db->num_rows($resql);
271  if (!empty($limit)) {
272  $sql .= ' '.$db->plimit($limit + 1, $offset);
273  }
274 
275  $resql = $db->query($sql);
276  if ($resql) {
277  $num = $db->num_rows($resql);
278  print_barre_liste($langs->trans('JobList'), $page, 'public/recruitment/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket');
279 
280  // Search bar
281  print '<form method="get" action="'.$url_form.'" id="searchFormList" >'."\n";
282  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
283  print '<input type="hidden" name="action" value="viewlist">';
284  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
285  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
286 
287  $varpage = empty($contextpage) ? $url_page_current : $contextpage;
288  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
289 
290  print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
291 
292  // Filter bar
293  print '<tr class="liste_titre">';
294 
295  if (!empty($arrayfields['t.datec']['checked'])) {
296  print '<td class="liste_titre"></td>';
297  }
298 
299  if (!empty($arrayfields['t.ref']['checked'])) {
300  print '<td class="liste_titre"></td>';
301  }
302 
303  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
304  print '<td class="liste_titre"></td>';
305  }
306 
307  if (!empty($arrayfields['t.tms']['checked'])) {
308  print '<td class="liste_titre"></td>';
309  }
310 
311  // Extra fields
312  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
313 
314  // Fields from hook
315  $parameters = array('arrayfields'=>$arrayfields);
316  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
317  print $hookmanager->resPrint;
318 
319  // Status
320  if (!empty($arrayfields['t.fk_statut']['checked'])) {
321  print '<td class="liste_titre">';
322  $selected = ($search_fk_status != "non_closed" ? $search_fk_status : '');
323  //$object->printSelectStatus($selected);
324  print '</td>';
325  }
326 
327  // Action column
328  print '<td class="liste_titre maxwidthsearch">';
329  $searchpicto = $form->showFilterButtons();
330  print $searchpicto;
331  print '</td>';
332  print '</tr>';
333 
334  // Field title
335  print '<tr class="liste_titre">';
336  if (!empty($arrayfields['t.datec']['checked'])) {
337  print_liste_field_titre($arrayfields['t.datec']['label'], $url_page_current, 't.datec', '', $param, '', $sortfield, $sortorder);
338  }
339  if (!empty($arrayfields['t.ref']['checked'])) {
340  print_liste_field_titre($arrayfields['t.ref']['label'], $url_page_current, 't.ref', '', $param, '', $sortfield, $sortorder);
341  }
342  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
343  print_liste_field_titre($arrayfields['t.fk_user_create']['label'], $url_page_current, 't.fk_user_create', '', $param, '', $sortfield, $sortorder);
344  }
345  if (!empty($arrayfields['t.tms']['checked'])) {
346  print_liste_field_titre($arrayfields['t.tms']['label'], $url_page_current, 't.tms', '', $param, '', $sortfield, $sortorder);
347  }
348 
349  // Extra fields
350  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
351 
352  // Hook fields
353  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
354  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
355  print $hookmanager->resPrint;
356 
357  if (!empty($arrayfields['t.fk_statut']['checked'])) {
358  print_liste_field_titre($arrayfields['t.fk_statut']['label'], $url_page_current, 't.fk_statut', '', $param, '', $sortfield, $sortorder);
359  }
360  print_liste_field_titre($selectedfields, $url_page_current, "", '', '', 'align="right"', $sortfield, $sortorder, 'center maxwidthsearch ');
361  print '</tr>';
362 
363  while ($obj = $db->fetch_object($resql))
364  {
365  print '<tr class="oddeven">';
366 
367  // Date ticket
368  if (!empty($arrayfields['t.datec']['checked'])) {
369  print '<td>';
370  print dol_print_date($db->jdate($obj->datec), 'dayhour');
371  print '</td>';
372  }
373 
374  // Ref
375  if (!empty($arrayfields['t.ref']['checked'])) {
376  print '<td class="nowraponall">';
377  print $obj->ref;
378  print '</td>';
379  }
380 
381  // Message author
382  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
383  print '<td>';
384  if ($obj->fk_user_create > 0) {
385  $user_create->firstname = (!empty($obj->user_create_firstname) ? $obj->user_create_firstname : '');
386  $user_create->name = (!empty($obj->user_create_lastname) ? $obj->user_create_lastname : '');
387  $user_create->id = (!empty($obj->fk_user_create) ? $obj->fk_user_create : '');
388  print $user_create->getFullName($langs);
389  } else {
390  print $langs->trans('Email');
391  }
392  print '</td>';
393  }
394 
395  if (!empty($arrayfields['t.tms']['checked'])) {
396  print '<td>'.dol_print_date($db->jdate($obj->tms), 'dayhour').'</td>';
397  }
398 
399  // Extra fields
400  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
401  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
402  if (!empty($arrayfields["ef.".$key]['checked'])) {
403  print '<td';
404  $align = $extrafields->getAlignFlag($key);
405  if ($align) {
406  print ' align="'.$align.'"';
407  }
408  print '>';
409  $tmpkey = 'options_'.$key;
410  print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
411  print '</td>';
412  }
413  }
414  }
415 
416  // Statut
417  if (!empty($arrayfields['t.fk_statut']['checked'])) {
418  print '<td class="nowraponall">';
419  $object->fk_statut = $obj->fk_statut;
420  print $object->getLibStatut(2);
421  print '</td>';
422  }
423 
424  print '<td></td>';
425 
426  $i++;
427  print '</tr>';
428  }
429 
430  print '</table>';
431  print '</form>';
432 
433  print '<form method="post" id="form_view" name="form_view" enctype="multipart/form-data" action="'.dol_buildpath('/public/recruitment/view.php', 1).'" style="display:none;">';
434  print '<input type="hidden" name="token" value="'.newToken().'">';
435  print '<input type="hidden" name="action" value="view">';
436  print '<input type="hidden" name="btn_view_list" value="1">';
437  print '<input type="hidden" name="track_id" value="">';
438  print '<input type="hidden" name="email" value="">';
439  print "</form>";
440  print '<script type="text/javascript">
441  function viewticket(ticket_id, email) {
442  var form = $("#form_view");
443  form.submit();
444  }
445  </script>';
446  }
447  }
448 } else {
449  print '<div class="error">Not Allowed<br><a href="'.$_SERVER['PHP_SELF'].'?ref='.$object->ref.'">'.$langs->trans('Back').'</a></div>';
450 }
451 
452 
453 print "</div>";
454 
455 // End of page
456 htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix, $object);
457 
458 llxFooter('', 'public');
459 
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.
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Class to manage standard extra fields.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
llxHeaderTicket($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '')
Show header for public pages.
Definition: ticket.lib.php:202
Class for RecruitmentJobPosition.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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
llxFooter()
Empty footer.
Definition: wrapper.php:59