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