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.188.114.150
<?php
function monthwiseAttXlreport($aobj_context)
{
session_start();
ini_set('memory_limit','300M');
ini_set('max_execution_time',3300);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$filename = 'monthwiseAttXlreport.csv';
$f = fopen('php://output', 'w');
$classId = trim($aobj_context->mobj_data["classid"]);
$datefrom = trim($aobj_context->mobj_data["datefrom"]);
$dateto = trim($aobj_context->mobj_data["dateto"]);
$type = trim($aobj_context->mobj_data["type"]);
$fteachcode = trim($aobj_context->mobj_data["fteachcode"]);
if($type == 'app'){
$collcode = trim($aobj_context->mobj_data["collcode"]);
}else{
$collcode=$_SESSION['collcode'];
}
$query = "select distinct d.fdate, d.FNOCLASS as fnoclass,d.fperiod as fperiod, a.fclassname,
a.fteachcode from attend_det d
inner join attclass a on a.fclassid = d.fclassid
where d.fclassid='${classId}' and d.fdate between date_format(str_to_date('{$datefrom}','%Y-%m-%d'),'%Y-%m-%d')
and date_format(str_to_date('{$dateto}','%Y-%m-%d'),'%Y-%m-%d')
and a.fcollcode ='{$collcode}'";
$result = $aobj_context->mobj_db->GetAll($query);
$teachdata = "select * from masteach where fteachcode = '{$fteachcode}'";
$teachres = $aobj_context->mobj_db->GetRow($teachdata);
$query_2 = "select a.fregno, group_concat(a.fpresent ORDER BY a.fdate separator '*') as fpresent,
s.fname from attend_det a
inner join student s on
s.fregno = a.fregno where a.fclassid = '${classId}' and
a.fdate between date_format(str_to_date('{$datefrom}','%Y-%m-%d'),'%Y-%m-%d')
and date_format(str_to_date('{$dateto}','%Y-%m-%d'),'%Y-%m-%d')
and a.fcollcode ='{$collcode}'
and ifnull(s.fdeleted,'') <> 'T'
group by a.fregno
order by s.fname";
$result_2 = $aobj_context->mobj_db->GetAll($query_2);
$collquery = "select ifnull(FCOLLCODE,'') as fcollcode,ifnull(FCOLLNAME,'') as fcollname,concat(FCOLLCODE, '-' ,FCOLLNAME, ', ' ,FTOWN) as fcoll
from college
where fcollcode = '{$collcode}'";
$rescollquery = $aobj_context->mobj_db->GetRow($collquery);
$unviquery = "select concat(funivname, '-' , ftown) as coll, funivadd1, ifnull(fregroll, 'Reg. No.')as fregroll from control";
$resuniquery = $aobj_context->mobj_db->GetRow($unviquery);
$dateform = date("d/m/Y",strtotime($datefrom));
$todate = date("d/m/Y",strtotime($dateto));
$arrW =0;
$subjRow ='';
$span = 0;
foreach($result as $key => $value){
$span = $span + count($value['fdate']);
}
foreach ($result_2 as $key => $v) {
// var_dump($v['fpresent']);
}
// die();
$colspan = 7 + $span;
if(!empty($result))
{
$e_data.="<table cellspacing='0' cellpadding='1' border='1' width = ''>";
$e_data.="<thead>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<th colspan='$colspan'>{$resuniquery['coll']}</th>";
$e_data.="</tr>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<th colspan='$colspan'>{$resuniquery['funivadd1']}$colspan</th>";
$e_data.="</tr>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<th colspan='$colspan'>College : {$rescollquery['fcoll']}</th>";
$e_data.="</tr>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<th colspan='$colspan'>Attendance Summary Range : {$dateform} - {$todate}</th>";
$e_data.="</tr>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<th colspan='$colspan'>Class : {$result[0]['fclassname']} ($classId)</th>";
$e_data.="</tr>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<th colspan='$colspan'>Teacher Name - Code : {$teachres['FTEACHNAME']} - $fteachcode</th>";
$e_data.="</tr>";
$e_data.="</thead>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<td rowspan='2'; style = 'text-align:center;font-weight: bold;row-height:40px;' >Sl. No.</td>";
$e_data.="<td rowspan='2'; style = 'text-align:center;font-weight: bold;row-height:40px;' >".$resuniquery['fregroll']."</td>";
$e_data.="<td rowspan='2'; style = 'text-align:center;font-weight: bold;row-height:40px;' >Name</td>";
// $cntclass=0;teachres
foreach($result as $key => $value){
// if($value['fnoclass'] > 1){
// $cntclass = $value['fnoclass'];
// }
$e_data.="<td rowspan='2'; style = 'text-align:center;font-weight: bold;row-height:40px; width:90px' >{$value['fdate']}<br> Period : {$value['fperiod']}<br> No. of Class : {$value['fnoclass']}</td>";
// for($i=0; $i < $value['fnoclass']; $i++){
// if($i > 1){
// array_push($cutclass,"P");
// }
// }
}
$e_data.="<td colspan='4'; style = 'text-align:center;font-weight: bold;row-height:40px;' >Total</td>";
$e_data.="</tr>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<td style = 'text-align:center;font-weight: bold;row-height:40px;' >Classes</td>";
$e_data.="<td style = 'text-align:center;font-weight: bold;row-height:40px;' >Present</td>";
$e_data.="<td style = 'text-align:center;font-weight: bold;row-height:40px;' >Absent</td>";
$e_data.="<td style = 'text-align:center;font-weight: bold;row-height:40px;' >%</td>";
$e_data.="</tr>";
$k=0;
$id=1;
$m=0;
$filename = 'monthwiseAttend';
foreach($result_2 as $key=>$value)
{
$classquery = "select SUM(if(ifnull(fpresent,'') <> '',FNOCLASS,0)) as fnoclass,
sum(if(fpresent = 'P',FNOCLASS,0)) as prent,
sum(if(fpresent = 'A',FNOCLASS,0)) as absent,
ROUND(sum(if(fpresent = 'P',FNOCLASS,0)) / SUM(if(ifnull(fpresent,'') <> '',FNOCLASS,0)) * 100,2) as pers
from attend_det
where FREGNO = '{$value['fregno']}' and fclassid = '{$classId}' and
fdate between date_format(str_to_date('{$datefrom}','%Y-%m-%d'),'%Y-%m-%d')
and date_format(str_to_date('{$dateto}','%Y-%m-%d'),'%Y-%m-%d')";
$resclassquery = $aobj_context->mobj_db->GetRow($classquery);
$e_data.="<tr style='height: 25px;'>";
$e_data.="<td style = 'text-align:center;' >$id</td>";
$e_data.="<td style = 'text-align:center;' >{$value['fregno']}</td>";
$e_data.="<td>{$value['fname']}</td>";
$totAbs = 0;
$totPre = 0;
foreach(explode('*',$value['fpresent']) as $v){
$e_data.="<td style = 'text-align:center;' >{$v}</td>";
if($v == 'A'){
$totAbs+=1;
}else{
// if($cntclass > 1){
// $totPre+=$cntclass;
// }else{
$totPre+=1;
// }
}
}
$e_data.="<td style = 'text-align:center;' >{$resclassquery['fnoclass']}</td>";
$e_data.="<td style = 'text-align:center;' >{$resclassquery['prent']}</td>";
$e_data.="<td style = 'text-align:center;' >{$resclassquery['absent']}</td>";
$e_data.="<td style = 'text-align:center;' >{$resclassquery['pers']}</td>";
$e_data.="</tr>";
$k++;
$id++;
$m++;
}
$e_data.="</table>";
$arr['total_count']= $m;
$arr['html']=$e_data;
$arr['error']=0;
}
else
{
$arr['html'] = '<p> No record found </p>';
}
header("Content-Type:application/xls");
header("Content-Disposition: attachment; filename={$filename}.xls");
echo $e_data;
}
?>
|