skill_tab.php 21 KB

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