public function certificate()
 {
     if (!$this->permissions['mod']) {
         $this->render('invalid', array('message' => $this->_getErrorMessage('no permission'), 'back_url' => 'index.php?r=' . $this->base_link_course . '/show'));
         return;
     }
     if (isset($_POST['undo'])) {
         Util::jump_to('index.php?r=' . $this->base_link_course . '/show');
     }
     require_once _lms_ . '/lib/lib.certificate.php';
     $cert = new Certificate();
     $id_course = Get::req('id_course', DOTY_INT, 0);
     if (isset($_POST['assign'])) {
         $point_required = Get::req('point_required', DOTY_INT, 0);
         // , $list_of_assign_obj, $list_of_who
         if (!$cert->updateCertificateCourseAssign($id_course, $_POST['certificate_assign'], $_POST['certificate_ex_assign'], $point_required)) {
             Util::jump_to('index.php?r=' . $this->base_link_course . '/show&err=_up_cert_err');
         }
         Util::jump_to('index.php?r=' . $this->base_link_course . '/show&res=_up_cert_ok');
     } else {
         require_once _base_ . '/lib/lib.table.php';
         $all_languages = Docebo::langManager()->getAllLanguages(true);
         $languages = array();
         foreach ($all_languages as $k => $v) {
             $languages[$v['code']] = $v['description'];
         }
         $query = "SELECT code, name, course_type" . " FROM %lms_course WHERE idCourse = '" . $id_course . "'";
         $course = sql_fetch_array(sql_query($query));
         $tb = new Table(false, Lang::t('_TITLE_CERTIFICATE_TO_COURSE', 'course'), Lang::t('_TITLE_CERTIFICATE_TO_COURSE', 'course'));
         $certificate_list = $cert->getCertificateList();
         $course_cert = $cert->getCourseCertificate($id_course);
         $course_ex_cert = $cert->getCourseExCertificate($id_course);
         $released = $cert->numOfcertificateReleasedForCourse($id_course);
         $point_required = $cert->getPointRequiredForCourse($id_course);
         $possible_status = array(AVS_NOT_ASSIGNED => Lang::t('_NOT_ASSIGNED', 'course'), AVS_ASSIGN_FOR_ALL_STATUS => Lang::t('_ASSIGN_FOR_ALL_STATUS', 'course'), AVS_ASSIGN_FOR_STATUS_INCOURSE => Lang::t('_ASSIGN_FOR_STATUS_INCOURSE', 'course'), AVS_ASSIGN_FOR_STATUS_COMPLETED => Lang::t('_ASSIGN_FOR_STATUS_COMPLETED', 'course'));
         $type_h = array('nowrap', 'nowrap', '', '', 'image');
         $cont_h = array(Lang::t('_TITLE', 'course'), Lang::t('_CERTIFICATE_LANGUAGE', 'course'), Lang::t('_CERTIFICATE_ASSIGN_STATUS', 'course'), Lang::t('_CERTIFICATE_EX_ASSIGN_STATUS', 'course'), Lang::t('_CERTIFICATE_RELEASED', 'course'));
         $tb->setColsStyle($type_h);
         $tb->addHead($cont_h);
         $view_cert = false;
         if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
             if (checkPerm('view', true, 'certificate', 'lms') || checkPerm('view', true, 'pcertificate', 'lms')) {
                 $view_cert = true;
             }
         } else {
             $view_cert = true;
         }
         while (list($id_cert, $cert) = each($certificate_list)) {
             $cont = array();
             $cont[] = '<label for="certificate_assign_' . $id_cert . '">' . $cert[CERT_NAME] . '</label>';
             $cont[] = isset($languages[$cert[CERT_LANG]]) ? $languages[$cert[CERT_LANG]] : $cert[CERT_LANG];
             //lang description?
             $cont[] = Form::getInputDropdown('dropdown_nowh', 'certificate_assign_' . $id_cert, 'certificate_assign[' . $id_cert . ']', $possible_status, isset($course_cert[$id_cert]) ? $course_cert[$id_cert] : 0, '');
             $cont[] = Form::getInputDropdown('dropdown_nowh', 'certificate_ex_assign_' . $id_cert, 'certificate_ex_assign[' . $id_cert . ']', $possible_status, isset($course_ex_cert[$id_cert]) ? $course_ex_cert[$id_cert] : 0, '');
             $cont[] = (isset($course_cert[$id_cert]) && $course_cert[$id_cert] != 0 && $view_cert ? '<a href="index.php?modname=' . (Docebo::user()->getUserLevelId() == ADMIN_GROUP_PUBLICADMIN ? 'p' : '') . 'certificate&amp;op=view_report_certificate&amp;id_certificate=' . $id_cert . '&amp;id_course=' . $id_course . '&amp;from=course&amp;of_platform=lms">' : '') . (isset($released[$id_cert]) ? $released[$id_cert] : '0') . (isset($course_cert[$id_cert]) && $course_cert[$id_cert] != 0 ? '</a>' : '');
             $tb->addBody($cont);
         }
         $course_info = $this->model->getInfo($id_course);
         $course_name = ($course_info['code'] !== '' ? '[' . $course_info['code'] . '] ' : '') . $course_info['name'];
         $this->render('certificate', array('id_course' => $id_course, 'tb' => $tb, 'point_required' => $point_required, 'base_link_course' => $this->base_link_course, 'course_name' => $course_name));
     }
 }