$redirecturl = new moodle_url('/' . $CFG->admin . '/report/cpd/index.php', array('cpdyearid' => $cpdyearid)); /* Redirect back to user CPDs */ if (!empty($cpdyearid)) { if (!($cpdyear = $DB->get_record('cpd_year', array('id' => $cpdyearid)))) { //get cpd year start and end print_error('invalidcpdyear', 'report_cpd'); } } if (!empty($cpdid)) { if (!($cpd_record = $DB->get_record('cpd', array('id' => $cpdid)))) { print_error('invalidcpdactivity', 'report_cpd'); } } //get data $activity_types = get_cpd_menu('activity_types'); $statuses = get_cpd_menu('statuses'); $mform = new edit_activity_form("edit_activity.php", compact('activity_types', 'statuses', 'cpdid', 'cpdyearid', 'cpdyear')); $frmdata = $mform->get_data(); if (!empty($frmdata)) { $errors = process_activity_form($frmdata, $redirecturl->out()); } else { if ($cpd_record) { $cpd_record = (array) $cpd_record; if ($cpd_record['duedate']) { $cpd_record['duedate[d]'] = date('d', $cpd_record['duedate']); $cpd_record['duedate[m]'] = date('m', $cpd_record['duedate']); $cpd_record['duedate[Y]'] = date('Y', $cpd_record['duedate']); unset($cpd_record['duedate']); } if ($cpd_record['startdate']) { $cpd_record['startdate[d]'] = date('d', $cpd_record['startdate']);
$filter_data->from = optional_param('from', null, PARAM_INT); $filter_data->to = optional_param('to', null, PARAM_INT); $filter_data->userid = $USER->id; if (($cpd_records = get_cpd_records($filter_data)) && !empty($download)) { // Add disclaimer $cpd_records[] = array(); $cpd_records[] = array(get_string('confirmstatement', 'report_cpd') . ':', ''); $cpd_records[] = array(get_string('date') . ':', ''); download_csv('cpd_record', $columns, $cpd_records); exit; } } else { $columns['edit'] = get_string('edit'); $columns['delete'] = get_string('delete'); } $cpd_years = get_cpd_menu('years'); $userid = $USER->id; $filter = new cpd_filter_form('index.php', compact('cpd_years', 'userid'), 'post', '', array('class' => 'cpdfilter')); if (empty($cpd_records)) { $filter_data = $filter->get_data(); if (empty($filter_data)) { // Filter object $filter_data = new stdClass(); $filter_data->userid = $USER->id; $cpdyearid = empty($cpdyearid) ? get_current_cpd_year() : $cpdyearid; $filter_data->cpdyearid = $cpdyearid; // Set cpd year id always needs to be set $filter_data->from = null; $filter_data->to = null; } if (!($errors = validate_filter($filter_data))) {
// Filter object $filter_data = new stdClass(); $filter_data->cpdyearid = optional_param('cpdyearid', null, PARAM_INT); $filter_data->filterbydate = optional_param('filterbydate', null, PARAM_BOOL); $filter_data->from = optional_param('from', null, PARAM_INT); $filter_data->to = optional_param('to', null, PARAM_INT); $filter_data->activitytypeid = optional_param('activitytypeid', null, PARAM_INT); $filter_data->userid = optional_param('userid', null, PARAM_INT); $cpd_records = get_cpd_records($filter_data, false, $extra_columns, $returned); if ($cpd_records && !empty($download)) { download_csv('cpd_record', $columns, $cpd_records); exit; } } $cpd_years = get_cpd_menu('years'); $activity_types = get_cpd_menu('activity_types'); $users = get_users_by_capability($systemcontext, 'report/cpd:userview', 'u.id, u.firstname, u.lastname', 'lastname ASC'); $filter = new cpd_filter_form('adminview.php', compact('cpd_years', 'activity_types', 'users'), 'post', '', array('class' => 'cpdfilter')); if (empty($cpd_records)) { if ($filter_data = $filter->get_data()) { if (!($errors = validate_filter($filter_data))) { $cpd_records = get_cpd_records($filter_data, false, $extra_columns, $returned); } } } // Print the header. if (has_capability('report/cpd:superadminview', $systemcontext) && empty($print)) { admin_externalpage_setup('cpdadminview'); // Include styles $CFG->stylesheets[] = $CFG->wwwroot . '/admin/report/cpd/css/style.css'; } else {