Example #1
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;
        $mform = $this->_form;
        $mform->addElement('header', 'settingsheader', get_string('system_settings', 'local_cobaltsettings'));
        $hier1 = new hierarchy();
        $schoolids = $hier1->get_assignedschools();
        if (!empty($schoolids)) {
            $count = sizeof($schoolids);
            if ($count > 1) {
                $parents = $hier1->get_school_parent($schoolids, '', true);
                $attributes1 = 'style="height:25px; width:29%; "';
                $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $parents, $attributes1);
                $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
            } else {
                $schoolname = $DB->get_record('local_school', array('id' => $schoolids[0]->id));
                $mform->addElement('static', 'sid', get_string('select', 'local_collegestructure'), $schoolname->fullname);
                $mform->addElement('hidden', 'schoolid', $schoolids[0]->id);
            }
        }
        $mform->addElement('advcheckbox', 'batch', null, 'Batch', array('group' => 1), array(0, 1));
        $mform->addElement('html', '<div style=" margin-left:265px;" class="form-description"><p>' . get_string('enable_batch', 'local_cobaltsettings') . '
			   </p></div>');
        $mform->addElement('advcheckbox', 'prefix_suffix', null, 'Prefix-Suffix', array('group' => 1), array(0, 1));
        $mform->addElement('html', '<div style=" margin-left:265px;" class="form-description"><p>' . get_string('create_batch', 'local_cobaltsettings') . '
			   </p></div>');
        $mform->addElement('advcheckbox', 'online_app', null, 'Online Applications', array('group' => 1), array(0, 1));
        $mform->addElement('html', '<div style=" margin-left:265px; color:light-grey" class="form-description"><p>' . get_string('enable_online', 'local_cobaltsettings') . '
			   </p></div>');
        $mform->addElement('advcheckbox', 'certificate', null, 'Issue certificates', array('group' => 1), array(0, 1));
        /* start of vijaya jan-29 */
        $mform->addElement('advcheckbox', 'onlinepayment', null, 'Online Payment', array('group' => 1), array(0, 1));
        /* end of vijaya jan-29 */
        $this->add_action_buttons(true, 'Submit');
    }
Example #2
0
function user_download_xls($fields) {

    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename(get_string('course', 'local_cobaltcourses') . '.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }


    $hierarchy = new hierarchy();
    $schoollist = $hierarchy->get_assignedschools();
    if (is_siteadmin()) {
        $schoollist = $hierarchy->get_school_items();
    }

    $sheetrow = 1;
    foreach ($schoollist as $school) {
        $courses = $DB->get_records('local_cobaltcourses', array('schoolid' => $school->id));
        foreach ($courses as $course) {
            $post = new stdclass();

            $post->fullname = $course->fullname;
            $post->shortname = $course->shortname;
            $departmentname = $DB->get_field('local_department', 'fullname', array('id' => $course->departmentid));
            $post->courselibraryname = $departmentname;
            $schoolname = $DB->get_field('local_school', 'fullname', array('id' => $course->schoolid));
            $post->organizationname = $schoolname;
            $post->summary = $course->summary;
            $post->coursetype = ($course->coursetype == 0) ? 'General' : 'Elective';
            $post->credithours = $course->credithours;
            $post->coursecost = $course->coursecost;
            $col = 0;
            foreach ($fields as $fieldname) {
                $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
                $col++;
            }
            $sheetrow++;
        }
    }

    $workbook->close();
    die;
}
Example #3
0
    public function definition() {
        global $CFG, $DB;
        $mform = & $this->_form;
        $hierarchy = new hierarchy();
        if (is_siteadmin()) {
            $scho = $hierarchy->get_school_items();
        } else {
            $scho = $hierarchy->get_assignedschools();
        }
        $count = count($scho);
        if ($count > 1) {
            $school = $hierarchy->get_school_parent($scho);
            $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $school);
            $mform->addRule('schoolid', get_string('required'), 'required', null, 'client');
        } else {
            $school = $DB->get_record('local_school', array('visible' => 1));
            $mform->addElement('static', 'school', get_string('schoolid', 'local_collegestructure'), $school->fullname);
            $mform->setType('school', PARAM_RAW);

            $mform->addElement('hidden', 'schoolid', $school->id);
            $mform->setType('schoolidid', PARAM_INT);
        }

        for ($i = 0; $i <= 23; $i++) {
            $hours[$i] = sprintf("%02d", $i);
        }
        for ($i = 0; $i < 60; $i+=5) {
            $minutes[$i] = sprintf("%02d", $i);
        }

        $durtime = array();
        $durtime[] = & $mform->createElement('select', 'starthours', get_string('hour', 'form'), $hours, false, true);
        $durtime[] = & $mform->createElement('select', 'startminutes', get_string('minute', 'form'), $minutes, false, true);
        $mform->addGroup($durtime, 'starttime', get_string('starttime', 'local_attendance'), array(' '), true);


        $durtimes = array();
        $durtimes[] = & $mform->createElement('select', 'endhours', get_string('hour', 'form'), $hours, false, true);
        $durtimes[] = & $mform->createElement('select', 'endminutes', get_string('minute', 'form'), $minutes, false, true);
        $mform->addGroup($durtimes, 'endtime', get_string('orgendtime', 'local_attendance'), array(' '), true);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $submit = ($this->_customdata['id'] > 0) ? 'Update' : 'Create';
        $this->add_action_buttons('false', $submit);
    }
Example #4
0
function user_download_xls($fields) {

    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename(get_string('department', 'local_departments') . '.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

    $hierarchy = new hierarchy();
    /*   Bug report #260 
     * Edited by hemalatha c arun <*****@*****.**>
     * resolved- If loggedin user is admin, downloading all the department   
     */
    if (is_siteadmin()) {
        $sql = "SELECT distinct(s.id),s.* FROM {local_school} s ORDER BY s.sortorder";
        $schoollist = $DB->get_records_sql($sql);
    } else
        $schoollist = $hierarchy->get_assignedschools();

    $sheetrow = 1;
    foreach ($schoollist as $school) {
        $departments = $DB->get_records('local_department', array('schoolid' => $school->id));
        foreach ($departments as $department) {
            $post = new stdclass();
            $post->shortname = $department->shortname;
            $post->fullname = $department->fullname;
            $schoolname = $DB->get_field('local_school', 'fullname', array('id' => $department->schoolid));
            $post->schoolname = $schoolname;
            $post->summary = $department->description;
            $col = 0;
            foreach ($fields as $fieldname) {
                $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
                $col++;
            }
            $sheetrow++;
        }
    }
    $workbook->close();
    die;
}
Example #5
0
function user_download_xls($fields) {
    $hier = new hierarchy();
    $schools = $hier->get_assignedschools();

    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename('Users.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

    $sheetrow = 1;
    $myuser = users::getInstance();

    $users = $DB->get_records_sql("SELECT u.id, u.username, u.email, u.firstname, u.lastname, u.city, u.country,
                                            u.lastaccess, u.confirmed, u.mnethostid, u.suspended FROM {user} u, {local_users} lu
                                            WHERE lu.userid = u.id ");

    foreach ($users as $user) {
        $rid = $myuser->get_rolename($user->id);
        $post = new stdclass();
        $post->firstname = $user->firstname;
        $post->lastname = $user->lastname;
        $post->email = $user->email;

        $post->schoolname = $myuser->get_schoolnames($user);
        $post->roleid = $myuser->get_rolename($user->id);
        $col = 0;
        foreach ($fields as $fieldname) {
            $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
            $col++;
        }
        $sheetrow++;
    }

    $workbook->close();
    die;
}
Example #6
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;

        $mform = $this->_form;
        $mform->addElement('header', 'settingsheader', get_string('addeditgradeletter', 'local_gradesubmission'));

        $PAGE->requires->yui_module('moodle-local_gradesubmission-heirarchyselector', 'M.local_gradesubmission.init_heirarchyselector', array(array('formid' => $mform->getAttribute('id'))));
        $id = $this->_customdata['id'];

        $disable = ($id > 0) ? 'disabled="disabled"' : '';

        $hierarchy = new hierarchy();
        $schools = $hierarchy->get_assignedschools();
        $count = count($schools);

        if ($count > 1) {
            $parents = $hierarchy->get_school_parent($schools);
            $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $parents, $disable);
            if ($id < 0) {
                $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
            }
            $mform->setType('schoolid', PARAM_INT);
        } else {
            $school_name = $DB->get_record('local_school', array('id' => $schools[0]->id));
            $mform->addElement('static', 'schid', get_string('schoolid', 'local_collegestructure'), $school_name->fullname);
            $mform->addElement('hidden', 'schoolid', $schools[0]->id);
            $mform->setType('schoolid', PARAM_INT);
        }

        $mform->registerNoSubmitButton('updatecourseformat');
        $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
        $mform->addElement('hidden', 'addprogramslisthere');
        $mform->setType('addprogramslisthere', PARAM_INT);
        $mform->addElement('hidden', 'addsemesterslisthere');
        $mform->setType('addsemesterslisthere', PARAM_INT);
        $mform->addElement('hidden', 'addclclasseslisthere');
        $mform->setType('addclclasseslisthere', PARAM_INT);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $this->add_action_buttons();
    }
Example #7
0
function user_download_xls($fields) {
    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename(get_string('program', 'local_programs') . '.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

    $hierarchy = new hierarchy();
    $schoollist = $hierarchy->get_assignedschools();
    $sheetrow = 1;
    foreach ($schoollist as $school) {
        $programs = $DB->get_records('local_program', array('schoolid' => $school->id));
        foreach ($programs as $program) {
            $post = new stdclass();
            $post->shortname = $program->shortname;
            $post->fullname = $program->fullname;
            $departmentname = $DB->get_field('local_department', 'fullname', array('id' => $program->departmentid));
            $post->departmentname = $departmentname;
            $schoolname = $DB->get_field('local_school', 'fullname', array('id' => $program->schoolid));
            $post->schoolname = $schoolname;
            $post->summary = $program->description;
            $post->type = ($program->type == 0) ? 'UnderGraduate' : 'PostGraduate';
            $post->duration = $program->duration;
            $col = 0;
            foreach ($fields as $fieldname) {
                $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
                $col++;
            }
            $sheetrow++;
        }
    }
    $workbook->close();
    die;
}
Example #8
0
        $d_event['description'] = $data->description;
        $d_event['userid'] = $USER->id;
        $d_event['eventtype'] = $data->activityname;
        $d_event['timestart'] = $data->startdate;
        $d_event['timemodified'] = $today;
        $d_event['visible'] = $data->publish;
        $data->visble = $data->publish;
        $data->userid = $USER->id;
        $data->timecreated = time();
        $data->timemodified = time();

        if (isset($data->eventlevel) && $data->eventlevel == 1 && $data->eventtypeid == 1) {
            if (is_siteadmin($USER)) {
                $faculties = $DB->get_records('local_school', array('visible' => 1));
            } else {
                $faculties = $hierarchy->get_assignedschools();
            }

            foreach ($faculties as $faculty) {
                $programlist = $DB->get_records('local_program', array('schoolid' => $faculty->id, 'visible' => 1));
                foreach ($programlist as $program) {
                    $data->schoolid = $program->schoolid;
                    $data->programid = $program->id;
                    $eventid = $acalendar->event_add_instance($data);
                    $d_event['uuid'] = $eventid;
                    $acalendar->devent_add($d_event);
                }
            }

            $options = array('style' => 'notifysuccess');
            $hierarchy->set_confirmation(get_string('eventsuccess', 'local_academiccalendar'), $returnurl, $options);
Example #9
0
    public function definition() {
        global $CFG, $DB, $PAGE;

        $mform = & $this->_form;

        $schoolid = $this->_customdata['sid'];
        $PAGE->requires->yui_module('moodle-local_classroomresources-building', 'M.local_classroomresources.init_building', array(array('formid' => $mform->getAttribute('id'))));
        $PAGE->requires->yui_module('moodle-local_classroomresources-floor', 'M.local_classroomresources.init_floor', array(array('formid' => $mform->getAttribute('id'))));
        $PAGE->requires->yui_module('moodle-local_classroomresources-classroom', 'M.local_classroomresources.init_classroom', array(array('formid' => $mform->getAttribute('id'))));

        $c = 'class="one";style="border:none";readonly="readonly";';
        $hierarchy = new hierarchy();
        if (is_siteadmin()) {
            $scho = $hierarchy->get_school_items();
        } else {
            $scho = $hierarchy->get_assignedschools();
        }
        $count = count($scho);
        $school = $hierarchy->get_school_parent($scho);
        $this->_customdata['id'];
        if ($this->_customdata['id'] > 0) {

            $mform->addElement('static', 'schoolid', get_string('schoolname', 'local_collegestructure'));
            $mform->setType('schoolid', PARAM_RAW);
            $mform->addElement('text', 'buildingid', get_string('buildingname', 'local_classroomresources'), $c);
            $mform->setType('buildingid', PARAM_RAW);
            $mform->addElement('text', 'floorid', get_string('floorname', 'local_classroomresources'), $c);
            $mform->setType('floorid', PARAM_RAW);
            $mform->addElement('text', 'classroomid', get_string('classroomid', 'local_classroomresources'), $c);
            $mform->setType('classroomid', PARAM_RAW);
            $resource = cobalt_resources::get_instance();
            $resourcelist = $hierarchy->get_records_cobaltselect_menu('local_resource', "schoolid=$schoolid AND visible=1", null, '', 'id,fullname', get_string('select', 'local_classroomresources'));
            $select = $mform->addElement('select', 'resourceid', get_string('resourceid', 'local_classroomresources'), $resourcelist);
            $select->setMultiple(true);
        } else {

            $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $school);
            $mform->addRule('schoolid', get_string('required'), 'required', null, 'client');


            $mform->addElement('hidden', 'beforefloor');
            $mform->setType('beforefloor', PARAM_RAW);
            $mform->addElement('hidden', 'beforeclass');
            $mform->setType('beforeclass', PARAM_RAW);
            $mform->addElement('hidden', 'beforeresource');
            $mform->setType('beforeresource', PARAM_RAW);
            $mform->addElement('hidden', 'beforer');
            $mform->setType('beforer', PARAM_RAW);
            $mform->registerNoSubmitButton('updatecourseformat');
            $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
        }

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $submit = ($this->_customdata['id'] > 0) ? 'Update' : 'Assign Resources';
        $this->add_action_buttons('false', $submit);
    }
Example #10
0
$PAGE->navbar->add(get_string('listdepts', 'local_departments'));

//-------------manage_dept heading------------------------
echo $OUTPUT->heading(get_string('dept_heading', 'local_departments'));
echo $OUTPUT->header();

try {

    $dept = $DB->get_record('local_department', array('id' => $id));
    $PAGE->set_title(get_string('department', 'local_departments') . ': ' . $dept->fullname);

//Heading of the page
    echo $OUTPUT->heading($dept->fullname); //Semester Name
//------------if registrar not assigned to any school it throws exception    
    $hier1 = new hierarchy();
    $schoolid = $hier1->get_assignedschools();
    if (empty($schoolid)) {
        $e = get_string('rnot_assigned', 'local_departments');
        throw new Exception($e);
    }

    $data[] = array('<b>' . get_string('deptid', 'local_departments') . '</b>', $dept->shortname);
    $schoolname = $DB->get_record('local_school', array('id' => $dept->schoolid));
    $data[] = array('<b>' . get_string('belongs', 'local_departments') . '</b>', $schoolname->fullname . 'school');

    // list of assigned school for the perticular department
    $school_list = $DB->get_records('local_assignedschool_dept', array('deptid' => $dept->id));
    if (!empty($school_list)) {
        $school_name = '';
        foreach ($school_list as $sl) {
            $sn = $DB->get_record('local_school', array('id' => $sl->assigned_schoolid));
Example #11
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;
        $mform = $this->_form;
        //------used for editing purpose(used to put static schoolname and shortname)
        $eid = $this->_customdata['temp'];
        //-------used for adding department from college structure plugin or other plugin
        $schoolid_collegestruct = $this->_customdata['scid'];
        /* Bug-id #262 
         * @author hemalatha c arun <*****@*****.**>  
         * resolved -string issue
         */

        if ($eid->id > 0) {
            $mform->addElement('header', 'editheader', get_string('edit_department', 'local_departments'));
            $mform->addHelpButton('editheader', 'deptnote', 'local_departments');
        } else {
            // get_string('create_note','local_departments');
            $mform->addElement('header', 'createheader', get_string('create_department', 'local_departments'));
            $mform->addHelpButton('createheader', 'deptnote', 'local_departments');
        }
        $attributes = 'style="height:30px; "';
        //------used for editing purpose(used to put static schoolname )
        if ($eid->id > 0) {
            $school = $DB->get_record('local_school', array('id' => $eid->schoolid));
            $mform->addElement('static', 'esid', get_string('schoolid', 'local_collegestructure'), $school->fullname);
        } else {
            $hier = new hierarchy();
            if (is_siteadmin($USER->id)) {
                $schoolids = $DB->get_records('local_school', array('visible' => 1));
            } else
                $schoolids = $hier->get_assignedschools();

            $count = sizeof($schoolids);
            if ($count > 1) {
                //  $items = $hier->get_school_items();
                $parents = $hier->get_school_parent($schoolids, '', true);
                //$attributes1='style="height:30px; width:29%; "';
                $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $parents);
                $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
                if ($schoolid_collegestruct > 0)
                    $mform->setDefault('schoolid', $schoolid_collegestruct);
            }
            else {          
                foreach($schoolids as $sid){
                  $schoolid=$sid->id;
                  $schoolname=$sid->fullname;
                }          
                $mform->addElement('static', 'sid', get_string('schoolid', 'local_collegestructure'), $schoolname);
                $mform->addElement('hidden', 'schoolid', $schoolid);
            }
        }
        $mform->setType('schoolid', PARAM_INT);

        $mform->addElement('text', 'fullname', get_string('deptfullname', 'local_departments'), $attributes);
        $mform->addRule('fullname', get_string('missing_deptfullname', 'local_departments'), 'required', null, 'client');
        $mform->setType('fullname', PARAM_RAW);
        $mform->addHelpButton('fullname', 'fullname_note', 'local_departments');

        //-----used to put static shortname while editing---------
        if ($eid->id > 0) {
            $mform->addElement('static', 'eshortname', get_string('deptid', 'local_departments'), $eid->shortname);
        } else {
            $mform->addElement('text', 'shortname', get_string('deptid', 'local_departments'), $attributes);
            $mform->addRule('shortname', get_string('missing_deptid', 'local_departments'), 'required', null, 'client');
            $mform->setType('shortname', PARAM_TEXT);
            $mform->addHelpButton('shortname', 'shortname_note', 'local_departments');
        }

        //$mform->addElement('textarea', 'description', get_string("description", "local_departments"), 'wrap="virtual" rows="6" cols="150"',$attributes);
        //$mform->setType('description', PARAM_TEXT);

        $mform->addElement('editor', 'description', get_string("description", "local_departments"));
        $mform->setType('description', PARAM_RAW);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $submitbuttonname = ($eid->id > 0) ? 'update_department' : 'create_department';
        $this->add_action_buttons(true, get_string($submitbuttonname, 'local_departments'));
    }
Example #12
0
$context =context_user::instance($USER->id);
if (has_capability('local/clclasses:enrollclass', $context) && !is_siteadmin()) {
    echo $OUTPUT->heading(get_string('myacademics', 'local_courseregistration'));
} else {
    echo $OUTPUT->heading(get_string('pluginname', 'local_academiccalendar'));
}
if (is_siteadmin($USER)) {
    $admin_school = $DB->get_records('local_school');
    if (empty($admin_school))
        throw new schoolnotfound_exception();
}

if (!is_siteadmin($USER)) {
    if (has_capability('local/collegestructure:manage', $systemcontext)) {
        $assigned_schools = $hierarchy->get_assignedschools();

        foreach ($assigned_schools as $assigned_school) {
            if ($assigned_school->id != null) {
                $aschools[] = $assigned_school->id;
            }
        }
        $schoollist = implode(',', $aschools);
        empty($schoollist) ? $schoollist = 0 : $schoollist;
        empty($sql) ? $sql .=' ((eventlevel=1) OR
                                     (schoolid in (' . $schoollist . ')))' : $sql .=' AND ((eventlevel=1) OR
                                     (schoolid in (' . $schoollist . ')))';
    } elseif (has_capability('local/clclasses:enrollclass', $usercontext)) {

        $userdetails = $DB->get_records('local_userdata', array('userid' => $USER->id));
        $usersems = $DB->get_records('local_user_semester', array('userid' => $USER->id));
Example #13
0
    public function definition() {
        global $CFG, $DB, $PAGE, $USER;
        $mform = & $this->_form;
        $hierarchy = new hierarchy();
        $id = $this->_customdata['id'];
        $deptid = $this->_customdata['deptid'];
        $schoid = $this->_customdata['schoid'];
        $semid = $this->_customdata['semid'];
        $courseid = $this->_customdata['courseid'];
        $classid = $this->_customdata['classid'];
        $classtype = $this->_customdata['classtype'];

        // remove empty value in classtype
        if ($classtype) {
            foreach ($classtype as $key => $value) {
                if ($value == 0)
                    unset($classtype[$key]);
            }
        }

        if (isset($classid))
            $classinfo = $DB->get_record('local_clclasses', array('id' => $classid, 'visible' => 1));


        $deptid = (isset($classinfo->departmentid) ? $classinfo->departmentid : 0);
        $schoolid = (isset($classinfo->schoolid) ? $classinfo->schoolid : 0);
        $semid = (isset($classinfo->semesterid) ? $classinfo->semesterid : 0);

        $id = $this->_customdata['id'];
        //$PAGE->requires->yui_module('moodle-local_clclasses-chooser', 'M.local_clclasses.init_chooser', array(array('formid' => $mform->getAttribute('id'))));
        $PAGE->requires->yui_module('moodle-local_timetable-timetable', 'M.local_timetable.init_timetable', array(array('formid' => $mform->getAttribute('id'))));
        $PAGE->requires->js('/local/timetable/unassign_type.js');
        $hierarchy = new hierarchy();
        if (is_siteadmin()) {
            $scho = $hierarchy->get_school_items();
        } else {
            $scho = $hierarchy->get_assignedschools();
        }
        $count = count($scho);
        $school = $hierarchy->get_school_parent($scho);

        $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $school);
        $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
        $mform->setType('schoolid', PARAM_RAW);
        $mform->setDefault('schoolid', $classinfo->schoolid);

        $mform->registerNoSubmitButton('updatecourseformat');
        $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));

        $mform->addElement('hidden', 'addsemesterlisthere');
        $mform->setType('addsemesterlisthere', PARAM_RAW);

        $mform->addElement('hidden', 'addclasslisthere');
        $mform->setType('addclasslisthere', PARAM_RAW);

        // adding classtype       
        $mform->addElement('header', 'settingsheader', get_string('classtype', 'local_timetable'));
        $classtypes = $DB->get_records_menu('local_class_scheduletype', array('schoolid' => $schoolid,'visible'=>1), '', 'id, classtype');
	if(sizeof($classtypes) > 0 ){
           $string_cltype = array('Select classtype', '-1' => 'All');
           $final_classtype = $string_cltype + $classtypes;
	  } 
	else  {
	  $string_cltype = array('Select classtype');   
          $final_classtype=$string_cltype + $classtypes;
	}

        if ($classid) {
            $select = $mform->addElement('select', 'classtype', get_string('classtype', 'local_timetable'), $final_classtype);
            $select->setMultiple(true);

            $mform->setType('classtype', PARAM_INT);
            $mform->addRule('classtype', get_string('required'), 'required', null, 'client');
        }


        $mform->addElement('html', '<a id="newclasstype" style="float:right;margin-right: 240px;cursor:pointer;"
			onclick="newclasstype(' . $schoolid . ')">' . get_string('classtype', 'local_timetable') . '</a>');

        $mform->addElement('html', '<div id="createclasstype"></div>');
        $mform->addElement('html', '<div id="myratings1"></div>');

        $mform->registerNoSubmitButton('scheduleclasstype');
        $mform->addElement('submit', 'scheduleclasstype', get_string('scheduleclasstype', 'local_timetable'));


        $scheduleclass = cobalt_scheduleclass::get_instance();
        $hour = $scheduleclass->hour();
        $min = $scheduleclass->min();
        $starttime = array();
        $endtime = array();
        /* Start of scheduleclass startdate */
        //providing semester startdate and enddate helpful to select date
        if ($semid) {
            $seminfo = $DB->get_record('local_semester', array('id' => $semid));
            $seminfo->startdate = date('d M Y', $seminfo->startdate);
            $seminfo->enddate = date('d M Y', $seminfo->enddate);
            $mform->addElement('static', 'datedescription', '', get_string('classschedule_datedescription', 'local_clclasses', $seminfo));
        }

        if ($classtype && $classinfo)
            $this->reapeat_schedulecontent_basedon_type($classtype, $classinfo);

        /* Bug Report #276
         * @author hemalatha c arun<*****@*****.**> 
         * Resolved- if classrom created under the online course, no need to display classroom dropdown box 
         */
//        if ($DB->record_exists('local_clclasses', array('id' => $classid, 'online' => 1))) {
//            
//        } else {
//            $classroom = $hierarchy->get_records_cobaltselect_menu('local_classroom', "schoolid=$schoid AND visible=1", null, '', 'id,fullname', '--Select--');
//            //$classroom=1;
//            $mform->addElement('select', 'classroomid', get_string('classroomids', 'local_classroomresources'), $classroom);
//            if (count($classroom) <= 1) {
//                $navigationlink = $CFG->wwwroot . '/local/classroomresources/classroom.php?linkschool=' . $schoid . '';
//                $navigationmsg = get_string('navigation_info', 'local_collegestructure');
//                $linkname = get_string('createclassroom', 'local_classroomresources');
//                $mform->addElement('static', 'classroomids_empty', '', $hierarchy->cobalt_navigation_msg($navigationmsg, $linkname, $navigationlink, 'margin-bottom: -15px;
//line-height: 0px;'));
//            }
//            $mform->addRule('classroomid', get_string('required'), 'required', null, 'client');
//        }
        /* Start of hidden fields */
        $time = time();
        $user = $USER->id;
        $mform->addElement('hidden', 'timecreated', $time);
        $mform->setType('timecreated', PARAM_INT);
        $mform->addElement('hidden', 'timemodified', $time);
        $mform->setType('timemodified', PARAM_INT);
        $mform->addElement('hidden', 'usermodified', $user);
        $mform->setType('usermodified', PARAM_INT);

        $mform->addElement('hidden', 'departmentid', $deptid);
        $mform->setType('departmentid', PARAM_INT);
        //
        $mform->addElement('hidden', 'schoid', $schoid);
        $mform->setType('schoid', PARAM_INT);
        $mform->addElement('hidden', 'deptid', $deptid);
        $mform->setType('deptid', PARAM_INT);
        //
        //   $mform->addElement('hidden', 'schoolid', $schoid);
        //  $mform->setType('schoolid', PARAM_INT);
        // $mform->addElement('hidden', 'semesterid', $semid);
        // $mform->setType('semesterid', PARAM_INT);
        //$mform->addElement('hidden', 'semid', $semid);
        //$mform->setType('semid', PARAM_INT);
        $mform->addElement('hidden', 'courseid', $courseid);
        $mform->setType('courseid', PARAM_INT);
        //$mform->addElement('hidden', 'classid', $classid);
        //$mform->setType('classid', PARAM_INT);
        /* Start of hidden id field */
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        /* Start of action buttons */
        $actionbutton = ($id > 0) ? get_string('scheduleclassroom', 'local_clclasses') : get_string('scheduleclassroom', 'local_clclasses');
        $this->add_action_buttons($cancel = true, $actionbutton);
    }
Example #14
0
 /**
  * @method  check_loginuser_registrar_admin
  * @todo to display school list based logged in user (registrar, admin)     * 
  * @param boolean $schoolids_in_formofstring (used to get schoolids in the form of string)    
  * @return based on condition it returns array of objects or string type of data
  */
 public function check_loginuser_registrar_admin($schoolids_in_formofstring = false) {
     global $DB, $USER, $CFG;
     $hier1 = new hierarchy();
     //  checking of login user is admin..
     if (is_siteadmin($USER->id)) {
         $schoolid = $DB->get_records('local_school', array('visible' => 1));
        
     } else {
         //------------if registrar not assigned to any school it throws exception    
         $users = $hier1->get_manager();
         $schoolid = $hier1->get_assignedschools();
         
     } // end of else
     if (empty($schoolid)) {
         throw new schoolnotfound_exception();
     }
     if ($schoolids_in_formofstring) {
         foreach ($schoolid as $sid) {
             $temp[] = $sid->id;
         }
         $school_id = implode(',', $temp);
         return $school_id;
     } else
         return $schoolid;
 }
Example #15
0
    /**
     * @method get_users_listing
     * @todo to get user list of school based on condition  
     * @param string $sort fieldname
     * @param string $dir specify the order to sort
     * @param int $page page number
     * @param int $recordsperpage records perpage
     * @param string $extraselect extra condition to select user
     * @param array $extraparams
     * @return array of objects , list of users
     */
    function get_users_listing($sort = 'lastaccess', $dir = 'ASC', $page = 0, $recordsperpage = 0, $extraselect = '', array $extraparams = null, $extracontext = null) {
        global $DB, $CFG;
        $extraselect;

        $select = "deleted <> 1 AND id <> :guestid";  //$select = "deleted=0";
        $params = array('guestid' => $CFG->siteguest);

        if ($extraselect) {
            $select .= " AND $extraselect";
            $params = $params + (array) $extraparams;
        }

        // If a context is specified, get extra user fields that the current user
        // is supposed to see.
        $extrafields = '';
        if ($extracontext) {
            $extrafields = get_extra_user_fields_sql($extracontext, '', '', array('id', 'username', 'email', 'firstname', 'lastname', 'city', 'country',
                'lastaccess', 'confirmed', 'mnethostid'));
        }
        /*
         * ###Bugreport#183-Filters
         * @author Naveen Kumar<*****@*****.**>
         * (Resolved) Added $select parameters for conditions 
         */
        // warning: will return UNCONFIRMED USERS
        //  print_object($params);
        $users = $DB->get_records_sql("SELECT *
                                       FROM {user}
                                       WHERE $select", $params);

        $hierarchy = new hierarchy();
        $schoollist = $hierarchy->get_assignedschools();
        $schoollist = $hierarchy->get_school_parent($schoollist, $selected = array(), $inctop = false, $all = false);
        if (is_siteadmin()) {
            $schoollist = $hierarchy->get_school_items();
        }
        $schoolidin = implode(',', array_keys($schoollist));
        if ($users && $schoollist) {
            $useridin = implode(',', array_keys($users));
            return $DB->get_records_sql("select user.* from (SELECT u.id, u.username, u.email, u.firstname, u.lastname, u.city, u.country,
                                            u.lastaccess, u.confirmed, u.mnethostid, u.suspended FROM {user} u
                                        JOIN {local_users} lu ON lu.userid = u.id
                                        JOIN {local_school_permissions} sp ON sp.userid = u.id
                                        WHERE u.id in ($useridin) AND sp.schoolid IN ($schoolidin)
                                        UNION
                                        SELECT u.id, u.username, u.email, u.firstname, u.lastname, u.city, u.country,
                                            u.lastaccess, u.confirmed, u.mnethostid, u.suspended FROM {user} u
                                        JOIN {local_users} lu ON lu.userid = u.id
                                        JOIN {local_userdata} ud ON ud.userid = u.id
                                        WHERE u.id in ($useridin) AND ud.schoolid IN ($schoolidin)) user GROUP BY user.id ORDER BY user.$sort $dir LIMIT $page, $recordsperpage ");
        }
    }
Example #16
0
    $semester = student_semesters($USER->id, 'courseregistration');
    // print_object($semester);
    foreach ($semester as $key => $value) {
        $current_semid = $key;
    }
    if (empty($current_semid))
        print_error(get_string('noactivesem', 'local_timetable'));

    $sessionsinfo = $DB->get_records_sql("select sd.* FROM {local_user_clclasses} as cl
                       JOIN {local_scheduleclass} as sd ON sd.classid= cl.classid and sd.visible=1
                       WHERE cl.semesterid=$current_semid and cl.userid=$USER->id  and from_unixtime('%Y',sd.startdate) > 2014 and sd.visible=1   ");
}
// only for registrar
else if (has_capability('local/collegestructure:manage', $systemcontext) && !is_siteadmin()) {
    $hier = new hierarchy();
    $schoolist = $hier->get_assignedschools();
    if ($schoolist) {
        $result = '';
        foreach ($schoolist as $school)
            $result[] = $school->id;
        $result = implode(',', $result);
        $sessionsinfo = $DB->get_records_sql("select * from {local_scheduleclass} where schoolid IN ($result) and  from_unixtime('%Y',startdate) > 2014 and visible=1");
    }
}
// only for instructor
else if (has_capability('local/clclasses:submitgrades', $systemcontext) && !is_siteadmin()) {

    $sessionsinfo = $DB->get_records_sql(" select sh.*  from  mdl_local_clclasses as cl
           JOIN mdl_local_scheduleclass as sh ON sh.classid=cl.id
     where sh.instructorid=$USER->id and from_unixtime('%Y',sh.startdate) > 2013 and sh.visible=1");
} else {
Example #17
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;

        $mform = $this->_form;
        $id = $this->_customdata['id'];

        $mform->addElement('header', 'settingsheader', get_string('addeditgradeletter', 'local_gradeletter'));

        $hierarchy = new hierarchy();
        if (is_siteadmin($USER->id)) {
            $schools = $DB->get_records('local_school', array('visible' => 1));
        } else {
            $schools = $hierarchy->get_assignedschools();
        }
        $noofschools = count($schools);

        if ($noofschools > 1) {
            $parents = $hierarchy->get_school_parent($schools);
            $mform->addElement('select', 'schoolid', get_string('select', 'local_collegestructure'), $parents);
            $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
            $mform->setType('schoolid', PARAM_INT);
        } else {
            foreach($schools as $sl){
                $schoolid  = $sl->id;
                $schoolname= $sl->fullname;
            }            
            $mform->addElement('static', 'schid', get_string('select', 'local_collegestructure'), $schoolname);
            $mform->addElement('hidden', 'schoolid', $schoolid);
            $mform->setType('schoolid', PARAM_INT);
        }

        $mform->addElement('text', 'letter', get_string('lettergrades', 'local_gradeletter'));
        $mform->addRule('letter', get_string('letterreq', 'local_gradeletter'), 'required', null, 'client');
        $mform->addRule('letter', get_string('lettersonly', 'local_gradeletter'), 'lettersonly', null, 'client');
        $mform->setType('letter', PARAM_TEXT);

        $mform->addElement('text', 'markfrom', get_string('markfrom', 'local_gradeletter'));
        $mform->addRule('markfrom', get_string('marksfromreq', 'local_gradeletter'), 'required', null, 'client');
        $mform->addRule('markfrom', null, 'numeric', null, 'client');
        // $mform->addRule('markfrom', get_string('markslengthmin','local_gradeletter'), 'minlength',2, 'client');
        $mform->setType('markfrom', PARAM_INT);

        $mform->addElement('text', 'markto', get_string('markto', 'local_gradeletter'));
        $mform->addRule('markto', get_string('reqmarktoval', 'local_gradeletter'), 'required', null, 'client');
        $mform->addRule('markto', null, 'numeric', null, 'client');
        $mform->addRule('markto', get_string('markslengthmin', 'local_gradeletter'), 'minlength', 2, 'client');
        $mform->setType('markto', PARAM_INT);

        $mform->addRule(array('markfrom', 'markto'), '"Mark from" value should be lesser than "Mark to" value.', 'compare', '<');

        $mform->addElement('text', 'gradepoint', get_string('gradepoint', 'local_gradeletter'));
        $mform->addRule('gradepoint', get_string('gradepointreq', 'local_gradeletter'), 'required', null, 'client');
        $mform->addRule('gradepoint', null, 'numeric', null, 'client');
        $mform->setType('gradepoint', PARAM_TEXT);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $submitlable = ($id > 0) ? get_string('updategradeletter', 'local_gradeletter') : get_string('creategradeletter', 'local_gradeletter');
        $this->add_action_buttons($cancel = true, $submitlable);
    }
Example #18
0
/**
 * process the mass enrolment
 * @param csv_import_reader $cir  an import reader created by caller
 * @param Object $course  a course record from table mdl_course
 * @param Object $context  course context instance
 * @param Object $data    data from a moodleform 
 * @return string  log of operations 
 */
function bulk_batch_enroll_newstudents($cir, $data) {
    global $CFG,$DB,$USER; $optype='';

    $returnurl = new moodle_url('/local/batches/bulk_enroll.php');
    //$STD_FIELDS = array('firstname', 'middlename', 'lastname', 'gender', 'dob', 'birthcountry', 'birthplace', 'fathername', 'pob', 'region', 'town', 'current_home_no', 'current_country', 'phone', 'email', 'howlong', 'same', 'permenant_country', 'permenant_home_no', 'state', 'city', 'pincode', 'contactname', 'primary_school', 'primary_year', 'primary_score', 'primary_place', 'undergraduate_in', 'ugname', 'ug_year', 'ug_score', 'ug_place', 'graduate_in', 'graduate_name', 'graduate_year', 'graduate_score', 'graduate_place', 'examname', 'hallticketno', 'score', 'no_of_months', 'reason', 'description','typeofstudent', 'typeofapplication', 'previousstudent', 'serviceid', 'typeofprogram');
    $STD_FIELDS = array('firstname', 'middlename', 'lastname', 'fathername','mothername','gender', 'dob','caste','category', 'current_country', 'phone', 'email', 'otherphone','city', 'pincode',   'typeofapplication',  'serviceid', 'fatheremail','address');

    $PRF_FIELDS = array();
   
    $result = '';
    
    //$roleid = $data->roleassign;
    //$useridfield = $data->firstcolumn;

    $enrollablecount = 0; $skipped=0;
    $createdgroupscount = 0;
    $createdgroupingscount = 0;
    $createdgroups = '';
    $createdgroupings = '';
    
    
    $filecolumns = uu_validate_admission_upload_columns($cir, $STD_FIELDS, $PRF_FIELDS, $returnurl);
    $upt = new uu_progress_tracker();
    $plugin = enrol_get_plugin('manual');
    // init csv import helper
    $cir->init();

    $linenum = 1;
    loop:
    while ($line = $cir->next()) {
    $result=''; $existsmail=0;
    
    $upt->flush();
    $linenum++;
    $admission = new stdClass();
    // add fields to admission object
    foreach ($line as $keynum => $value) {
        if (!isset($filecolumns[$keynum])) {
            // this should not happen
            continue;
        }
        $key = $filecolumns[$keynum];
	
        $admission->$key = $value;
    }
    


    $admission->linenum = $linenum;    
    
//    	 // ----------  getting curriculumid--------------------
//        $curriculum = trim($admission->curriculumname);
//        $curriculumid = $DB->get_field('local_curriculum', 'id', array('fullname' => $curriculum));
//	
//	 // ---------- getting batchid---------------
//        $batchname = trim($admission->batchname);
//
//        $batchid = $DB->get_field('cohort', 'id', array('name' => $batchname));

	if(empty($data->batchid)){
	  $result .= '<div class="alert alert-error">'.get_string('emptybatch','local_batches').'</div>';
                goto loop;
	}
        $batchid =$data->batchid;
        $batchmapinfo=$DB->get_record('local_batch_map',array('batchid'=>$batchid));
    
    
//     if (!empty($admission->previousstudent) && !empty($admission->serviceid) && $admission->previousstudent == 2) {
//
//        // schools validation
//       // $scname = trim($admission->schoolname);
//        $schoollist = $DB->get_record('local_school', array('fullname' => $data->schoolid));
//        if (empty($schoollist)) {	    
//	    $result .= '<div class="alert alert-error">'.get_string('invalidschool_ub', 'local_batches', $admission). '</div>';         
//            goto loop;
//        }
//        $scid = $schoollist->id;
//        // check schoolname
//        $hier = new hierarchy();
//        $schools = $hier->get_assignedschools();
//        if (is_siteadmin()) {
//            $schools = $hier->get_school_items();
//        }
//        $c = 0;
//        foreach ($schools as $scl) {
//            if ($scid == $scl->id) {
//                ++$c;
//                break;
//            }
//        }
//        if ($c == 0) {
//	    $result .= '<div class="alert alert-error">'.get_string('invalidschoolpermission_ub', 'local_batches', $admission). '</div>';                 
//            goto loop;
//        }
//
//        if (empty($admission->typeofprogram)) {
//	    $result .= '<div class="alert alert-error">'.get_string('emptytypeofprogram_ub', 'local_batches', $admission). '</div>';         
//          
//            goto loop;
//        }
//        // type of program validation
//        if ($admission->typeofprogram > 2 || $admission->typeofprogram < 1) {
//	    $result .= '<div class="alert alert-error">'.get_string('invalidtypeofprogram_ub', 'local_batches', $admission). '</div>';
//      
//            goto loop;
//        }
//        if (empty($admission->typeofapplication)) {
//	     $result .= '<div class="alert alert-error">'.get_string('emptytypeofapplication_ub', 'local_batches', $admission). '</div>';
//       
//            goto loop;
//        }
//        if ($admission->typeofapplication > 2 || $admission->typeofapplication < 1) {
//	      $result .= '<div class="alert alert-error">'.get_string('invalidtypeofapplication_ub', 'local_batches', $admission). '</div>';
//       
//            goto loop;
//        }
//	
//        //  program validation
////        $prg = trim($admission->programname);
////        $programlist = $DB->get_record('local_program', array('fullname' => $prg));
////        if (empty($programlist)) {
////	    $result .= '<div class="alert alert-error">'.get_string('invalidprogramname_ub', 'local_batches', $admission). '</div>';
////       
////            goto loop;
////        }
////        $prgid = $programlist->id;
////
////        $programs = $DB->get_records('local_program', array('id' => $prgid, 'schoolid' => $scid, 'programlevel' => $admission->typeofprogram));
////        if (empty($programs)) {
////	    $result .= '<div class="alert alert-error">'.get_string('invalidmapprogramname_ub', 'local_batches', $admission). '</div>';
////          //  echo '<h3 style="color:red;">Program "' . $admission->programname . '" is not under given School "' . $admission->schoolname . '" or not under given typeofprogram "' . $admission->typeofprogram . '" at line no. "' . $linenum . '" of excelsheet.</h3>';
////            goto loop;
////        }
//
//          
//        $scid= $data->schoolid;
//	$prgid=$data->program;
//        $time = date('m/d/Y');
//        $time = strtotime($time);
//        $openadms = $DB->get_record_sql('select * from {local_event_activities} where schoolid = ' . $scid . ' and programid = ' . $prgid . ' and publish = 1 and ((' . $time . ' BETWEEN startdate and enddate) or (' . $time . ' >= startdate and enddate = 0))  and eventtypeid = 1');
//        $serviceid = trim($admission->serviceid);
//        if (empty($openadms)) {
//             $result .='<h3 style="color:red;">Admissions are not opened for the applied program entered at line no. "' . $linenum . '" of uploaded excelsheet.</h3>';
//            goto loop;
//        }
//        $applcntid = $DB->get_field('local_userdata', 'applicantid', array('serviceid' => $serviceid, 'schoolid' => $scid));
//        if (empty($applcntid)) {
//            $result .= '<h3 style="color:red;">You have entered invalid serviceid "' . $admission->serviceid . '" at line no. "' . $linenum . '" of uploaded excelsheet.';
//            goto loop;
//        }
//        $result = $DB->get_record('local_admission', array('id' => $applcntid));
//        $previous = $result;
//        $previous->dateofapplication = time();
//        $previous->typeofprogram = $admission->typeofprogram;
//        $previous->typeofapplication = $admission->typeofapplication;
//        $previous->program = $prgid;
//        $previous->status = 0;
//        $DB->insert_record('local_admission', $previous);
//        $admissionsnew++;
//        // print_object($previous);
//    } else {
	
		
	// ----------to checking unique email id---------------
	if($admission->email){
	   if($existsuser=$DB->get_record('user',array('email'=>$admission->email))){

	      $existsmail= 1;
	     //  if( $DB->record_exists('cohort_members',array('userid'=>$existsuser->id,'cohortid'=>$batchid)))
	     $result .= '<div class="alert alert-error">'.get_string('useremailidexists_ub', 'local_batches', $admission). '</div>';
       
            goto loop;	    
	   }    
	}
	// ----------to checking unique service id (Rollid)---------------
        if($admission->serviceid){
	   if($existsuser=$DB->get_record('local_userdata',array('serviceid'=>$admission->serviceid))){
	     $result .= '<div class="alert alert-error">'.get_string('existsserviceid', 'local_batches', $admission). '</div>';
       
            goto loop;	    
	    
	   }
	   
	    
	}
        
        //if ($admission->previousstudent != 1) {
        //     $result .= '<h3 style="color:red;">You have entered invalid previousstudent "' . $admission->previousstudent . '" at line no. "' . $linenum . '" of uploaded excelsheet.';
        //    goto loop;
        //}
        if (!isset($admission->email)) {
            // prevent warnings below
            $admission->email = '';
        }

        // make sure we really have admissionname
        if (empty($admission->email)) {
            $admissionserrors++;
            continue;
        }
        $admission->email = trim($admission->email);
        $existingadmission = $DB->get_record_sql("select * from {local_admission} where email = '$admission->email' and (status=0 or status=1)");
        // add default values for remaining fields
        $formdefaults = array();
        foreach ($STD_FIELDS as $field) {
            if (isset($admission->$field)) {
                continue;
            }
            // all validation moved to form2
            if (isset($formdata->$field)) {
                // process templates
                $formdefaults[$field] = true;
            }
        }
        foreach ($PRF_FIELDS as $field) {
            if (isset($admission->$field)) {
                continue;
            }
            if (isset($formdata->$field)) {
                $formdefaults[$field] = true;
            }
        }
        // can we process with update or insert?
        $skip = false;
        if ($optype == 'UU_ADMISSION_ADDNEW') {
            if ($existingadmission) {
                $admissionsskipped++;
                $skip = true;
            }
        }
        if ($skip) {
            continue;
        }
        // save the new admission to the database
        // schools validation
        //$scname = trim($admission->schoolname);
        //$schoollist = $DB->get_record('local_school', array('fullname' => $scname));
        //if (empty($schoollist)) {
        //    $result .= '<h3 style="color:red;">Invalid school  "' . $admission->schoolname . '" entered at line no. "' . $linenum . '" of excelsheet.</h3>';
        //    goto loop;
        //}
       // $scid = $schoollist->id;
        // check schoolname
        $hier = new hierarchy();
        $schools = $hier->get_assignedschools();
        if (is_siteadmin()) {
            $schools = $hier->get_school_items();
        }
        $c = 0;
        foreach ($schools as $scl) {
            if ($scid == $scl->id) {
                ++$c;
                break;
            }
        }
        //if ($c == 0) {
        //     $result .='<h3 style="color:red;">Sorry you are not assigned to this school "' . $admission->schoolname . '" entered at line no. "' . $linenum . '" of uploaded excelsheet.</h3>';
        //    goto loop;
        //}
        //if (empty($admission->typeofprogram)) {
        //     $result .= '<h3 style="color:red;">Please enter value for "typeofprogram" field in line no. "' . $linenum . '" of uploaded excelsheet.</h3>';
        //    goto loop;
        //}
        if (empty($admission->typeofapplication)) {
             $result .= '<div class="alert alert-error">Please enter value for "typeofapplication" field in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        if ($admission->typeofapplication > 2 || $admission->typeofapplication < 1) {
             $result .= '<div class="alert alert-error">You have entered invalid typeofapplication "' . $admission->typeofapplication . '" at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        // type of program validation
        //if ($admission->typeofprogram > 2 || $admission->typeofprogram < 1) {
        //     $result .= '<h3 style="color:red;">You have entered invalid typeofprogram "' . $admission->typeofprogram . '" at line no. "' . $linenum . '" of uploaded excelsheet.';
        //    goto loop;
        //}
        //  program validation
        //$prg = trim($admission->programname);
        //$programlist = $DB->get_record('local_program', array('fullname' => $prg));
        //if (empty($programlist)) {
        //     $result .='<div class="alert alert-error">Invalid program name "' . $admission->programname . '" entered at line no. "' . $linenum . '" of excelsheet.</div>';
        //    goto loop;
        //}
        //$prgid = $programlist->id;

        if($batchmapinfo->programid>0)
        $prgid=$batchmapinfo->programid;
        else
	$prgid= $data->program;
        
        if($batchmapinfo->schoolid>0)
        $scid=$batchmapinfo->schoolid;
        else        
	$scid =$data->schoolid;
        
        if($batchmapinfo->curriculumid>0)
        $curriculumid=$batchmapinfo->curriculumid;
        else        
	$curriculumid =$data->curriculumid;
        
        //$programs = $DB->get_records('local_program', array('id' => $prgid, 'schoolid' => $scid, 'programlevel' => $admission->typeofprogram));
        //if (empty($programs)) {
        //     $result .='<div class="alert alert-error">Program "' . $admission->programname . '" is not under given School "' . $admission->schoolname . '" or not under given typeofprogram "' . $admission->typeofprogram . '" at line no. "' . $linenum . '" of excelsheet.</div>';
        //    goto loop;
        //}
        //$time = date('m/d/Y');
        //$time = strtotime($time);
        //$openadms = $DB->get_record_sql('select * from {local_event_activities} where schoolid = ' . $scid . ' and programid = ' . $prgid . ' and publish = 1 and ((' . $time . ' BETWEEN startdate and enddate) or (' . $time . ' >= startdate and enddate = 0))  and eventtypeid = 1');
        //if (empty($openadms)) {
        //     $result .= '<div class="alert alert-error">Admissions are not opened for the applied program entered at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        // type of student validation
        //if ($admission->typeofstudent > 3 || $admission->typeofstudent < 1) {
        //    $result .='<div class="alert alert-error">You have entered invalid typeofstudent "' . $admission->typeofstudent . '" at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        $year = time();
        $year_in_number = date('Y');
        if (empty($admission->dob)) {
            $result .= '<div class="alert alert-error">Please enter dob in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        $ex = explode('/', $admission->dob);        
        if((sizeof($ex))<2){
         $ex = explode('-', $admission->dob);
        }
        if((sizeof($ex))<2){
           $ex = explode('.', $admission->dob);
        }
        
        $howlong = $year_in_number - $ex[2];
        $dob = strtotime($ex[0].'/'.$ex[1].'/'.$ex[2]);

        $true = checkdate($ex[0],$ex[1],$ex[2]);
        if ($true == false) {
            $result .= '<div class="alert alert-error">Invalid  dob "' . $admission->dob . '" format entered at line no. "' . $linenum . '" of uploaded excelsheet. </div>';
            goto loop;
        }
        
        if(empty($dob)){
              $result .= '<div class="alert alert-error">check  dob date format "' . $admission->dob . '" format entered at line no. "' . $linenum . '" of uploaded excelsheet. </div>';  
            
        }
                
        // check dob
        if ($dob > $year) {
             $result .='<div class="alert alert-error">dob "' . $admission->dob . '" should be less than present date at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        // check howlong
        //if ($howlong < $admission->howlong) {
        //     $result .= '<div class="alert alert-error"> howlong ' . $admission->howlong . '  should not be greater than your age at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //// check primary year
        //if ($admission->primary_year > $year_in_number) {
        //     $result .= '<div class="alert alert-error">primary_year "' . $admission->primary_year . '" should not br greater than present date at line no. "' . $linenum . '".</div>';
        //    goto loop;
        //}
        //if ($admission->primary_year < $ex[2]) {
        //     $result .= '<div class="alert alert-error">primary_year "' . $admission->primary_year . '" should not be less than dob at line no. "' . $linenum . '".</div>';
        //    goto loop;
        //}
        //if ($admission->typeofprogram == 2) {
        //    if ($admission->ug_year > $year_in_number) {
        //        $result .= '<div class="alert alert-error">ug_year  "' . $admission->ug_year . '" should not be greater than present date at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if ($admission->ug_year < $admission->primary_year) {
        //       $result .= '<div class="alert alert-error">ug_year "' . $admission->ug_year . '"  should not be less than primary year at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if ($admission->ug_year < $ex[2]) {
        //        $result .= '<div class="alert alert-error">ug_year "' . $admission->ug_year . '" should not be less than dob at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if ($admission->ug_year == $admission->primary_year) {
        //        $result .= '<div class="alert alert-error">ug_year "' . $admission->ug_year . '"  should not be less than primary year at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //}
        //if ($admission->same > 2 || $admission->same < 1) {
        //    $result .='<div class="alert alert-error">Number entered for field same "' . $admission->same . '" is invalid at line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //$value1 = numeric_validation($admission->pob);
        //if ($value1 == 0) {
        //     $result .= '<div class="alert alert-error">Enter valid value for field pob in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        // check phone number
        $phone_length = strlen($admission->phone);
        //if ($phone_length > 15 || $phone_length < 10) {
        //    echo '<div class="alert alert-error">Enter valid phone number in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->current_home_no)) {
        //    echo '<div class="alert alert-error">Please enter current_home_no in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        if (empty($admission->current_country)) {
            echo '<div class="alert alert-error">Please enter current_country in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        
        if(empty($admission->address)){
            echo '<div class="alert alert-error">Please enter address in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop; 
            
        }
        //if (empty($admission->fathername)) {
        //    echo '<div class="alert alert-error">Please enter fathername in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->pob)) {
        //    echo '<div class="alert alert-error">Please enter pob in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (!trim($admission->region)) {
        //    echo '<div class="alert alert-error">Please enter region in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->town)) {
        //    echo '<div class="alert alert-error">Please enter town in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->birthcountry)) {
        //    echo '<div class="alert alert-error">Please enter birthcountry in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        $check_mail = filter_var($admission->email, FILTER_VALIDATE_EMAIL);
        if ($check_mail == false) {
            echo '<div class="alert alert-error">Please enter valid email in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        $country = get_string_manager()->get_list_of_countries();
        //if (!empty($admission->birthcountry)) {
        //    if (!array_key_exists($admission->birthcountry, $country)) {
        //        echo '<div class="alert alert-error">Please enter valid code for birthcountry in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //}
        if (!empty($admission->current_country)) {
            if (!array_key_exists($admission->current_country, $country)) {
                echo '<div class="alert alert-error">Please enter valid code for current_country  in line  no. "' . $linenum . '" of uploaded excelsheet.</div>';
                goto loop;
            }
        }

        //if (empty($admission->same)) {
        //    echo '<div class="alert alert-error">Please enter value for "same" field in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        if (empty($admission->firstname)) {
            echo '<div class="alert alert-error">Please enter firstname in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        if (empty($admission->lastname)) {
            echo '<div class="alert alert-error">Please enter lastname in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }
        if (empty($admission->gender)) {
            echo '<div class="alert alert-error">Please enter gender in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            goto loop;
        }

        //if (empty($admission->birthplace)) {
        //    echo '<div class="alert alert-error">Please enter birthplace in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->primary_school)) {
        //    echo '<div class="alert alert-error">Please enter primary_school in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->primary_year)) {
        //    echo '<div class="alert alert-error">Please enter primary_year in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->primary_score)) {
        //    echo '<div class="alert alert-error">Please enter primary_score in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->primary_place)) {
        //    echo '<div class="alert alert-error">Please enter primary_place in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if (empty($admission->typeofstudent)) {
        //    echo '<div class="alert alert-error">Please enter typeofstudent in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //    goto loop;
        //}
        //if ($admission->typeofstudent == 2) {
        //    if (empty($admission->examname)) {
        //        echo '<div class="alert alert-error">Please enter examname in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->hallticketno)) {
        //        echo '<div class="alert alert-error">Please enter hallticketno in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->score)) {
        //        echo '<div class="alert alert-error">Please enter score in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //}
        //if ($admission->typeofstudent == 3) {
        //    if (empty($admission->no_of_months)) {
        //        echo '<div class="alert alert-error">Please enter no_of_months in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->reason)) {
        //        echo '<div class="alert alert-error">Please enter reason in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->description)) {
        //        echo '<div class="alert alert-error">Please enter description in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //}
        //if ($admission->typeofprogram == 2) {
        //    if (empty($admission->undergraduate_in)) {
        //        echo '<div class="alert alert-error">Please enter undergraduate_in in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->ugname)) {
        //        echo '<div class="alert alert-error">Please enter ugname in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->ug_year)) {
        //        echo '<div class="alert alert-error">Please enter ug_year in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->ug_score)) {
        //        echo '<div class="alert alert-error">Please enter ug_score in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //    if (empty($admission->ug_place)) {
        //        echo '<div class="alert alert-error">Please enter ug_place in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
        //        goto loop;
        //    }
        //}
      //  if ($admission->same == 2) {
            //if (empty($admission->permenant_country)) {
            //    echo '<div class="alert alert-error">Please enter permenant_country in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            //    goto loop;
            //}
            //if (!empty($admission->permenant_country)) {
            //    if (!array_key_exists($admission->permenant_country, $country)) {
            //        echo '<div class="alert alert-error">Please enter valid code for permenant_country in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            //        goto loop;
            //    }
            //}
            if (empty($admission->city)) {
                echo '<div class="alert alert-error">Please enter city in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
                goto loop;
            }
            //if (empty($admission->permenant_home_no)) {
            //    echo '<div class="alert alert-error">Please enter permenant_home_no in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            //    goto loop;
            //}
            //if (empty($admission->state)) {
            //    echo '<div class="alert alert-error">Please enter state in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            //    goto loop;
            //}
            //if (empty($admission->pincode)) {
            //    echo '<div class="alert alert-error">Please enter pincode in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            //    goto loop;
            //}
            //$value2 = numeric_validation($admission->pincode);
            //if ($value2 == 0) {
            //    echo '<div class="alert alert-error">Enter valid value for field pincode in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            //    goto loop;
            //}

            //if (empty($admission->contactname)) {
            //    echo '<div class="alert alert-error">Please enter contactname in line no. "' . $linenum . '" of uploaded excelsheet.</div>';
            //    goto loop;
            //}
       
	
        $data->firstname = $admission->firstname;
        $data->middlename = $admission->middlename;
        $data->lastname = $admission->lastname;
        $data->gender = $admission->gender;
        $data->dob = $dob;
        //$data->birthcountry = $admission->birthcountry;
        //$data->birthplace = $admission->birthplace;
        $data->fathername = $admission->fathername;
        //$data->pob = $admission->pob;
        $data->caste = $admission->caste;
        $data->category = $admission->category;
        $data->otherphone = $admission->otherphone;
        $data->fatheremail = $admission->fatheremail;
        //$data->town = $admission->town;
        //$data->howlong = $admission->howlong;
        //$data->currenthno = $admission->current_home_no;
        $data->currentcountry = $admission->current_country;
        $data->phone = $admission->phone;
        $data->email = $admission->email;
        $data->mothername = $admission->mothername;
       // $data->same = $admission->same;
	// permanent address same as temporary address or current address
        //if ($data->same == 1) {
        //    $data->pcountry = $admission->current_country;
        //    $data->permenanthno = $admission->current_home_no;
        //    $data->state = $admission->region;
        //    $data->city = $admission->town;
        //    $data->pincode = $admission->pob;
        //    $data->contactname = $admission->fathername;
        //}
        //if ($data->same == 2) {
        //    $data->pcountry = $admission->permenant_country;
        //    $data->permanenthno = $admission->permenant_home_no;
        //    $data->state = $admission->state;
            $data->city = $admission->city;
            $data->pincode = $admission->pincode;
        //    $data->contactname = $admission->contactname;
       // }
        //$data->primaryschoolname = $admission->primary_school;
        //$data->primaryyear = $admission->primary_year;
        //$data->primaryscore = $admission->primary_score;
        //$data->primaryplace = $admission->primary_place;
        //$data->typeofstudent = $admission->typeofstudent;
        //international student
        //if ($data->typeofstudent == 2) {
        //    $data->examname = $admission->examname;
        //    $data->hallticketno = $admission->hallticketno;
        //    $data->score = $admission->score;
        //} elseif ($data->typeofstudent == 3) {   //mature student
        //    $data->noofmonths = $admission->no_of_months;
        //    $data->reason = $admission->reason;
        //    $data->description = $admission->description;
        //}

        $data->programid = $prgid;
        $data->typeofapplication = 1;
        
        $data->status = 0;
      //  $data->typeofprogram = $admission->typeofprogram;
        //if ($data->typeofprogram == 2) { // graduate
        //    $data->ugin = $admission->undergraduate_in;
        //    $data->ugname = $admission->ugname;
        //    $data->ugyear = $admission->ug_year;
        //    $data->ugscore = $admission->ug_score;
        //    $data->ugplace = $admission->ug_place;
        //}
        $data->previousstudent = 1;
        $data->dateofapplication = time();
	$data->uploadfile=0;
        $data->address= $admission->address;
         
        $data->id = $DB->insert_record('local_admission', $data);
	$applicantid =  $data->id;
        $program = $DB->get_field('local_program', 'shortname', array('id' => $prgid));
        $random = random_string(5);
        $update = new Stdclass();
        $update->id = $data->id;
        $update->applicationid = substr($program,0,8).$data->id.$random;
        
        
        $applicationid = $DB->update_record('local_admission', $update);
        $data->id ++;
        $admissionsnew++;

        $admission->batchid= $batchid;
        $csvfields= $admission;
	if(isset($data->id)){	  
	//  $result =$data->id;
	
	 $response = local_batches_enroll_batches($applicantid,$curriculumid,$batchid, $csvfields );
	 }
         if($response){
            $enrollablecount++;
         }
         else
            $skipped++; 
         
   } // end of while

   
      $result .= get_string('numberofenrolled', 'local_batches', $enrollablecount) . "";
      $result .= '<div class="alert alert-error">'.get_string('numberofskippedusers','local_batches', $skipped).'</div>';
   
   return $result;
}// end of  function
Example #19
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE, $hierarchy;

        $mform = $this->_form;

        $PAGE->requires->yui_module('moodle-local_scheduleexam-scheduleexamchooser', 'M.local_scheduleexam.init_scheduleexamchooser', array(array('formid' => $mform->getAttribute('id'))));
        $id = $this->_customdata['id'];

        $disable = ($id > 0) ? 'disabled="disabled"' : '';

        $hierarchy = new hierarchy();
        if (is_siteadmin($USER->id)) {
            $schools = $DB->get_records('local_school', array('visible' => 1));
        } else {
            $schools = $hierarchy->get_assignedschools();
        }

        if ($id > 0) {
            $mform->addElement('header', 'editexamheader', get_string('editexamheader', 'local_scheduleexam'));
            $mform->addHelpButton('editexamheader', 'editexamheader', 'local_scheduleexam');
        } else {
            $mform->addElement('header', 'createexamheader', get_string('createexamheader', 'local_scheduleexam'));
            $mform->addHelpButton('createexamheader', 'createexamheader', 'local_scheduleexam');
        }

        $parents = $hierarchy->get_school_parent($schools);
        $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $parents, $disable);
        if ($id < 0) {
            $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
        }
        $mform->setType('schoolid', PARAM_INT);


        $mform->registerNoSubmitButton('updatecourseformat');
        $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
        $mform->addElement('hidden', 'addsemesterslisthere');
        $mform->setType('addsemesterslisthere', PARAM_INT);
        $mform->addElement('hidden', 'addclclasseslisthere');
        $mform->setType('addclclasseslisthere', PARAM_INT);
        
        $mform->addElement('hidden', 'addcobaltcourseehere');
        $mform->setType('addcobaltcourseehere', PARAM_INT);
        
        $mform->addElement('hidden', 'addexamtypehere');
        $mform->setType('addexamtypehere', PARAM_INT);
        
        $mform->addElement('hidden', 'addexamtypeempty_msg');
        $mform->setType('addexamtypeempty_msg', PARAM_RAW);
        
        $mform->addElement('hidden', 'addlecturetypehere');
        $mform->setType('addlecturetypehere', PARAM_INT);
        
        $mform->addElement('hidden', 'addlecturetypeempty_msg');
        $mform->setType('addlecturetypeempty_msg', PARAM_RAW);
        
        $mform->addElement('date_selector', 'opendate', get_string('opendate', 'local_scheduleexam'));
        $mform->addRule('opendate', get_string('opendatereq', 'local_scheduleexam'), 'required', null, 'client');

        //*************************************************************************************************************
        $shour['null'] = 'Hour';
        for ($sthour = 0; $sthour <= 23; $sthour++) {
            if ($sthour < 10)
                $shour['0' . $sthour] = '0' . $sthour;
            else
                $shour[$sthour] = $sthour;
        }
        $smin['null'] = 'Mins';
        for ($stmin = 0; $stmin <= 59; $stmin++) {
            if ($stmin < 10)
                $smin['0' . $stmin] = '0' . $stmin;
            else
                $smin[$stmin] = $stmin;
        }

        $starttime = array();
        $starttime[] = & $mform->createElement('select', 'starttimehour', '', $shour);
        $starttime[] = & $mform->createElement('select', 'starttimemin', '', $smin);
        $mform->addGroup($starttime, 'starttimearr', get_string('starttimehour', 'local_scheduleexam'), array(' '), false);
        $mform->addRule('starttimearr', get_string('missingstarttimehour', 'local_scheduleexam'), 'required', null, 'client');

        $endtime = array();
        $endtime[] = & $mform->createElement('select', 'endtimehour', '', $shour);
        $endtime[] = & $mform->createElement('select', 'endtimemin', '', $smin);
        $mform->addGroup($endtime, 'endtimearr', get_string('endtimehour', 'local_scheduleexam'), array(' '), false);
        $mform->addRule('endtimearr', get_string('missingendtimehour', 'local_scheduleexam'), 'required', null, 'client');


        $mform->addElement('text', 'grademin', get_string('grademin', 'local_scheduleexam'), $disable);
        $mform->setType('grademin', PARAM_INT);
        if ($id < 0) {
            $mform->addRule('grademin', get_string('grademinreq', 'local_scheduleexam'), 'required', null, 'client');
            $mform->addRule('grademin', get_string('grademinnum', 'local_scheduleexam'), 'numeric', null, 'client');
        }

        $mform->addElement('text', 'grademax', get_string('grademax', 'local_scheduleexam'), $disable);
        $mform->setType('grademax', PARAM_INT);
        if ($id < 0) {
            $mform->addRule('grademax', get_string('grademaxreq', 'local_scheduleexam'), 'required', null, 'client');
            $mform->addRule('grademax', get_string('grademaxnum', 'local_scheduleexam'), 'numeric', null, 'client');
        }
//            $mform->addElement('text', 'examweightage', get_string('examweightage', 'local_scheduleexam'), $disable);
//            $mform->setType('examweightage', PARAM_INT);
//        if($id < 0){
//            $mform->addRule('examweightage', get_string('examweightagereq', 'local_scheduleexam'), 'required', null, 'client');
//            $mform->addRule('examweightage', get_string('examweightagenum', 'local_scheduleexam'), 'numeric', null, 'client');
//        }
        //*****************************************************************************************

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        if ($id < 0) {
            $this->add_action_buttons('false', 'Schedule Assessment');
        } else {
            $this->add_action_buttons('false', 'Update Assessment');
        }
    }
Example #20
0
    print_error('You dont have permissions');
}
$PAGE->set_url('/local/modules/index.php');
$string = get_string('pluginname', 'local_modules') . ':' . get_string('viewmodules', 'local_modules');
$PAGE->set_title($string);
//Header and the navigation bar
$PAGE->set_heading($SITE->fullname);
$PAGE->navbar->add(get_string('managemodule', 'local_modules'));
$PAGE->navbar->add(get_string('viewmodules', 'local_modules'));
$instance = new cobalt_modules();
//echo $OUTPUT->header();
echo $OUTPUT->header();
//Heading of the page
echo $OUTPUT->heading(get_string('managemodule', 'local_modules'));
$hier = new hierarchy();
$schools = $hier->get_assignedschools();
$currenttab = "lists";
$instance->print_tabs($currenttab, -1);

// 
// Moodle 2.2 and onwards
if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding) {
    echo $OUTPUT->box(get_string('allowframembedding', 'local_modules'));
}

$schools = $hier->get_school_parent($schools, $selected = array(), $inctop = false, $all = false);
if (is_siteadmin()) {
    $schools = $hier->get_school_items();
}

$schoollist_string = implode(',', array_keys($schools));
Example #21
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;
        $mform = $this->_form;
        //------used for editing purpose(used to put static schoolname and shortname)
        $eid = $this->_customdata['temp'];
        $hierarchy= new hierarchy();
        $PAGE->requires->yui_module('moodle-local_prefix-hideshow', 'M.local_prefix.init_hideshow', array(array('formid' => $mform->getAttribute('id'))));
        if ($eid->id > 0)
            $mform->addElement('header', 'settingsheader', get_string('editprefix_settings', 'local_prefix'));
        else
            $mform->addElement('header', 'settingsheader', get_string('prefixs', 'local_prefix'));

        $prefix = prefix_suffix::getInstance();
        $entitylist = $hierarchy->get_records_cobaltselect_menu('local_create_entity', '', null, '', 'id,entity_name', '--Select--');
        $mform->addElement('select', 'entityid', get_string('entityid', 'local_prefix'), $entitylist);
        $mform->addRule('entityid', get_string('entityid', 'local_prefix'), 'required', null, 'client');
        //------used for editing purpose(used to put static schoolname )
        if ($eid->id > 0) {
            $school = $DB->get_record('local_school', array('id' => $eid->schoolid));
            $mform->addElement('static', 'esid', get_string('select', 'local_collegestructure'), $school->fullname);

            $program = $DB->get_record('local_program', array('id' => $eid->programid));
            $mform->addElement('static', 'epid', get_string('selectprogram', 'local_programs'), $program->fullname);
        } else {
            $hier = new hierarchy();
            if (is_siteadmin($USER->id)) {
                $schoolids = $DB->get_records('local_school', array('visible' => 1));
            } else {
                $schoolids = $hier->get_assignedschools();
            }
            $count = sizeof($schoolids);
            if ($count > 1) {
                $items = $hier->get_school_items();
                $parents = $hier->get_school_parent($schoolids, '', true);
                $mform->addElement('select', 'schoolid', get_string('select', 'local_collegestructure'), $parents);
                $mform->addRule('schoolid', get_string('select', 'local_collegestructure'), 'required', null, 'client');
                $mform->registerNoSubmitButton('updatecourseformat');
                $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
            } else {
                  
                 foreach($schoolids as $sid){
                  $schoolid=$sid->id;
                  $schoolname=$sid->fullname;
                }          
                $mform->addElement('static', 'sid', get_string('schoolid', 'local_collegestructure'), $schoolname);
                $mform->addElement('hidden', 'schoolid', $schoolid);
            }
        }

        $mform->setType('schoolid', PARAM_INT);
        $mform->addElement('hidden', 'addprogramlisthere');
        $mform->setType('addprogramlisthere', PARAM_INT);

        $mform->addElement('text', 'sequence_no', get_string('sequence', 'local_prefix'));
        $mform->addRule('sequence_no', get_string('spaces', 'local_prefix'), 'regex', '/[^ ]+/', 'client');
        $mform->addRule('sequence_no', get_string('num', 'local_prefix'), 'numeric', null, 'client');
        $mform->addRule('sequence_no', get_string('seq1', 'local_prefix'), 'required', null, 'client');
        $mform->setType('sequence_no', PARAM_RAW);

        $mform->addElement('text', 'prefix', get_string('prefix', 'local_prefix'));
        $mform->addRule('prefix', get_string('spaces', 'local_prefix'), 'regex', '/[^ ]+/', 'client');
        $mform->addRule('prefix', get_string('pre1', 'local_prefix'), 'required', null, 'client');
        $mform->setType('prefix', PARAM_RAW);

        $mform->addElement('text', 'suffix', get_string('suffix', 'local_prefix'));
        $mform->addRule('suffix', get_string('spaces', 'local_prefix'), 'regex', '/[^ ]+/', 'client');
        $mform->addRule('suffix', get_string('suf1', 'local_prefix'), 'required', null, 'client');
        $mform->setType('suffix', PARAM_RAW);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $mform->addElement('hidden', 'page');
        $mform->setType('page', PARAM_INT);
        $i = get_string('submit', 'local_prefix');

        $this->add_action_buttons(true, 'Submit');
    }
Example #22
0
    public function definition() {
        global $CFG, $DB, $PAGE, $USER;
        $mform = & $this->_form;
        /*  Bug report #304 -Edit Class>Short Name- Error
         * @author hemalatha c arun <*****@*****.**>
         * Resolved- added valid condition avoiding duplication of shortname and also updated strings
         */
        $id = $this->_customdata['id'];
        $PAGE->requires->yui_module('moodle-local_clclasses-chooser', 'M.local_clclasses.init_chooser', array(array('formid' => $mform->getAttribute('id'))));
        $hierarchy = new hierarchy();
        if (is_siteadmin()) {
            $scho = $hierarchy->get_school_items();
        } else {
            $scho = $hierarchy->get_assignedschools();
        }
        $count = count($scho);
        $school = $hierarchy->get_school_parent($scho);

        $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $school);
        $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
        $mform->setType('schoolid', PARAM_RAW);

        $mform->registerNoSubmitButton('updatecourseformat');
        $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));

        $mform->addElement('hidden', 'addsemesterlisthere');
        $mform->setType('addsemesterlisthere', PARAM_RAW);

        $mform->addElement('hidden', 'adddepartmentlisthere');
        $mform->setType('adddepartmentlisthere', PARAM_RAW);
        $style = "style='height:25px !important;'";
        $mform->addElement('hidden', 'adddepartmentemptymsg');
        $mform->setType('adddepartmentemptymsg', PARAM_RAW);

        $mform->addElement('hidden', 'addcobaltcoursehere');
        $mform->setType('addcobaltcoursehere', PARAM_RAW);


        $mform->addElement('text', 'fullname', get_string('classesname', 'local_clclasses'), $style);
        $mform->addHelpButton('fullname', 'classesname', 'local_clclasses');
        $mform->addRule('fullname', get_string('missingclassesname', 'local_clclasses'), 'required', null, 'client');
        $mform->setType('fullname', PARAM_RAW);

        $mform->addElement('text', 'shortname', get_string('classesshortname', 'local_clclasses'), $style);
        $mform->addHelpButton('shortname', 'classesshortname', 'local_clclasses');
        $mform->addRule('shortname', get_string('missingclassesshort', 'local_clclasses'), 'required', null, 'client');
        $mform->setType('shortname', PARAM_RAW);



        $mform->addElement('text', 'classlimit', get_string('classlimit', 'local_clclasses'), $style);
        $mform->addHelpButton('classlimit', 'classlimit', 'local_clclasses');
        $mform->addRule('classlimit', get_string('missinglimit', 'local_clclasses'), 'required', null, 'client');
        $mform->addRule('classlimit', get_string('numeric', 'local_admission'), 'numeric', null, 'client');
        $mform->setType('classlimit', PARAM_RAW);

        $selecttype = array();
        $selecttype['1'] = get_string('clsmode_1', 'local_clclasses');
        $selecttype['2'] = get_string('clsmode_2', 'local_clclasses');
        $mform->addElement('select', 'type', get_string('classmode', 'local_clclasses'), $selecttype);
        $mform->addHelpButton('type', 'classmode', 'local_clclasses');
        $mform->addRule('type', get_string('missingtype', 'local_clclasses'), 'required', null, 'client');
        $mform->setType('type', PARAM_INT);



        $mform->addElement('hidden', 'addonlinelisthere');
        $mform->setType('addonlinelisthere', PARAM_RAW);

        $mform->addElement('hidden', 'addonlinecoursehere');
        $mform->setType('addonlinecoursehere', PARAM_RAW);


        $mform->addElement('hidden', 'addinstructorhere');
        $mform->setType('addinstructorhere', PARAM_RAW);


        $mform->addElement('editor', 'description', get_string('description', 'local_clclasses'), null);
        $mform->setType('description', PARAM_RAW);

        /* $style="style='height:25px !important;'";
          $mform->addElement('text', 'fullname', get_string('classesname', 'local_clclasses'),$style);
          $mform->addHelpButton('fullname', 'classesname', 'local_clclasses');
          $mform->addRule('fullname', get_string('missingclassesname','local_clclasses'), 'required', null, 'client');
          $mform->setType('fullname', PARAM_RAW);

          $mform->addElement('text', 'shortname', get_string('classesshortname', 'local_clclasses'),$style);
          $mform->addHelpButton('shortname', 'classesshortname', 'local_clclasses');
          $mform->addRule('shortname', get_string('missingclassesshort','local_clclasses'), 'required', null, 'client');
          $mform->setType('shortname', PARAM_RAW);

          $mform->addElement('editor', 'description', get_string('description', 'local_clclasses'), null, $editoroptions);
          $mform->setType('description', PARAM_RAW);

          $mform->addElement('text', 'classlimit',get_string('classlimit','local_clclasses'),$style);
          $mform->addHelpButton('classlimit', 'classlimit', 'local_clclasses');
          $mform->addRule('classlimit', get_string('missinglimit','local_clclasses'), 'required', null, 'client');
          $mform->addRule('classlimit', get_string('numeric','local_admission'), 'numeric', null,'client');
          $mform->setType('classlimit', PARAM_RAW);

          $selecttype=array();
          $selecttype['1']=get_string('clsmode_1','local_clclasses');
          $selecttype['2']=get_string('clsmode_2','local_clclasses');
          $mform->addElement('select', 'type',get_string('classmode','local_clclasses'),$selecttype);
          $mform->addHelpButton('type', 'classmode', 'local_clclasses');
          $mform->addRule('type', get_string('missingtype','local_clclasses'), 'required', null, 'client');
          $mform->setType('type', PARAM_INT); */

        $mform->addElement('html', '<div id="myratings1"></div>');
        $mform->addElement('html', '<div id="myratings2"></div>');
        $submit = get_string('createclasses', 'local_clclasses');

        $time = time();
        $userid = $USER->id;
        $mform->addElement('hidden', 'timecreated', $time);
        $mform->setType('timecreated', PARAM_INT);

        $mform->addElement('hidden', 'timemodified', $time);
        $mform->setType('timemodified', PARAM_INT);

        $mform->addElement('hidden', 'usermodified', $userid);
        $mform->setType('usermodified', PARAM_INT);


        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $actionbutton = ($id > 0) ? get_string('updateclass', 'local_clclasses') : get_string('createclasses', 'local_clclasses');


        $this->add_action_buttons($cancel = true, $actionbutton);
    }
Example #23
0
 /**
  * @method  school_formelement_condition
  * @todo to display school field form element based on condition (if multiple school providing drop down box else static field)
  * @param object $mform    
  * @return array of objects(form elements)
  */
 public function school_formelement_condition($mform) {
     global $DB, $CFG, $USER;
     $hier = new hierarchy();
     if (is_siteadmin($USER->id)) {
         $schoolids = $DB->get_records('local_school', array('visible' => 1));
     } else
         $schoolids = $hier->get_assignedschools();
     if (!empty($schoolids)) {
         $count = sizeof($schoolids);
         if ($count > 1) {
             $parents = $hier->get_school_parent($schoolids, '', true);
             $mform->addElement('select', 'schoolid', get_string('select', 'local_collegestructure'), $parents);
             $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
         } else {
             $schoolname = $DB->get_record('local_school', array('id' => $schoolids[0]->id));
             $mform->addElement('static', 'sid', get_string('schoolid', 'local_collegestructure'), $schoolname->fullname);
             $mform->addElement('hidden', 'schoolid', $schoolids[0]->id);
         }
         $mform->setType('schoolid', PARAM_INT);
     }
 }
Example #24
0
    /**
     * @method settingelements
     * @todo to set form elements
     * @param object $mform object
     * @param string $place1
     * @param string $place2 
     * @return array of objects ($mfrom objects)
     * */
    public function settingelements($mform, $place1, $place2) {
        global $hierarchy;
        $hierarchy = new hierarchy();
        $faculties = $hierarchy->get_assignedschools();
        $school = $hierarchy->get_school_parent($faculties);
        $newel = $mform->createElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $school);
        $mform->insertElementBefore($newel, $place1);
        $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
        $school_value = $mform->getElementValue('schoolid');

        //Creating program element after getting the school value
        if (isset($school_value) && !empty($school_value)) {
            $school_id = $school_value[0];
            $programs = $hierarchy->get_records_cobaltselect_menu('local_program', "schoolid=$school_id AND visible=1", null, '', 'id,fullname', '--Select--');
            $newel2 = $mform->createElement('select', 'programid', get_string('selectprogram', 'local_programs'), $programs);
            $mform->insertElementBefore($newel2, $place2);
            $mform->addRule('programid', get_string('missingfullname', 'local_programs'), 'required', null, 'client');
            $program_value = $mform->getElementValue('programid');
            return $program_value;
        }
    }
Example #25
0
function get_events() {
    global $DB, $CFG, $USER;
    $systemcontext = get_context_instance(CONTEXT_SYSTEM);
    ?>
    <?php

    if (is_siteadmin()) {
$time = time();

        $sql = 'select * from {local_event_activities} where FROM_UNIXTIME("%d-%m-%y",startdate) >= FROM_UNIXTIME("%d-%m-%y",'.$time.') OR 
              FROM_UNIXTIME("%d-%m-%y",'.$time.') <= FROM_UNIXTIME("%d-%m-%y",enddate) LIMIT 0,3';
        
        $eactivities = $DB->get_records_sql($sql);
        if (!empty($eactivities)) {
            $data = array();
			$i = 1;
            foreach ($eactivities as $eactivity) {
				if($i > 3){
					break;
				}
                $line = array();
                $eactivity->startdate = date('d-m-Y', $eactivity->startdate);
                $startdate = $eactivity->startdate;
                $eactivity->enddate > 0 ? $eactivity->enddate = date('d-m-Y', $eactivity->enddate) : $eactivity->enddate = '';
                $enddate = $eactivity->enddate;
                $view = new moodle_url('' . $CFG->wwwroot . '/local/academiccalendar/viewevent.php', array('id' => $eactivity->id));
                $line[] = html_writer::link($view, $eactivity->eventtitle);
                if ($enddate) {
                    $line[] = $startdate . '&nbsp;&nbsp;-&nbsp;&nbsp;' . $enddate;
                } else {
                    $line[] = $startdate;
                }
				$i++;
                $data[] = $line;
            }
            $table = new html_table();
            $table->head = array(
                get_string('eventtitle', 'local_academiccalendar'),
                'Date'
            );
            $table->width = '100%';
            $table->align = array('left','left');
            $table->size = array('50%','50%');
            $table->data = $data;
            $string = html_writer::table($table);
			if(sizeof($data) > 3)
				$string.='<a href="../local/academiccalendar/index.php">View more...</a>';
            return $string;
        } else {
            $string = '<p>No events created till now.</p>';
            return $string;
        } 
    } elseif (has_capability('local/collegestructure:manage', $systemcontext) && !is_siteadmin()) {
        $hier = new hierarchy();
        $time = time();
        $schoolslist = $hier->get_assignedschools();
        $array = array();
        $schools = $hier->get_school_parent($schoolslist, $array, false, false);
        foreach ($schools as $key => $value) {
		if($key!=null) {
            $schoollist[] = $key;
			}
        }
        $schoollist_string = implode(',', $schoollist);
        $sql = "select * from {local_event_activities} where eventlevel=2 and schoolid in ( $schoollist_string ) and (FROM_UNIXTIME('%d-%m-%y',startdate) >= FROM_UNIXTIME('%d-%m-%y',$time) OR 
              FROM_UNIXTIME('%d-%m-%y',$time) <= FROM_UNIXTIME('%d-%m-%y',enddate)) LIMIT 0,3";
        $eactivities = $DB->get_records_sql($sql);
        if (!empty($eactivities)) {
            $data = array();
            foreach ($eactivities as $eactivity) {
                $line = array();
                $eactivity->startdate = date('d-m-Y', $eactivity->startdate);
                $startdate = $eactivity->startdate;
                $eactivity->enddate > 0 ? $eactivity->enddate = date('d M Y', $eactivity->enddate) : $eactivity->enddate = '';
                $enddate = $eactivity->enddate;
                $view = new moodle_url('' . $CFG->wwwroot . '/local/academiccalendar/viewevent.php', array('id' => $eactivity->id));
                $line[] = html_writer::link($view, $eactivity->eventtitle);
                if ($enddate) {
                    $line[] = $startdate . '&nbsp;&nbsp;-&nbsp;&nbsp;' . $enddate;
                } else {
                    $line[] = $startdate;
                }
                $data[] = $line;
            } 
            $table = new html_table();
            $table->head = array(
                get_string('eventtitle', 'local_academiccalendar'),
                'Date'
                
            );
            $table->width = '100%';
            $table->align = array('left', 'left');
            $table->size = array('50%', '50%');
            $table->data = $data;
            $string = html_writer::table($table);
            return $string;
        } else {
            $string = '<p>No events created till now.</p>';
            return $string;
        }
    } else {
        $time = time();
        $userdetails = $DB->get_records('local_userdata', array('userid' => $USER->id));
        if ($userdetails) {
            foreach ($userdetails as $userdetail) {
                $schoollist[] = $userdetail->schoolid;
                $programlist[] = $userdetail->programid;
            }
            $schoollist_string = implode(',', $schoollist);
            $programlist_string = implode(',', $programlist);
//            $string = '<div id="event_tabs">
//		<ul>
//		<li><a href="#fragment-3"><span>Academic Events</span></a></li>
//		<li><a href="#fragment-2"><span>Global Events</span></a></li>
//		</ul>';
//
//            $string.='<div id="fragment-3">';
//            $sql = 'select * from {local_event_activities} where (FROM_UNIXTIME("%d-%m-%y",startdate) >= FROM_UNIXTIME("%d-%m-%y",'.$time.') OR 
//              FROM_UNIXTIME("%d-%m-%y",'.$time.') <= FROM_UNIXTIME("%d-%m-%y",enddate)) and 
//                                     (eventlevel=2 and schoolid in (' . $schoollist_string . ')) OR
//                                     (
//                                     eventlevel=3 and schoolid in (' . $schoollist_string . ') AND
//                                     programid in (' . $programlist_string . ')
//                                     ) LIMIT 0,3';
//
//            $eactivities1 = $DB->get_records_sql($sql);
//
//            $data = array();
//            foreach ($eactivities1 as $eactivity) {
//                $line = array();
//                $eactivity->startdate = strtoupper(date('d-M-Y', $eactivity->startdate));
//                $startdate = $eactivity->startdate;
//                $eactivity->enddate > 0 ? $eactivity->enddate = strtoupper(date('d-M-Y', $eactivity->enddate)) : $eactivity->enddate = '';
//                $enddate = $eactivity->enddate;
//                $view = new moodle_url('' . $CFG->wwwroot . '/local/academiccalendar/viewevent.php', array('id' => $eactivity->id));
//                $line[] = html_writer::link($view, $eactivity->eventtitle);
//                if ($enddate) {
//                    $line[] = $startdate . '&nbsp;&nbsp;-&nbsp;&nbsp;' . $enddate;
//                } else {
//                    $line[] = $startdate;
//                }
//                $data[] = $line;
//            }
//            $table = new html_table();
//            $table->head = array(
//                get_string('eventtitle', 'local_academiccalendar'),
//                get_string('date', 'block_classrooms')
////                                   get_string('enddate','local_academiccalendar')
//            );
//            $table->width = '100%';
//            $table->align = array('left', 'center');
//            $table->size = array('50%', '50%');
//            $table->data = $data;
//            $string.= html_writer::table($table);
//            if($data)
//                $string .= '<a href="' . $CFG->wwwroot . '/local/academiccalendar/index.php" > View All </a> ';
//            else
//                $string .= '<p>No events created.</p>';
//            $string.='</div>';
//            
//            $string.='<div id="fragment-2">';
            $sql = 'select * from {local_event_activities} where eventlevel=1 and (FROM_UNIXTIME("%d-%m-%y",startdate) >= FROM_UNIXTIME("%d-%m-%y",'.$time.') OR 
              FROM_UNIXTIME("%d-%m-%y",'.$time.') <= FROM_UNIXTIME("%d-%m-%y",enddate)) LIMIT 0,3';
            $eactivities = $DB->get_records_sql($sql);
            $data1 = array();
            foreach ($eactivities as $eactivity) {
                $line1 = array();
                $eactivity->startdate = strtoupper(date('d-M-Y', $eactivity->startdate));
                $startdate = $eactivity->startdate;
                $eactivity->enddate > 0 ? $eactivity->enddate = strtoupper(date('d-M-Y', $eactivity->enddate)) : $eactivity->enddate = '';
                $enddate = $eactivity->enddate;
                $view = new moodle_url('' . $CFG->wwwroot . '/local/academiccalendar/viewevent.php', array('id' => $eactivity->id));
                $line1[] = html_writer::link($view, $eactivity->eventtitle);
                if ($enddate) {
                    $line1[] = $startdate . '&nbsp;&nbsp;-&nbsp;&nbsp;' . $enddate;
                } else {
                    $line1[] = $startdate;
                }
//				$line1[] =  $enddate;
                $data1[] = $line1;
            }
            $table1 = new html_table();
            $table1->head = array(
                get_string('eventtitle', 'local_academiccalendar'),
                'Date'
//                                   get_string('enddate','local_academiccalendar')
            );
            $table1->width = '100%';
            $table1->align = array('left', 'center');
            $table1->size = array('50%', '50%');
            $table1->data = $data1;
            $string.= html_writer::table($table1);
            if($data1)
                $string .= '<a href="' . $CFG->wwwroot . '/local/academiccalendar/index.php" > View All </a> ';
            else
                $string .= '<p>No events created.</p>';
            //$string.='</div>';
            //$string .= '</div>';
            return $string;
        }
        else
            $string = '<p>You are not registered to any type of courses.</p>';
        return $string;
    }
    ?>
<?php } ?>
Example #26
0
 function get_usercount($extraselect = '', array $extraparams = null)
 {
     global $DB, $CFG, $SESSION;
     $select = " u.id <> :guestid AND u.deleted = 0";
     $params = array('guestid' => $CFG->siteguest);
     if ($extraselect) {
         $select .= " AND {$extraselect}";
         $params = $params + (array) $extraparams;
     }
     if (isset($SESSION->user_filtering['courseid'])) {
         $sql = "SELECT u.* FROM {user_enrolments} ue\n\t\t\t\t\t\t\t\t\t\tJOIN {enrol} e ON e.id = ue.enrolid\n\t\t\t\t\t\t\t\t\t\tJOIN {user} u ON u.id = ue.userid\n\t\t\t\t\t\t\t\t\t\tJOIN {course} c ON c.id = e.courseid\n\t\t\t\t\t\t\t\t\t\tWHERE c.visible = 1 AND ue.status = 0 AND {$select}";
         $users = $DB->get_records_sql($sql, $params);
     } else {
         $users = $DB->get_records_sql("SELECT u.*, lu.rosterid\n\t\t\t\t\t\t\t   FROM {user} u\n\t\t\t\t\t\t\t   JOIN {local_users} lu ON lu.userid = u.id\n\t\t\t\t\t\t\t   WHERE {$select}", $params);
     }
     $records = array();
     if (!empty($users)) {
         $useridin = implode(',', array_keys($users));
         $hierarchy = new hierarchy();
         $schoollist = $hierarchy->get_assignedschools();
         $schoollist = $hierarchy->get_school_parent($schoollist, $selected = array(), $inctop = false, $all = false);
         if (is_siteadmin()) {
             $schoollist = $hierarchy->get_school_items();
         }
         if (!empty($schoollist)) {
             $schoolidin = implode(',', array_keys($schoollist));
             $records = $DB->get_records_sql("(SELECT u.* FROM {user} u\n                                         JOIN {local_users} lu ON lu.userid = u.id\n                                         JOIN {local_school_permissions} sp ON sp.userid = u.id\n\n                                         WHERE u.id in ({$useridin}) AND sp.schoolid IN ({$schoolidin}))\n                                         UNION\n                                         (SELECT u.* FROM {user} u\n                                         JOIN {local_users} lu ON lu.userid = u.id\n                                         JOIN {local_userdata} ud ON ud.userid = u.id\n                                        WHERE u.id in ({$useridin}) AND ud.schoolid IN ({$schoolidin}))");
         }
     }
     return sizeof($records);
 }
Example #27
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;
        $hierarchy = new hierarchy();
        $mform = $this->_form;
        $id = $this->_customdata['id'];
        $mform->addElement('header', 'settingsheader', get_string('accountingperiod', 'local_onlinepayment'));
        $schoollist = $hierarchy->get_assignedschools();
        if (is_siteadmin()) {
            $schoollist = $hierarchy->get_school_items();
        }
        $schoollist = $hierarchy->get_school_parent($schoollist, $selected = array(), $inctop = true, $all = false);
        if ($id < 0) {
            $mform->addElement('select', 'schoolid', get_string('select', 'local_collegestructure'), $schoollist);
            $mform->setType('schoolid', PARAM_INT);
            $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
        } else {
            $mform->addElement('static', 'school_name', get_string('schoolname', 'local_collegestructure'));
            $mform->addElement('hidden', 'schoolid');
            $mform->setType('schoolid', PARAM_INT);
        }
        $mform->addElement('date_selector', 'datefrom', get_string('startdate', 'local_academiccalendar'), array('optional' => true));
        $mform->addElement('date_selector', 'dateto', get_string('enddate', 'local_academiccalendar'), array('optional' => true));
        $mform->addRule('datefrom', get_string('missingstartdate', 'local_academiccalendar'), 'required', null, 'client');
        $mform->addRule('dateto', get_string('missingenddate', 'local_academiccalendar'), 'required', null, 'client');

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $buttonarray = array();
        $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('submit'));
        $buttonarray[] = &$mform->createElement('cancel');
        $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
    }
Example #28
0
    $yesurl = new moodle_url('/local/curriculum/assigncourses.php', array('id' => $id, 'mode' => $mode, 'cid' => $cid, 'unassign' => 1, 'courseid' => $courseid, 'confirm' => 1, 'sesskey' => sesskey()));
    $message = get_string('confirmunassign', 'local_curriculum');
    echo $OUTPUT->confirm($message, $yesurl, $returnurl);
    echo $OUTPUT->footer();
    die;
}

//page breadcrumb and header
$PAGE->navbar->add(get_string('managecurriculum', 'local_curriculum'), new moodle_url('/local/curriculum/index.php', array('id' => $cid)));
if ($id)
    $PAGE->navbar->add(get_string('manageplan', 'local_curriculum'), new moodle_url('/local/curriculum/viewcurriculum.php', array('id' => $cid, 'assign' => 1)));
$PAGE->navbar->add(get_string('assigncourses', 'local_curriculum'));
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('managecurriculum', 'local_curriculum'));
//try{
$schoollist = $hierarchy->get_assignedschools();
if (is_siteadmin()) {
    $schoollist = $hierarchy->get_school_items();
}
$count = count($schoollist); //Count of schools to which registrar is assigned
if ($count < 1) {
    throw new Exception(get_string('notassignedschool', 'local_collegestructure'));
}
//Tab view
$curriculum = new curricula();
$curriculum->print_curriculumtabs($mode);

if ($id)
    $plan = $DB->get_record('local_curriculum_plan', array('id' => $id));
$cur = $DB->get_record('local_curriculum', array('id' => $cid));
if ($id)
Example #29
0
 /**
  * @method ac_hierarchyelements
  * @todo creates hierarchy elements in form (school,program and semester)
  * @param1 object $mform  (form object)
  * @param2 string $place1 (element1 position)
  * @param3 string $place2 (element2 position)
  * @param4 int $eventlevel (event level ID)
  * @param5 int $eventtypeid (event type ID)
  * @return form elments add to form 
  */
 public function ac_hierarchyelements($mform, $place1, $place2, $eventlevel, $eventtype) {
     global $USER, $DB;
     $hierarchy = new hierarchy();
     if ($eventlevel != 1) {
         $isadmin = is_siteadmin($USER);
         if ($isadmin) {
             $school = $hierarchy->get_records_cobaltselect_menu('local_school', 'visible=1', null, '', 'id,fullname', '--Select--');
         } else {
             $faculties = $hierarchy->get_assignedschools();
             $school = $hierarchy->get_school_parent($faculties, null, true, false);
         }
         $newel = $mform->createElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $school);
         $mform->insertElementBefore($newel, $place1);
         $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
         $school_value = $mform->getElementValue('schoolid');
     }
     /* ---Creating program element after getting the school value--- */
     if (isset($school_value) && !empty($school_value) && $school_value[0] > 0 && $eventlevel == 3) {
         $school_id = $school_value[0];
         $programs = $hierarchy->get_records_cobaltselect_menu('local_program', "schoolid=$school_value[0] AND visible=1", null, '', 'id,fullname', '--Select--');
         $newel2 = $mform->createElement('select', 'programid', get_string('program', 'local_programs'), $programs);
         $mform->insertElementBefore($newel2, $place2);
         $mform->addRule('programid', get_string('missingfullname', 'local_programs'), 'required', null, 'client');
         $program_value = $mform->getElementValue('programid');
         return $program_value;
     }
     if (isset($school_value) && !empty($school_value) && $school_value[0] > 0 && $eventlevel == 4) {
         $school_id = $school_value[0];
         //if ($eventtype == 2)
         //    $semesters = $hierarchy->get_upcoming_school_semesters($school_id);
         //else
             $semesters = $hierarchy->get_school_semesters($school_id);
         $newel2 = $mform->createElement('select', 'semesterid', get_string('semester', 'local_semesters'), $semesters);
         $mform->insertElementBefore($newel2, $place2);
         $mform->addRule('semesterid', get_string('semester_help', 'local_semesters'), 'required', null, 'client');
         $sem_value = $mform->getElementValue('semesterid');
         if($sem_value[0]){
            $this->static_description_dateselection($mform, $sem_value[0],$eventtype,$school_id,1);
         }
         return $sem_value;
     }
 }