require("../../config.php");
require_once('edit_interview_form.php');
$id = optional_param('interview_id', 0, PARAM_INT);
if ($id) {
$candidates = $DB->get_record('locfb_interview', array('interview_id' => $id), '*', MUST_EXIST);
$pagedesc = 'Edit Interviews';
$pageparams = array('interview_id' => $id);
}else{
$candidates = new stdClass;
$pagedesc = 'Add Interviews';
$pageparams = array();
$candidates->interview_id = null;
}
$site = get_site();
$fullname = $site->fullname;
$systemcontext = context_system::instance();
//$PAGE->set_heading($fullname);
$PAGE->set_pagelayout('admin');
$PAGE->set_context($systemcontext);
$PAGE->set_url('/local/candidates/edit_interview.php', $pageparams);
$textfieldoptions = array('trusttext'=>true, 'subdirs'=>true, 'maxfiles'=> 2, 'maxbytes'=> $CFG->maxbytes, 'context' => $systemcontext);
$args = array(
'editoroptions' => $textfieldoptions
);
$editform = new candidates_edit_interview_form(null, $args);
$editform->set_data($candidates);
if ($editform->is_cancelled()) {
redirect($CFG->wwwroot.'/local/candidates/interview.php');
}else if ($cnddata = $editform->get_data()) {
//echo "Data Fetch";
$candidates->interview_heading = $cnddata->interview_heading;
$candidates->content = $cnddata->content['text'];
$candidates->contact = $cnddata->contact;
$candidates->priority = $cnddata->priority;
$candidates->status = $cnddata->status;
$url = $CFG->wwwroot.'/local/candidates/interview.php';
if (empty($candidates->interview_id)) {
$candidate_id = $DB->insert_record('locfb_interview', $candidates);
$candidates->interview_id = $candidate_id;
print_r($candidates);
//exit;
$msg = 'interview added successfully.';
} else {
$candidate_id = $candidates->interview_id;
$DB->update_record('locfb_interview', $candidates);
$msg = 'Candidates updated successfully.';
}
redirect($url, $msg);
}
echo $OUTPUT->header();
echo $OUTPUT->heading($pagedesc);
$editform->display();
echo $OUTPUT->footer();
please show me where i made mistake.