dolibarr  16.0.5
skill_card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4  * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
5  * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
6  * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
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 
29 // Load Dolibarr environment
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
32 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
34 require_once DOL_DOCUMENT_ROOT . '/hrm/class/skill.class.php';
35 require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_skill.lib.php';
36 
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array("hrm", "other", 'products'));
40 
41 // Get parameters
42 $id = GETPOST('id', 'int');
43 $ref = GETPOST('ref', 'alpha');
44 $action = GETPOST('action', 'aZ09');
45 $confirm = GETPOST('confirm', 'alpha');
46 $cancel = GETPOST('cancel', 'aZ09');
47 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'skillcard'; // To manage different context of search
48 $backtopage = GETPOST('backtopage', 'alpha');
49 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
50 //$lineid = GETPOST('lineid', 'int');
51 
52 // Initialize technical objects
53 $object = new Skill($db);
54 $extrafields = new ExtraFields($db);
55 //$diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
56 $hookmanager->initHooks(array('skillcard', 'globalcard')); // Note that conf->hooks_modules contains array
57 
58 // Fetch optionals attributes and labels
59 $extrafields->fetch_name_optionals_label($object->table_element);
60 
61 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
62 
63 
64 // Initialize array of search criterias
65 $search_all = GETPOST("search_all", 'alpha');
66 $search = array();
67 foreach ($object->fields as $key => $val) {
68  if (GETPOST('search_' . $key, 'alpha')) {
69  $search[$key] = GETPOST('search_' . $key, 'alpha');
70  }
71 }
72 
73 if (empty($action) && empty($id) && empty($ref)) {
74  $action = 'view';
75 }
76 
77 // Load object
78 include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
79 
80 
81 $permissiontoread = $user->rights->hrm->all->read;
82 $permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
83 $permissiontodelete = $user->rights->hrm->all->delete;
84 $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/skill';
85 
86 // Security check (enable the most restrictive one)
87 //if ($user->socid > 0) accessforbidden();
88 //if ($user->socid > 0) $socid = $user->socid;
89 //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
90 //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
91 if (empty($conf->hrm->enabled)) accessforbidden();
92 if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden();
93 
94 $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL;
95 
96 
97 /*
98  * Actions
99  */
100 
101 $parameters = array();
102 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
103 if ($reshook < 0) {
104  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
105 }
106 
107 if (empty($reshook)) {
108  $error = 0;
109 
110  $backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php';
111 
112  if (empty($backtopage) || ($cancel && empty($id))) {
113  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
114  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
115  $backtopage = $backurlforlist;
116  } else {
117  $backtopage = DOL_URL_ROOT.'/hrm/skill_card.php?id=' . ($id > 0 ? $id : '__ID__');
118  }
119  }
120  }
121 
122  $triggermodname = 'hrm_SKILL_MODIFY'; // Name of trigger action code to execute when we modify record
123 
124 
125  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
126  $noback = 1;
127  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
128 
129  // action update on Skilldet
130  $skilldetArray = GETPOST("descriptionline", "array:alphanohtml");
131 
132  if (!$error) {
133  if (is_array($skilldetArray) && count($skilldetArray) > 0) {
134  foreach ($skilldetArray as $key => $SkValueToUpdate) {
135  $skilldetObj = new Skilldet($object->db);
136  $res = $skilldetObj->fetch($key);
137  if ($res > 0) {
138  $skilldetObj->description = $SkValueToUpdate;
139  $resupd = $skilldetObj->update($user);
140  if ($resupd <= 0) {
141  setEventMessage($langs->trans('errorUpdateSkilldet'));
142  }
143  }
144  }
145  }
146  }
147 
148 
149  // Actions when linking object each other
150  include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php';
151 
152  // Actions when printing a doc from card
153  include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php';
154 
155  // Action to move up and down lines of object
156  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
157 
158  // Action to build doc
159  include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php';
160 
161  if ($action == 'set_thirdparty' && $permissiontoadd) {
162  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
163  }
164  if ($action == 'classin' && $permissiontoadd) {
165  $object->setProject(GETPOST('projectid', 'int'));
166  }
167 
168  // Actions to send emails
169  $triggersendname = 'hrm_SKILL_SENTBYMAIL';
170  $autocopy = 'MAIN_MAIL_AUTOCOPY_SKILL_TO';
171  $trackid = 'skill' . $object->id;
172  include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php';
173 }
174 
175 
176 /*
177  * View
178  */
179 
180 $form = new Form($db);
181 $formfile = new FormFile($db);
182 $formproject = new FormProjets($db);
183 
184 $title = $langs->trans("skill");
185 $help_url = '';
186 llxHeader('', $title, $help_url);
187 
188 
189 // Part to create
190 if ($action == 'create') {
191  print load_fiche_titre($langs->trans("NewSkill"), '', 'object_' . $object->picto);
192 
193  print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
194  print '<input type="hidden" name="token" value="' . newToken() . '">';
195  print '<input type="hidden" name="action" value="add">';
196  $backtopage .= (strpos($backtopage, '?') > 0 ? '&' : '?' ) ."objecttype=job";
197  if ($backtopage) {
198  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
199  }
200  if ($backtopageforcancel) {
201  print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
202  }
203 
204  print dol_get_fiche_head(array(), '');
205 
206  print '<table class="border centpercent tableforfieldcreate">' . "\n";
207 
208  // Common attributes
209  include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
210 
211  // Other attributes
212  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
213 
214 
215  // SKILLDET ADD
216  //@todo je stop ici ... à continuer (affichage des 5 skilled input pour create action
217  //print $object->showInputField($val, $key, $value, '', '['']', '', 0);
218 
219  print '</table>' . "\n";
220 
221  print dol_get_fiche_end();
222 
223  print '<div class="center">';
224  print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
225  print '&nbsp; ';
226 
227  print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
228  print '</div>';
229 
230  print '</form>';
231 
232  //dol_set_focus('input[name="ref"]');
233 }
234 
235 // Part to edit record
236 // and skilldet edition
237 if (($id || $ref) && $action == 'edit') {
238  print load_fiche_titre($langs->trans("Skill"), '', 'object_' . $object->picto);
239 
240  print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
241  print '<input type="hidden" name="token" value="' . newToken() . '">';
242  print '<input type="hidden" name="action" value="update">';
243  print '<input type="hidden" name="id" value="' . $object->id . '">';
244  if ($backtopage) {
245  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
246  }
247  if ($backtopageforcancel) {
248  print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
249  }
250 
251  print dol_get_fiche_head();
252 
253  print '<table class="border centpercent tableforfieldedit">' . "\n";
254 
255  // Common attributes
256  include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
257 
258  print '</table>';
259 
260  // Other attributes
261  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
262 
263  // SKILLDET
264 
265  print dol_get_fiche_head(array(), '');
266 
267  $SkilldetRecords = $object->fetchLines();
268 
269  if (is_array($SkilldetRecords) && count($SkilldetRecords) == 0) {
270  $object->createSkills(1);
271  }
272 
273  if (is_array($SkilldetRecords) && count($SkilldetRecords) > 0) {
274  print '<table>';
275  foreach ($SkilldetRecords as $sk) {
276  if ($sk->rankorder > $MaxNumberSkill) {
277  continue;
278  }
279 
280  print '<table class="border centpercent =">' . "\n";
281  $sk->fields = dol_sort_array($sk->fields, 'position');
282  foreach ($sk->fields as $key => $val) {
283  if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
284  continue;
285  }
286 
287  if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
288  continue; // We don't want this field
289  }
290 
291  print '<tr class="field_' . $key . '"><td';
292  print ' class="titlefieldcreate';
293  if (isset($val['notnull']) && $val['notnull'] > 0) {
294  print ' fieldrequired';
295  }
296  if (preg_match('/^(text|html)/', $val['type'])) {
297  print ' tdtop';
298  }
299  print '">';
300  // if (!empty($val['help'])) {
301  // print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
302  // } else {
303  print $langs->trans($val['label']).'&nbsp;'.$langs->trans('rank').'&nbsp;'.$sk->rankorder;
304  // }
305  print '</td>';
306  print '<td class="valuefieldcreate">';
307  // if (!empty($val['picto'])) {
308  // print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth');
309  // }
310  // if (in_array($val['type'], array('int', 'integer'))) {
311  // $value = GETPOSTISSET($key) ? GETPOST($key, 'int') : $sk->$key;
312  // } elseif ($val['type'] == 'double') {
313  // $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $sk->$key;
314  // } elseif (preg_match('/^(text|html)/', $val['type'])) {
315  // $tmparray = explode(':', $val['type']);
316  if (!empty($tmparray[1])) {
317  $check = $tmparray[1];
318  } else {
319  $check = 'restricthtml';
320  }
321 
322  $skilldetArray = GETPOST("descriptionline", "array");
323  if (empty($skilldetArray)) {
324  $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $sk->$key;
325  } else {
326  $value=$skilldetArray[$sk->id];
327  }
328  //
329  // } elseif ($val['type'] == 'price') {
330  // $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($sk->$key);
331  // } else {
332  // $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $sk->$key;
333  // }
334  //var_dump($val.' '.$key.' '.$value);
335  if ($val['noteditable']) {
336  print $sk->showOutputField($val, $key, $value, '', '', '', 0);
337  } else {
339  print $sk->showInputField($val, $key, $value, "", "line[" . $sk->id . "]", "", "");
340  }
341  print '</td>';
342  print '</tr>';
343  }
344  }
345  print '</table>';
346  }
347 
348 
349  print dol_get_fiche_end();
350 
351  print '<div class="center"><input type="submit" class="button button-save" name="save" value="' . $langs->trans("Save") . '">';
352  print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">';
353  print '</div>';
354 
355  print '</form>';
356 }
357 
358 
359 // Part to show record
360 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
361  $res = $object->fetch_optionals();
362 
363  $head = skillPrepareHead($object);
364  print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto);
365 
366  $formconfirm = '';
367 
368  // Confirmation to delete
369  if ($action == 'delete') {
370  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteSkill'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
371  }
372  // Confirmation to delete line
373  if ($action == 'deleteline') {
374  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
375  }
376  // Clone confirmation
377  if ($action == 'clone') {
378  // Create an array for form
379  $formquestion = array();
380  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
381  }
382 
383  // Confirmation of action xxxx
384  if ($action == 'xxx') {
385  $formquestion = array();
386  /*
387  $forcecombo=0;
388  if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
389  $formquestion = array(
390  // 'text' => $langs->trans("ConfirmClone"),
391  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
392  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
393  // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
394  );
395  */
396  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
397  }
398 
399  // Call Hook formConfirm
400  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
401  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
402  if (empty($reshook)) {
403  $formconfirm .= $hookmanager->resPrint;
404  } elseif ($reshook > 0) {
405  $formconfirm = $hookmanager->resPrint;
406  }
407 
408  // Print form confirm
409  print $formconfirm;
410 
411 
412  // Object card
413  // ------------------------------------------------------------
414  $linkback = '<a href="' . DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
415 
416 
417  $morehtmlref = '<div class="refid">';
418  $morehtmlref.= $object->label;
419  $morehtmlref .= '</div>';
420  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
421 
422 
423  print '<div class="fichecenter">';
424  print '<div class="fichehalfleft">';
425  print '<div class="underbanner clearboth"></div>';
426  print '<table class="border centpercent tableforfield">' . "\n";
427 
428  $object->fields['label']['visible']=0; // Already in banner
429  include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
430 
431  // Other attributes. Fields from hook formObjectOptions and Extrafields.
432  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
433 
434 
435  print '</table>';
436  print '</div>';
437  print '</div>';
438 
439  print '<div class="clearboth"></div>';
440 
441  print dol_get_fiche_end();
442 
443 
444  //dol_include_once('/hrm/tpl/hrm_skillde.fiche.tpl.php');
445 
446  // Buttons for actions
447 
448  if ($action != 'presend' && $action != 'editline') {
449  print '<div class="tabsAction">' . "\n";
450  $parameters = array();
451  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
452  if ($reshook < 0) {
453  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
454  }
455 
456  if (empty($reshook)) {
457  // Back to draft
458  if ($object->status == $object::STATUS_VALIDATED) {
459  print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=confirm_setdraft&confirm=yes&token=' . newToken(), '', $permissiontoadd);
460  }
461 
462  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
463 
464  // Delete (need delete permission, or if draft, just need create/modify permission)
465  print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete);
466  }
467  print '</div>' . "\n";
468  }
469 }
470 
471 //*----------------------------------------------------------------------------
472 //*----------------------------------------------------------------------------
473 
474 
475 //*---------------------------------------------------------------------------
476 
477 if ($action != "create" && $action != "edit") {
478  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
479  require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
480  require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
481 
482  // load hrm libraries
483  require_once __DIR__ . '/class/skilldet.class.php';
484 
485  // for other modules
486  //dol_include_once('/othermodule/class/otherobject.class.php');
487 
488  $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
489  $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
490  $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
491  $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
492  $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
493  $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
494  $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'skilldetlist'; // To manage different context of search
495  $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
496  $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
497 
498  $id = GETPOST('id', 'int');
499 
500  // Load variable for pagination
501  $limit = 0;
502  $sortfield = GETPOST('sortfield', 'aZ09comma');
503  $sortorder = GETPOST('sortorder', 'aZ09comma');
504  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
505  if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
506  // If $page is not defined, or '' or -1 or if we click on clear filters
507  $page = 0;
508  }
509  $offset = $limit * $page;
510  $pageprev = $page - 1;
511  $pagenext = $page + 1;
512 
513  // Initialize technical objects
514  $objectline = new Skilldet($db);
515  // $diroutputmassaction = $conf->hrm->dir_output . '/temp/massgeneration/' . $user->id;
516  // $hookmanager->initHooks(array('skilldetlist')); // Note that conf->hooks_modules contains array
517 
518  // Default sort order (if not yet defined by previous GETPOST)
519  if (!$sortfield) {
520  reset($objectline->fields); // Reset is required to avoid key() to return null.
521  $sortfield = "t." . key($objectline->fields); // Set here default search field. By default 1st field in definition.
522  }
523  if (!$sortorder) {
524  $sortorder = "ASC";
525  }
526 
527  // Initialize array of search criterias
528  $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
529  $search = array();
530  foreach ($objectline->fields as $key => $val) {
531  if (GETPOST('search_' . $key, 'alpha') !== '') {
532  $search[$key] = GETPOST('search_' . $key, 'alpha');
533  }
534  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
535  $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_' . $key . '_dtstartmonth', 'int'), GETPOST('search_' . $key . '_dtstartday', 'int'), GETPOST('search_' . $key . '_dtstartyear', 'int'));
536  $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_' . $key . '_dtendmonth', 'int'), GETPOST('search_' . $key . '_dtendday', 'int'), GETPOST('search_' . $key . '_dtendyear', 'int'));
537  }
538  }
539 
540  // List of fields to search into when doing a "search in all"
541  $fieldstosearchall = array();
542  foreach ($objectline->fields as $key => $val) {
543  if (!empty($val['searchall'])) {
544  $fieldstosearchall['t.' . $key] = $val['label'];
545  }
546  }
547 
548  // Definition of array of fields for columns
549  $arrayfields = array();
550  foreach ($objectline->fields as $key => $val) {
551  // If $val['visible']==0, then we never show the field
552  if (!empty($val['visible'])) {
553  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
554  $arrayfields['t.' . $key] = array(
555  'label' => $val['label'],
556  'checked' => (($visible < 0) ? 0 : 1),
557  'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
558  'position' => $val['position'],
559  'help' => isset($val['help']) ? $val['help'] : ''
560  );
561  }
562  }
563 
564  $objectline->fields = dol_sort_array($objectline->fields, 'position');
565  $arrayfields = dol_sort_array($arrayfields, 'position');
566 
567 
568  /*
569  * View
570  */
571 
572  $form = new Form($db);
573 
574  $now = dol_now();
575 
576  $help_url = '';
577  $title = $langs->transnoentitiesnoconv("Skilldets");
578  $morejs = array();
579  $morecss = array();
580 
581 
582  // Build and execute select
583  // --------------------------------------------------------------------
584  $sql = 'SELECT ';
585  $sql .= $objectline->getFieldList('t');
586  $sql .= " FROM " . MAIN_DB_PREFIX . $objectline->table_element . " as t";
587  if ($objectline->ismultientitymanaged == 1) {
588  $sql .= " WHERE t.entity IN (" . getEntity($objectline->element) . ")";
589  } else {
590  $sql .= " WHERE 1 = 1 ";
591  }
592 
593  if (!empty($id)) {
594  $sql .= " AND fk_skill = " . ((int) $id) . " ";
595  }
596 
597  // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
598  if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
599  $num = $nbtotalofrecords;
600  } else {
601  if ($limit) {
602  $sql .= $db->plimit($limit + 1, $offset);
603  }
604 
605  $resql = $db->query($sql);
606  if (!$resql) {
607  dol_print_error($db);
608  exit;
609  }
610 
611  $num = $db->num_rows($resql);
612  }
613 
614  print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
615  if ($optioncss != '') {
616  print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
617  }
618  print '<input type="hidden" name="token" value="' . newToken() . '">';
619  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
620  print '<input type="hidden" name="action" value="list">';
621  print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
622  print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
623  print '<input type="hidden" name="page" value="' . $page . '">';
624  print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
625  if (!empty($id)) {
626  print '<input type="hidden" name="id" value="' . $id . '">';
627  }
628 
629  $param_fk = "&fk_skill=" . $id . "&fk_user_creat=" . $user->rowid;
630  $backtopage = dol_buildpath('/hrm/skill_card.php', 1) . '?id=' . $id;
631  //$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/skilldet_card.php', 1) . '?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF']) . $param_fk . '&backtopage=' . $backtopage, '', $permissiontoadd);
632 
633  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, "", '', '', 0, 0, 1);
634 
635  // Add code for pre mass action (confirmation or email presend form)
636  $topicmail = "SendSkilldetRef";
637  $modelmail = "skilldet";
638  $objecttmp = new Skilldet($db);
639  $trackid = 'xxxx' . $object->id;
640  //include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
641 
642  if ($search_all) {
643  foreach ($fieldstosearchall as $key => $val) {
644  $fieldstosearchall[$key] = $langs->trans($val);
645  }
646  print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall) . '</div>';
647  }
648 
649  $moreforfilter = '';
650  /*$moreforfilter.='<div class="divsearchfield">';
651  $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
652  $moreforfilter.= '</div>';*/
653 
654  $parameters = array();
655  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
656  if (empty($reshook)) {
657  $moreforfilter .= $hookmanager->resPrint;
658  } else {
659  $moreforfilter = $hookmanager->resPrint;
660  }
661 
662  if (!empty($moreforfilter)) {
663  print '<div class="liste_titre liste_titre_bydiv centpercent">';
664  print $moreforfilter;
665  print '</div>';
666  }
667 
668  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
669  // $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
670  // $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
671 
672  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
673  print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
674 
675 
676  // Fields title label
677  // --------------------------------------------------------------------
678  print '<tr class="liste_titre">';
679  foreach ($objectline->fields as $key => $val) {
680  // $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
681  // if ($key == 'status') {
682  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
683  // } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
684  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
685  // } elseif (in_array($val['type'], array('timestamp'))) {
686  // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
687  // } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
688  // $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
689  // }
690  if (!empty($arrayfields['t.' . $key]['checked'])) {
691  print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, ($cssforfield ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield . ' ' : '')) . "\n";
692  }
693  }
694  print '<td></td>';
695  print '<td></td>';
696  print '</tr>' . "\n";
697 
698 
699  // Display all ranks of skill
700  // --------------------------------------------------------------------
701 
702  $i = 0;
703  $totalarray = array();
704  $totalarray['nbfield'] = 0;
705  while ($i < ($limit ? min($num, $limit) : $num)) {
706  $obj = $db->fetch_object($resql);
707  if (empty($obj)) {
708  break; // Should not happen
709  }
710 
711  if ($obj->rankorder > $MaxNumberSkill) {
712  continue;
713  }
714 
715  // Store properties in $objectline
716  $objectline->setVarsFromFetchObj($obj);
717 
718  // Show here line of result
719  print '<tr class="oddeven">';
720  foreach ($objectline->fields as $key => $val) {
721  // $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
722  // if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
723  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
724  // } elseif ($key == 'status') {
725  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
726  // }
727  //
728  // if (in_array($val['type'], array('timestamp'))) {
729  // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
730  // } elseif ($key == 'ref') {
731  // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
732  // }
733  //
734  // if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
735  // $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
736  // }
737  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
738 
739  if (!empty($arrayfields['t.' . $key]['checked'])) {
740  print '<td' . ($cssforfield ? ' class="' . $cssforfield . '"' : '') . '>';
741  if ($key == 'status') {
742  print $objectline->getLibStatut(5);
743  } elseif ($key == 'rowid') {
744  print $objectline->showOutputField($val, $key, $objectline->id, '');
745  // ajout pencil
746  print '<a class="timeline-btn" href="' . DOL_MAIN_URL_ROOT . '/comm/action/skilldet_card.php?action=edit&id=' . $objectline->id . '"><i class="fa fa-pencil" title="' . $langs->trans("Modify") . '" ></i></a>';
747  } else {
748  print $objectline->showOutputField($val, $key, $objectline->$key, '');
749  }
750  print '</td>';
751 
752 
753  if (!$i) {
754  $totalarray['nbfield']++;
755  }
756  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
757  if (!$i) {
758  $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
759  }
760  if (!isset($totalarray['val'])) {
761  $totalarray['val'] = array();
762  }
763  if (!isset($totalarray['val']['t.' . $key])) {
764  $totalarray['val']['t.' . $key] = 0;
765  }
766  $totalarray['val']['t.' . $key] += $objectline->$key;
767  }
768  }
769  }
770 
771 
772  // LINE EDITION | SUPPRESSION
773 
774  print '<td>';
775 
776  print '</td>';
777  print '<td>';
778  // add pencil
779  //@todo change to proper call dol_
780  //print '<a class="timeline-btn" href="' . dol_buildpath("custom/hrm/skilldet_card.php?action=edit&id=" . $objectline->id, 1) . '"><i class="fa fa-pencil" title="' . $langs->trans("Modify") . '" ></i></a>';
781  // add trash
782  //@todo change to proper call dol_
783  //print '<a class="timeline-btn" href="'.dol_buildpath("custom/hrm/skilldet_card.php?action=delete&id=".$objectline->id,1) .'"><i class="fa fa-trash" title="'.$langs->trans("Delete").'" ></i></a>';
784  //print '</td>';
785 
786 
787  // Fields from hook
788  $parameters = array('arrayfields' => $arrayfields, 'object' => $objectline, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
789  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
790  print $hookmanager->resPrint;
791  /*// Action column
792  print '<td class="nowrap center">';
793 
794  print '</td>';*/
795  if (!$i) {
796  $totalarray['nbfield']++;
797  }
798 
799  print '</tr>' . "\n";
800 
801  $i++;
802  }
803 
804 
805  // If no record found
806 
807  if ($num == 0) {
808  $colspan = 1;
809  foreach ($arrayfields as $key => $val) {
810  if (!empty($val['checked'])) {
811  $colspan++;
812  }
813  }
814  print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs->trans("NoRecordFound") . '</td></tr>';
815  }
816 
817 
818  $db->free($resql);
819 
820  $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
821  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
822  print $hookmanager->resPrint;
823 
824  print '</table>' . "\n";
825  print '</div>' . "\n";
826 
827  print '</form>' . "\n";
828 
829  // if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
830  // $hidegeneratedfilelistifempty = 1;
831  // if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
832  // $hidegeneratedfilelistifempty = 0;
833  // }
834  //
835  // require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
836  // $formfile = new FormFile($db);
837  //
838  // // Show list of available documents
839  // $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
840  // $urlsource .= str_replace('&amp;', '&', $param);
841  //
842  // $filedir = $diroutputmassaction;
843  // $genallowed = $permissiontoread;
844  // $delallowed = $permissiontoadd;
845  //
846  // print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
847  // }
848 
849  print '<div class="fichecenter"><div class="fichehalfleft">';
850 
851  // Show links to link elements
852  $linktoelem = $form->showLinkToObjectBlock($object, null, array('skill'));
853  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
854 
855  print '</div><div class="fichehalfright">';
856 
857  $MAXEVENT = 10;
858 
859  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/hrm/skill_agenda.php?id='.$object->id);
860 
861  // List of actions on element
862  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
863  $formactions = new FormActions($db);
864  $somethingshown = $formactions->showactions($object, $object->element . '@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
865 
866  print '</div></div>';
867 }
868 
869 // End of page
870 llxFooter();
871 $db->close();
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
skillPrepareHead
skillPrepareHead($object)
Prepare array of tabs for Skill.
Definition: hrm_skill.lib.php:33
getTitleFieldOfList
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
Definition: functions.lib.php:5049
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
dol_sort_array
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
Definition: functions.lib.php:8385
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
verifCond
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
Definition: functions.lib.php:8582
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dolGetButtonAction
dolGetButtonAction($label, $html='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
Definition: functions.lib.php:10450
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
$formactions
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Definition: agenda_other.php:178
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:576
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
getEntity
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Definition: functions.lib.php:148
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
setEventMessage
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
Definition: functions.lib.php:8108
print_barre_liste
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.
Definition: functions.lib.php:5257
Skill
Class for Skill.
Definition: skill.class.php:36
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8611
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
Skilldet
Class for Skilldet.
Definition: skilldet.class.php:36
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
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
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