public function definition() { global $USER, $cm; if (is_array($locations = praxe_get_available_locations($USER->id, praxe_record::getData('isced'), praxe_record::getData('studyfield'))) && count($locations)) { //$mform =& $this->_form; $this->content_before_form .= get_string('assigntolocation_text_forstudents', 'praxe'); $form = '<form class="mform" action="' . praxe_get_base_url() . '" method="post">'; $form .= '<input type="hidden" name="post_form" value="assignlocation" />'; $form .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; $table = new stdClass(); $table->head = array('', get_string('school', 'praxe'), get_string('subject', 'praxe'), get_string('teacher', 'praxe')); $table->align = array('center', 'left', 'center', 'center'); foreach ($locations as $loc) { $row = array('<input id="praxe_loc_' . $loc->id . '" type="radio" name="location" value="' . $loc->id . '" />'); $sch = "<a href=\"" . praxe_get_base_url(array('viewaction' => 'viewschool', 'schoolid' => $loc->school)) . "\" title=\"" . get_string('school_detail', 'praxe') . "\">" . s($loc->name) . "</a>"; $sch .= "<div class=\"praxe_detail\">" . s($loc->street) . ', ' . s($loc->city) . "</div>"; $row[] = $sch; $row[] = s($loc->subject); if (!is_null($loc->teacherid)) { $teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname)); $row[] = praxe_get_user_fullname($teacher); } else { $row[] = ''; } $table->data[] = $row; //$row .= '<label for="praxe_loc_'.$loc->id.'">'.$text.'</label>'; //$form .= "<div class=\"tr\">$row</div>"; } $form .= html_writer::table($table, true); $form .= '<div class="fitem center" style="margin: 10px 0;">' . '<input type="submit" id="id_submitbutton" value="Submit" name="submitbutton" /> ' . '<input type="submit" id="id_cancel" onclick="skipClientValidation = true; return true;" value="Cancel" name="cancel" />' . '</div>'; $form .= '</form>'; $this->content .= "<div>{$form}</div>"; //$mform->addElement('header', null, get_string('locations', 'praxe')); /* $options = array(); $radioarray = array(); foreach($locations as $loc) { //print_object($loc); $link = "<a target='_blank' href='view.php?id=$cm->id&praxeaction=viewschool&schoolid=$loc->school' title='".get_string('school_detail','praxe')."'>".get_string('school_detail','praxe')."</a>"; $text = s($loc->name) . "($link) - " . s($loc->subject); $text .= "<br>".s($loc->street).', '.s($loc->zip).' '.s($loc->city); if(!is_null($loc->teacherid)) { $teacher = (object) array('id' => $loc->teacherid, 'firstname' => s($loc->teacher_name), 'lastname' => s($loc->teacher_lastname)); $text .= " (".praxe_get_user_fullname($teacher).")"; } $radioarray[] = $mform->createElement('radio', 'location', null, $text, $loc->id, array('class'=>'radio location')); } $mform->addGroup($radioarray, 'location', get_string('locations','praxe').':', '<hr>', false); $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'client'); $mform->addRule('location', get_string('locationisrequired', 'praxe'), 'required', null, 'server'); //$mform->addElement('select', 'location', get_string('chooselocation', 'praxe'), $options, array('size' => count($options) > 15 ? '15' : count($options)+1)); $mform->addElement('hidden', 'post_form', 'assigntolocation'); */ //$this->add_action_buttons(true, get_string('submit')); } else { $this->content_before_form .= get_string('nolocationsavailable', 'praxe'); } }
/** * * @param object $rec - object of praxe record to be shown * @return string */ public static function show_record_detail($rec) { global $mode, $USER, $CFG, $OUTPUT; /// left top table /// $tab1 = new html_table(); $tab1->align = array('right', 'left'); //$tab1->width = '300px'; $tab1->attributes['class'] = "floatinfotable left twocolstable"; $school = array($rec->name); if (strlen(trim($rec->city))) { $school[] = $rec->city; } if (strlen(trim($rec->street))) { $school[] = $rec->street; } if (strlen(trim($rec->phone))) { $school[] = $rec->phone; } if (strlen(trim($rec->email))) { $school[] = $rec->email; } $tab1->data[] = array(get_string('school', 'praxe') . ":", format_string(implode(', ', $school))); $tab1->data[] = array(get_string('subject', 'praxe') . ":", $rec->subject); if ($rec->teacherid && $USER->id != $rec->teacherid) { $tab1->data[] = array(get_string('teacher', 'praxe') . ":", praxe_get_user_fullname((object) array('id' => $rec->teacherid, 'firstname' => $rec->teacher_firstname, 'lastname' => $rec->teacher_lastname))); } /// right top table /// $tab2 = new html_table(); $tab2->align = array('right', 'left'); //$tab2->width = '350px'; $tab2->attributes['class'] = "floatinfotable left twocolstable last"; $tab2->data[] = array(get_string('student', 'praxe') . ":", praxe_get_user_fullname($rec->student)); $tab2->data[] = array(get_string('status', 'praxe') . ":", praxe_get_status_info($rec->status)); if ($rec->status == PRAXE_STATUS_ASSIGNED) { $tab2->data[] = array(get_string('action') . ':', self::confirm_location_form($rec->id)); return html_writer::table($tab1) . html_writer::table($tab2) . '<div class="clearer"></div>'; } $return = html_writer::table($tab1) . html_writer::table($tab2) . '<div class="clearer"></div>'; $return .= "<h3>" . get_string('schedule', 'praxe') . "</h3>"; $schedules = praxe_get_schedules($rec->id); if (!$schedules) { return $return . get_string('no_schedule_items', 'praxe'); } $sched = array(); $cols = array(); foreach ($schedules as $sch) { if (!isset($sched[date("j_m", $sch->timestart)])) { $sched[date("j_m", $sch->timestart)] = array('date' => $sch->timestart); } $sched[date("j_m", $sch->timestart)][$sch->lesnumber] = $sch; if (!in_array($sch->lesnumber, $cols)) { $cols[] = $sch->lesnumber; } } /// schedule table /// $tab3 = new html_table(); if (count($cols)) { sort($cols); } $tab3->head = $cols; array_unshift($tab3->head, get_string('date')); for ($i = 1; $i < count($tab3->head); $i++) { if (is_null($tab3->head[$i])) { $tab3->head[$i] = "---"; } else { $tab3->head[$i] = s($tab3->head[$i]) . "." . get_string('lesson', 'praxe'); } } $cellf = new html_table_cell(); $cellf->attributes['class'] = "header first"; $cellf->header = true; $paramsToAssing = array('post_form' => 'assigntoinspection', 'sesskey' => sesskey(), 'submitbutton' => 'true', 'userid' => $USER->id); $paramsToRemAssing = array('post_form' => 'removefrominspection', 'sesskey' => sesskey(), 'submitbutton' => 'true'); foreach ($sched as $row) { $datetd = userdate($row['date'], get_string('strftimeday', 'praxe')) . "<br />" . userdate($row['date'], get_string('strftimedateshort')); $cell = clone $cellf; $cell->text = $datetd; $cells = array($cell); foreach ($cols as $k => $c) { if (isset($row[$c])) { $item = userdate($row[$c]->timestart, get_string('strftimetime')) . " - " . userdate($row[$c]->timeend, get_string('strftimetime')) . "<br>" . s($row[$c]->lessubject) . "<br>" . get_string('schoolroom', 'praxe') . ": " . s($row[$c]->schoolroom); $item = "<div>" . $OUTPUT->action_link(praxe_get_base_url(array("mode" => $mode, "recordid" => $rec->id, "scheduleid" => $row[$c]->id)), $item, null, array('title' => get_string('detail', 'praxe'))) . "</div>"; if (count($row[$c]->inspectors)) { foreach ($row[$c]->inspectors as $insp) { $item .= "<div class=\"inspector right\">" . $OUTPUT->render(new pix_icon('icon_inspect', get_string('inspection', 'praxe'), 'praxe')) . " " . praxe_get_user_fullname($insp); /// remove assinging from item action /// if ($USER->id == $insp->id || praxe_has_capability('manageallincourse')) { $params = $paramsToRemAssing; $params['scheduleid'] = $row[$c]->id; $params['inspid'] = $insp->id; $item .= $OUTPUT->action_icon(praxe_get_base_url($params), new pix_icon('t/delete', get_string('removeinspection', 'praxe'))); } $item .= "</div>"; } } else { if (praxe_has_capability('assignselftoinspection')) { $params = $paramsToAssing; $params['scheduleid'] = $row[$c]->id; /// assign inspector button /// $item .= "<div class=\"inspector right\">" . $OUTPUT->single_button(praxe_get_base_url($params), get_string('gotoinspection', 'praxe'), 'post') . '</div>'; } } $cells[] = new html_table_cell($item); } else { $cells[] = new html_table_cell(' '); } } $tab3->data[] = new html_table_row($cells); } return $return . html_writer::table($tab3); }
$filteractualloc = optional_param('factualloc', 0, PARAM_INT); ///filter for locations actual $filteryearloc = optional_param('fyearloc', 0, PARAM_INT); $viewtabrows[] = new tabobject(PRAXE_TAB_EDITTEACHER_HOME, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_HOME], get_string('records_list', 'praxe')); $viewtabrows[] = new tabobject(PRAXE_TAB_EDITTEACHER_SCHOOLS, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_SCHOOLS], get_string('schools', 'praxe')); if (praxe_has_capability('manageallincourse')) { $viewtabrows[] = new tabobject(PRAXE_TAB_EDITTEACHER_ADDSCHOOL, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_ADDSCHOOL], get_string('addschool', 'praxe')); } if ($tab == PRAXE_TAB_EDITTEACHER_HOME) { $recordid = optional_param('recordid', 0, PARAM_INT); $records = praxe_get_praxe_records(praxe_record::getData('id')); if ($records) { $options = array(); $options[0] = get_string('all'); foreach ($records as $rec) { $options[$rec->id] = $rec->schoolname . " - " . praxe_get_user_fullname($rec->teacherid) . " - " . $rec->subject . " - " . praxe_get_user_fullname($rec->student); } $sel = new single_select(praxe_get_base_url(array('mode' => $mode)), 'recordid', $options, $recordid, null, 'praxepop_recorddetail'); $sel->label = get_string('praxe', 'praxe'); $tab_content .= $OUTPUT->render($sel); } } if ($tab == PRAXE_TAB_EDITTEACHER_SCHOOLS || !is_null($viewschool)) { $activated[] = PRAXE_TAB_EDITTEACHER_SCHOOLS; /// school list exists /// if (is_array($schools = praxe_get_schools())) { /// schoolid is not valid(for this user at least) or viewschool is null => set to default view of schools/// if (!array_key_exists($viewschool, $schools)) { $viewschool = 0; if ($mode != $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_TEACHERS] && $mode != $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_LOCATIONS]) { $mode = $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_SCHOOLS];
/** * * @param int $headm [optional][default null] * @param int $schoolid [optional][default null] * @return string - if no records, returns empty string */ public static function school_teachers_by_schools($headm = null, $schoolid = null) { $ret = ''; $ext = praxe_get_ext_teachers_at_school($headm, $schoolid); if (!$ext) { return get_string('no_teachers_for_this_school', 'praxe'); } $arr = array(); foreach ($ext as $id => $teach) { if (!isset($arr[$teach->schoolid])) { $arr[$teach->schoolid] = new stdClass(); $arr[$teach->schoolid]->name = $teach->name; $arr[$teach->schoolid]->street = $teach->street; $arr[$teach->schoolid]->teachers = array(); } $arr[$teach->schoolid]->teachers[$id] = new stdClass(); $arr[$teach->schoolid]->teachers[$id]->firstname = $teach->firstname; $arr[$teach->schoolid]->teachers[$id]->lastname = $teach->lastname; $arr[$teach->schoolid]->teachers[$id]->id = $teach->teacherid; } $strstud = get_string('firstname') . ' / ' . get_string('lastname'); $strloc = get_string('locations', 'praxe'); $table = new html_table(); $table->head = array($strstud); $table->align = array('left'); foreach ($arr as $sch) { $data = array(); foreach ($sch->teachers as $teach) { if (is_null($teach->id)) { continue; } $data[] = array(praxe_get_user_fullname($teach->id)); } if (count($data)) { $table->data = $data; if (is_null($schoolid)) { $ret .= '<h3>' . s($sch->name) . '</h3>'; } $ret .= html_writer::table($table); } } return $ret; }
public function show_schedule($schedules, $boolReturn = true, $editlinks = array()) { global $CFG, $OUTPUT; if (!$schedules) { $ret = get_string('no_schedule_items', 'praxe'); if ($boolReturn) { return $ret; } else { $this->content .= $ret; return true; } } $table = new html_table(); $table->head = array(get_string('date'), get_string('lesson_number', 'praxe'), get_string('time'), get_string('yearclass', 'praxe'), get_string('schoolroom', 'praxe'), get_string('subject', 'praxe'), get_string('lesson_theme', 'praxe'), get_string('edit'), get_string('inspection', 'praxe')); $table->align = array('left', 'center', 'center', 'center', 'center', 'left', 'left', 'center', 'center'); $editable = praxe_has_capability('editstudentschedule') || praxe_has_capability('manageallincourse'); $params = $editlinks; $delparams = array('praxeaction' => 'deleteschedule'); foreach ($schedules as $item) { if (is_null($item->lesnumber)) { $item->lesnumber = "---"; } else { $item->lesnumber .= "."; } $row = array(userdate((int) $item->timestart, get_string('strftimedateshort')), $item->lesnumber, userdate((int) $item->timestart, "%H:%M") . ' - ' . userdate((int) $item->timeend, "%H:%M"), praxe_get_yearclass($item->yearclass), s($item->schoolroom), s($item->lessubject), format_text($item->lestheme)); if ($editable && $item->timestart - PRAXE_TIME_TO_EDIT_SCHEDULE > time()) { $params['scheduleid'] = $item->id; $delparams['scheduleid'] = $item->id; $row[] = $OUTPUT->action_icon(praxe_get_base_url($params), new pix_icon('t/edit', get_string('edit'))) . $OUTPUT->action_icon(praxe_get_base_url($delparams), new pix_icon('t/delete', get_string('delete'))); } else { $row[] = "---"; } if (count($item->inspectors)) { $ins = ""; foreach ($item->inspectors as $insp) { $ins .= "<div class=\"inspector right\">" . $OUTPUT->render(new pix_icon('icon_inspect', get_string('inspection', 'praxe'), 'praxe')) . " " . praxe_get_user_fullname($insp) . "</div>"; } $row[] = $ins; } else { $row[] = " "; } $table->data[] = $row; } if ($boolReturn) { return html_writer::table($table); } else { $this->content .= html_writer::table($table); return true; } }