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