dolibarr 21.0.0-alpha
skill_card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4 * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
5 * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
6 * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
7 * Copyright (C) 2023-2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024 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
40// Load translation files required by the page
41$langs->loadLangs(array('hrm', 'other', 'products')); // why products?
42
43// Get parameters
44$id = GETPOSTINT('id');
45$ref = GETPOST('ref', 'alpha');
46$action = GETPOST('action', 'aZ09');
47$confirm = GETPOST('confirm', 'alpha');
48$cancel = GETPOST('cancel', 'aZ09');
49$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'skillcard'; // To manage different context of search
50$backtopage = GETPOST('backtopage', 'alpha');
51$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
52$lineid = GETPOSTINT('lineid');
53
54// Initialize a technical objects
55$object = new Skill($db);
56$extrafields = new ExtraFields($db);
57//$diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
58$hookmanager->initHooks(array('skillcard', 'globalcard')); // Note that conf->hooks_modules contains array
59
60// Fetch optionals attributes and labels
61$extrafields->fetch_name_optionals_label($object->table_element);
62
63$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
64
65
66// Initialize array of search criteria
67$search_all = GETPOST("search_all", 'alpha');
68$search = array();
69foreach ($object->fields as $key => $val) {
70 if (GETPOST('search_' . $key, 'alpha')) {
71 $search[$key] = GETPOST('search_' . $key, 'alpha');
72 }
73}
74
75if (empty($action) && empty($id) && empty($ref)) {
76 $action = 'view';
77}
78
79// Load object
80include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
81
82// Permissions
83$permissiontoread = $user->hasRight('hrm', 'all', 'read');
84$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
85$permissiontodelete = $user->hasRight('hrm', 'all', 'delete');
86
87$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/skill';
88
89// Security check (enable the most restrictive one)
90//if ($user->socid > 0) accessforbidden();
91//if ($user->socid > 0) $socid = $user->socid;
92//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
93//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
94if (empty($conf->hrm->enabled)) {
96}
97if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) {
99}
100
101$MaxNumberSkill = getDolGlobalInt('HRM_MAXRANK', Skill::DEFAULT_MAX_RANK_PER_SKILL);
102
103
104/*
105 * Actions
106 */
107
108$parameters = array();
109$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
110if ($reshook < 0) {
111 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
112}
113
114if (empty($reshook)) {
115 $error = 0;
116
117 $backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php';
118
119 if (empty($backtopage) || ($cancel && empty($id))) {
120 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
121 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
122 $backtopage = $backurlforlist;
123 } else {
124 $backtopage = DOL_URL_ROOT.'/hrm/skill_card.php?id=' . ($id > 0 ? $id : '__ID__');
125 }
126 }
127 }
128
129 $triggermodname = 'HRM_SKILL_MODIFY'; // Name of trigger action code to execute when we modify record
130
131 // action update on Skilldet must be done before real update action in core/actions_addupdatedelete.inc.php
132 $skilldetArray = GETPOST("descriptionline", "array:alphanohtml");
133 if (!$error) {
134 if (is_array($skilldetArray) && count($skilldetArray) > 0) {
135 if ($action == 'update' && $permissiontoadd) {
136 foreach ($skilldetArray as $key => $SkValueToUpdate) {
137 $skilldetObj = new Skilldet($object->db);
138 $res = $skilldetObj->fetch($key);
139 if ($res > 0) {
140 $skilldetObj->description = $SkValueToUpdate;
141 $resupd = $skilldetObj->update($user);
142 if ($resupd <= 0) {
143 setEventMessage($langs->trans('errorUpdateSkilldet'), 'errors');
144 $error++;
145 }
146 }
147 }
148 }
149 }
150 }
151
152 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
153 $noback = 1;
154 if (in_array($action, array("confirm_delete", "update"))) {
155 $noback = 0;
156 }
157
158 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
159
160 if (!$error) {
161 if (is_array($skilldetArray) && count($skilldetArray) > 0) {
162 if ($action == 'add' && $permissiontoadd) {
163 $arraySkill = $object->fetchLines();
164 '@phan-var-force Skilldet[] $arraySkill';
165 $index = 0;
166 foreach ($arraySkill as $skilldet) {
167 if ($skilldet->rankorder != 0) {
168 if (isset($skilldetArray[$index])) {
169 $SkValueToUpdate = $skilldetArray[$index];
170 $skilldet->description = !empty($SkValueToUpdate) ? $SkValueToUpdate : $skilldet->description;
171 $resupd = $skilldet->update($user);
172 if ($resupd <= 0) {
173 setEventMessage($langs->trans('errorUpdateSkilldet'), 'errors');
174 }
175 }
176 $index++;
177 }
178 }
179 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
180 exit;
181 }
182 }
183 }
184
185
186
187
188 // Actions when linking object each other
189 include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php';
190
191 // Actions when printing a doc from card
192 include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php';
193
194 // Action to move up and down lines of object
195 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
196
197 // Action to build doc
198 include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php';
199
200 if ($action == 'set_thirdparty' && $permissiontoadd) {
201 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
202 }
203 if ($action == 'classin' && $permissiontoadd) {
204 $object->setProject(GETPOSTINT('projectid'));
205 }
206
207 // Actions to send emails
208 $triggersendname = 'HRM_SKILL_SENTBYMAIL';
209 $autocopy = 'MAIN_MAIL_AUTOCOPY_SKILL_TO';
210 $trackid = 'skill' . $object->id;
211 include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php';
212
213 if ($action == 'confirm_clone' && $confirm != 'yes') {
214 $action = '';
215 }
216
217 if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) {
218 $id = $result->id;
219 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
220 exit;
221 }
222}
223
224
225/*
226 * View
227 */
228
229$form = new Form($db);
230$formfile = new FormFile($db);
231$formproject = new FormProjets($db);
232
233$title = $langs->trans("Skill");
234$help_url = '';
235llxHeader('', $title, $help_url);
236
237
238// Part to create
239if ($action == 'create') {
240 print load_fiche_titre($langs->trans("NewSkill"), '', 'object_' . $object->picto);
241
242 print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
243 print '<input type="hidden" name="token" value="' . newToken() . '">';
244 print '<input type="hidden" name="action" value="add">';
245 $backtopage .= (strpos($backtopage, '?') > 0 ? '&' : '?') ."objecttype=job";
246 if ($backtopage) {
247 print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
248 }
249 if ($backtopageforcancel) {
250 print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
251 }
252
253 print dol_get_fiche_head(array(), '');
254
255 print '<table class="border centpercent tableforfieldcreate">' . "\n";
256
257 // Common attributes
258 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
259
260 // Other attributes
261 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
262
263
264 // SKILLDET ADD
265 //@todo je stop ici ... à continuer (affichage des 5 skilled input pour create action
266 //print $object->showInputField($val, $key, $value, '', '['']', '', 0);
267
268 print '</table>' . "\n";
269 print '<hr>';
270
271 print '<table class="border centpercent =">' . "\n";
272 for ($i = 1; $i <= $MaxNumberSkill; $i++) {
273 print '<tr><td class="titlefieldcreate tdtop">'. $langs->trans('Description') . ' ' . $langs->trans('rank') . ' ' . $i . '</td>';
274 print '<td class="valuefieldcreate"><textarea name="descriptionline[]" rows="5" class="flat minwidth100" style="margin-top: 5px; width: 90%"></textarea></td>';
275 }
276 print '</table>';
277
278 print dol_get_fiche_end();
279
280 print '<div class="center">';
281 print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
282 print '&nbsp; ';
283 print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="history.go(-1)"') . '>';
284 print '</div>';
285
286 print '</form>';
287
288 //dol_set_focus('input[name="ref"]');
289}
290
291// Part to edit record
292// and skilldet edition
293if (($id || $ref) && $action == 'edit') {
294 print load_fiche_titre($langs->trans("Skill"), '', 'object_' . $object->picto);
295
296 print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
297 print '<input type="hidden" name="token" value="' . newToken() . '">';
298 print '<input type="hidden" name="action" value="update">';
299 print '<input type="hidden" name="id" value="' . $object->id . '">';
300 if ($backtopage) {
301 print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
302 }
303 if ($backtopageforcancel) {
304 print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
305 }
306
307 print dol_get_fiche_head();
308
309 print '<table class="border centpercent tableforfieldedit">' . "\n";
310
311 // Common attributes
312 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
313
314 // Other attributes
315 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
316
317 print '</table>';
318
319 print '<hr>';
320
321 // SKILLDET
322 $SkilldetRecords = $object->fetchLines();
323 '@phan-var-force Skilldet[] $SkilldetRecords';
324
325 if (is_array($SkilldetRecords) && count($SkilldetRecords) == 0) {
326 $object->createSkills(1);
327 }
328
329 if (is_array($SkilldetRecords) && count($SkilldetRecords) > 0) {
330 print '<table>';
331 foreach ($SkilldetRecords as $sk) {
332 if ($sk->rankorder > $MaxNumberSkill) {
333 continue;
334 }
335
336 print '<table class="border centpercent =">' . "\n";
337 $sk->fields = dol_sort_array($sk->fields, 'position');
338 foreach ($sk->fields as $key => $val) {
339 if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
340 continue;
341 }
342
343 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
344 continue; // We don't want this field
345 }
346
347 print '<tr class="field_' . $key . '"><td';
348 print ' class="titlefieldcreate';
349 if (isset($val['notnull']) && $val['notnull'] > 0) {
350 print ' fieldrequired';
351 }
352 if (preg_match('/^(text|html)/', $val['type'])) {
353 print ' tdtop';
354 }
355 print '">';
356 // if (!empty($val['help'])) {
357 // print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
358 // } else {
359 print $langs->trans($val['label']).'&nbsp;'.$langs->trans('rank').'&nbsp;'.$sk->rankorder;
360 // }
361 print '</td>';
362 print '<td class="valuefieldcreate">';
363 // if (!empty($val['picto'])) {
364 // print img_picto('', $val['picto'], '', 0, 0, 0, '', 'pictofixedwidth');
365 // }
366 // if (in_array($val['type'], array('int', 'integer'))) {
367 // $value = GETPOSTISSET($key) ? GETPOST($key, 'int') : $sk->$key;
368 // } elseif ($val['type'] == 'double') {
369 // $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $sk->$key;
370 // } elseif (preg_match('/^(text|html)/', $val['type'])) {
371 // $tmparray = explode(':', $val['type']);
372 if (!empty($tmparray[1])) {
373 $check = $tmparray[1];
374 } else {
375 $check = 'restricthtml';
376 }
377
378 $skilldetArray = GETPOST("descriptionline", "array");
379 if (empty($skilldetArray)) {
380 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $sk->$key;
381 } else {
382 $value = $skilldetArray[$sk->id];
383 }
384 //
385 // } elseif ($val['type'] == 'price') {
386 // $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($sk->$key);
387 // } else {
388 // $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $sk->$key;
389 // }
390 //var_dump($val.' '.$key.' '.$value);
391 if (!empty($val['noteditable'])) {
392 print $sk->showOutputField($val, $key, $value, '', '', '', 0);
393 } else {
395 print $sk->showInputField($val, $key, $value, "", "line[" . $sk->id . "]", "", "");
396 }
397 print '</td>';
398 print '</tr>';
399 }
400 }
401 print '</table>';
402 }
403
404
405 print dol_get_fiche_end();
406
407 print '<div class="center"><input type="submit" class="button button-save" name="save" value="' . $langs->trans("Save") . '">';
408 print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">';
409 print '</div>';
410
411 print '</form>';
412}
413
414
415// Part to show record
416if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
417 $res = $object->fetch_optionals();
418
419 $head = skillPrepareHead($object);
420 print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto);
421
422 $formconfirm = '';
423
424 // Confirmation to delete
425 if ($action == 'delete') {
426 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteSkill'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
427 }
428 // Confirmation to delete line
429 if ($action == 'deleteline') {
430 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
431 }
432 // Confirmation clone
433 if ($action === 'clone') {
434 $formquestion = array(
435 array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
436 );
437 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->label), 'confirm_clone', $formquestion, 'yes', 1, 280);
438 }
439
440 // Confirmation of action xxxx
441 if ($action == 'xxx') {
442 $formquestion = array();
443 /*
444 $forcecombo=0;
445 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
446 $formquestion = array(
447 // 'text' => $langs->trans("ConfirmClone"),
448 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
449 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
450 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
451 );
452 */
453 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
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') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', '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($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, $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
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class for Skill.
Class for Skilldet.
llxFooter()
Footer empty.
Definition document.php:107
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)
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.