private function show_all_my_locations($bOnlyActual = 0, $year = 0) { global $USER, $CFG, $tab_modes, $DB, $OUTPUT; if (!($all = praxe_get_locations(null, null, null, $bOnlyActual, $year))) { return get_string('nolocationsavailable', 'praxe'); } $table = new html_table(); $strname = get_string('schoolname', 'praxe'); $strsubject = get_string('subject', 'praxe'); $strstudy = get_string('studyfield', 'praxe'); $strisced = get_string('iscedlevel', 'praxe'); $stryear = get_string('year', 'praxe'); $strterm = get_string('term', 'praxe'); $table->head = array($strname, $strsubject, $strisced, $strstudy, $stryear, $strterm, get_string('active', 'praxe'), get_string('edit')); $table->align = array('left', 'left', 'left', 'left', 'center', 'center', 'center'); $stredit = get_string('edit'); foreach ($all as $loc) { if ($loc->teacherid != $USER->id) { continue; } $row = array(s($loc->name), s($loc->subject), praxe_get_isced_text($loc->isced), s($loc->studyfieldname) . " (" . s($loc->shortcut) . ")"); $row[] = s($loc->year); $row[] = praxe_get_term_text($loc->term); $row[] = $loc->active == 1 ? get_string('yes') : get_string('no'); if (praxe_has_capability('editanylocation') || praxe_has_capability('editownlocation') && $USER->id == $loc->teacherid) { $row[] = $OUTPUT->action_icon(praxe_get_base_url(array("mode" => $tab_modes['extteacher'][PRAXE_TAB_EXTTEACHER_EDITLOCATION], "locationid" => $loc->id)), new pix_icon('t/edit', $stredit)); } else { $row[] = get_string('already_used', 'praxe'); } $table->data[] = $row; } if (count($table->data)) { return html_writer::table($table); } return get_string('nolocationsavailable', 'praxe'); }
function praxe_get_available_locations($user, $isced = 0, $studyfield = null) { global $cm, $course, $CFG, $DB; if (!is_array($all = praxe_get_locations($isced, $studyfield, true, true))) { return false; } /// used locations in all instances of praxe, which are set iqual like this instance (term, year, studyfield,isced) /// $sql = "SELECT rec.location, rec.*\n\t\t\t\tFROM {praxe_records} rec\n\t\t\t\tINNER join {praxe} praxe ON (praxe = praxe.id)\n\t\t\t\tWHERE year = ? AND term = ?\n\t\t\t\tAND studyfield = ? AND (status <> ? OR student = ?)"; /// selection of location with specific isced level /// $params = array(date('Y', time()), praxe_record::getData('term'), praxe_record::getData('studyfield'), PRAXE_STATUS_REFUSED, $user); if ($isced > 0) { $sql .= "AND isced = ?"; $params[] = praxe_record::getData('isced'); } if (!is_array($used = $DB->get_records_sql($sql, $params))) { return $all; } $result = array_diff_key($all, $used); return $result; }