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