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