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