function definition() { global $DB, $PAGE; $mform = & $this->_form; $reportid = $this->_customdata['id']; $scheduledreportid = $this->_customdata['scheduleid']; $PAGE->requires->yui_module('moodle-block_cobalt_reports-schedulertype', 'M.block_cobalt_reports.init_schedulertype', array(array('formid' => $mform->getAttribute('id')))); $mform->addElement('hidden', 'id', $reportid); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'scheduleid', $scheduledreportid); $mform->setType('scheduleid', PARAM_INT); $exportoptions = cr_get_export_plugins(); $reportname = $DB->get_field('block_cobalt_reports', 'name', array('id' => $reportid)); $exporttofilesystem = false; if (get_config('block_cobalt_reports', 'exportfilesystem') == 1) { $exporttofilesystem = true; } if ($scheduledreportid < 0) { $pagename = 'addscheduledreport'; } else { $pagename = 'editscheduledreport'; } $mform->addElement('header', 'general', get_string($pagename, 'block_cobalt_reports')); $mform->addElement('static', 'report', get_string('report', 'block_cobalt_reports'), $reportname); $mform->addElement('select', 'exportformat', get_string('export', 'block_cobalt_reports'), $exportoptions); if ($exporttofilesystem) { $exporttosystemarray = array(); $exporttosystemarray[] = & $mform->createElement('radio', 'exporttofilesystem', '', get_string('exporttoemail', 'block_cobalt_reports'), REPORT_EMAIL); $exporttosystemarray[] = & $mform->createElement('radio', 'exporttofilesystem', '', get_string('exporttosave', 'block_cobalt_reports'), REPORT_EXPORT); $exporttosystemarray[] = & $mform->createElement('radio', 'exporttofilesystem', '', get_string('exporttoemailandsave', 'block_cobalt_reports'), REPORT_EXPORT_AND_EMAIL); $mform->setDefault('exporttofilesystem', 1); $mform->addGroup($exporttosystemarray, 'exporttofilesystemarray', get_string('exportfilesystemoptions', 'block_cobalt_reports'), array('<br />'), false); } else { $mform->addElement('hidden', 'emailsaveorboth', REPORT_EMAIL); $mform->setType('emailsaveorboth', PARAM_TEXT); } //Schedule type options $scheduling = new schedule(); $frequencyselect = $scheduling->get_options(); $mform->registerNoSubmitButton('updatefrequency'); $mform->addElement('submit', 'updatefrequency', get_string('updatefrequency', 'block_cobalt_reports')); $mform->addElement('select', 'frequency', get_string('schedule', 'block_cobalt_reports'), $frequencyselect); $mform->addElement('hidden', 'frequentpos'); $mform->setType('frequentpos', PARAM_RAW); $this->add_action_buttons(); }
$scheduledreport->daily = $scheduledreport->schedule; break; case 2: $scheduledreport->weekly = $scheduledreport->schedule; break; case 3: $scheduledreport->monthly = $scheduledreport->schedule; break; } $mform->set_data($scheduledreport); } $myreportsurl = $CFG->wwwroot . '/blocks/cobalt_reports'; $scheduledreports = $DB->get_records('block_cobaltreports_schedule', array('reportid' => $reportid)); $scheduling = new schedule(); $frequencyselect = $scheduling->get_options(); $data = array(); foreach ($scheduledreports as $sreport) { $line = array(); $line[] = $DB->get_field('block_cobalt_reports', 'name', array('id' => $sreport->reportid)); $line[] = $sreport->exportformat; $line[] = $scheduling->get_formatted($sreport->frequency, $sreport->schedule); $buttons = array(); $buttons[] = html_writer::link(new moodle_url('/blocks/cobalt_reports/components/scheduler/schedule.php', array('id' => $reportid, 'courseid' => $courseid, 'scheduleid' => $sreport->id, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall'))); $buttons[] = html_writer::link(new moodle_url('/blocks/cobalt_reports/components/scheduler/schedule.php', array('id' => $reportid, 'courseid' => $courseid, 'scheduleid' => $sreport->id, 'sesskey' => sesskey(), 'delete' => 1)), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall'))); $line[] = implode(' ', $buttons); $data[] = $line; } $table = new html_table();