예제 #1
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE, $OUTPUT;
        global $hierarchy;
        $mform = $this->_form;
        $id = $this->_customdata['id'];
        $scid = null;
        if (isset($this->_customdata['scid'])) {
            $scid = $this->_customdata['scid'];
        }
        $PAGE->requires->yui_module('moodle-local_timetable-timetable', 'M.local_timetable.init_timetable', array(array('formid' => $mform->getAttribute('id'))));
        //  $heading = ($id > 0) ? get_string('editclass', 'local_class') : get_string('createclass', 'local_class') ;

        $mform->addElement('header', 'settingsheader', get_string('settime_intervals', 'local_timetable'));
        //if ($id < 0) {
        //    $mform->addHelpButton('settingsheader', 'createclass', 'local_timetable');
        //}

        $hier = new hierarchy();
        $timetable_ob = manage_timetable::getInstance();
        $timetable_ob->school_formelement_condition($mform);
        
        
        
        $mform->addElement('hidden', 'addsemesterlisthere');
        $mform->setType('addsemesterlisthere', PARAM_INT);

        //$mform->addElement('advcheckbox', 'visible', get_string('publish','local_class'), null, array('group'=>1), array(0, 1));
        $mform->addElement('checkbox', 'visible', get_string('publish', 'local_timetable'), '', array('checked' => 'checked', 'name' => 'my-checkbox', 'data-size' => 'small', 'data-on-color' => 'info', 'data-off-color' => 'warning', 'data-on-text' => 'Yes', 'data-switch-set' => 'size', 'data-off-text' => 'No', 'class' => 'btn btn-default'));
        $mform->addHelpButton('visible', 'publish', 'local_timetable');
        $mform->setDefault('visible', true);

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


        // Sections start *******************************************************************

        include('settimeintervals_form.php');
        //class_section_fields($mform, $id, $style);

        $submitlable = ($id > 0) ? get_string('submit') : get_string('submit');
        $this->add_action_buttons($cancel = true, $submitlable);
    }
예제 #2
0
    function definition() {
        global $USER, $CFG, $DB, $PAGE;
        $mform = $this->_form;
        $mform->addElement('header', 'settingsheader', get_string('classtypeheader', 'local_timetable'));

        $timetable_ob = manage_timetable::getInstance();
        $timetable_ob->school_formelement_condition($mform, false);

        $mform->addElement('text', 'classtype', get_string('classtype', 'local_timetable'));
        $mform->addRule('classtype', get_string('spaces', 'local_timetable'), 'regex', '/^[^\s]+[A-Za-z0-9-_\",\s]+$/', 'client');
        $mform->addRule('classtype', get_string('missing_classtype', 'local_timetable'), 'required', null, 'client');
        $mform->setType('classtype', PARAM_TEXT);

        $mform->addElement('checkbox', 'visible', get_string('publish', 'local_timetable'), '', array('checked' => 'checked', 'name' => 'my-checkbox', 'data-size' => 'small', 'data-on-color' => 'info', 'data-off-color' => 'warning', 'data-on-text' => 'Yes', 'data-switch-set' => 'size', 'data-off-text' => 'No', 'class' => 'btn btn-default'));
        $mform->addHelpButton('visible', 'publish', 'local_timetable');
        $mform->setDefault('visible', true);

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        // $i = get_string('submit', 'local_prefix');
        $this->add_action_buttons();
    }
예제 #3
0
            unset($classtype[$key]);
    }
}






$systemcontext =  context_system::instance();
//$PAGE->requires->css('/local/clclasses/css/style.css');
$PAGE->set_pagelayout('admin');
$PAGE->set_context($systemcontext);
$semclass = new schoolclasses();
$hierarchy = new hierarchy();
$tmobject = manage_timetable::getInstance();
require_login();
if ($CFG->forcelogin) {
    require_login();
} else {
    user_accesstime_log();
}
// -------------Edited by hema----------------------------------------
$assigninstructor_cap = array('local/clclasses:manage', 'local/clclasses:assigninstructor', 'local/classroomresources:manage');
if (!has_any_capability($assigninstructor_cap, $systemcontext)) {
    print_error('You dont have permissions');
}
$currenturl = "{$CFG->wwwroot}/local/timetable/scheduleclassview.php";
$returnurl = "{$CFG->wwwroot}/local/timetable/scheduleclass.php";
//
if ($id > 0) {
예제 #4
0
파일: index.php 프로젝트: anilch/Personel
$PAGE->set_context($systemcontext);

require_login();

$PAGE->set_url('/local/timetable/index.php');
//Header and the navigation bar
$PAGE->set_heading($SITE->fullname);
$PAGE->navbar->add(get_string('pluginname', 'local_timetable'), new moodle_url('/local/timetable/index.php'));
$PAGE->navbar->add(get_string('setstandardview_timings', 'local_timetable'), new moodle_url('/local/timetable/index.php'));

//this is the return url 
$returnurl = new moodle_url('/local/timetable/index.php', array('id' => $id));
$currenturl = "{$CFG->wwwroot}/local/timetable/index.php";

// calling manage_dept class instance.....
$timetable_ob = manage_timetable::getInstance();
$hier1 = new hierarchy();

//for edit purpose  //
//if ($id > 0)
//    $PAGE->navbar->add(get_string('edit_department', 'local_departments'));
//else
//    $PAGE->navbar->add(get_string('createdept', 'local_departments'));        

echo $OUTPUT->header();
//----------------manage dept heading------------------------
echo $OUTPUT->heading(get_string('pluginname', 'local_timetable'));


// checking if login user is registrar or admin
$schoolid = $timetable_ob->check_loginuser_registrar_admin();
예제 #5
0
파일: lib.php 프로젝트: anilch/Personel
 public static function getInstance() {
     if (!self::$_singleton) {
         self::$_singleton = new manage_timetable();
     }
     return self::$_singleton;
 }
예제 #6
0
    public function validation($data, $files) {
        global $DB, $CFG;
	
        $tmobject = manage_timetable::getInstance();
        $errors = array();
        $classtypeid = $data['classtypeid'];
	
	
        // foreach ($classtypes as $cltype) {

        $classtypeinfo = $DB->get_record('local_class_scheduletype', array('id' => $classtypeid));
        $clname = $classtypeinfo->classtype;
        $userstartdate = $data[$clname . 'dates[startdate]'];

        $userenddate = $data[$clname . 'dates[enddate]'];

        $noofdays = $userenddate - $userstartdate;
        $noofdays = floor($noofdays / (60 * 60 * 24)) + 1;


        // to hold available days from  slected date range
        for ($i = $userstartdate; $i <= $userenddate; $i += 86400) {
            // if (date('w', $i) != 0 && date('w', $i) != 6)
            $availabledays[] = date('w', $i);
        }

	$days_arrayname = $clname . 'days';
        $mon = $data[$days_arrayname]['mon'];
        $tue = $data[$days_arrayname]['tue'];
        $wed = $data[$days_arrayname]['wed'];
        $thu = $data[$days_arrayname]['thu'];
        $fri = $data[$days_arrayname]['fri'];
        $sat = $data[$days_arrayname]['sat'];
        $sun = $data[$days_arrayname]['sun'];	
	
	     // check selected dates fallin corresponding selected days  
       if ($noofdays < 7 && ((!in_array('1', $availabledays) && $mon) || (!in_array('2', $availabledays) && $tue) || (!in_array('3', $availabledays) && $wed) || (!in_array('4', $availabledays) && $thu) || (!in_array('5', $availabledays) && $fri)|| (!in_array('0', $availabledays) && $sun)|| (!in_array('6', $availabledays) && $sat))) {
                
            $workingdays = array(0,1, 2, 3, 4, 5, 6);
            $missingdays = array_diff($workingdays, $availabledays);           
            $dayslist = array('0' =>'Sunday','1' => 'Monday', '2' => 'Tuesday', '3' => 'Wednesday', '4' => 'Thursday', '5' => 'Friday','6' =>'Saturday');
            if (!empty($missingdays)) {
                $dateerror = get_string('availabledays_error','local_clclasses');
                foreach ($availabledays as $key => $value) {
                    $dateerror .= '<li>' . $dayslist[$value] . '</li>';
                }
                $errors[$clname . 'days'] = $dateerror;
            }
        }
	



        $no_day = $mon == 0 && $tue == 0 && $wed == 0 && $thu == 0 && $fri == 0 && $sun == 0 && $sat == 0;
        if ($no_day) {
            $errors[$clname . 'days'] = get_string('selecttheday', 'local_clclasses');
        }

        /* Bug report #283  -  Classes>Scheduling- Not before semester and   Bug report #284  
         * @author hemalatha c arun <*****@*****.**>
         * Resolved - added validation when user select the startdate and enddate not in between the semester enddate and startdate 
         */

        // $semid = $this->_customdata['semesterid'];
        $semid = $data['semesterid'];
        $semesterinfo = $DB->get_record('local_semester', array('id' => $semid));

        $startdate = strtotime(date('d-m-Y', $userstartdate));
        $enddate = strtotime(date('d-m-Y', $userenddate));
        if ($semesterinfo) {
            $semdate = new stdclass();
            $semdate->startdate = date('d-M-Y', $semesterinfo->startdate);
            $semdate->enddate = date('d-M-Y', $semesterinfo->enddate);
        }

	 if ($startdate > $enddate)
                $errors[$clname . 'dates'] = get_string('startdatelessthan_enddate', 'local_clclasses');    
	    
	    
	    
        $semstartdate = strtotime(date('d-m-Y', $semesterinfo->startdate));
        $semenddate = strtotime(date('d-m-Y', $semesterinfo->enddate));
        if ($semstartdate <= $startdate && $startdate <= $semenddate) {
            
        } else
            $errors[$clname . 'dates'] = get_string('datenotmatch_semstardate', 'local_clclasses', $semdate);

        if ($semstartdate <= $enddate && $enddate <= $semenddate) {
            
        } else
            $errors[$clname . 'dates'] = get_string('datenotmatch_semenddate', 'local_clclasses', $semdate);

	    
	 
        // if user selected custom timings, valdating is starttime and endtime     
        if (isset($data[$clname]['othertimeinterval'])) {
            $customtimeintervals = $data[$clname]['customtimeintervals'];

            $starthours = $customtimeintervals['starthours'];
            $startminutes = $customtimeintervals['startminutes'];
            $endhours = $customtimeintervals['endhours'];
            $endminutes = $customtimeintervals['endminutes'];
            $start_td = $customtimeintervals['start_td'];
            $end_td = $customtimeintervals['end_td'];
            if (($starthours == 0 && $startminutes == 0 ) || ($endhours == 0 && $endminutes == 0)) {
                $errors[$clname . '[customtimeintervals]'] = get_string('customintervalempty', 'local_timetable');
            }


            $starttime = sprintf("%02d", $starthours) . ':' . sprintf("%02d", $startminutes) . $start_td;
            $endtime = sprintf("%02d", $endhours) . ':' . sprintf("%02d", $endminutes) . $end_td;
            $start_timestamp = strtotime($starttime);
            $end_timestamp = strtotime($endtime);
	    
	    // checking already is time intervals available or what , if so forcing user to select the defined intervals
	    $schoolid= $data['schoolid']; $semesterid=$data['semesterid'];
	    
	    $tempstarttime = date('H:i:s', strtotime($starttime));
	    $tempendtime = date('H:i:s', strtotime($endtime));
	    
	    $sql= "select * from mdl_local_timeintervals where schoolid=1 and semesterid=1
                                and '$tempstarttime' = starttime and '$tempendtime' = endtime";
				 
	    $exists_timeintervals = $DB->get_records_sql($sql);
	    if(sizeof($exists_timeintervals)>0) 
	      $errors[$clname . '[timeinterval]'] = get_string('existtimeintervals', 'local_timetable');
            //---------------------------------------------------------------------------------------------------

            if ($start_timestamp > $end_timestamp)
                $errors[$clname . '[customtimeintervals]'] = 'starttime should be less than endtime';
        }// end of timeintervals validation
        else {
            if ($data[$clname]['timeinterval'] <= 0)
                $errors[$clname . '[timeinterval]'] = get_string('emptytimeinterval', 'local_timetable');
        }

        // comparision starts from here
        //  $response = $this->checking_conflicts_static_classtypes($data, $classtypes, $cltype);
        //  if ($response)
        //     $errors[$clname . '[timeinterval]'] = 'class room is busy ';


        $timearray = $tmobject->timetable_get_timeformat($data, $clname);

        $availabledaysarray = $tmobject->timetable_get_availabledays_format($data, $clname);
        $classroomarrayname = $clname . 'classroom';
        if (isset($classroomarrayname['classroomid']))
            $classroomid = $classroomarrayname['classroomid'];
        else
            $classroomid = 0;

        if ($userstartdate != null && $userenddate != null && $timearray['starttime'] != null && $timearray['endtime'] != null && !empty($availabledaysarray)) {
            $value = $tmobject->check_conflicts($userstartdate, $userenddate, $timearray['starttime'], $timearray['endtime'], $data['schoolid'], $classroomid, $data['id'], $availabledaysarray);
            if ($value > 0) {
                $errors[$clname . '[timeinterval]'] = 'This classroom is busy';
            }
            // }// end of foreach
        }// end of function 

        return $errors;
    }
예제 #7
0
    public function timetable_scheduledclass_view($tmobject) {
        global $DB, $CFG, $OUTPUT, $USER, $PAGE;
        $PAGE->requires->js('/local/timetable/js/tmember_toggle.js');
        $output = '';
        $timetablelibob = manage_timetable::getInstance();
        $classlist = $tmobject->scheduled_list;
        $semclass = new schoolclasses();
        if ($classlist) {
            $j = 0;
            foreach ($classlist as $clas) {
                if ($j > 0)
                    $displaynone = "display:none";
                else
                    $displaynone = "";
                $line = array();
                // $instructor[] = $clas->instructor;
                $instructor_info = $timetablelibob->timetable_display_instructorname($clas);
                $first_inner = $this->get_firstpart_ofrow($clas);
                $status = $tmobject->class_status($clas->id);

                // $extrainfo = html_writer::start_tag('div', array('class' => 'myteam_ul'));
                $second_inner = "<ul id='timetable_secondinner'><li>" . get_string('instructor', 'local_cobaltcourses') . " :" . $instructor_info;
                $second_inner .= "<li>" . get_string('noenrollments', 'local_timetable') . ": $status->noapproved</li>";
                $second_inner .= "<li>" . get_string('scheduleinfo', 'local_timetable') . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/switch'), 'class' => 'iconsmall', 'onclick' => 'teammember_list(' . $clas->id . ')', 'id' => 'tm_switchbutton'), array('style' => 'cursor:pointer')) . "</li></ul>";

                $toggle = "<div id = 'dialog$clas->id' class = 'tmem_toggle dialog1' style = '$displaynone;clear:both; '>";

                $toggle .= $this->toggle_scheduleclassview($clas, $tmobject);
                $toggle .="</div>";
                //$schedule = $DB->get_field('local_scheduleclass', 'id', array('classid' => $clas->id));
                //if (!$schedule) {
                //    $schedule = -1;
                //}
                //
                ////   displaying buttons
                //$options = array(array('link' => new moodle_url('/local/clclasses/enroluser.php', array('id' => $clas->id, 'semid' => $clas->semesterid, 'activesemid' => $activesemesterid)), 'string' => get_string('enrollusers', 'local_clclasses')),
                //    array('link' => new moodle_url('/local/clclasses/scheduleclass.php', array('id' => $schedule, 'classid' => $clas->id, 'semid' => $clas->semesterid, 'schoid' => $clas->schoolid, 'deptid' => $clas->departmentid, 'courseid' => $clas->cobaltcourseid, 'sesskey' => sesskey())), 'string' => get_string('assigninstructor', 'local_clclasses')),
                //    array('link' => new moodle_url('/local/clclasses/examsetting.php', array('id' => $clas->id, 'semid' => $clas->semesterid, 'schoolid' => $clas->schoolid, 'sesskey' => sesskey())), 'string' => get_string('criteria', 'local_clclasses')),
                //    array('link' => new moodle_url('/local/evaluations/create_evaluation.php', array('clid' => $clas->id, 'sesskey' => sesskey())), 'string' => get_string('evaluation', 'local_clclasses'))
                //);
                //$menulist = array();
                //foreach ($options as $types) {
                //    $menulist[] = '<button>' . html_writer::link($types['link'], $types['string']) . '</button>';
                //    $menulist[] = '<hr />';
                //}
                //// Remove the last element (will be an HR)
                //array_pop($menulist);
                // Display the content as a list
                //  $third_inner = html_writer::alist($menulist, array('class' => 'third_inner cl_buttonrow'), 'ul');
                $third_inner = "<div id='timetable_thirdinner'>$clas->semestername</div>";
                $cell1 = new html_table_cell();
                $cell1->attributes['class'] = 'colms_cell';
                $cell1->text = $first_inner . $second_inner . $toggle . $third_inner;
                $line[] = $cell1;
                $line[] = $clas->classname;
                $line[] = $clas->semestername;
                $line[] = ($clas->online == 1 ? 'Online' : 'Offline');
                $data[] = $line;
                $j++;
            }// end of  foreach
        }// end of if



        $PAGE->requires->js('/local/timetable/js/scheduleview.js');
        $output = "<div id='filter-box' >";
        $output .= '<div class="filterarea"></div></div>';

        $table = new html_table();
        $table->head = array('', '', '', '');
        $table->id = "timetable_sc";
        $table->size = array('100%');
        $table->align = array('left');
        $table->width = '99%';
        $table->data = $data;

        $output .= html_writer::table($table);
        return $output;
    }
예제 #8
0
    public function get_firstpart_ofrow( $clas){
        global $CFG, $DB, $USER, $PAGE, $OUTPUT;
          $timetablelibob = manage_timetable::getInstance();
        $systemcontext = context_system::instance();
         $semclass = new schoolclasses();
         $first_inner ='';
          // to get instructor name
                $instructor = array();
                $instructor_info =$timetablelibob->timetable_display_instructorname($clas);
            
            
             //   displaying crud operation button
            $delete_cap = array('local/clclasses:manage', 'local/clclasses:delete');
            if (has_any_capability($delete_cap, $systemcontext)) {
                $options[] =array( 'link'=>new moodle_url('/local/clclasses/createclass.php', array('id' => $clas->id, 'delete' => 1, 'sesskey' => sesskey())), 'string'=>html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'title' => get_string('delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall')));
            }

            $update_cap = array('local/clclasses:manage', 'local/clclasses:update');
            if (has_any_capability($update_cap, $systemcontext)) {
               $options[]  = array( 'link'=>new moodle_url('/local/clclasses/createclass.php', array('id' => $clas->id, 'sesskey' => sesskey())), 'string'=>html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/edit'), 'title' => get_string('edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall')));
            }

            $visible_cap = array('local/clclasses:manage', 'local/clclasses:visible');
            if (has_any_capability($visible_cap, $systemcontext)) {
                if ($clas->visible) {
                     $options[]  = array( 'link'=>new moodle_url('/local/clclasses/createclass.php', array('id' => $clas->id,  'hide' => 1, 'sesskey' => sesskey())), 'string'=>html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/hide'), 'title' => get_string('inactive'), 'alt' => get_string('hide'), 'class' => 'iconsmall')));
                } else {
                     $options[]  = array( 'link'=>new moodle_url('/local/clclasses/createclass.php', array('id' => $clas->id,  'show' => 1, 'sesskey' => sesskey())), 'string'=>html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/show'), 'title' => get_string('active'), 'alt' => get_string('show'), 'class' => 'iconsmall')));
                }
            }
            

             /*   $menulist = array();
                
                $scheduled=$DB->get_records('local_scheduleclass',array('classid'=>$clas->id));
                if($scheduled)
                 $menulist[0] =get_string('scheduled','local_clclasses').html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/grade_correct'), 'title' => get_string('scheduled','local_clclasses'), 'alt' => get_string('scheduled','local_clclasses'), 'class' => 'iconsmall'));
                else
                 $menulist[0] =get_string('scheduled','local_clclasses').html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'), 'title' => get_string('scheduled','local_clclasses'), 'alt' => get_string('notyetscheduled','local_clclasses'), 'class' => 'iconsmall'));
                 
                foreach ($options as $types) {
                    $menulist[] =  html_writer::link($types['link'], $types['string']);
                    $menulist[] = '<hr />';
                }
                // Remove the last element (will be an HR)
                array_pop($menulist); */
                // Display the content as a list
                 $first_inner = html_writer::start_tag('div', array('class' => 'first_inner'));
               // $first_inner .= html_writer::alist($menulist, array('class' => 'cl_curdrow'), 'ul');
              
                $first_inner .= html_writer::start_tag('span', array('class' => 'first_inner1'));
                $first_inner .='<span class="td_mainitem" id="cl_name">'. $clas->shortname.': '.$clas->classname .'</span><span id="cl_instructorname" class="item_italic item_gray">  with '. $instructor_info . '</span>';
                //if ($clas->scheduledate) {
                //   $first_inner .='<span >'.  $clas->scheduledate;
                //    !empty($classlist->availableweekdays) ?  $first_inner .= $clas->scheduletime . '<br />(' . $clas->availableweekdays . ')' :  $first_inner .=  $clas->scheduletime;
                //    $first_inner .='</span>'; 
                //} else {                  
                //    $first_inner .='<span>'. html_writer::tag('a', get_string('scheduleclass', 'local_classroomresources'), array('href' => '' . $CFG->wwwroot . '/local/clclasses/scheduleclass.php?classid=' . $clas->id . '&semid=' . $clas->semesterid . '&schoid=' . $clas->schoolid . '&deptid=' . $clas->departmentid . '&courseid=' . $clas->cobaltcourseid . ''));
                //   $first_inner .=html_writer::tag('a', get_string('scheduleclass', 'local_classroomresources'), array('href' => '' . $CFG->wwwroot . '/local/clclasses/scheduleclass.php?classid=' . $clas->id . '&semid=' . $clas->semesterid . '&schoid=' . $clas->schoolid . '&deptid=' . $clas->departmentid . '&courseid=' . $clas->cobaltcourseid . '')).'</span>';
                //}
               /* $first_inner .=  html_writer::start_tag('ul', array('class' => 'first_innerclassdetail'));
                $first_inner .= '<li class="item_gray">'.get_string('offlinecoursename','local_clclasses').' :<b>'.$clas->coursename.'</b>, ';
                $first_inner .= get_string('type','local_clclasses').':<b>'.($clas->online==1? 'Online' :'Offline').'</b>';
                if($clas->online==1){
                $onlinecourse  =$DB->get_record('course',array('id'=>$clas->onlinecourseid));
                if($onlinecourse){
                   $onlinecourselink = html_writer::tag('a', $onlinecourse->fullname, array('href' => ''.$CFG->wwwroot.'/course/view.php?id='.$onlinecourse->id.''));
                   $first_inner .= ',   '. get_string('cobaltcourse','local_clclasses').': <b>'.$onlinecourselink.'</b></li>';
                  }
                }
                $first_inner .= html_writer::end_tag('ul'); */
                $first_inner .= html_writer::end_tag('span');
                
                
           
                
                
                $first_inner .= html_writer::end_tag('div');
        
        return $first_inner;
        
    }// end of function