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