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