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.22.74.192


Current Path : /var/www/html/sdu/src/
Upload File :
Current File : /var/www/html/sdu/src/attendance.php

<?php
function SaveAttendanceDetails($aobj_context)
{
    session_start();	
    include_once("/JSON.php"); 
	$json = new Services_JSON();
	
	$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)
	{
	
		$update="update attend set
		{$conducted_field}='{$av->c}',
		{$attended_field}='{$av->a}',
		FENTDATE=now()
		where fregno= '{$av->r}' and fdegree = '{$degree_code}'  and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
		//var_dump($update);
		$lobj_insert_qry = $aobj_context->mobj_db->Execute($update);
		
		$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  fregno= '{$av->r}' and fdegree = '{$degree_code}'  and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";	
		$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)
			where  fregno= '{$av->r}' and fdegree = '{$degree_code}'  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 fdegree = '{$degree_code}'  and fexamno = '{$Examno}' and fsubcode = '{$Sub_code}'";
		//var_dump($query3);		
		$results3 = $aobj_context->mobj_db->Execute($query3);
	}
		
	/* $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)
	{
		$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"];

	$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'];	
 
	$Subcode = $aobj_context->mobj_data["Subcode"];
	$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.'/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
		$Section_query ="and stu.FSECTION ='{$Section}'";
		
	unlink($filename);  
	$fp = fopen($filename, 'w+');		
		
	$e_data.="<table  width='75%' 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:60px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Reg No</center></td>";
	$e_data.="<td  style='padding:2px; width:140px; 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 distinct FFREEZED from collatt where fdegree = '{$Degcode}' and fexamno = '{$Examno}' and fsubcode = '{$Subcode}' and FPERIOD = '{$month_name}'";
	//var_dump($query);
	$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
	{
		$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.fdegree = mak.fdegree AND 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);
		//var_dump($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:80px;border:none;' 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)' > </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); 
	
	echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
	return; 
	
}
?>