<div id="show_departments" >
				<img src="loader.gif"  id="loader" alt="" />
			</div>
		<?php 
    }
    echo '<br/><input type="submit" value="View Report" name="report">';
    $OUTPUT->box_start('generalbox categorybox');
    echo '</form>';
}
if ($export) {
    $downloadType = $_POST['downloadType'];
    if ($downloadType == "Excel") {
        ExportToExcel($table);
    }
    if ($downloadType == "pdf") {
        ExportToPDF($table, $name, $type);
    }
}
/* if($export   ){               
       ExportToExcel($table);
   }*/
if (isset($_POST['report']) && ($hod == 1 || $observer == 1 || $admin == 1)) {
    echo html_writer::table($table);
}
$OUTPUT->box_end();
echo $OUTPUT->footer();
//================Export to Excel================//
function ExportToExcel($data, $name, $type)
{
    global $CFG;
    global $headings;
if ($type == 1) {
    $reportname = "Attendance Report";
}
if ($type == 2) {
    $reportname = "Short Attendance Report";
}
if ($type == 3) {
    $reportname = "Absentee Report (Period Wise)";
}
$export = optional_param('export', false, PARAM_BOOL);
$template = optional_param('template', false, PARAM_BOOL);
$content = $_POST['content'];
//optional_param('content',"", PARAM_ALPHANUM);
if ($template) {
    //echo $content;
    ExportToPDF($content);
}
$perd = optional_param('perd', false, PARAM_BOOL);
$start = $_POST['start'];
$end = $_POST['end'];
$context = get_context_instance(CONTEXT_COURSECAT, $categoryid);
if ($categoryid != -1) {
    require_capability('block/custom_reports:getattendancereport', $context);
}
$report = get_string('attendance_custom_reports', 'block_custom_reports');
$navlinks[] = array('name' => get_string('attendance_custom_reports', 'block_custom_reports'), 'link' => null, 'type' => 'activityinstance');
$navigation = build_navigation($navlinks);
if (!$export) {
    print_header('Attendance Custom Report', 'Attendance Custom Report', $navigation, '', '', true, '', user_login_string($SITE) . $langmenu);
}
if ($courses = get_courses($categoryid, '', 'c.id, c.fullname, c.startdate, c.idnumber, c.shortname') or $export or $perd) {