0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.219.81.129


Current Path : /var/www/oasis/Report_details_old/
Upload File :
Current File : /var/www/oasis/Report_details_old/fee_summary.php

<?php
function Generatefeesummary($aobj_context)
{
	session_start();
	$collcode = $_SESSION['collcode'];
	
	ini_set('memory_limit','300M');
	ini_set('max_execution_time',3300);
	
	
	$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
	$main_src = $main_src_obj[1];
	
	$pdf_writer_class = $aobj_context->main_src."/Excel_Writer/Writer.php";
	$Workbook = $aobj_context->main_src."/Excel_Writer/Workbook.php";
	$PEAR = $aobj_context->main_src."/Excel_Writer/PEAR.php";
	//var_dump($aobj_context->main_src);die();
	//$root_pdf_file_download = $aobj_context->main_src."/Report_details/output/report_me_student_list.pdf";
	require_once($pdf_writer_class);
	require_once($Workbook);
	require_once($PEAR);
	ini_set('memory_limit','300M');
	ini_set('max_execution_time',3300);
	$filename = 'Fee_Summary';
	$xls =& new Spreadsheet_Excel_Writer(""); 
	$xls->setVersion(8);
// Add a worksheet to the file, returning an object to add data to
	$sheet =& $xls->addWorksheet('Binary Count');


	
	
	
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$f = fopen('php://output', 'w'); 
	
	
	
	
	$degree_from = trim($aobj_context->mobj_data["degree_from"]);
	$degree_to = trim($aobj_context->mobj_data["degree_to"]);
	
	$coll_from = trim($aobj_context->mobj_data["coll_from"]);
	$coll_to = trim($aobj_context->mobj_data["coll_to"]);

	$date_from = trim($aobj_context->mobj_data["date_from"]);
	$date_to = trim($aobj_context->mobj_data["date_to"]);
	
	$reporttype = trim($aobj_context->mobj_data["reporttype"]);
    $report = trim($aobj_context->mobj_data["report"]);
    
    
    $collegewise = trim($aobj_context->mobj_data["collegewise"]);
    $degreewsie = trim($aobj_context->mobj_data["degreewsie"]);
    
	$format_a = array('bordercolor' => 'Black',
            'left' => 0, 
            'bottom' => 0,
            'right' =>0,
            'top' => 0,
            'bold'=>'1',
            'size' => '14',
            'color'=>'Black',
            'align' => 'center');
	
	if($collegewise == '1')
	{    
		$order = "fcollcode,fdegree";
		$degree = "cs.fdegree";
		$name = "Degree";
	}
	if($degreewsie == '1')
	{   
		$order = "fdegree,fcollcode"; 
		$degree = "concat(cs.fdegree,' - ',FDESCPN) as fdegree";
		$name = 'College';
	}

	if($report == 'Categorywise Summary')
	{	
		$title1 = array('Sl. No.',"$name",'CAT-I','GM','IIA','IIB','IIIA','IIIB','SC','ST');
		$w = array('30','60','50','50','50','50','50','50','50','50');
		$a = array('a','b','c','d','e','f','g','h','i','j','k','l');
		$l = 'j';
	}
	else if($report == 'Genderwise Summary')
	{	
		$title1 = array('Sl. No.',"$name",'M','F');
		$w = array('30','60','60','60');
		$a = array('a','b','c','d','e','f','g','h','i','j','k','l');
		$l = 'd';
	}
	else if($report == 'Payment Typewise Report')
	{	
		$title1 = array('Sl. No.',"$name",'Post Office','Bank','Net Banking');
		$w = array('30','60','60','60','60');
		$a = array('a','b','c','d','e','f','g','h','i','j','k','l');
		$l = 'e';
	}
	else
	{
		$title1 = array('Sl. No.',"$name",'I Semester','II Semester','III Semester','IV Semester','V Semester','VI Semester','VII Semester','VIII Semester');
		$w = array('30','60','100','100','100','100','100','100','100','100');
		$a = array('a','b','c','d','e','f','g','h','i','j','k','l');
		$l = 'j';
	}	
	
     if($reporttype == 'examapplication')
     {    
		
		if($report == "Categorywise Summary")
		{
			$query = "select concat(cs.fcollcode,' - ',c.fcollname) as fcollcode ,{$degree},
			sum(case when ifnull(cs.FCATEGORY,'') = '{$title1[2]}' then cs.ftotalfee else 0 end) as '{$title1[2]}',
			sum(case when cs.FCATEGORY ='{$title1[3]}' then cs.ftotalfee else 0 end)  {$title1[3]},
			sum(case when cs.FCATEGORY ='{$title1[4]}' then cs.ftotalfee else 0 end)  {$title1[4]},
			sum(case when cs.FCATEGORY ='{$title1[5]}' then cs.ftotalfee else 0 end)  {$title1[5]},
			sum(case when cs.FCATEGORY ='{$title1[6]}' then cs.ftotalfee else 0 end)  {$title1[6]},
			sum(case when cs.FCATEGORY ='{$title1[7]}' then cs.ftotalfee else 0 end)  {$title1[7]},
			sum(case when cs.FCATEGORY ='{$title1[8]}' then cs.ftotalfee else 0 end) {$title1[8]},
			sum(case when cs.FCATEGORY ='{$title1[9]}' then cs.ftotalfee else 0 end)  {$title1[9]}
			from appcandsum cs,college c,degree d  
			where  cs.fcollcode = c.fcollcode
			and ifnull(FRECPTDATE,'') <> '' and d.fdegree = cs.fdegree and cs.fexamno = d.fexamno
			and ifnull(FTOTALFEE,'') <> '' and fpaymentstatus = 'success'
			group by cs.fcollcode,cs.fdegree 
			order by {$order}";

		}
		else if($report == "Genderwise Summary")
		{
			$query = "select concat(cs.fcollcode,' - ',c.fcollname) as fcollcode ,{$degree},
			sum(case when ifnull(s.FSEX,'') = '{$title1[2]}' then cs.ftotalfee else 0 end) as '{$title1[2]}',
			sum(case when ifnull(s.FSEX,'') ='{$title1[3]}' then cs.ftotalfee else 0 end)  {$title1[3]}
			from appcandsum cs,college c,student s,degree d
			where  cs.fcollcode = c.fcollcode and s.fdegree = cs.fdegree and s.fcollcode = cs.fcollcode
			and s.fregno = cs.fregno
			and ifnull(FRECPTDATE,'') <> '' and d.fdegree = cs.fdegree and cs.fexamno = d.fexamno
			and ifnull(FTOTALFEE,'') <> '' and fpaymentstatus = 'success'
			group by cs.fcollcode,cs.fdegree 
			order by {$order}";

		}
		else if($report == "Payment Typewise Report")
		{
			$query = "select concat(cs.fcollcode,' - ',c.fcollname) as fcollcode ,{$degree},
			sum(case when ifnull(cs.FPAYMENTYPE,'') = 'POSTOFFICE' then cs.ftotalfee else 0 end) as '{$title1[2]}',
			sum(case when ifnull(cs.FPAYMENTYPE,'') ='DEBIT/CREDIT/NET BANKING' then cs.ftotalfee else 0 end)  '{$title1[3]}',
			sum(case when ifnull(cs.FPAYMENTYPE,'') ='BANK' then cs.ftotalfee else 0 end)  '{$title1[4]}'
			from appcandsum cs,college c,degree d  
			where  cs.fcollcode = c.fcollcode
			and ifnull(FRECPTDATE,'') <> '' and d.fdegree = cs.fdegree and cs.fexamno = d.fexamno
			and ifnull(FTOTALFEE,'') <> '' and fpaymentstatus = 'success'
			group by cs.fcollcode,cs.fdegree 
			order by {$order}";

		}
		else	
		{
			$query = "select concat(cs.fcollcode,'-',college.fcollname,',',ftown) as fcollcode,{$degree},
			sum(FEXAMFEEA) as '{$title1[2]}',sum(FEXAMFEEB) as '{$title1[3]}',sum(FEXAMFEEC) as '{$title1[4]}',
			sum(FEXAMFEED) as '{$title1[5]}',sum(FEXAMFEEE) as '{$title1[6]}',sum(FEXAMFEEF) as '{$title1[7]}',
			sum(FEXAMFEEG) as '{$title1[8]}',
			sum(FEXAMFEEH) as '{$title1[9]}' FROM appcandsum cs,college,degree d 
			where ifnull(FRECPTDATE,'') <> '' and ifnull(FTOTALFEE,'') <> '' 
			and  college.fcollcode = cs.fcollcode and d.fdegree = cs.fdegree and cs.fexamno = d.fexamno and  fpaymentstatus = 'success'
			group by fcollcode,fdegree
			order by {$order}";
        }
		
     }else if($reporttype == 'revaluation')
     {
        $query = "select rs.fcollcode,rs.fdegree,rs.fexamno as fexamno,sum(rs.famount) as famount,s.FCASTE,FCORRTYPE from res_stud rs
        inner join student s on s.fdegree = rs.fdegree and s.fregno = rs.fregno and s.fcollcode = rs.fcollcode
        where FPAYMENTSTATUS = 'success' and ifnull(fackdate,'') <> ''  
        group by fdegree,fcollcode,fexamno,FCORRTYPE";
        
        
     }else if($reporttype == 'revaluation')
     {
         $query = "select concat(candsum.fcollcode,'-',college.fcollname,',',ftown) as fcollcode,{$degree},sum(FEXAMFEEA) as 1sem,sum(FEXAMFEEB) as 2sem,sum(FEXAMFEEC) as 3sem,
        sum(FEXAMFEED) as 4sem,sum(FEXAMFEEE) as 5sem,sum(FEXAMFEEF) as 6sem,sum(FEXAMFEEG) as 7sem,
        sum(FEXAMFEEH) as 8sem FROM candsum,college,degree d 
        where ifnull(FRECPTDATE,'') <> '' and ifnull(FTOTALFEE,'') <>'' and  college.fcollcode = candsum.fcollcode and d.fdegree = candsum.fdegree and candsum.fexamno = d.fexamno
        group by fcollcode,fdegree
        order by {$order}";
     }   
     
	//var_dump($query);die();
	$lobj_get_data = $aobj_context->mobj_db->GetAll($query);
	
	$arrW =0;
	$subjRow ='';
	
	$format_a = array('bordercolor' => 'black',
            'left' => 1, 
            'bottom' => 1,
            'right' => 1,
            'top' => 1,
            'bold'=>'1',
            'size' => '12',
            'color'=>'black',
            'align' => 'center');
	$format =& $xls->addFormat($format_a);
	if(!empty($lobj_get_data))
	{
		$query1 = "select funivname from control";
		$result = $aobj_context->mobj_db->GetRow($query1);
		
		$sheet->write(0,0, $result['funivname'],$format);
		$sheet->mergeCells(0,0,0,count($w));
		
		$sheet->write(1,0,$report,$format);
		$sheet->mergeCells(1,0,1,count($w));
		
		$sheet->write(2,0,'Date Range : '.$date_from.' - '.$date_to,$format);
		$sheet->mergeCells(2,0,2,count($w));
		
		$sheet->write(3,0,'College Range : '.$coll_from.' - '.$coll_to,$format);
		$sheet->mergeCells(3,0,3,count($w));
		
		$sheet->write(4,0,'Degree Range : '.$degree_from.' - '.$degree_to,$format);
		$sheet->mergeCells(4,0,4,count($w));
		
		
		$format_a = array('bordercolor' => 'black',
            'left' => 1, 
            'bottom' => 1,
            'right' => 1,
            'top' => 1,
            'bold'=>'1',
            'size' => '11',
            'color'=>'black',
            'align' => 'center');
	$format =& $xls->addFormat($format_a);
		for($i = 0;$i<count($w);$i++)
		{
			$sheet->writeString(5,$i, $title1[$i],$format);
		}
		$sheet->writeString(5,$i, "Total",$format);
		$e_data.="</tr>";							
		$filename = 'Fee_Summary';
		$counter_degree = 1;
		$collcodeold = '';
		$collcodenew = '';
		$degcodenew = '';
		$degcodeold = '';
		$j = 6;	
		$n = 1;
		$k = 6;
		foreach($lobj_get_data as $key=>$value)
		{
			$format_a = array('bordercolor' => 'black',
            'left' => 1, 
            'bottom' => 1,
            'right' => 1,
            'top' => 1,
            'bold'=>'0',
            'size' => '10',
			'italic'=>'1',
			'text_v_align'=>'50',
			'height' => '50',
            'color'=>'black',
            'align' => 'center');
		$format =& $xls->addFormat($format_a);
			$z = count($w)-1;
			for($i = 2;$i<count($w);$i++)
			{
				if($collegewise	== '1')
				{   
					$format_a = array('bordercolor' => 'black',
						'left' => 1, 
						'bottom' => 1,
						'right' => 1,
						'top' => 1,
						'bold'=>'1',
						'size' => '10',
						'italic'=>'1',	
						'text_v_align'=>'50',
						'height' => '50',
						'color'=>'black',
						'align' => 'Left',
						'underline'=> '1');
					$format =& $xls->addFormat($format_a);
					$collcodenew = $value['fcollcode'];	
					if($collcodenew != $collcodeold)
					{
						$fcollcode = wordwrap($value['fcollcode'], 500, '\n', false);
						$sheet->write($j,1, $fcollcode,$format);
						$sheet->mergeCells($j,1,$j,9);
						$collcodeold = $collcodenew;
						$j++;
						$n = 1;
					}	
					
				}
				if($degreewsie == '1')
				{   
					
					$format_a = array('bordercolor' => 'black',
						'left' => 1, 
						'bottom' => 1,
						'right' => 1,
						'top' => 1,
						'bold'=>'1',
						'size' => '10',	
						'text_v_align'=>'50',
						'height' => '50',
						'color'=>'black',
						'align' => 'Left',
						'underline'=> '1');
					$format =& $xls->addFormat($format_a);

					$degcodenew = $value['fdegree'];	
					if($degcodenew != $degcodeold)
					{
						$fdegree = wordwrap($value['fdegree'], 500, '\n', false);
						$sheet->write($j,1, $fdegree,$format);
						$sheet->mergeCells($j,1,$j,9);
						$degcodeold = $degcodenew;
						$j++;
						$n = 1;
					}
										
				}
				
				$format_a = array('bordercolor' => 'black',
            'left' => 1, 
            'bottom' => 1,
            'right' => 1,
            'top' => 1,
            'bold'=>'0',
            'size' => '10',
			'text_v_align'=>'50',
			'height' => '50',
            'color'=>'black',
            'align' => 'left');
		$format =& $xls->addFormat($format_a);
				$sheet->write($j,0, $n,$format);
				if($degreewsie == '1')	
					$sheet->write($j,1, $value['fcollcode'],$format);
				
				if($collegewise	== '1')
					$sheet->write($j,1, $value['fdegree'],$format);
			$format_a = array('bordercolor' => 'black',
			'left' => 1, 
			'bottom' => 1,
			'right' => 1,
			'top' => 1,
			'bold'=>'0',
			'size' => '10',
			'text_v_align'=>'50',
			'height' => '50',
			'color'=>'black',
			'align' => 'right');
			$format =& $xls->addFormat($format_a);
				$sheet->write($j,$i, $value[$title1[$i]],$format);
			}	
			$z = $j;
			$j++;
			$n++;
			$format_a = array('bordercolor' => 'black',
            'left' => 1, 
            'bottom' => 1,
            'right' => 1,
            'top' => 1,
            'bold'=>'1',
            'size' => '10',
            'color'=>'black',
            'align' => 'right');
			$format =& $xls->addFormat($format_a);
			
			$sheet->write($z,count($w),"=sum(c$j:$l$j)",$format);
			$k++;
			$counter_degree++;
		}
		$k = $k+1;
		$format_a = array('bordercolor' => 'black',
            'left' => 1, 
            'bottom' => 1,
            'right' => 1,
            'top' => 1,
            'bold'=>'1',
            'size' => '10',
            'color'=>'black',
            'align' => 'right');
		$format =& $xls->addFormat($format_a);
		$sheet->write($j,0,"Total",$format);
		$sheet->mergeCells($j,0,$j,1);
		for($i = 2;$i<count($w)+1;$i++)
		{	
			$sheet->write($j,$i,"=sum($a[$i]4:$a[$i]$j)",$format);
		}
		
	}
	else
	{
		$arr['html'] = '<p> No record found </p>';
	}	
	header("Content-Type:application/xls");
	header("Content-Disposition: attachment; filename={$filename}.xls"); 
	echo $sheet;
echo $sheet;
// Finish the spreadsheet, dumping it to the browser
$xls->close();

}

?>