dolibarr  17.0.4
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')); // why 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 // Permissions
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 (!empty($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  $nbtotalofrecords = 0;
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=" . (!empty($user->rowid) ? $user->rowid :0);
630  $backtopage = dol_buildpath('/hrm/skill_card.php', 1) . '?id=' . $id;
631  $param = "";
632  $massactionbutton = "";
633  //$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);
634 
635  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, "", '', '', 0, 0, 1);
636 
637  // Add code for pre mass action (confirmation or email presend form)
638  $topicmail = "SendSkilldetRef";
639  $modelmail = "skilldet";
640  $objecttmp = new Skilldet($db);
641  $trackid = 'xxxx' . $object->id;
642  //include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
643 
644  if ($search_all) {
645  foreach ($fieldstosearchall as $key => $val) {
646  $fieldstosearchall[$key] = $langs->trans($val);
647  }
648  print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall) . '</div>';
649  }
650 
651  $moreforfilter = '';
652  /*$moreforfilter.='<div class="divsearchfield">';
653  $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
654  $moreforfilter.= '</div>';*/
655 
656  $parameters = array();
657  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
658  if (empty($reshook)) {
659  $moreforfilter .= $hookmanager->resPrint;
660  } else {
661  $moreforfilter = $hookmanager->resPrint;
662  }
663 
664  if (!empty($moreforfilter)) {
665  print '<div class="liste_titre liste_titre_bydiv centpercent">';
666  print $moreforfilter;
667  print '</div>';
668  }
669 
670  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
671  // $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
672  // $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
673 
674  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
675  print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
676 
677 
678  // Fields title label
679  // --------------------------------------------------------------------
680  print '<tr class="liste_titre">';
681  foreach ($objectline->fields as $key => $val) {
682  // $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
683  // if ($key == 'status') {
684  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
685  // } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
686  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
687  // } elseif (in_array($val['type'], array('timestamp'))) {
688  // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
689  // } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
690  // $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
691  // }
692  if (!empty($arrayfields['t.' . $key]['checked'])) {
693  print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, (!empty($cssforfield) ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, (!empty($cssforfield) ? $cssforfield . ' ' : '')) . "\n";
694  }
695  }
696  print '<td></td>';
697  print '<td></td>';
698  print '</tr>' . "\n";
699 
700 
701  // Display all ranks of skill
702  // --------------------------------------------------------------------
703 
704  $i = 0;
705  $totalarray = array();
706  $totalarray['nbfield'] = 0;
707  while ($i < ($limit ? min($num, $limit) : $num)) {
708  $obj = $db->fetch_object($resql);
709  if (empty($obj)) {
710  break; // Should not happen
711  }
712 
713  if ($obj->rankorder > $MaxNumberSkill) {
714  continue;
715  }
716 
717  // Store properties in $objectline
718  $objectline->setVarsFromFetchObj($obj);
719 
720  // Show here line of result
721  print '<tr class="oddeven">';
722  foreach ($objectline->fields as $key => $val) {
723  // $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
724  // if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
725  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
726  // } elseif ($key == 'status') {
727  // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
728  // }
729  //
730  // if (in_array($val['type'], array('timestamp'))) {
731  // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
732  // } elseif ($key == 'ref') {
733  // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
734  // }
735  //
736  // if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
737  // $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
738  // }
739  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
740 
741  if (!empty($arrayfields['t.' . $key]['checked'])) {
742  print '<td' . ($cssforfield ? ' class="' . $cssforfield . '"' : '') . '>';
743  if ($key == 'status') {
744  print $objectline->getLibStatut(5);
745  } elseif ($key == 'rowid') {
746  print $objectline->showOutputField($val, $key, $objectline->id, '');
747  // ajout pencil
748  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>';
749  } else {
750  print $objectline->showOutputField($val, $key, $objectline->$key, '');
751  }
752  print '</td>';
753 
754 
755  if (!$i) {
756  $totalarray['nbfield']++;
757  }
758  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
759  if (!$i) {
760  $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
761  }
762  if (!isset($totalarray['val'])) {
763  $totalarray['val'] = array();
764  }
765  if (!isset($totalarray['val']['t.' . $key])) {
766  $totalarray['val']['t.' . $key] = 0;
767  }
768  $totalarray['val']['t.' . $key] += $objectline->$key;
769  }
770  }
771  }
772 
773 
774  // LINE EDITION | SUPPRESSION
775 
776  print '<td>';
777 
778  print '</td>';
779  print '<td>';
780  // add pencil
781  //@todo change to proper call dol_
782  //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>';
783  // add trash
784  //@todo change to proper call dol_
785  //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>';
786  //print '</td>';
787 
788 
789  // Fields from hook
790  $parameters = array('arrayfields' => $arrayfields, 'object' => $objectline, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
791  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
792  print $hookmanager->resPrint;
793  /*// Action column
794  print '<td class="nowrap center">';
795 
796  print '</td>';*/
797  if (!$i) {
798  $totalarray['nbfield']++;
799  }
800 
801  print '</tr>' . "\n";
802 
803  $i++;
804  }
805 
806 
807  // If no record found
808 
809  if ($num == 0) {
810  $colspan = 1;
811  foreach ($arrayfields as $key => $val) {
812  if (!empty($val['checked'])) {
813  $colspan++;
814  }
815  }
816  print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs->trans("NoRecordFound") . '</td></tr>';
817  }
818 
819  if (!empty($resql)) $db->free($resql);
820 
821  $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
822  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
823  print $hookmanager->resPrint;
824 
825  print '</table>' . "\n";
826  print '</div>' . "\n";
827 
828  print '</form>' . "\n";
829 
830  // if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
831  // $hidegeneratedfilelistifempty = 1;
832  // if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
833  // $hidegeneratedfilelistifempty = 0;
834  // }
835  //
836  // require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
837  // $formfile = new FormFile($db);
838  //
839  // // Show list of available documents
840  // $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
841  // $urlsource .= str_replace('&amp;', '&', $param);
842  //
843  // $filedir = $diroutputmassaction;
844  // $genallowed = $permissiontoread;
845  // $delallowed = $permissiontoadd;
846  //
847  // print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
848  // }
849 
850  print '<div class="fichecenter"><div class="fichehalfleft">';
851 
852  // Show links to link elements
853  $linktoelem = $form->showLinkToObjectBlock($object, null, array('skill'));
854  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
855 
856  print '</div><div class="fichehalfright">';
857 
858  $MAXEVENT = 10;
859 
860  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/hrm/skill_agenda.php?id='.$object->id);
861 
862  // List of actions on element
863  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
864  $formactions = new FormActions($db);
865  $somethingshown = $formactions->showactions($object, $object->element . '@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
866 
867  print '</div></div>';
868 }
869 
870 // End of page
871 llxFooter();
872 $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') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_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='')
Show tabs of a record.
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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.
setEventMessage($mesgs, $style='mesgs')
Set event message 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.
skillPrepareHead($object)
Prepare array of tabs for Skill.
$formconfirm
if ($action == 'delbookkeepingyear') {
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.