skill_tab.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <?php
  2. /* Copyright (C) 2021 grégory Blémand <contact@atm-consulting.fr>
  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. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/hrm/skill_tab.php
  23. * \ingroup hrm
  24. * \brief Page to add/delete/view skill to jobs/users
  25. */
  26. // Load Dolibarr environment
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
  29. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
  30. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
  31. require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
  32. require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php';
  33. require_once DOL_DOCUMENT_ROOT . '/hrm/class/skill.class.php';
  34. require_once DOL_DOCUMENT_ROOT . '/hrm/class/skillrank.class.php';
  35. require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_skill.lib.php';
  36. require_once DOL_DOCUMENT_ROOT .'/hrm/class/evaluation.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_evaluation.lib.php';
  38. // Load translation files required by the page
  39. $langs->loadLangs(array('hrm', 'other'));
  40. // Get Parameters
  41. $action = GETPOST('action', 'aZ09');
  42. $confirm = GETPOST('confirm', 'alpha');
  43. $cancel = GETPOST('cancel', 'aZ09');
  44. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'skillcard'; // To manage different context of search
  45. $backtopage = GETPOST('backtopage', 'alpha');
  46. $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
  47. $id = GETPOST('id', 'int');
  48. $TSkillsToAdd = GETPOST('fk_skill', 'array');
  49. $objecttype = GETPOST('objecttype', 'alpha');
  50. $TNote = GETPOST('TNote', 'array');
  51. $lineid = GETPOST('lineid', 'int');
  52. if (empty($objecttype)) {
  53. $objecttype = 'job';
  54. }
  55. $TAuthorizedObjects = array('job', 'user');
  56. $skill = new SkillRank($db);
  57. // Initialize technical objects
  58. if (in_array($objecttype, $TAuthorizedObjects)) {
  59. if ($objecttype == 'job') {
  60. $object = new Job($db);
  61. } elseif ($objecttype == "user") {
  62. $object = new User($db);
  63. }
  64. } else {
  65. accessforbidden('ErrorBadObjectType');
  66. }
  67. $hookmanager->initHooks(array('skilltab', 'globalcard')); // Note that conf->hooks_modules contains array
  68. // Load object
  69. include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  70. if (method_exists($object, 'loadPersonalConf')) {
  71. $object->loadPersonalConf();
  72. }
  73. // Permissions
  74. $permissiontoread = $user->hasRight('hrm', 'all', 'read');
  75. $permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  76. // Security check (enable the most restrictive one)
  77. if ($user->socid > 0) {
  78. accessforbidden();
  79. }
  80. if (!isModEnabled('hrm')) {
  81. accessforbidden();
  82. }
  83. if (!$permissiontoread) {
  84. accessforbidden();
  85. }
  86. /*
  87. * Actions
  88. */
  89. $parameters = array();
  90. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  91. if ($reshook < 0) {
  92. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  93. }
  94. if (empty($reshook)) {
  95. $error = 0;
  96. $backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php';
  97. if (empty($backtopage) || ($cancel && empty($id))) {
  98. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  99. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  100. $backtopage = $backurlforlist;
  101. } else {
  102. $backtopage = DOL_URL_ROOT.'/hrm/skill_list.php?id=' . ($id > 0 ? $id : '__ID__');
  103. }
  104. }
  105. }
  106. // update national_registration_number
  107. if ($action == 'setnational_registration_number') {
  108. $object->national_registration_number = (string) GETPOST('national_registration_number', 'alphanohtml');
  109. $result = $object->update($user);
  110. if ($result < 0) {
  111. setEventMessages($object->error, $object->errors, 'errors');
  112. }
  113. }
  114. if ($action == 'addSkill') {
  115. $error = 0;
  116. if (empty($TSkillsToAdd)) {
  117. setEventMessage('ErrNoSkillSelected', 'errors');
  118. $error++;
  119. }
  120. if (!$error) {
  121. foreach ($TSkillsToAdd as $k=>$v) {
  122. $skillAdded = new SkillRank($db);
  123. $skillAdded->fk_skill = $v;
  124. $skillAdded->fk_object = $id;
  125. $skillAdded->objecttype = $objecttype;
  126. $ret = $skillAdded->create($user);
  127. if ($ret < 0) {
  128. setEventMessages($skillAdded->error, null, 'errors');
  129. }
  130. //else unset($TSkillsToAdd);
  131. }
  132. if ($ret > 0) {
  133. setEventMessages($langs->trans("SaveAddSkill"), null);
  134. }
  135. }
  136. } elseif ($action == 'saveSkill') {
  137. if (!empty($TNote)) {
  138. foreach ($TNote as $skillId => $rank) {
  139. $TSkills = $skill->fetchAll('ASC', 't.rowid', 0, 0, array('customsql' => 'fk_object=' . ((int) $id) . " AND objecttype='" . $db->escape($objecttype) . "' AND fk_skill = " . ((int) $skillId)));
  140. if (is_array($TSkills) && !empty($TSkills)) {
  141. foreach ($TSkills as $tmpObj) {
  142. $tmpObj->rankorder = $rank;
  143. $tmpObj->update($user);
  144. }
  145. }
  146. }
  147. setEventMessages($langs->trans("SaveLevelSkill"), null);
  148. header("Location: " . DOL_URL_ROOT.'/hrm/skill_tab.php?id=' . $id. '&objecttype=job');
  149. exit;
  150. }
  151. } elseif ($action == 'confirm_deleteskill' && $confirm == 'yes') {
  152. $skillToDelete = new SkillRank($db);
  153. $ret = $skillToDelete->fetch($lineid);
  154. setEventMessages($langs->trans("DeleteSkill"), null);
  155. if ($ret > 0) {
  156. $skillToDelete->delete($user);
  157. }
  158. }
  159. }
  160. /*
  161. * View
  162. */
  163. $form = new Form($db);
  164. $formfile = new FormFile($db);
  165. $formproject = new FormProjets($db);
  166. $title = $langs->trans("RequiredSkills");
  167. $help_url = '';
  168. llxHeader('', $title, $help_url);
  169. // Part to show record
  170. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
  171. $res = $object->fetch_optionals();
  172. // view configuration
  173. if ($objecttype == 'job') {
  174. require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php';
  175. $head = jobPrepareHead($object);
  176. $listLink = dol_buildpath('/hrm/job_list.php', 1);
  177. } elseif ($objecttype == "user") {
  178. require_once DOL_DOCUMENT_ROOT . "/core/lib/usergroups.lib.php";
  179. $object->getRights();
  180. $head = user_prepare_head($object);
  181. $listLink = dol_buildpath('/user/list.php', 1);
  182. }
  183. print dol_get_fiche_head($head, 'skill_tab', $langs->trans("Workstation"), -1, $object->picto);
  184. $formconfirm = '';
  185. // Confirmation to delete
  186. /*if ($action == 'delete') {
  187. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteSkill'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
  188. }*/
  189. // Confirmation to delete line
  190. if ($action == 'ask_deleteskill') {
  191. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&objecttype=' . $objecttype . '&lineid=' . $lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteskill', '', 0, 1);
  192. }
  193. // Clone confirmation
  194. /*if ($action == 'clone') {
  195. // Create an array for form
  196. $formquestion = array();
  197. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
  198. }*/
  199. // Call Hook formConfirm
  200. $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
  201. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  202. if (empty($reshook)) {
  203. $formconfirm .= $hookmanager->resPrint;
  204. } elseif ($reshook > 0) {
  205. $formconfirm = $hookmanager->resPrint;
  206. }
  207. // Print form confirm
  208. print $formconfirm;
  209. // Object card
  210. // ------------------------------------------------------------
  211. if ($objecttype == 'job') {
  212. $linkback = '<a href="' . dol_buildpath('/hrm/job_list.php', 1) . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
  213. $morehtmlref = '<div class="refid">';
  214. $morehtmlref.= $object->label;
  215. $morehtmlref .= '</div>';
  216. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
  217. } else {
  218. $linkback = '<a href="' . $listLink . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
  219. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid" rel="noopener">';
  220. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  221. $morehtmlref .= '</a>';
  222. $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
  223. $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
  224. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref, '&objecttype='.$objecttype);
  225. }
  226. // Get all available skills
  227. $static_skill = new Skill($db);
  228. $TAllSkills = $static_skill->fetchAll();
  229. // Array format for multiselectarray function
  230. $TAllSkillsFormatted=array();
  231. if (!empty($TAllSkills)) {
  232. foreach ($TAllSkills as $k=>$v) {
  233. $TAllSkillsFormatted[$k] = $v->label;
  234. }
  235. }
  236. // table of skillRank linked to current object
  237. //$TSkillsJob = $skill->fetchAll('ASC', 't.rowid', 0, 0);
  238. $sql_skill = "SELECT sr.fk_object, sr.rowid, s.label,s.skill_type, sr.rankorder, sr.fk_skill";
  239. $sql_skill .=" FROM ".MAIN_DB_PREFIX."hrm_skillrank AS sr";
  240. $sql_skill .=" JOIN ".MAIN_DB_PREFIX."hrm_skill AS s ON sr.fk_skill = s.rowid";
  241. $sql_skill .= " AND sr.fk_object = ".((int) $id);
  242. $result = $db->query($sql_skill);
  243. $numSkills = $db->num_rows($result);
  244. for ($i=0; $i < $numSkills; $i++) {
  245. $objSkillRank = $db->fetch_object($result);
  246. $TSkillsJob[] = $objSkillRank;
  247. }
  248. $TAlreadyUsedSkill = array();
  249. if (is_array($TSkillsJob) && !empty($TSkillsJob)) {
  250. foreach ($TSkillsJob as $skillElement) {
  251. $TAlreadyUsedSkill[$skillElement->fk_skill] = $skillElement->fk_skill;
  252. }
  253. }
  254. print '<div class="fichecenter">';
  255. print '<div class="fichehalfleft">';
  256. print '<div class="underbanner clearboth"></div>';
  257. print '<table class="border centpercent tableforfield">'."\n";
  258. if ($objecttype == 'job') {
  259. // Common attributes
  260. //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
  261. //unset($object->fields['fk_project']); // Hide field already shown in banner
  262. //unset($object->fields['fk_soc']); // Hide field already shown in banner
  263. $object->fields['label']['visible']=0; // Already in banner
  264. include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
  265. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  266. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  267. } else {
  268. // Login
  269. print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
  270. if (!empty($object->ldap_sid) && $object->statut == 0) {
  271. print '<td class="error">';
  272. print $langs->trans("LoginAccountDisableInDolibarr");
  273. print '</td>';
  274. } else {
  275. print '<td>';
  276. $addadmin = '';
  277. if (property_exists($object, 'admin')) {
  278. if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
  279. $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
  280. } elseif (!empty($object->admin)) {
  281. $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
  282. }
  283. }
  284. print showValueWithClipboardCPButton(!empty($object->login) ? $object->login : '').$addadmin;
  285. print '</td>';
  286. }
  287. print '</tr>'."\n";
  288. $object->fields['label']['visible']=0; // Already in banner
  289. $object->fields['firstname']['visible']=0; // Already in banner
  290. $object->fields['lastname']['visible']=0; // Already in banner
  291. //include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
  292. // Ref employee
  293. print '<tr><td class="titlefield">'.$langs->trans("RefEmployee").'</td>';
  294. print '<td class="error">';
  295. print showValueWithClipboardCPButton(!empty($object->ref_employee) ? $object->ref_employee : '');
  296. print '</td>';
  297. print '</tr>'."\n";
  298. // National Registration Number
  299. print '<tr><td class="titlefield">'.$langs->trans("NationalRegistrationNumber").' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&objecttype=user&action=editnational_registration_number&token='.newToken().'">'.img_picto($langs->trans("Edit"), 'edit').'</a></td>';
  300. print '<td>';
  301. if ($action == 'editnational_registration_number') {
  302. $ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&objecttype=user">';
  303. $ret .= '<input type="hidden" name="action" value="setnational_registration_number">';
  304. $ret .= '<input type="hidden" name="token" value="'.newToken().'">';
  305. $ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
  306. $ret .= '<input type="text" name="national_registration_number" value="'.$object->national_registration_number.'">';
  307. $ret .= '<input type="submit" class="button smallpaddingimp" name="modify" value="'.$langs->trans("Modify").'"> ';
  308. $ret .= '<input type="submit" class="button smallpaddingimp button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
  309. $ret .= '</form>';
  310. print $ret;
  311. } else {
  312. print showValueWithClipboardCPButton(!empty($object->national_registration_number) ? $object->national_registration_number : '');
  313. }
  314. print '</td>';
  315. print '</tr>'."\n";
  316. }
  317. print '</table>';
  318. print '</div>';
  319. print '</div>';
  320. print '<div class="clearboth"></div><br>';
  321. if ($objecttype != 'user' && $permissiontoadd) {
  322. // form to add new skills
  323. print '<br>';
  324. print '<form name="addSkill" method="post" action="' . $_SERVER['PHP_SELF'] . '">';
  325. print '<input type="hidden" name="objecttype" value="' . $objecttype . '">';
  326. print '<input type="hidden" name="id" value="' . $id . '">';
  327. print '<input type="hidden" name="action" value="addSkill">';
  328. print '<input type="hidden" name="token" value="'.newToken().'">';
  329. print '<div class="div-table-responsive-no-min">';
  330. print '<table id="tablelines" class="noborder noshadow" width="100%">';
  331. print '<tr><td style="width:90%">' . $langs->trans('AddSkill') . '</td><td style="width:10%"></td></tr>';
  332. print '<tr>';
  333. print '<td>';
  334. print img_picto('', 'shapes', 'class="pictofixedwidth"');
  335. print $form->multiselectarray('fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0, 'widthcentpercentminusx') . '</td>';
  336. print '<td><input class="button reposition" type="submit" value="' . $langs->trans('Add') . '"></td>';
  337. print '</tr>';
  338. print '</table>';
  339. print '</div>';
  340. print '</form>';
  341. }
  342. print '<br>';
  343. print '<div class="clearboth"></div>';
  344. if ($objecttype != 'user' && $permissiontoadd) {
  345. print '<form name="saveSkill" method="post" action="' . $_SERVER['PHP_SELF'] . '">';
  346. print '<input type="hidden" name="objecttype" value="' . $objecttype . '">';
  347. print '<input type="hidden" name="id" value="' . $id . '">';
  348. print '<input type="hidden" name="token" value="'.newToken().'">';
  349. print '<input type="hidden" name="action" value="saveSkill">';
  350. }
  351. if ($objecttype != 'user') {
  352. print '<div class="div-table-responsive-no-min">';
  353. print '<table id="tablelines" class="noborder centpercent" width="100%">';
  354. print '<tr class="liste_titre">';
  355. print '<th>'.$langs->trans('SkillType').'</th>';
  356. print '<th>'.$langs->trans('Label').'</th>';
  357. print '<th>'.$langs->trans('Description').'</th>';
  358. print '<th>'.$langs->trans($objecttype === 'job' ? 'RequiredRank' : 'EmployeeRank').'</th>';
  359. if ($objecttype === 'job') {
  360. print '<th class="linecoledit"></th>';
  361. print '<th class="linecoldelete"></th>';
  362. }
  363. print '</tr>';
  364. if (!is_array($TSkillsJob) || empty($TSkillsJob)) {
  365. print '<tr><td><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
  366. } else {
  367. $sk = new Skill($db);
  368. foreach ($TSkillsJob as $skillElement) {
  369. $sk->fetch((int) $skillElement->fk_skill);
  370. print '<tr>';
  371. print '<td>';
  372. print Skill::typeCodeToLabel($sk->skill_type);
  373. print '</td><td class="linecolfk_skill">';
  374. print $sk->getNomUrl(1);
  375. print '</td>';
  376. print '<td>';
  377. print $sk->description;
  378. print '</td><td class="linecolrank">';
  379. print displayRankInfos($skillElement->rankorder, $skillElement->fk_skill, 'TNote', $objecttype == 'job' && $permissiontoadd ? 'edit' : 'view');
  380. print '</td>';
  381. if ($objecttype != 'user' && $permissiontoadd) {
  382. print '<td class="linecoledit"></td>';
  383. print '<td class="linecoldelete">';
  384. print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $skillElement->fk_object . '&amp;objecttype=' . $objecttype . '&amp;action=ask_deleteskill&amp;lineid=' . $skillElement->id . '">';
  385. print img_delete();
  386. print '</a>';
  387. }
  388. print '</td>';
  389. print '</tr>';
  390. }
  391. }
  392. print '</table>';
  393. if ($objecttype != 'user' && $permissiontoadd) {
  394. print '<td><input class="button pull-right" type="submit" value="' . $langs->trans('SaveRank') . '"></td>';
  395. }
  396. print '</div>';
  397. if ($objecttype != 'user' && $permissiontoadd) {
  398. print '</form>';
  399. }
  400. }
  401. // liste des evaluation liées
  402. if ($objecttype == 'user' && $permissiontoadd) {
  403. $evaltmp = new Evaluation($db);
  404. $job = new Job($db);
  405. $sql = "select e.rowid,e.ref,e.fk_user,e.fk_job,e.date_eval,ed.rankorder,ed.required_rank,ed.fk_skill,s.label";
  406. $sql .= " FROM ".MAIN_DB_PREFIX."hrm_evaluation as e";
  407. $sql .= ", ".MAIN_DB_PREFIX."hrm_evaluationdet as ed";
  408. $sql .= ", ".MAIN_DB_PREFIX."hrm_skill as s";
  409. $sql .= " WHERE e.rowid = ed.fk_evaluation";
  410. $sql .= " AND s.rowid = ed.fk_skill";
  411. $sql .= " AND e.fk_user = ".((int) $id);
  412. $sql .= " AND e.status > 0";
  413. $resql = $db->query($sql);
  414. $num = $db->num_rows($resql);
  415. print_barre_liste($langs->trans("Evaluations"), $page, $_SERVER["PHP_SELF"], '', '', '', '', $num, $num, $evaltmp->picto, 0);
  416. print '<div class="div-table-responsive-no-min">';
  417. print '<table id="tablelines" class="noborder centpercent" width="100%">';
  418. print '<tr class="liste_titre">';
  419. print '<th>'.$langs->trans('Label').'</th>';
  420. print '<th>'.$langs->trans('Description').'</th>';
  421. print '<th>'.$langs->trans('DateEval').'</th>';
  422. print '<th>'.$langs->trans('Status').'</th>';
  423. print '<th>'.$langs->trans("Result").' ' .$form->textwithpicto('', GetLegendSkills(), 1) .'</th>';
  424. print '</tr>';
  425. if (!$resql) {
  426. print '<tr><td><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
  427. } else {
  428. $i = 0;
  429. $sameRef = array();
  430. $objects = array();
  431. while ($i < $num) {
  432. $obj = $db->fetch_object($resql);
  433. $obj->result = getRankOrderResults($obj);
  434. $objects[$i] = $obj;
  435. $i++;
  436. }
  437. //grouped skills by evaluation
  438. $resultArray = getGroupedEval($objects);
  439. foreach ($resultArray as $object) {
  440. if (is_array($object)) {
  441. $evaltmp->fetch($object[0]->rowid);
  442. $evaltmp->id = $object[0]->rowid;
  443. $evaltmp->ref = $object[0]->ref;
  444. $job->fetch($object[0]->fk_job);
  445. } else {
  446. $evaltmp->ref = $object->ref;
  447. $evaltmp->fetch($object->rowid);
  448. $evaltmp->id = $object->rowid;
  449. $job->fetch($object->fk_job);
  450. }
  451. print '<tr>';
  452. print '<td>';
  453. print $evaltmp->getNomUrl(1);
  454. print '</td><td class="linecolfk_skill">';
  455. print $job->getNomUrl(1);
  456. print '</td>';
  457. print '<td>';
  458. print dol_print_date((!is_array($object) ? $object->date_eval : $object[0]->date_eval), 'day', 'tzserver');
  459. print '</td><td>';
  460. print $evaltmp->getLibStatut(2);
  461. print '</td>';
  462. print '<td class="linecolrank tdoverflowmax300">';
  463. if (!is_array($object)) {
  464. print $object->result;
  465. } else {
  466. foreach ($object as $skill) {
  467. print $skill->result;
  468. }
  469. }
  470. print '</td>';
  471. print '</tr>';
  472. }
  473. }
  474. print '</table>';
  475. }
  476. print dol_get_fiche_end();
  477. llxFooter();
  478. }