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