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


Current Path : /proc/thread-self/root/var/www/html/sjbitapi/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/sjbitapi/src/getAttDet.php

<?php

function getStudAttDet($aobj_context)
{ 
	$data_json = file_get_contents("php://input");
	$data = json_decode($data_json,true);
    
	if($_SERVER['PHP_AUTH_USER'] == 'sjbitapiuser' && $_SERVER['PHP_AUTH_PW'] == 'logsjbit@124')
	{

	}else
	{
		$arry='Unauthorized User';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
		return;
	}

	if(count($data) <=0)	
	{
		$arry='Kindaly Pass Data';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
		return;
	}

	
	$i = 0;
	$resrayy = [];
	$error = 0;
	$succes = 0;
	$sem=["1"=>"A","2"=>"B","3"=>"C","4"=>"D","5"=>"E","6"=>"F","7"=>"G","8"=>"H","9"=>"I","10"=>"J"];
	foreach($data as $val)
    {
	
		$semvalue = $sem[$val['sem']];
		$subcode = $val['subcode'];
		$usn = $val['usn'];
		$attcond = $val['attcond'];
		$attatend = $val['attatend'];
		$attper = $val['attper'];
		$pushusr = $val['pushusr'];
		
		if($subcode == '')
		{
			$arry='Kindly Send Sub. Code';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
			return;
		}else if($semvalue == '')
		{
			$arry='Kindly Send Program Semester';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
			return;
		}else if($usn == '')
		{
			$arry='Kindly Send USN';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
			return;
		}else if($attcond == '')
		{
			$arry='Kindly Send Attendance Conducted';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
			return;
		}else if($attatend == '')
		{
			$arry='Kindly Send Attendance Attended';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
			return;
		}
		else if($attper == '')
		{
			$arry='Kindly Send Attendance Percentage';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
			return;
		}else if($pushusr == '')
		{
			$arry='Kindly Send Push User';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arry,-1,"Failure");
			return;
		}
		
		$query = "select fregno,fcollcode,fdegree 
		from student where fregno = '{$usn}'";
		$res1 = $aobj_context->mobj_db->getRow($query);
		$fcollcode = $res1['fcollcode'];
		$fdegree = $res1['fdegree'];
		if($res1)
		{
			$query = "select fcsubcode 
			from subject where fdegree = '{$fdegree}'
			and fexamno = '{$semvalue}'
			and fsubshort = '{$subcode}'
			and fintass = 'F'";
			$res2 = $aobj_context->mobj_db->getRow($query);
			$fcsubcode = $res2['fcsubcode'];

			if($res2)
			{
				$query = "INSERT INTO attendapi (fregno,fdegree,fexamno,fcollcode,fsubcode,fattcond,fattend,fattper,fcreatedate,fpushuser)
				VALUES ('{$usn}','{$fdegree}','{$semvalue}','{$fcollcode}','{$fcsubcode}','{$attcond}','{$attatend}','{$attper}',now(),'{$pushusr}')
				on duplicate key update fattcond = '{$attcond}',fattend = '{$attatend}',fattper = '{$attper}', fupddate = now(),
				fupduser = '{$pushusr}'";
		
				$result = $aobj_context->mobj_db->Execute($query);
				
				$upd = "update attend set FTOTC = '{$attcond}', FTOTA = '{$attatend}', FPER = '{$attper}',
				FCREATEDATE = now(), FCREATEUSER = '{$pushusr}'
				where fregno = '{$usn}'
				and fexamno = '{$semvalue}'
				and fsubcode = '{$fcsubcode}'";
				
				$result = $aobj_context->mobj_db->Execute($upd);

				$res['status'] = "T";
				$res['usn'] = $usn;
				$res['subcode'] = $subcode;
				$res['msg'] = "Updated Successfully";
				$succes++;
			}else
			{
				$res['status'] = "F";
				$res['usn'] = $usn;
				$res['subcode'] = $subcode;
				$res['msg'] = "Invalid Subject or Subject Code";
				$error++;
			}
		}else
		{
				$res['status'] = "F";
				$res['usn'] = $usn;
				$res['subcode'] = $subcode;
				$res['msg'] = "Invaid USN";
				$error++;
		}

		$i++;
		array_push($resrayy,$res);
    }

	$msg = "success";
	if($succes >'0' && $error == '0')
	{
		$msg = "success";
	}else if($error>'0' && $succes == '0')
	{
		$msg  = "Failure";
	}else if($succes >'0' && $error>'0')
	{
		$msg = "Partial";
	}

	$arry['resdata'] = $resrayy;
	echo $aobj_context->mobj_output->ToJSONEnvelope($arry,0,$msg);
	return;
	
}

?>