Exemple #1
0
    public function definition() {
        global $USER, $CFG, $PAGE;
        $school = new school();
        $mform = $this->_form;
        $id = $this->_customdata['id'];
        $schools = $this->_customdata['tool'];
        $editoroptions = $this->_customdata['editoroptions'];
        if ($id < 0)
            $mform->addElement('header', 'settingsheader', get_string('createschool', 'local_collegestructure'));
        else
            $mform->addElement('header', 'settingsheader', get_string('editschool', 'local_collegestructure'));
        $tools = array();
        $hierarchy = new hierarchy();
        $items = $hierarchy->get_school_items(true);
        $parents = $hierarchy->get_school_parent($items, $schools->id);
        if (count($parents) <= 1) {
            $mform->addElement('hidden', 'parentid', 0);
            $mform->setType('parentid', PARAM_RAW);
        } else {
            $mform->addElement('select', 'parentid', get_string('parent', 'local_collegestructure'), $parents);
            $mform->setType('parentid', PARAM_RAW);
        }
        $mform->addHelpButton('parentid', 'parent', 'local_collegestructure');
        $mform->addElement('text', 'fullname', get_string('schoolname', 'local_collegestructure'), $tools);
        $mform->setType('fullname', PARAM_TEXT);
        $mform->addRule('fullname', get_string('missingschoolname', 'local_collegestructure'), 'required', null, 'client');

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

        $selecttype = array();
        $selecttype['1'] = get_string('campus', 'local_collegestructure');
        $selecttype['2'] = get_string('university', 'local_collegestructure');
        $selecttype['3'] = get_string('location', 'local_collegestructure');
        $mform->addElement('select', 'type', get_string('type', 'local_collegestructure'), $selecttype);
        $mform->addHelpButton('type', 'type', 'local_collegestructure');
        $mform->setType('type', PARAM_RAW);
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $now = date("d-m-Y");
        $now = strtotime($now);
        $mform->addElement('hidden', 'timecreated', $now);
        $mform->setType('timecreated', PARAM_RAW);
        $mform->addElement('hidden', 'usermodified', $USER->id);
        $mform->setType('usermodified', PARAM_RAW);
        $themelist = $school->cobalt_get_theme_list();
        $mform->addElement('select', 'theme', get_string('theme', 'local_collegestructure'), $themelist);
        $mform->setType('theme', PARAM_RAW);
        $mform->addRule('theme', get_string('missingtheme', 'local_collegestructure'), 'required', null, 'client');
        $submit = ($id > 0) ? get_string('update_school', 'local_collegestructure') : get_string('create', 'local_collegestructure');
        $this->add_action_buttons('false', $submit);
    }
Exemple #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;
}
Exemple #3
0
    public function definition() {
        global $USER, $CFG, $PAGE;
        $id = optional_param('id', -1, PARAM_INT);
        $hierarchy = new hierarchy();
        $mform = $this->_form;
        if ($id < 0)
            $PAGE->requires->yui_module('moodle-local_modules-schoolchooser', 'M.local_modules.init_schoolchooser', array(array('formid' => $mform->getAttribute('id'))));
        $editoroptions = $this->_customdata['editoroptions'];
        $items = $hierarchy->get_school_items();
        $school = $hierarchy->get_school_parent($items);
        $editoroptions = $this->_customdata['editoroptions'];
        if ($id > 0)
            $mform->addElement('header', 'settingsheader', get_string('editmodule', 'local_modules'));
        else
            $mform->addElement('header', 'settingsheader', get_string('createmodule', 'local_modules'));
        if ($id < 0) {

            $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('updateschoolformat');
            $mform->addElement('submit', 'updateschoolformat', get_string('courseformatudpate'));
            $mform->addElement('hidden', 'addprogramslisthere');
            $mform->setType('addprogramslisthere', PARAM_RAW);
        }

        if ($id > 0) {
            $mform->addElement('static', 'school_name', get_string('schoolid', 'local_collegestructure'));
            $mform->addElement('hidden', 'schoolid');
            $mform->setType('schoolid', PARAM_RAW);
            $mform->addElement('static', 'program_name', get_string('programname', 'local_programs'));
            $mform->addElement('hidden', 'programid');
            $mform->setType('programid', PARAM_RAW);
        }
        $tools = array();
        $mform->addElement('text', 'fullname', get_string('modulename', 'local_modules'), $tools);
        $mform->addRule('fullname', get_string('missingmodulename', 'local_modules'), 'required', null, 'client');
        $mform->setType('fullname', PARAM_RAW);
        $mform->addElement('editor', 'description', get_string('description', 'local_modules'), null, $editoroptions);
        $mform->setType('description', PARAM_RAW);

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

        $submitlable = ($id > 0) ? get_string('savemodule', 'local_modules') : get_string('createmodule', 'local_modules');
        $this->add_action_buttons($cancel = true, $submitlable);
        // $this->add_action_buttons();
    }
Exemple #4
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);
    }
Exemple #5
0
 function definition() {
     global $USER, $CFG, $DB, $PAGE;
     $id = optional_param('id', -1, PARAM_INT);
     $hierarchy = new hierarchy();
     $instance = new cobalt_examtype();
     $mform = $this->_form;
     $editoroptions = $this->_customdata['editoroptions'];
     if ($id > 0)
         $mform->addElement('header', 'settingsheader', get_string('editexamtype', 'local_examtype'));
     else
         $mform->addElement('header', 'settingsheader', get_string('addeditexamtype', 'local_examtype'));
     $items = $hierarchy->get_school_items();
     $school = $hierarchy->get_school_parent($items);
     if ($id < 0) {
         $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);
     }
     if ($id > 0) {
         $mform->addElement('static', 'school_name', get_string('schoolid', 'local_collegestructure'));
         $mform->addElement('hidden', 'schoolid');
         $mform->setType('schoolid', PARAM_RAW);
     }
     $mform->addElement('text', 'examtype', get_string('examtype', 'local_examtype'));
     $mform->addRule('examtype', get_string('examtypereq', 'local_examtype'), 'required', null, 'client');
     $mform->setType('examtype', PARAM_RAW);
     $mform->addElement('editor', 'description', get_string('description', 'local_examtype'), null, $editoroptions);
     $mform->setType('description', PARAM_RAW);
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     if ($id < 0)
         $save = get_string('addeditexamtype', 'local_examtype');
     else
         $save = get_string('updateexamtype', 'local_examtype');
     $this->add_action_buttons(true, $save);
 }
Exemple #6
0
<?php

require_once(dirname(__FILE__) . '/../../config.php');
global $CFG, $DB, $PAGE, $USER;
require_once($CFG->dirroot . '/local/classroomresources/lib.php');
require_once($CFG->dirroot . '/local/classroomresources/resource_form.php');
$id = optional_param('id', -1, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$visible = optional_param('visible', -1, PARAM_INT);
$linkschool = optional_param('linkschool', 0, PARAM_INT);
$hierarchy = new hierarchy();


//error handling 
$hierarchy->get_school_items();

$conf = new object();
$currenttab = 'create';
$systemcontext = context_system::instance();
if ($id > 0) {

    if (!($tool = $DB->get_record('local_building', array('id' => $id)))) {
        throw new exception(get_string('invalidtoolid', 'local_building'));
    } else {
        $tool->schoolid = $DB->get_field('local_school', 'fullname', array('id' => $tool->schoolid));
        $tool->description = array('text' => $tool->description, 'format' => FORMAT_HTML);
    }
} else {
    $tool = new stdClass();
    $tool->id = -1;
Exemple #7
0
//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));
if (empty($schoollist_string)) {
    echo get_string('no_records', 'local_request');

    echo $OUTPUT->footer();
    die;
}
$tools = $DB->get_records_sql('select * from {local_module} where schoolid in (' . $schoollist_string . ')');
$data = array();
$capabilities_array = array('local/modules:manage', 'local/modules:delete', 'local/modules:update', 'local/modules:visible');
$assigncourse_cap = array('local/modules:manage', 'local/modules:assigncourse');
foreach ($tools as $tool) {
    $line = array();
Exemple #8
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);
    }
Exemple #9
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);
    }
    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);
    }
Exemple #11
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);
 }
Exemple #12
0
if (!empty($approve) && !empty($classid)) {

    registrarapprovecourse($userid, $classid);
}
if (!empty($reject) && !empty($classid)) {

    registrarrejectcourse($userid, $classid);
}

/*
 * ###Bugreport #174-Course Approvals
 * @author Naveen Kumar<*****@*****.**>
 * (Resolved) Retreiving assigned schools clclasses only
 */
$hierarchy = new hierarchy();
$assigned_schools = $hierarchy->get_school_items();

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

foreach ($assigned_schools as $assignedschool) {
    $asarray[] = $assignedschool->id;
}
$assignedschoolstring = implode(',', $asarray);
// $compare_scale_clause = $DB->sql_compare_text("event")  . ' != ' . $DB->sql_compare_text(":et");
$query = "SELECT c.id as userclassid,lc.*,
                cc.id AS courseid,
                c.classid AS classid,
                c.userid AS userid,c.event,
Exemple #13
0
$semesters = $DB->get_records_sql($mysql);

$data = array();
foreach ($semesters as $semester) {
    $line = array();
    $line[] = $semester->fullname;
    $schoollist = $DB->get_records('local_school_semester', array('semesterid' => $semester->id));
    $schoolname = '';
    $unassign = '';
    foreach ($schoollist as $school) {
        $schoolname .= '<div>' . $DB->get_field('local_school', 'fullname', array('id' => $school->schoolid)) . '</div>';
        $unassign .= '<div>' . html_writer::link(new moodle_url('/local/semesters/assign.php', array('schoolid' => $school->schoolid, 'semesterid' => $school->semesterid, 'unassign' => 1, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'title' => get_string('unassign', 'local_semesters'), 'alt' => get_string('unassign', 'local_semesters'), 'class' => 'iconsmall'))) . '</div>';
    }
    $line[] = $schoolname;
    $line[] = $unassign;
    $items = $hierarchy->get_school_items();
    $items = $mysemester->remove_assignedschool($items, $semester->id);
    $parents = $hierarchy->get_school_parent($items);
    $scl = new single_select(new moodle_url('/local/semesters/assign.php?semesterid=' . $semester->id . ''), 'schoolid', $parents, '', null);
    $line[] = $OUTPUT->render($scl);
    $data[] = $line;
}
if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding) {
    echo $OUTPUT->box(get_string('viewsemesterreportspage', 'local_semesters'));
}
if (!empty($data)) {  //if data is present in the table then only display the filters
    $PAGE->requires->js('/local/semesters/semesterjs.js');
}
//View Part starts
//start the table
$table = new html_table();
Exemple #14
0
    function get_content() {
        global $CFG, $DB, $PAGE,$USER,$OUTPUT;
        require_once($CFG->dirroot.'/local/lib.php');
		
		if(!isloggedin()){
			return $this->content;
		}
		
        if ($this->content !== NULL) {
            return $this->content;
        }
		
		if(!has_capability('local/collegestructure:manage', context_system::instance())){
			return $this->content;
		}
		
		$this->content = new stdClass();
		$this->content->items = array();
		
		
		$hierarchy = new hierarchy;
		$schools = $hierarchy->get_school_items();
		$schoolidin = '';
		if(!empty($schools)){
			$schoolidin = implode(', ', array_keys($schools));
		}

		$renderer = $this->page->get_renderer('block_dashboard');
		
		//Programs...
		$programs    = $DB->get_records_select('local_program', 'schoolid IN ('.$schoolidin.') AND visible = 1');
		$programtable = $renderer->display_programs($hierarchy, $programs);
		
		//Curriculums...
		$curriculums = $DB->get_records_select('local_curriculum', 'schoolid IN ('.$schoolidin.') AND visible = 1');
		$curriculumtable = $renderer->display_curriculums($hierarchy, $curriculums);
		
		//Departments...
		$departments = $DB->get_records_select('local_department', 'schoolid IN ('.$schoolidin.') AND visible = 1');
		$depts       = $DB->get_records_sql("SELECT * FROM {local_department} d, {local_assignedschool_dept} sd WHERE d.id = sd.deptid AND sd.assigned_schoolid IN ($schoolidin) AND d.visible=1");
		$departments = $departments + $depts;		
		$departmenttable = $renderer->display_departments($hierarchy, $departments);
		
		//Classes...
		$classes = $DB->get_records_select('local_clclasses', 'schoolid IN ('.$schoolidin.') AND visible = 1');
		$classtable = $renderer->display_classes($hierarchy, $classes);
		
		//Courses...
		$courses = $DB->get_records_select('local_cobaltcourses', 'schoolid IN ('.$schoolidin.') AND visible = 1');
		$coursetable = $renderer->display_courses($hierarchy, $courses);
		
		//Exams...
		$exams = $DB->get_records_select('local_scheduledexams', 'schoolid IN ('.$schoolidin.') AND visible = 1');
		$examtable = $renderer->display_exams($hierarchy, $exams);
		
		$this->content->items[] = '<div class="row row-fluid span12 dashboard_tablerow desktop-first-column">' .
									html_writer::tag('div', $head . $programtable, array('class'=>'span4 dashboard_table')) .
									html_writer::tag('div', $curriculumtable, array('class'=>'span4 dashboard_table')) .
									html_writer::tag('div', $departmenttable, array('class'=>'span4 dashboard_table')) .
									'</div><div class="row row-fluid span12 dashboard_tablerow desktop-first-column">' .
									html_writer::tag('div', $coursetable, array('class'=>'span4 dashboard_table')) .
									html_writer::tag('div', $classtable, array('class'=>'span4 dashboard_table')) .
									html_writer::tag('div', $examtable, array('class'=>'span4 dashboard_table')) .
									'</div>';
			
		$this->content->footer = '';
		$this->page->requires->js('/blocks/dashboard/javascript/custom.js');
		return $this->content;
    }
Exemple #15
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
Exemple #16
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);
    }
Exemple #17
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 ");
        }
    }
Exemple #18
0
    $heading = get_string('myacademics', 'local_courseregistration');
    $PAGE->navbar->add(get_string('myacademics', 'local_courseregistration'));
} else {

    $heading = get_string('mycurrentplan', 'local_courseregistration');
    $PAGE->navbar->add(get_string('mycurrentplan', 'local_courseregistration'));
}
echo $OUTPUT->header();
echo $OUTPUT->heading($heading);
//--------error handling
$hier = new hierarchy();

// to check logged in user is student or not
$student=$hier->is_student($USER->id);
if(empty($student))
$hier->get_school_items();

$exams = new schedule_exam();
/* ---Moodle 2.2 and onwards--- */
$currenttab = 'mycurrentplan';
/* ---adding tabs--- */
if (has_capability('local/courseregistration:view', $context))
    $exams->studentside_tabs($currenttab);


if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding) {
    echo $OUTPUT->box(get_string('myclasstabdes', 'local_courseregistration'));
}
$today = date('Y-m-d');

Exemple #19
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');
    }
    function get_content()
    {
        global $CFG, $DB, $PAGE, $USER, $OUTPUT;
        require_once $CFG->dirroot . '/local/lib.php';
        if (!isloggedin()) {
            return $this->content;
        }
        if ($this->content !== NULL) {
            return $this->content;
        }
        if (!has_capability('local/collegestructure:manage', context_system::instance())) {
            return $this->content;
        }
        $this->content = new stdClass();
        $this->content->items = array();
        $hierarchy = new hierarchy();
        $schools = $hierarchy->get_school_items();
        foreach ($schools as $school) {
            $list = array();
            $programs = $DB->count_records('local_program', array('schoolid' => $school->id, 'visible' => 1));
            $departments = $DB->count_records('local_department', array('schoolid' => $school->id, 'visible' => 1));
            $depts = $DB->count_records_sql("SELECT count(distinct d.id) FROM {local_department} d, {local_assignedschool_dept} sd WHERE d.id = sd.deptid AND sd.assigned_schoolid = {$school->id} AND d.visible=1");
            $departments = $departments + $depts;
            if (is_siteadmin()) {
                $semesters = $DB->count_records('local_school_semester', array('schoolid' => $school->id));
            } else {
                $semesters = $DB->count_records_sql("SELECT count(distinct ss.id) FROM {local_semester} AS se JOIN {local_school_semester} ss ON ss.semesterid=se.id JOIN {local_school_permissions} AS sp ON sp.schoolid=ss.schoolid WHERE sp.userid={$USER->id} and ss.schoolid={$school->id}");
            }
            $itemdepth = 'depth' . min(10, $school->depth);
            // @todo get based on item type or better still, don't use inline styles :-(
            $itemicon = $OUTPUT->pix_url('/i/item');
            $cssclass = !$school->visible ? 'dimmed' : '';
            $link = html_writer::start_tag('div', array('class' => 'hierarchyitem '));
            $link .= $OUTPUT->action_link(new moodle_url('/local/collegestructure/view.php', array('id' => $school->id)), format_string($school->fullname), null, array('class' => $cssclass));
            if ($school->type == 2) {
                $link .= "-(Organization)";
            }
            $link .= html_writer::end_tag('div');
            $table = new html_table();
            //$table->id =  $itemdepth;
            $table->head = array();
            $table->width = '100%';
            $table->align = array('left', 'center', 'center');
            $table->size = array('60%', '20%', '20%');
            $programlink = html_writer::link(new moodle_url('/local/programs/program.php'), '<button>Add</button>', array('schoolid' => $school->id));
            $departmentlink = html_writer::link(new moodle_url('/local/departments/departments.php'), '<button>Add</button>', array('schoolid' => $school->id));
            $semesterlink = html_writer::link(new moodle_url('/local/semesters/semester.php'), '<button>Add</button>', array('schoolid' => $school->id));
            $programs = $programs ? '<a href="javascript:void(0)" id="program' . $school->id . '">' . $programs . '</a>' : 'NA';
            $departments = $departments ? '<a href="javascript:void(0)" id="department' . $school->id . '">' . $departments . '</a>' : 'NA';
            $semesters = $semesters ? '<a href="javascript:void(0)" id="semester' . $school->id . '">' . $semesters . '</a>' : 'NA';
            $table->data = array(array('Programs', '<b>' . $programs . '</b>', $programlink), array('Departments', '<b>' . $departments . '</b>', $departmentlink), array('Semesters', '<b>' . $semesters . '</b>', $semesterlink));
            $left_panel = '<div class="display_table left_panel">' . html_writer::table($table) . '</div>';
            /* By Vinod for right side info */
            $today = date('Y-m-d');
            //active semester
            $activesem = $DB->get_record_sql("SELECT ls.id,ls.fullname\n                                    FROM {local_school_semester} AS ss\n                                    JOIN {local_semester} AS ls\n                                      ON ss.semesterid=ls.id where ss.schoolid={$school->id} AND ls.visible = 1\n\t\t\t\t\t\t\t\t\t   AND  '{$today}' BETWEEN from_unixtime( ls.startdate,  '%Y-%m-%d' ) AND from_unixtime( ls.enddate,  '%Y-%m-%d' )\n\t\t\t\t\t\t\t\t\t   group by ls.id");
            $active = $activesem ? $activesem->fullname : 'NA';
            // enrolled count in active semester
            $enrolled = $DB->count_records('local_user_clclasses', array('semesterid' => $activesem->id, 'registrarapproval' => 1));
            //classes count in current semester
            $classes = $DB->count_records('local_clclasses', array('semesterid' => $activesem->id, 'visible' => 1));
            //Pending Approvals to all the classes
            $pending = $DB->count_records('local_user_clclasses', array('semesterid' => $activesem->id, 'registrarapproval' => 0));
            //New admissions
            $admissions = $DB->count_records_sql("SELECT count(id) FROM {local_admission} WHERE schoolid = {$school->id} AND id NOT IN (SELECT applicationid FROM {local_userdata})");
            $right_panel = '<p><span class="right_lable">Active Semester: </span><span class="right_value">' . $active . '</span></p>
							<p><span class="right_lable">Classes in Current Semester: </span><span class="right_value">' . $classes . '</span></p>
							<p><span class="right_lable">Enrollments in Current Semester: </span><span class="right_value">' . $enrolled . '</span></p>
							<p><span class="right_lable">Pending Approvals: </span><span class="right_value">' . $pending . '</span></p>
							<p><span class="right_lable">New Admissions: </span><span class="right_value">' . $admissions . '</span></p>';
            $right_panel = '<div class="display_table right_panel">' . $right_panel . '</div>';
            $this->content->items[] = $link . $left_panel . $right_panel;
            $PAGE->requires->event_handler('#program' . $school->id . '', 'mouseenter', 'M.util.init_block_landing_board', array('schoolid' => $school->id, 'id' => '#program' . $school->id . '', 'type' => 'program'));
            $PAGE->requires->event_handler('#department' . $school->id . '', 'mouseenter', 'M.util.init_block_landing_board', array('schoolid' => $school->id, 'id' => '#department' . $school->id . '', 'type' => 'department'));
            $PAGE->requires->event_handler('#semester' . $school->id . '', 'mouseenter', 'M.util.init_block_landing_board', array('schoolid' => $school->id, 'id' => '#semester' . $school->id . '', 'type' => 'semester'));
        }
        $this->content->footer = '';
        $this->page->requires->js('/blocks/landing_board/javascript/custom.js');
        return $this->content;
    }
Exemple #21
0
    public function definition() {
        global $USER, $CFG, $DB, $PAGE;

        $mform = $this->_form;
        $PAGE->requires->yui_module('moodle-local_clclasses-schoolchooser', 'M.local_clclasses.init_schoolchooser', array(array('formid' => $mform->getAttribute('id'))));
        $editoroptions = $this->_customdata['editoroptions'];
        $id = $this->_customdata['id'];
        if ($id > 0)
            $mform->addElement('header', 'settingsheader', get_string('editclasses', 'local_clclasses'));
        else
            $mform->addElement('header', 'settingsheader', get_string('createclasses', 'local_clclasses'));

        $tools = array();
        $enddate = date("d/m/Y");
        $startdate = date("d/m/Y");

        $hierarchy = new hierarchy();
        $items = $hierarchy->get_school_items();
        $parents = $hierarchy->get_school_parent($items);
        $mform->addElement('select', 'schoolid', get_string('schoolid', 'local_collegestructure'), $parents);
        $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);
        $mform->registerNoSubmitButton('updatedepartment');
        $mform->addElement('submit', 'updatedepartment', get_string('courseformatudpate'));

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

        $mform->addElement('text', 'fullname', get_string('classesname', 'local_clclasses'), $tools);
        $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'), $tools);
        $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);

        $now = date("d-m-Y");
        $now = strtotime($now);
        $mform->addElement('text', 'classlimit', get_string('classlimit', 'local_clclasses'));
        $mform->addHelpButton('classlimit', 'classlimit', 'local_clclasses');
        $mform->addRule('classlimit', get_string('missinglimit', 'local_clclasses'), 'required', 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);

        $selectonline = array();
        $selectonline[''] = get_string('select', 'local_clclasses');
        $selectonline['1'] = get_string('online', 'local_clclasses');
        $selectonline['2'] = get_string('offline', 'local_clclasses');
        $mform->addElement('select', 'online', get_string('classtype', 'local_clclasses'), $selectonline);
        $mform->addHelpButton('online', 'classtype', 'local_clclasses');
        $mform->addRule('online', get_string('missingonline', 'local_clclasses'), 'required', null, 'client');
        $mform->setType('online', PARAM_INT);

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

        $mform->addElement('hidden', 'addonlinecoursehere');
        $mform->setType('addonlinecoursehere', PARAM_RAW);
        $mform->addElement('html', '<a name="Iheader"> </a>');
        /* ---assing instructor heading task--- */
        $mform->addElement('header', 'settingsheader', get_string('assigninstructor', 'local_clclasses'));

        $mform->addElement('hidden', 'adddepartmentinhere');
        $mform->setType('adddepartmentinhere', PARAM_RAW);
        $mform->registerNoSubmitButton('updateinstructor');
        $mform->addElement('submit', 'updateinstructor', get_string('courseformatudpate'));

        $mform->addElement('hidden', 'addinstructorhere');
        $mform->setType('addinstructorhere', PARAM_RAW);
        /* ---Area for Scheduling the classes--- */

        $mform->addElement('header', 'settingsheader', get_string('scheduleclassroom', 'local_clclasses'));

        $scheduleclass = cobalt_scheduleclass::get_instance();
        $hour = $scheduleclass->hour();
        $min = $scheduleclass->min();
        $starttime = array();
        $endtime = array();
        $mform->addElement('html', '<a name="zheader"> </a>');
        $mform->addElement('date_selector', 'startdate', get_string('from', 'local_clclasses'), array('optional' => true));
        $mform->addHelpButton('startdate', 'from', 'local_clclasses');
        $mform->setDefault('startdate', time() + 3600 * 24);
        $mform->addElement('date_selector', 'enddate', get_string('to', 'local_clclasses'), array('optional' => true));
        $mform->addHelpButton('enddate', 'to', 'local_clclasses');
        $mform->setDefault('enddate', time() + 3600 * 24);
        $starttime[] = &$mform->createElement('select', 'starthour', get_string('starthour', 'local_classroomresources'), $hour);
        $starttime[] = &$mform->createElement('select', 'startmin', get_string('startmin', 'local_classroomresources'), $min);
        $mform->addGroup($starttime, 'starttime', 'Start Time', array(' '), false);
        $endtime[] = &$mform->createElement('select', 'endhour', get_string('endhour', 'local_classroomresources'), $hour);
        $endtime[] = &$mform->createElement('select', 'endmin', get_string('endmin', 'local_classroomresources'), $min);
        $mform->addGroup($endtime, 'endtime', 'End Time', array(' '), false);



        /* ---End of schedule classes--- */

        $mform->addElement('advcheckbox', 'choose', get_string('getfreeclass', 'local_clclasses'));
        $mform->addHelpButton('choose', 'getfreeclass', 'local_clclasses');
        $mform->setDefault('choose', 0);
        $mform->addHelpButton('startdate', 'from', 'local_clclasses');
        $mform->addElement('hidden', 'beforeclassroom');
        $mform->setType('beforeclassroom', PARAM_RAW);
        $mform->registerNoSubmitButton('updateclassrooms');
        $mform->addElement('submit', 'updateclassrooms', get_string('courseformatudpate'));

        $mform->addElement('hidden', 'timecreated', $now);
        $mform->setType('timecreated', PARAM_RAW);
        $mform->addElement('hidden', 'usermodified', $USER->id);
        $mform->setType('usermodified', PARAM_RAW);

        $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);
    }
Exemple #22
0
    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)
    $name = $cplan->name($plan);
else
Exemple #23
0
    /* ---for now--- */

    $baseurl = new moodle_url('/local/collegestructure/assignusers.php', $urlparams + array('sesskey' => sesskey()));
    foreach ($users as $id => $auser) {
        $count++;
        echo '<tr>';
        $checkexist = $DB->get_records('local_school_permissions', array('schoolid' => $schoolids, 'userid' => $id));
        if ($checkexist)
            $startclass = 'class="dimmed"  disabled="disabled"';
        else
            $startclass = 'class="courseassign"';
        echo '<td align="left"><a ' . $startclass . ' href="' . $CFG->wwwroot . '/user/view.php?id=' . $id . '">' . format_string($auser) . '&nbsp;</a></td>';
        echo '<td align="center">';
        echo '<input type="checkbox" name="c' . $id . '" ' . $startclass . ' />';
        echo '</td>';
        echo "</tr>";
    }

    $items = $hierarchy->get_school_items(true);
    $parents = $hierarchy->get_school_parent($items);
    echo '<tr><td colspan="3" align="center">';
    $sdclass = 'class="dimmed"  disabled="disabled"';
    echo html_writer::select($parents, 'moveto', $parents, null, array('id' => 'movetoid'));
    echo '<input type="submit" id="movetoid"  value="Assign Registrars" />';
    echo '</td></tr>';
    echo '</table>';
    echo '</div></form>';
    echo '<br />';
}
echo $OUTPUT->footer();