123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /* For licensing terms, see /license.txt */
- use Chamilo\CoreBundle\Framework\Container;
- /**
- * @package chamilo.admin
- */
- $cidReset = true;
- //require_once '../inc/global.inc.php';
- Display::display_header(null);
- $form = new FormValidator('export_certificate');
- $courses = CourseManager::get_courses_list(0, 0, 'title');
- $options = array();
- foreach ($courses as $course) {
- $options[$course['id']] = $course['title'];
- }
- $form->addElement('select', 'course', get_lang('Course'), $options);
- $form->addElement('file', 'file', get_lang('File'));
- $form->addButton('submit', get_lang('Submit'));
- $form->display();
- if ($form->validate()) {
- $values = $form->getSubmitValues();
- if (isset($_FILES['file']['tmp_name']) &&
- !empty($_FILES['file']['tmp_name'])
- ) {
- $users = Import::csv_reader($_FILES['file']['tmp_name']);
- $courseId = $values['course'];
- $courseInfo = api_get_course_info_by_id($courseId);
- $courseCode = $courseInfo['code'];
- $cats = Category:: load(
- null,
- null,
- $courseCode,
- null,
- null,
- 0,
- false
- );
- if (isset($cats[0])) {
- /** @var Category $cat */
- $userList = array();
- foreach ($users as $user) {
- $userInfo = api_get_user_info_from_official_code(
- $user['official_code']
- );
- if (!empty($userInfo)) {
- $userList[] = $userInfo;
- }
- }
- Category::exportAllCertificates(
- $cat->get_id(),
- $userList
- );
- }
- }
- }
- Display :: display_footer();
|