dolibarr 21.0.0-beta
skill_card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4 * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
5 * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
6 * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
7 * Copyright (C) 2023-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
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', 'aZ09');
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 if (!$error) {
142 if (is_array($skilldetArray) && count($skilldetArray) > 0) {
143 if ($action == 'update' && $permissiontoadd) {
144 foreach ($skilldetArray as $key => $SkValueToUpdate) {
145 $skilldetObj = new Skilldet($object->db);
146 $res = $skilldetObj->fetch($key);
147 if ($res > 0) {
148 $skilldetObj->description = $SkValueToUpdate;
149 $resupd = $skilldetObj->update($user);
150 if ($resupd <= 0) {
151 setEventMessage($langs->trans('errorUpdateSkilldet'), 'errors');
152 $error++;
153 }
154 }
155 }
156 }
157 }
158 }
159
160 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
161 $noback = 1;
162 if (in_array($action, array("confirm_delete", "update"))) {
163 $noback = 0;
164 }
165
166 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
167
168 if (!$error) {
169 if (is_array($skilldetArray) && count($skilldetArray) > 0) {
170 if ($action == 'add' && $permissiontoadd) {
171 $arraySkill = $object->fetchLines();
172 '@phan-var-force Skilldet[] $arraySkill';
173 $index = 0;
174 foreach ($arraySkill as $skilldet) {
175 if ($skilldet->rankorder != 0) {
176 if (isset($skilldetArray[$index])) {
177 $SkValueToUpdate = $skilldetArray[$index];
178 $skilldet->description = !empty($SkValueToUpdate) ? $SkValueToUpdate : $skilldet->description;
179 $resupd = $skilldet->update($user);
180 if ($resupd <= 0) {
181 setEventMessage($langs->trans('errorUpdateSkilldet'), 'errors');
182 }
183 }
184 $index++;
185 }
186 }
187 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
188 exit;
189 }
190 }
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') {
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
386 $skilldetArray = GETPOST("descriptionline", "array");
387 if (empty($skilldetArray)) {
388 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $sk->$key;
389 } else {
390 $value = $skilldetArray[$sk->id];
391 }
392 //
393 // } elseif ($val['type'] == 'price') {
394 // $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($sk->$key);
395 // } else {
396 // $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $sk->$key;
397 // }
398 //var_dump($val.' '.$key.' '.$value);
399 if (!empty($val['noteditable'])) {
400 print $sk->showOutputField($val, $key, $value, '', '', '', 0);
401 } else {
403 print $sk->showInputField($val, $key, $value, "", "line[" . $sk->id . "]", "", "");
404 }
405 print '</td>';
406 print '</tr>';
407 }
408 }
409 print '</table>';
410 }
411
412
413 print dol_get_fiche_end();
414
415 print '<div class="center"><input type="submit" class="button button-save" name="save" value="' . $langs->trans("Save") . '">';
416 print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">';
417 print '</div>';
418
419 print '</form>';
420}
421
422
423// Part to show record
424if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
425 $res = $object->fetch_optionals();
426
427 $head = skillPrepareHead($object);
428 print dol_get_fiche_head($head, 'card', $langs->trans("Workstation"), -1, $object->picto);
429
430 $formconfirm = '';
431
432 // Confirmation to delete
433 if ($action == 'delete') {
434 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteSkill'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
435 }
436 // Confirmation to delete line
437 if ($action == 'deleteline') {
438 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
439 }
440 // Confirmation clone
441 if ($action === 'clone') {
442 $formquestion = array(
443 array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
444 );
445 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->label), 'confirm_clone', $formquestion, 'yes', 1, 280);
446 }
447
448 // Confirmation of action xxxx
449 if ($action == 'xxx') {
450 $formquestion = array();
451 /*
452 $forcecombo=0;
453 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
454 $formquestion = array(
455 // 'text' => $langs->trans("ConfirmClone"),
456 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
457 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
458 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
459 );
460 */
461 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
462 }
463
464 // Call Hook formConfirm
465 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
466 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
467 if (empty($reshook)) {
468 $formconfirm .= $hookmanager->resPrint;
469 } elseif ($reshook > 0) {
470 $formconfirm = $hookmanager->resPrint;
471 }
472
473 // Print form confirm
474 print $formconfirm;
475
476
477 // Object card
478 // ------------------------------------------------------------
479 $linkback = '<a href="' . DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
480
481
482 $morehtmlref = '<div class="refid">';
483 $morehtmlref .= $object->label;
484 $morehtmlref .= '</div>';
485 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
486
487
488 print '<div class="fichecenter">';
489 print '<div class="fichehalfleft">';
490 print '<div class="underbanner clearboth"></div>';
491 print '<table class="border centpercent tableforfield">' . "\n";
492
493 $object->fields['label']['visible'] = 0; // Already in banner
494 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
495
496 // Other attributes. Fields from hook formObjectOptions and Extrafields.
497 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
498
499
500 print '</table>';
501 print '</div>';
502 print '</div>';
503
504 print '<div class="clearboth"></div>';
505
506 print dol_get_fiche_end();
507
508
509 //dol_include_once('/hrm/tpl/hrm_skillde.fiche.tpl.php');
510
511 // Buttons for actions
512
513 if ($action != 'presend' && $action != 'editline') {
514 print '<div class="tabsAction">' . "\n";
515 $parameters = array();
516 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
517 if ($reshook < 0) {
518 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
519 }
520
521 if (empty($reshook)) {
522 // Back to draft
523 if ($object->status == $object::STATUS_VALIDATED) {
524 print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=confirm_setdraft&confirm=yes&token=' . newToken(), '', $permissiontoadd);
525 }
526
527 print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
528
529 // Clone
530 if ($permissiontoadd) {
531 print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.$object->id, '');
532 }
533 // Delete (need delete permission, or if draft, just need create/modify permission)
534 print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete);
535 }
536 print '</div>' . "\n";
537 }
538}
539
540
541//*---------------------------------------------------------------------------
542
543if ($action != "create" && $action != "edit") {
544 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
545 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
546 require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
547
548 // load hrm libraries
549 require_once __DIR__ . '/class/skilldet.class.php';
550
551 // for other modules
552 //dol_include_once('/othermodule/class/otherobject.class.php');
553
554 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
555 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
556 $show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
557 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
558 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
559 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
560 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'skilldetlist'; // To manage different context of search
561 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
562 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
563
564 $id = GETPOSTINT('id');
565
566 // Load variable for pagination
567 $limit = 0;
568 $sortfield = GETPOST('sortfield', 'aZ09comma');
569 $sortorder = GETPOST('sortorder', 'aZ09comma');
570 $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
571 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
572 // If $page is not defined, or '' or -1 or if we click on clear filters
573 $page = 0;
574 }
575 $offset = $limit * $page;
576 $pageprev = $page - 1;
577 $pagenext = $page + 1;
578
579 // Initialize a technical objects
580 $objectline = new Skilldet($db);
581 // $diroutputmassaction = $conf->hrm->dir_output . '/temp/massgeneration/' . $user->id;
582 // $hookmanager->initHooks(array('skilldetlist')); // Note that conf->hooks_modules contains array
583
584 // Default sort order (if not yet defined by previous GETPOST)
585 if (!$sortfield) {
586 reset($objectline->fields); // Reset is required to avoid key() to return null.
587 $sortfield = "t." . key($objectline->fields); // Set here default search field. By default 1st field in definition.
588 }
589 if (!$sortorder) {
590 $sortorder = "ASC";
591 }
592
593 // Initialize array of search criteria
594 $search_all = GETPOST('search_all', 'alphanohtml');
595 $search = array();
596 foreach ($objectline->fields as $key => $val) {
597 if (GETPOST('search_' . $key, 'alpha') !== '') {
598 $search[$key] = GETPOST('search_' . $key, 'alpha');
599 }
600 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
601 $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_' . $key . '_dtstartmonth'), GETPOSTINT('search_' . $key . '_dtstartday'), GETPOSTINT('search_' . $key . '_dtstartyear'));
602 $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_' . $key . '_dtendmonth'), GETPOSTINT('search_' . $key . '_dtendday'), GETPOSTINT('search_' . $key . '_dtendyear'));
603 }
604 }
605
606 // List of fields to search into when doing a "search in all"
607 $fieldstosearchall = array();
608 foreach ($objectline->fields as $key => $val) {
609 if (!empty($val['searchall'])) {
610 $fieldstosearchall['t.' . $key] = $val['label'];
611 }
612 }
613
614 // Definition of array of fields for columns
615 $arrayfields = array();
616 foreach ($objectline->fields as $key => $val) {
617 // If $val['visible']==0, then we never show the field
618 if (!empty($val['visible'])) {
619 $visible = (int) dol_eval((string) $val['visible'], 1, 1, '1');
620 $arrayfields['t.' . $key] = array(
621 'label' => $val['label'],
622 'checked' => (($visible < 0) ? 0 : 1),
623 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
624 'position' => $val['position'],
625 'help' => isset($val['help']) ? $val['help'] : ''
626 );
627 }
628 }
629
630 $objectline->fields = dol_sort_array($objectline->fields, 'position');
631 $arrayfields = dol_sort_array($arrayfields, 'position');
632
633
634 // View
635
636 $form = new Form($db);
637
638 $now = dol_now();
639
640 $help_url = '';
641 $title = $langs->transnoentitiesnoconv("Skilldets");
642 $morejs = array();
643 $morecss = array();
644 $nbtotalofrecords = '';
645
646 // Build and execute select
647 // --------------------------------------------------------------------
648 $sql = 'SELECT ';
649 $sql .= $objectline->getFieldList('t');
650 $sql .= " FROM " . MAIN_DB_PREFIX . $objectline->table_element . " as t";
651 if ($objectline->ismultientitymanaged == 1) {
652 $sql .= " WHERE t.entity IN (" . getEntity($objectline->element) . ")";
653 } else {
654 $sql .= " WHERE 1 = 1 ";
655 }
656 $sql .= " AND fk_skill = ".((int) $id);
657 $sql .= " AND rankorder <> 0";
658
659 $resql = $db->query($sql);
660 $nbtotalofrecords = $db->num_rows($resql);
661 $num = $db->num_rows($resql);
662
663 print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
664 if ($optioncss != '') {
665 print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
666 }
667 print '<input type="hidden" name="token" value="' . newToken() . '">';
668 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
669 print '<input type="hidden" name="action" value="list">';
670 print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
671 print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
672 print '<input type="hidden" name="page" value="' . $page . '">';
673 print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
674 if (!empty($id)) {
675 print '<input type="hidden" name="id" value="' . $id . '">';
676 }
677
678 $param_fk = "&fk_skill=" . $id . "&fk_user_creat=" . (!empty($user->rowid) ? $user->rowid : 0);
679 $backtopage = dol_buildpath('/hrm/skill_card.php', 1) . '?id=' . $id;
680 $param = "";
681 $massactionbutton = "";
682 //$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);
683
684 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, '', '', 0, 0, 0, 1);
685
686 // Add code for pre mass action (confirmation or email presend form)
687 $topicmail = "SendSkilldetRef";
688 $modelmail = "skilldet";
689 $objecttmp = new Skilldet($db);
690 $trackid = 'xxxx' . $object->id;
691 //include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
692
693 if ($search_all) {
694 foreach ($fieldstosearchall as $key => $val) {
695 $fieldstosearchall[$key] = $langs->trans($val);
696 }
697 print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . implode(', ', $fieldstosearchall) . '</div>';
698 }
699
700 $moreforfilter = '';
701 /*$moreforfilter.='<div class="divsearchfield">';
702 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
703 $moreforfilter.= '</div>';*/
704
705 $parameters = array();
706 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
707 if (empty($reshook)) {
708 $moreforfilter .= $hookmanager->resPrint;
709 } else {
710 $moreforfilter = $hookmanager->resPrint;
711 }
712
713 if (!empty($moreforfilter)) {
714 print '<div class="liste_titre liste_titre_bydiv centpercent">';
715 print $moreforfilter;
716 print '</div>';
717 }
718
719 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
720 // $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
721 // $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
722
723 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
724 print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
725
726
727 // Fields title label
728 // --------------------------------------------------------------------
729 print '<tr class="liste_titre">';
730 foreach ($objectline->fields as $key => $val) {
731 // $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
732 // if ($key == 'status') {
733 // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
734 // } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
735 // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
736 // } elseif (in_array($val['type'], array('timestamp'))) {
737 // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
738 // } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
739 // $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
740 // }
741 if (!empty($arrayfields['t.' . $key]['checked'])) {
742 print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, (!empty($cssforfield) ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, (!empty($cssforfield) ? $cssforfield . ' ' : '')) . "\n";
743 }
744 }
745 //print '<td></td>';
746 print '<td></td>';
747 print '</tr>' . "\n";
748
749
750 // Display all ranks of skill
751 // --------------------------------------------------------------------
752
753 $i = 0;
754 $totalarray = array();
755 $totalarray['nbfield'] = 0;
756 while ($i < ($limit ? min($num, $limit) : $num)) {
757 $obj = $db->fetch_object($resql);
758 if (empty($obj)) {
759 break; // Should not happen
760 }
761
762 if ($obj->rankorder > $MaxNumberSkill) {
763 continue;
764 }
765
766 // Store properties in $objectline
767 $objectline->setVarsFromFetchObj($obj);
768
769 // Show here line of result
770 print '<tr class="oddeven">';
771 foreach ($objectline->fields as $key => $val) {
772 // $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
773 // if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
774 // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
775 // } elseif ($key == 'status') {
776 // $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
777 // }
778 //
779 // if (in_array($val['type'], array('timestamp'))) {
780 // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
781 // } elseif ($key == 'ref') {
782 // $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
783 // }
784 //
785 // if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
786 // $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
787 // }
788 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
789
790 if (!empty($arrayfields['t.' . $key]['checked'])) {
791 print '<td' . (empty($cssforfield) ? '' : ' class="' . $cssforfield . '"') . '>';
792 if ($key == 'status') {
793 print $objectline->getLibStatut(5);
794 } elseif ($key == 'rowid') {
795 print $objectline->showOutputField($val, $key, $objectline->id, '');
796 // ajout pencil
797 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>';
798 } else {
799 print $objectline->showOutputField($val, $key, $objectline->$key, '');
800 }
801 print '</td>';
802
803
804 if (!$i) {
805 $totalarray['nbfield']++;
806 }
807 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
808 if (!$i) {
809 $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
810 }
811 if (!isset($totalarray['val'])) {
812 $totalarray['val'] = array();
813 }
814 if (!isset($totalarray['val']['t.' . $key])) {
815 $totalarray['val']['t.' . $key] = 0;
816 }
817 $totalarray['val']['t.' . $key] += $objectline->$key;
818 }
819 }
820 }
821
822
823 // LINE EDITION | SUPPRESSION
824
825 print '<td>';
826 print '</td>';
827
828 // print '<td>';
829 // add pencil
830 //@todo change to proper call dol_
831 //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>';
832 // add trash
833 //@todo change to proper call dol_
834 //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>';
835 // print '</td>';
836
837
838 // Fields from hook
839 $parameters = array('arrayfields' => $arrayfields, 'object' => $objectline, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
840 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
841 print $hookmanager->resPrint;
842 /*// Action column
843 print '<td class="nowrap center">';
844
845 print '</td>';*/
846 if (!$i) {
847 $totalarray['nbfield']++;
848 }
849
850 print '</tr>' . "\n";
851
852 $i++;
853 }
854
855
856 // If no record found
857
858 if ($num == 0) {
859 $colspan = 2;
860 foreach ($arrayfields as $key => $val) {
861 if (!empty($val['checked'])) {
862 $colspan++;
863 }
864 }
865 print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
866 }
867
868 if (!empty($resql)) {
869 $db->free($resql);
870 }
871
872 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
873 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook
874 print $hookmanager->resPrint;
875
876 print '</table>' . "\n";
877 print '</div>' . "\n";
878
879 print '</form>' . "\n";
880
881 // if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
882 // $hidegeneratedfilelistifempty = 1;
883 // if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
884 // $hidegeneratedfilelistifempty = 0;
885 // }
886 //
887 // require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
888 // $formfile = new FormFile($db);
889 //
890 // // Show list of available documents
891 // $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
892 // $urlsource .= str_replace('&amp;', '&', $param);
893 //
894 // $filedir = $diroutputmassaction;
895 // $genallowed = $permissiontoread;
896 // $delallowed = $permissiontoadd;
897 //
898 // print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
899 // }
900
901 print '<div class="fichecenter"><div class="fichehalfleft">';
902
903 // Show links to link elements
904 $tmparray = $form->showLinkToObjectBlock($object, array(), array('skill'), 1);
905 $linktoelem = $tmparray['linktoelem'];
906 $htmltoenteralink = $tmparray['htmltoenteralink'];
907 print $htmltoenteralink;
908
909 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
910
911 print '</div><div class="fichehalfright">';
912
913 $MAXEVENT = 10;
914
915 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/hrm/skill_agenda.php?id='.$object->id);
916
917 // List of actions on element
918 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
919 $formactions = new FormActions($db);
920 $somethingshown = $formactions->showactions($object, $object->element . '@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
921
922 print '</div></div>';
923}
924
925// End of page
926llxFooter();
927$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
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:71
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)
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.