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.17.165.196
Current Path : /var/www/oasis/src/ |
| Current File : /var/www/oasis/src/attendance.php |
<?php
function SaveAttendanceDetails($aobj_context)
{
session_start();
include_once("/JSON.php");
$json = new Services_JSON();
include("error_log.php");
$type = $aobj_context->mobj_data["stype"];
$teacher_id = $aobj_context->mobj_data["teacher_id"];
$class_id = $aobj_context->mobj_data["class_id"];
if($type == 'AttEntTeachWise'){
$query="select distinct fdegree,fexamno from attendsum
where fteachcode='{$teacher_id}' and fclassid='{$class_id}'";
$result = $aobj_context->mobj_db->GetRow($query);
$degree_code = $result["fdegree"];
$Examno = $result["fexamno"];
}else {
$degree_code = ($aobj_context->mobj_data["Fdegree"]);
$Examno = ($aobj_context->mobj_data["FExamno"]);
}
// $degree_code = ($aobj_context->mobj_data["Fdegree"]);
// $Examno = ($aobj_context->mobj_data["FExamno"]);
$Sub_code = ($aobj_context->mobj_data["Fsubcode"]);
$month_name = ($aobj_context->mobj_data["month_name"]);
$College_Code = $_SESSION['collcode'];
$funivcode = $_SESSION['FUNIVCODE'];
$User_code = $_SESSION['usr'];
$conducted_field="F{$month_name}C ";
$attended_field="F{$month_name}A ";
$lstr_param = stripslashes($aobj_context->mobj_data["output_details"]);
$mobj_jsondata = $json->decode($lstr_param);
$att_details = get_object_vars($mobj_jsondata);
foreach($att_details as $ak=>$av)
{
if($funivcode != '051')
{
$query = "select {$conducted_field} as conduct, {$attended_field} as attend
from attend where fregno= '{$av->r}' and fdegree = '{$degree_code}' and fexamno = '{$Examno}'
and fsubcode = '{$Sub_code}'";
$res = $aobj_context->mobj_db->getRow($query);
$conduct = $res['conduct'];
$attend = $res['attend'];
}
if($funivcode == '051')
{
$update="update attend set
{$conducted_field}='{$av->c}',
{$attended_field}='{$av->a}',
ftotc = '{$av->c}',
FTOTA = '{$av->a}',
fper = IFNULL(ROUND((('$av->a'/'{$av->c}')*100),2),0),
FENTDATE=now()
where fregno= '{$av->r}' and fexamno = '{$Examno}'
and fsubcode = '{$Sub_code}'
and fcollcode = '{$College_Code}'";
$lobj_insert_qry = $aobj_context->mobj_db->Execute($update);
}else
{
$update="update attend set
{$conducted_field}='{$av->c}',
{$attended_field}='{$av->a}',
FENTDATE=now()
where fregno= '{$av->r}' and fexamno = '{$Examno}'
and fsubcode = '{$Sub_code}'
and fcollcode = '{$College_Code}'";
$lobj_insert_qry = $aobj_context->mobj_db->Execute($update);
}
// die();
if($funivcode != '051' && $funivcode != '052')
{
$oldmarks = $res['fmarks'];
$univcode = $_SESSION['FUNIVCODE'];
$mob = $_SESSION['FMOBILE'];
$usr = $_SESSION['usr'];
$college_code = $_SESSION['collcode'];
$remark = "ATT - Attendace Entry - $degree_code, $Examno, $Sub_code, $College_Code, $month_name, Conducted: ".$av->c.", Attended: ".$av->a." Old Conducted: $conduct, Attended: ".$attend;
$enttype = "ATT";
$res = error_logs($aobj_context,$univcode,$remark,$college_code,$enttype,$usr,$mob);
$query1 = "update attend set ftotc = IFNULL(FJANC,0)+IFNULL(FFEBC,0)+IFNULL(FMARC,0)+IFNULL(FAPRC,0)+IFNULL(FMAYC,0)+IFNULL(FJUNC,0)
+IFNULL(FJULC,0)+IFNULL(FAUGC,0)+IFNULL(FSEPC,0)+IFNULL(FOCTC,0)+IFNULL(FNOVC,0)+IFNULL(FDECC,0)+IFNULL(FOVERALL_SEMC,0)
where fregno= '{$av->r}' and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
// var_dump($query1);
// die();
$results1 = $aobj_context->mobj_db->Execute($query1);
//var_dump($query1);
$query2 = "update attend set FTOTA = IFNULL(FJANA,0)+IFNULL(FFEBA,0)+IFNULL(FMARA,0)+IFNULL(FAPRA,0)+IFNULL(FMAYA,0)+IFNULL(FJUNA,0)
+IFNULL(FJULA,0)+IFNULL(FAUGA,0)+IFNULL(FSEPA,0)+IFNULL(FOCTA,0)+IFNULL(FNOVA,0)+IFNULL(FDECA,0)+IFNULL(FOVERALL_SEMA,0)
where fregno= '{$av->r}' and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
$results2 = $aobj_context->mobj_db->Execute($query2);
//var_dump($query2);
$query3 = "UPDATE attend set fper = IFNULL(ROUND((IFNULL(FTOTA,0)*100)/IFNULL(FTOTC,0),2),0)
where fregno= '{$av->r}' and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
//var_dump($query3);
$results3 = $aobj_context->mobj_db->Execute($query3);
}
}
// die();
/* $query1 = "update attend set ftotc = IFNULL(FJANC,0)+IFNULL(FFEBC,0)+IFNULL(FMARC,0)+IFNULL(FAPRC,0)+IFNULL(FMAYC,0)+IFNULL(FJUNC,0)
+IFNULL(FJULC,0)+IFNULL(FAUGC,0)+IFNULL(FSEPC,0)+IFNULL(FOCTC,0)+IFNULL(FNOVC,0)+IFNULL(FDECC,0)
where fdegree ={$degree_code} and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
$results1 = $aobj_context->mobj_db->Execute($query1);
$query2 = "update attend set FTOTA = IFNULL(FJANA,0)+IFNULL(FFEBA,0)+IFNULL(FMARA,0)+IFNULL(FAPRA,0)+IFNULL(FMAYA,0)+IFNULL(FJUNA,0)
+IFNULL(FJULA,0)+IFNULL(FAUGA,0)+IFNULL(FSEPA,0)+IFNULL(FOCTA,0)+IFNULL(FNOVA,0)+IFNULL(FDECA,0)
where fdegree ={$degree_code} and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
$results2 = $aobj_context->mobj_db->Execute($query2);
$query3 = "UPDATE attend set fper = IFNULL(ROUND((IFNULL(FTOTA,0)*100)/IFNULL(FTOTC,0),0),0)
where fdegree ={$degree_code} and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
$results3 = $aobj_context->mobj_db->Execute($query3); */
if($funivcode == '017')
{
$get_studentInfo = "SELECT DISTINCT fcollcode, fdegree,fregno FROM attend
WHERE fdegree = '{$degree_code}' AND fexamno = '{$Examno}'
and fsubcode = '{$Sub_code}' and ifnull(fper,0) < 75
ORDER BY fcollcode,fdegree,fexamno";
$lobj_get_studentInfo = $aobj_context->mobj_db->getAll($get_studentInfo);
if($lobj_get_studentInfo > 0)
{
$query ="delete from attshort where fdegree = '{$degree_code}' AND fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
$results = $aobj_context->mobj_db->Execute($query);
//var_dump($query);
$query = "insert into attshort
(select fdegree,fexamno,fsubcode,fregno,'Shortage of Attendance. Not Eligilble' from attend
where fdegree = '{$degree_code}' AND fexamno = '{$Examno}' and fsubcode = '{$Sub_code}' and ifnull(fper,0) < 75)";
$results = $aobj_context->mobj_db->Execute($query);
//var_dump($query);
}
}
if($lobj_insert_qry)
{
if($funivcode == '052' || $funivcode == '051' || $funivcode == '021')
{
$query = "update attend set ftotc = IFNULL(FJANC,0)+IFNULL(FFEBC,0)+IFNULL(FMARC,0)+IFNULL(FAPRC,0)+IFNULL(FMAYC,0)+IFNULL(FJUNC,0)
+IFNULL(FJULC,0)+IFNULL(FAUGC,0)+IFNULL(FSEPC,0)+IFNULL(FOCTC,0)+IFNULL(FNOVC,0)+IFNULL(FDECC,0)+IFNULL(FOVERALL_SEMC,0)
where fcollcode = '{$College_Code}'";
//var_dump($query);
$results = $aobj_context->mobj_db->Execute($query);
$query = "update attend set FTOTA = IFNULL(FJANA,0)+IFNULL(FFEBA,0)+IFNULL(FMARA,0)+IFNULL(FAPRA,0)+IFNULL(FMAYA,0)+IFNULL(FJUNA,0)+IFNULL(FJULA,0)+IFNULL(FAUGA,0)+IFNULL(FSEPA,0)+IFNULL(FOCTA,0)+IFNULL(FNOVA,0)+IFNULL(FDECA,0)+IFNULL(FOVERALL_SEMA,0)
where fcollcode = '{$College_Code}'";
//var_dump($query);
$results = $aobj_context->mobj_db->Execute($query);
$query = "UPDATE attend set fper = IFNULL(ROUND((IFNULL(FTOTA,0)*100)/IFNULL(FTOTC,0),2),0)
where fcollcode = '{$College_Code}'";
//var_dump($query);
$results = $aobj_context->mobj_db->Execute($query);
}
$rdata = "Updated Successfully.";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
return $rdata;
}
else
{
$rdata = "No Updation / Add..!";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure"));
return $rdata;
}
}
// function getmonthrange($aobj_context)
// {
// $Degcode = $aobj_context->mobj_data["degree"];
// $Examno = $aobj_context->mobj_data["examno"];
// $funivcode = $_SESSION['FUNIVCODE'];
// if($funivcode == '033'){
// $get_records = "select 'ALL' as fattfrommth,'ALL' as fatttomth from collexam
// where fdegree = '{$Degcode}' and fexamno = '{$Examno}'";
// }else{
// $get_records = "select fattfrommth, fatttomth from collexam
// where fdegree = '{$Degcode}' and fexamno = '{$Examno}'";
// }
// $lobj_get_record = $aobj_context->mobj_db->GetRow($get_records);
// echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_get_record,0,"success");
// return;
// }
function GetAttendanceRegisterNumbers($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
session_start();
$College_Code = $_SESSION['collcode'];
$funivcode = $_SESSION['FUNIVCODE'];
$type = $aobj_context->mobj_data["stype"];
$teacher_id = $aobj_context->mobj_data["teacher_id"];
$class_id = $aobj_context->mobj_data["class_id"];
$Subcode = $aobj_context->mobj_data["Subcode"];
if($type == 'AttEntTeachWise'){
$query="select fdegree,fexamno from attendsum
where fteachcode='{$teacher_id}' and fclassid='{$class_id}'
";
$result = $aobj_context->mobj_db->GetRow($query);
$Degcode = $result["fdegree"];
$Examno = $result["fexamno"];
}else {
$Degcode = $aobj_context->mobj_data["Degcode"];
$Examno = $aobj_context->mobj_data["Examno"];
}
$Section = $aobj_context->mobj_data["Section"];
$month_name = $aobj_context->mobj_data["month_name"];
$conducted_field=" ifnull(F{$month_name}C,0) ";
$attended_field=" ifnull(F{$month_name}A,0) ";
$path = $aobj_context->main_src.'/'.$aobj_context->mobj_data["db"].'/imported_files/';
$path_name = "imported_files/att_{$College_Code}_{$_SESSION['user_id']}.html";
$filename = "{$path}att_{$College_Code}_{$_SESSION['user_id']}.html";
if($Section =='All')
$Section_query ='';
else
{
if($funivcode == '052')
$Section_query ="and stu.fsectionnew ='{$Section}'";
else
$Section_query ="and stu.FSECTION ='{$Section}'";
}
unlink($filename);
$fp = fopen($filename, 'w+');
$e_data.="<table width='95%' cellspacing='0' class='tr_ventor_row' cellpadding='0' border='0' >";
$e_data.="<th align='left' colspan='4' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:12px; padding-left:6px; height:24px;'>Attendance Entry</th>";
$e_data.="<tr class='ui-state-default ui-jqgrid-hdiv'>";
$e_data.="<td style='padding:2px; width:80px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>USN</center></td>";
$e_data.="<td style='padding:2px; width:180px; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Student Name</center></td>";
$e_data.="<td style='padding:2px; width:20px; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Classes Conducted</center></td>";
$e_data.="<td style='padding:2px; width:20px; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Classes Attended</center></td>";
$e_data.="</tr>";
$query = "select * from collexam where fdegree = '{$Degcode}' and fexamno = '{$Examno}'
and fcollcode = '{$College_Code}'
and DATE_FORMAT(NOW(),'%Y-%m-%d') between DATE_FORMAT(collexam.fattfrom,'%Y-%m-%d')
AND DATE_FORMAT(collexam.fattto,'%Y-%m-%d')";
$result = $aobj_context->mobj_db->GetAll($query);
if ($result == false)
{
$e_data.="<tr style='height: 20'>";
$e_data.="<td COLSPAN=4 align = 'center'>Dates Are not enabled</td>";
$e_data.="</tr>";
}else
{
$query = "select distinct FFREEZED from collatt where fdegree = '{$Degcode}' and fexamno = '{$Examno}' and fsubcode = '{$Subcode}' and FPERIOD = '{$month_name}'";
// var_dump($query,"else");
$results = $aobj_context->mobj_db->GetRow($query);
if($results['FFREEZED'] == 'T')
{
$e_data.="<tr style='height: 20'>";
$e_data.="<td COLSPAN=4 align = 'center'>Attendance entry freezed for given details.</td>";
$e_data.="</tr>";
}
else{
if($type == 'AttEntTeachWise'){
$get_records="SELECT mak.fintcode,stu.FREGNO, stu.FNAME,
{$conducted_field} AS conducted,
{$attended_field} AS attended
FROM student stu
INNER JOIN attend mak ON stu.FREGNO=mak.FREGNO
INNER JOIN subject sub ON sub.FCSUBCODE = mak.FSUBCODE and mak.fdegree = sub.fdegree
and mak.fexamno = sub.fexamno
INNER JOIN degree d ON d.FDEGREE =mak.FDEGREE AND d.Fexamno=mak.Fexamno
AND d.FMEYEAR=mak.FYEAR AND d.FMEEXAMTYP=mak.FEXAMTYPE
INNER JOIN attendsum a ON a.fdegree=mak.fdegree AND a.fexamno=mak.fexamno AND a.fcollcode=mak.fcollcode
and a.fregno = mak.fregno
and a.fsubcode = mak.fsubcode
WHERE stu.FREGNO != ''
AND fclassid='{$class_id}' AND a.fteachcode='{$teacher_id}'
and a.fcollcode = '{$College_Code}'
and a.fsubcode = '{$Subcode}'
GROUP BY stu.FREGNO ORDER BY stu.FREGNO LIMIT 0, 1000";
// var_dump($get_records);
}
else{
$get_records = "SELECT mak.fintcode,stu.FREGNO, stu.FNAME ,
{$conducted_field} as conducted,
{$attended_field} as attended
FROM student stu
INNER JOIN attend mak ON stu.FREGNO=mak.FREGNO
and mak.fdegree='{$Degcode}' and mak.fexamno='{$Examno}' and mak.FCOLLCODE='{$College_Code}'
inner join subject sub on sub.FCSUBCODE = mak.FSUBCODE
inner join degree d on d.FDEGREE =mak.FDEGREE
and d.Fexamno=mak.Fexamno
and d.FMEYEAR=mak.FYEAR and d.FMEEXAMTYP=mak.FEXAMTYPE
and sub.FCSUBCODE='{$Subcode}' and sub.FDEGREE='{$Degcode}' and sub.FEXAMNO='{$Examno}'
WHERE stu.FREGNO != '' {$Section_query}
group by stu.FREGNO order by stu.FREGNO limit 0, 1000";
}
$lobj_get_records = $aobj_context->mobj_db->GetAll($get_records);
$k=1;
$border_bottom="";
foreach($lobj_get_records as $key=>$value)
{
$fintcode=$value['fintcode'];
$conducted=$value['conducted'];
$attended=$value['attended'];
if($k==count($lobj_get_records))
$border_bottom="border-bottom:1px solid #C5DBEC;";
$on_blur=($type=='Edit')?" onblur=\"validateEditRegNoMarks(this.id);\" ":" ";
$on_focus=($type=='Edit')?" onfocus=\"if(\$g_mes_edit_valid_marks_flag==0) $('#mes_marks_{$value['FREGNO']}').focus();\" ":" ";
$e_data.="<tr class='ui-widget-content jqgrow'>";
$e_data.="<td tabindex=-1 align='center' style='{$border_bottom}; border-left:1px solid #C5DBEC;border-right:1px solid #C5DBEC; padding:2px;'><input tabindex=-1 {$inp_class} type=text name='Regno' style='width:98%;border:none;text-align:center;' readonly id='reg_{$k}' value='{$value['FREGNO']}'> </td>";
$e_data.="<td tabindex=-1 align='left' style='{$border_bottom};border-right:1px solid #C5DBEC; padding:2px;' id='mes_std_name_{$value['FREGNO']}' > {$value['FNAME']} </td>";
$e_data.="<td tabindex=1 align='center' style='{$border_bottom};border-right:1px solid #C5DBEC; padding:2px;'> <input onblur='AssignAttendanceNextTdConductedVal({$k});' type=text style='width:30px;text-align:center;{$border}' id='conducted_{$k}' class='ElementCount' onkeypress='return acceptNumbersOnlyForModule(event);' value='{$conducted}' onfocusin='changeBackgroundcolortd(this.id)' > </td>";
$e_data.="<td tabindex=2 align='center' style='{$border_bottom};border-right:1px solid #C5DBEC; padding:2px;'> <input onblur='validateAttendedVal({$k});' type=text style='width:30px;text-align:center;{$border}' id='attended_{$k}' class='ElementCount' onkeypress='return acceptNumbersOnlyForModule(event);' value='{$attended}' onfocusin='changeBackgroundcolortd(this.id)' >
<input type = 'hidden' id='upd_{$k}' value = 'N'>
</td>";
$e_data.="</tr>";
$k++;
}
if(empty($lobj_get_records))
{
$e_data.="<tr style='height: 20'>";
$e_data.="<td COLSPAN=4 align = 'center'>No Records Found For this Search</td>";
$e_data.="</tr>";
}
}
}
$e_data.="</table><br>";
fwrite($fp, $e_data);
$arr['filenme']=$path_name;
//$arr['table_data']=$lobj_get_records;
fclose($fp);
if($funivcode == '051')
{
$get_app_cand_det="insert ignore into marks (FDEGREE, FEXAMNO, FCOLLCODE, FREGNO, FSUBCODE, fmarks, fyear, fexamtype,FMODIFYDATE1)
select c.fdegree,c.fexamno,c.fcollcode,c.fregno,
s.fcsubcode,'-1', c.fyear,c.fexamtype,now()
from canddet c inner join
subject s on c.fdegree = s.fdegree and c.fexamno = s.fexamno
and c.fsubcode = s.FSUBCODE
inner join candsum cs on c.fregno =cs.fregno
and c.fexamno = cs.ffreshexam
where c.fexamno = '{$Examno}'
and c.fcollcode = '{$College_Code}'
and c.fdegree = '{$Degcode}'
and ifnull(c.fpassmth,'') = ''
and s.fintass = 'T' and ifnull(s.FCODENO,'F') = 'F'";
$res1 = $aobj_context->mobj_db->Execute($get_app_cand_det);
$query1 = "insert ignore into collia(fdegree,fexamno,fcollcode,fsubcode,FCREATEUSER)
select distinct fdegree,fexamno,fcollcode,fsubcode,'A' from marks";
$res2 = $aobj_context->mobj_db->Execute($query1);
$query = "insert ignore into attend (fcollcode, fdegree, fexamno, fsubcode,fregno,fyear, fexamtype)
select cd.fcollcode, cd.fdegree, cd.fexamno, s.fcsubcode,cd.fregno, cd.fyear, cd.fexamtype
from canddet cd inner join subject s on cd.fdegree = s.fdegree and cd.fexamno = s.fexamno
and cd.fsubcode = s.fsubcode
inner join candsum cs on cd.fregno =cs.fregno
and cd.fexamno = cs.ffreshexam
where cd.fcollcode = '{$College_Code}'
and cd.fdegree = '{$Degcode}'
and cd.fexamno = '{$Examno}'
and ifnull(s.fattent,'F') = 'T'
group by cd.fcollcode, cd.fdegree, cd.fexamno,cd.fregno,s.fcsubcode";
$res2 = $aobj_context->mobj_db->Execute($query);
}
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
return;
}
?>
|