<?php
	include "db_connection/db_connection.php";
	include "config/functions.php";
	ini_set('max_execution_time', 300);	
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}		
		
	$data = '';
	$MAS_CAT = '';
	$CAT_ID = '';
	
	$SLCT_CAT = "SELECT master_cat_name,master_cat_id FROM master_cat WHERE statu_s='active'";
	$QURY_CAT = mysqli_query($connect,$SLCT_CAT);		
	if(mysqli_num_rows($QURY_CAT)>0)
	{
		while($FTCH_CAT = mysqli_fetch_object($QURY_CAT))
		{	
			$MAS_CAT = $MAS_CAT.$FTCH_CAT->master_cat_name." \t ";
			$CAT_ID[$FTCH_CAT->master_cat_id] = $FTCH_CAT->master_cat_id;
		}
	}
	$heading	    = "Sl.No \t Name of Dept \t ".$MAS_CAT." \n ";
	for($i=1;$i<17;$i++)
	{		 
		$data = $data.data_fun($i,$CAT_ID);
	} 
	
	$result = $heading.$data;
	$saving_file_name 	= "Total Dept Pending on ".date("d-m-Y");
	header("Content-type: application/octet-stream");
	header("Content-Disposition: attachment; filename=\"$saving_file_name.xls\"");
	header("Content-Transfer-Encoding: binary");
	if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
	{
		header('Cache-Control: public');
	}
	echo $result;
	exit;  
?>