function mycompetences(&$url) { checkPerm('view'); $html = ""; $html .= getTitleArea(Lang::t('_COMPETENCES'), 'competences'); $html .= '<div class="std_block">'; $cmodel = new CompetencesAdm(); $fmodel = new FunctionalrolesAdm(); $id_user = getLogUserId(); $ucomps = $cmodel->getUserCompetences($id_user); $rcomps = $fmodel->getUserRequiredCompetences($id_user); $ucomps_info = $cmodel->getCompetencesInfo(array_keys($ucomps)); $language = getLanguage(); $_typologies = $cmodel->getCompetenceTypologies(); $_types = $cmodel->getCompetenceTypes(); $icon_actv = '<span class="ico-sprite subs_actv"><span>' . Lang::t('_COMPETENCE_OBTAINED', 'competences') . '</span></span>'; $icon_req = '<span class="ico-sprite subs_actv"><span>' . Lang::t('_MANDATORY', 'competences') . '</span></span>'; //******************* require_once _base_ . '/lib/lib.table.php'; $table = new Table(Get::sett('visuItem'), Lang::t('_COMPETENCES'), Lang::t('_COMPETENCES')); $style_h = array('', '', 'image', 'image', 'image', 'image', 'image'); $label_h = array(Lang::t('_NAME', 'competences'), Lang::t('_TYPOLOGY', 'competences'), Lang::t('_TYPE', 'standard'), Lang::t('_SCORE', 'competences'), Lang::t('_DATE_LAST_COMPLETE', 'subscribe'), Lang::t('_COMPETENCES_REQUIRED', 'competences')); $table->addHead($label_h, $style_h); foreach ($ucomps_info as $id_competence => $cinfo) { $line = array(); $line[] = $cinfo->langs[$language]['name']; $line[] = $_typologies[$cinfo->typology]; $line[] = $_types[$cinfo->type]; $line[] = $cinfo->type == 'score' ? '<b>' . $ucomps[$id_competence]->score_got . '</b>' : $icon_actv; $line[] = Format::date($ucomps[$id_competence]->last_assign_date, 'datetime'); $line[] = array_key_exists($id_competence, $rcomps) ? $icon_req : ''; $table->addBody($line); } $html .= $table->getTable(); $html .= '</div>'; $html .= Form::openForm('beck_url', 'index.php'); $html .= Form::openButtonSpace(); $html .= Form::getButton('close', 'close', Lang::t('_CLOSE', 'standard')); $html .= Form::closeButtonSpace(); $html .= Form::closeform(); cout($html, 'content'); }
* - $json = Serci */ echo getTitleArea($title); ?> <div class="std_block"> <?php echo getBackUi('index.php?r=adm/functionalroles/show', Lang::t('_BACK', 'standard')); $html = ""; require_once _base_ . '/lib/lib.table.php'; $table = new Table(); $label_h = array(Lang::t('_NAME', 'competences'), Lang::t('_TYPE', 'standard'), Lang::t('_REQUIRED_SCORE', 'fncroles'), Lang::t('_EXPIRATION_DAYS', 'fncroles'), Lang::t('_COURSE', 'course'), Lang::t('_SCORE', 'fncroles')); $style_h = array('', 'img-cell', 'img-cell', 'img-cell', '', 'img-cell'); $table->addHead($label_h, $style_h); $language = getLanguage(); $cmodel = new CompetencesAdm(); $_types = $cmodel->getCompetenceTypes(); $_typologies = $cmodel->getCompetenceTypologies(); $rs_counter = 1; foreach ($competences_info as $id_competence => $cinfo) { $courses = isset($courses_info[$id_competence]) ? $courses_info[$id_competence] : array(); $cinfo_content_1 = $cinfo->langs[$language]['name']; $cinfo_content_2 = $_types[$cinfo->type]; $cinfo_content_3 = $cinfo->type == 'score' ? $cinfo->role_score : '-'; $cinfo_content_4 = $cinfo->role_expiration > 0 ? $cinfo->role_expiration . ' ' . Lang::t('_DAYS', 'standard') : Lang::t('_NEVER', 'standard'); $num_courses = count($courses); if ($num_courses > 0) { $first = true; foreach ($courses as $course) { $line = array(); if ($first) { $line[] = array('rowspan' => count($courses), 'value' => $cinfo_content_1, 'style' => 'yui-dt-rs-' . ($rs_counter % 2 > 0 ? 'odd' : 'even'));
function getUserCompetences(&$comp_data) { $tb = new Table(0, Lang::t('_USERCOMPETENCES_CAPTION', 'profile'), Lang::t('_USERCOMPETENCES_SUMMARY', 'profile')); $tb->addHead(array(Lang::t('_NAME', 'competences'), Lang::t('_CATEGORY', 'competences'), Lang::t('_TYPOLOGY', 'standard'), Lang::t('_TYPE', 'standard'), Lang::t('_SCORE', 'competences'), Lang::t('_MANDATORY', 'competences'), Lang::t('_GAP', 'fncroles')), array('', '', 'img-cell', 'img-cell', 'img-cell', 'img-cell', 'img-cell')); $icon_flag_ok = '<span class="ico-sprite subs_actv"><span>' . Lang::t('_MEET', 'competences') . '</span></span>'; $icon_flag_no = '<span class="ico-sprite subs_noac"><span>' . Lang::t('_NOT_SATISFIED', 'competences') . '</span></span>'; $icon_active = '<span class="ico-sprite subs_actv"><span>' . Lang::t('_MANDATORY', 'competences') . '</span></span>'; $icon_warn = '<span class="ico-sprite fd_notice"><span>' . Lang::t('_NOT_SATISFIED', 'competences') . '</span></span>'; $cmodel = new CompetencesAdm(); $_types = $cmodel->getCompetenceTypes(); $_typologies = $cmodel->getCompetenceTypologies(); $_categories = $cmodel->getCategoriesLangs(); $lang_code = getLanguage(); if (count($comp_data) > 0) { foreach ($comp_data as $id_competence => $value) { $_category_name = ""; if ($value->id_category <= 0) { $_category_name .= '<i>(' . Lang::t('_NO_CATEGORY', 'competences') . ')</i>'; } else { if (isset($_categories[$value->id_category][$lang_code]['name'])) { $_category_name .= $_categories[$value->id_category][$lang_code]['name']; } } $_score = ''; switch ($value->type) { case 'flag': $_score = $value->score > 0 ? $icon_flag_ok : $icon_flag_no; break; case 'score': $_score = (int) $value->score; break; } $_gap = ""; if ($value->required !== false) { if ($value->type == 'score') { if ($value->gap < 0) { $_gap .= '<b class="red">' . (int) $value->gap . '</b> ' . $icon_warn; } else { $_gap .= '<b class="green">' . (int) $value->gap . '</b> ' . $icon_flag_ok; } } else { if ($value->score > 0) { $_gap = $icon_flag_ok; } else { $_gap = $icon_warn; } } } else { $_gap .= '-'; } $tb->addBody(array($value->name, $_category_name, $_typologies[$value->typology], $_types[$value->type], $_score, $value->required ? $icon_active : '', $_gap)); } } else { $line = array(array('colspan' => 5, 'value' => Lang::t('_NO_CONTENT', 'competences'))); $tb->addBody($line); } return $tb->getTable(); }
public function getcompetencetabledataTask() { //read from input and prepare filter and pagination variables $id_fncrole = Get::req('id_fncrole', DOTY_INT, -1); //TO DO: if $id_fncrole <= 0 ... $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $filter_text = Get::req('filter_text', DOTY_STRING, ''); $searchFilter = array('text' => $filter_text); //get total from database and validate the results count $total = $this->model->getManageCompetencesTotal($id_fncrole, $searchFilter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } //set pagination argument $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir); //read records from database $list = $this->model->getManageCompetencesList($id_fncrole, $pagination, $searchFilter); //prepare the data for sending $output_results = array(); if (is_array($list) && count($list) > 0) { $cmodel = new CompetencesAdm(); $_typologies = $cmodel->getCompetenceTypologies(); $_types = $cmodel->getCompetenceTypes(); foreach ($list as $idst => $record) { //prepare output record $_str = strip_tags($record->description); $_description = strlen($_str) > 100 ? substr($_str, 0, 97) . '...' : $_str; $output_results[] = array('id' => $record->id_competence, 'category' => Layout::highlight($record->category, $filter_text), 'name' => Layout::highlight($record->name, $filter_text), 'description' => Layout::highlight($_description, $filter_text), 'typology' => $_typologies[$record->typology], 'type' => $_types[$record->type], 'score' => $record->type == 'flag' ? '-' : $record->score, 'expiration' => $record->expiration > 0 ? $record->expiration : Lang::t('_NEVER', 'standard'), 'del' => 'ajax.adm_server.php?r=adm/functionalroles/del_competence&id_competence=' . (int) $record->id_competence . '&id_fncrole=' . (int) $id_fncrole); } } $output = array('totalRecords' => $total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $rowsPerPage, 'results' => count($list), 'records' => $output_results); echo $this->json->encode($output); }