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.116.47.194
<?php
function xlAttMonthWiseReportUniclare($aobj_context)
{
session_start();
$collcode=$_SESSION['collcode'];
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');
$univcode = trim($aobj_context->mobj_data["univcode"]);
$collcode = trim($aobj_context->mobj_data["collcode"]);
$teachcode = trim($aobj_context->mobj_data["teachcode"]);
$classid = trim($aobj_context->mobj_data["classid"]);
$datefrom = trim($aobj_context->mobj_data["fromDate"]);
$dateto = trim($aobj_context->mobj_data["todate"]);
$query = "select distinct d.FNOCLASS as fnoclass, d.fdate, a.fclassname 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}','%d/%m/%Y'),'%Y-%m-%d')
and date_format(str_to_date('{$dateto}','%d/%m/%Y'),'%Y-%m-%d')
and a.fcollcode ='{$collcode}' and fteachcode = '{$teachcode}'";
$result = $aobj_context->mobj_db->GetAll($query);
$query_2 = "select a.fregno, group_concat(a.fpresent 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}','%d/%m/%Y'),'%Y-%m-%d')
and date_format(str_to_date('{$dateto}','%d/%m/%Y'),'%Y-%m-%d')
and a.fcollcode ='{$collcode}'
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);
$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']);
}
$colspan = 6 + $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'>Nitte (Deemed to be University)</th>";
$e_data.="</tr>";
$e_data.="<tr style='height: 25px;'>";
$e_data.="<th colspan='$colspan'>Nitte, Karkala Taluk, Udupi - 5741$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 : {$datefrom} - {$dateto}</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.="</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;' >USN</td>";
$e_data.="<td rowspan='2'; style = 'text-align:center;font-weight: bold;row-height:40px;' >Name</td>";
foreach($result as $key => $value){
$e_data.="<td rowspan='2'; style = 'text-align:center;font-weight: bold;row-height:40px;' >{$value['fdate']}</td>";
}
$e_data.="<td colspan='3'; 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.="</tr>";
$k=0;
$id=1;
$m=0;
$filename = 'monthwiseAttend';
foreach($result_2 as $key=>$value)
{
$classquery = "select SUM(FNOCLASS) as fnoclass from attend_det
where FREGNO = '{$value['fregno']}' and fclassid = '{$classid}'";
$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{
$totPre+=1;
}
}
$e_data.="<td style = 'text-align:center;' >{$resclassquery['fnoclass']}</td>";
$e_data.="<td style = 'text-align:center;' >{$totPre}</td>";
$e_data.="<td style = 'text-align:center;' >{$totAbs}</td>";
$e_data.="</tr>";
$k++;
$id++;
$m++;
}
$e_data.="</table>";
//var_dump($e_data);die();
$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;
}
?>
|