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 : 3.138.113.44


Current Path : /proc/thread-self/root/var/www/oasis/Report_details_old/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/Report_details_old/report_marks_elementwise.php

<?php

function GeneratElementWiseReport($aobj_context)
{
	session_start();
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
    $college_code = $_SESSION['collcode']; 
	$degree_code = $aobj_context->mobj_data["degree_code"]; 
	$exam_code = $aobj_context->mobj_data["exam_code"]; 
	$sublist_start = $aobj_context->mobj_data["subwise_start"]; 
	$sublist_end = $aobj_context->mobj_data["subwise_end"]; 
	$element_type = $aobj_context->mobj_data["elemtype"]; 
	$sectionfrom = $aobj_context->mobj_data["sectionfrom"];
	$sectionto = $aobj_context->mobj_data["sectionto"];
	$dbname = "resultsg_reva2";
	$fp = fopen('php://output', 'w');
	$slno=0;
	
	$sql = "select m.FREGNO,stu.fname,stu.fsection,
	LENGTH(CONCAT(',',',',',',GROUP_CONCAT(s.fsubname ORDER BY s.fcsubcode))) titlength,
	concat(',',',',',',group_concat(s.fcsubcode order by s.fcsubcode)) fsubcode,
	concat('Reg.no,','Name,','Section,',group_concat(replace(s.fshortname,s.fssubtype,'') order by s.fcsubcode)) fshortname,
	concat(',',',',',',group_concat(s.fsmaxmarks order by s.fcsubcode)) as fcsubcode,
	group_concat(if(m.FMARKS>=0,m.FMARKS,if(m.FMARKS=-2,'A','-')) order by s.FCSUBCODE separator ',')  as fsubmarks,
	concat(',',',',',',group_concat(s.fsubname order by s.fcsubcode)) fsubname
	from subject s left outer join marks m on s.fdegree = m.fdegree 
	and s.fexamno = m.fexamno and s.fcsubcode = m.fsubcode 
	and s.FDEGREE='{$degree_code}' 
	and s.FEXAMNO='{$exam_code}' and SUBSTR(s.fssubname,1,2)  = '{$element_type}'
	left join student stu on m.fdegree = stu.fdegree and m.fregno = stu.fregno
	where m.FCOLLCODE='{$college_code}' 
	and s.fsubcode between '{$sublist_start}' and '{$sublist_end}' and IF(IFNULL(stu.fsection,'') <> '', stu.fsection BETWEEN '{$sectionfrom}' AND '{$sectionto}',1=1)
	and if(s.fdegree='BTEE',m.FREGNO not like 'R15CV%',1 = 1)
	and IFNULL(m.FDELETED,'F') <> 'T' and ifnull(s.fintass,'F') = 'T'
	group by stu.fsection, m.FREGNO order by stu.fsection, m.FREGNO";
    $header = $aobj_context->mobj_db->GetAll($sql);

	/* $i = 2;
	$e_data.="<table cellspacing='0' cellpadding='1' border='1' width = ''>";
	$e_data.="<tr>";
	$e_data.="<td style = 'text-align:center;font-weight: bold;' >Sl. No.</td>";
	foreach($header as $key=>$row)
	{
		$vads = ($header as $key=>$row);
		$e_data.="<td style = 'text-align:center;font-weight: bold;' >{$vads[$i]}</td>";
		$i++;
	}
	$e_data.="</tr>"; */
	$titlength = 0;
	
	foreach($header as $key=>$row) 
	{
		$length = $row['titlength'];		
		$headertit[$row['titlength']] = $row['fsubname'];
		$headerele[$row['titlength']] = $row['fsubcode'];
		$headeshort[$row['titlength']] = $row['fshortname'];
		if($length >= $titlength )
			$titlength = $length;
		
	}
	
	$vads = explode(',',$headertit[$titlength]);
	fputcsv($fp, $vads);
	
	$vads = explode(',',$headerele[$titlength]);
	fputcsv($fp, $vads);
	
	$vads = explode(',',$headeshort[$titlength]);
	fputcsv($fp, $vads);
	/* foreach($header as $key=>$row) 
	{
		$vads = explode(',',$row['fsubcode']);
		fputcsv($fp, $vads);
		break;
	} */
	
	/* foreach($header as $key=>$row) 
	{
		$vads = explode(',',$row['fshortname']);
		fputcsv($fp, $vads);
		break;
	} */

    $sql = "select stu.fsection,concat(m.FREGNO,',',stu.fname,',',stu.fsection,',',group_concat(if(m.FMARKS>=0,m.FMARKS,if(m.FMARKS=-2,'A','-')) order by s.FCSUBCODE ))  as fsubmarks
			from subject s left outer join marks m on s.fdegree = m.fdegree 
			and s.fexamno = m.fexamno and s.fcsubcode = m.fsubcode 
			and s.FDEGREE='{$degree_code}' 
			and s.FEXAMNO='{$exam_code}' and SUBSTR(s.fssubname,1,2)  = '{$element_type}'
			left join student stu on m.fdegree = stu.fdegree and m.fregno = stu.fregno
			where m.FCOLLCODE='{$college_code}' 
			and s.fsubcode between '{$sublist_start}' and '{$sublist_end}' and  IF(IFNULL(stu.fsection,'') <> '', stu.fsection BETWEEN '{$sectionfrom}' AND '{$sectionto}',1=1)
			and if(s.fdegree='BTEE',m.FREGNO not like 'R15CV%',1 = 1)
			and IFNULL(m.FDELETED,'F') <> 'T' and ifnull(s.fintass,'F') = 'T'
			group by stu.fsection, m.FREGNO order by stu.fsection, m.FREGNO";
			$result = $aobj_context->mobj_db->GetAll($sql);

	if ($fp ) 
	{
		header('Content-Type: text/csv');
		header('Content-Disposition: attachment; filename="export.csv"');
		header('Pragma: no-cache');
		header('Expires: 0');
		foreach($result as $key=>$row) 
		{	
			$vads = explode(',',$row['fsubmarks']);
			fputcsv($fp, $vads);
			//$hd[] =  $row[3]
		}
		die;
	}
    fclose($fp);
}





?>