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


Current Path : /var/www/html/sjbitapi/src/
Upload File :
Current File : /var/www/html/sjbitapi/src/studentsubject.php

<?php

function getStudentSubject($aobj_context)
{ 
	$data_json = file_get_contents("php://input");
	$data = json_decode($data_json,true);
    
	if($_SERVER['PHP_AUTH_USER'] == 'revaapiuser' && $_SERVER['PHP_AUTH_PW'] == 'reva@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)
    {
	
		$query = "select fdegree,FMEYEAR,FMEEXAMTYP from degree where fedegcode = '{$val['degcode']}' and fexamno = 'A'";
		$res1 = $aobj_context->mobj_db->getRow($query);
		$fdegree = $res1['fdegree'];
		$year = $res1['FMEYEAR'];
		$examtype = $res1['FMEEXAMTYP'];
		
		if($res1)
		{
			$semvalue = $sem[$val['sem']];
			$query = "select fcollcode from college where fecollcode = '{$val['collcode']}'";
			$res2 = $aobj_context->mobj_db->getRow($query);
			$collcode = $res2['fcollcode'];
			if($res2)
			{

				
				$query = "select fsubcode from subject where fdegree = '{$fdegree}'
				and fexamno = '{$semvalue}'
				and fesubcode = '{$val['subcode']}'";
				// var_dump($query);
				// die();
				$res3 = $aobj_context->mobj_db->getRow($query);
				$fsubcode = $res3['fsubcode'];
				if($res3)
				{
					if($fsubcode == '')
					{
						$res['status'] = "F";
						$res['logisysextid'] = $val['logisysextid'];
						$res['msg'] = "Subject Code cant be Empty";
						$error++;
					}else
					{

						if($val['rtype'] == 'I')
						{
							$query = "INSERT INTO estudsub (flogid,fregno,fcollcode,fdegree,fsubcode,fecollcode,fcollname,fdegcode, fdegname, fsem, fesubcode, fsubname, fatten, frtype,fcreateddate)
							VALUES ('{$val['logisysextid']}','{$val['regno']}','{$collcode}','{$fdegree}','{$fsubcode}','{$val['collcode']}',
							'{$val['collname']}','{$val['degcode']}',
							'{$val['degname']}','{$semvalue}',
							'{$val['subcode']}','{$val['subname']}',
							'{$val['attend']}','{$val['rtype']}',now())";
							$result = $aobj_context->mobj_db->Execute($query);

							$query = "insert ignore into candsum(fregno,fdegree,fexamno,fcollcode,fappeara,fyear,fexamtype,ffreshexam,fstype) 
							select fregno,fdegree,fsem,fcollcode,'A','{$year}','{$examtype}','A','E' from estudsub where fregno = '{$val['regno']}'";
							$result1 = $aobj_context->mobj_db->Execute($query);

							$query = "insert ignore into canddet(fregno,fdegree,fexamno,fcollcode,fsubcode,fyear,fexamtype,fstype) 
							select fregno,fdegree,fsem,fcollcode,fsubcode,'{$year}','{$examtype}','E' from estudsub where fregno = '{$val['regno']}'";
							$result1 = $aobj_context->mobj_db->Execute($query);

							if($result && $result1)
							{
								$res['status'] = "T";
								$res['logisysextid'] = $val['logisysextid'];
								$res['msg'] = "Inserted Successfully";
								$succes++;
							}else
							{
								$res['status'] = "F";
								$res['logisysextid'] = $val['logisysextid'];
								$res['msg'] = "Insertion Failed";
								$error++;
							}

						}else if($val['rtype'] == 'U')
						{
							$query = "select fsubcode,fesubcode,fsubname From estudsub 
							where flogid = '{$val['logisysextid']}'
							and fregno = '{$val['regno']}'";
							$res2 = $aobj_context->mobj_db->getRow($query);
							$oldsubcode = $res2['fsubcode'];
							
							$upd = "update estudsub set fesubcode = '{$val['subcode']}',fsubname = '{$val['subname']}',
							fsubcode = '{$fsubcode}'
							where flogid = '{$val['logisysextid']}'
							and fregno = '{$val['regno']}'";
							$result = $aobj_context->mobj_db->Execute($upd);

							$upd1 = "update canddet set fsubcode = '{$fsubcode}'
							where fregno = '{$val['regno']}'
							and fsubcode = '{$oldsubcode}'";
						

							$result = $aobj_context->mobj_db->Execute($upd1);
							
							if($result)
							{
								$res['status'] = "T";
								$res['logisysextid'] = $val['logisysextid'];
								$res['msg'] = "Updated Successfully";
								$succes++;
							}else
							{
								$res['status'] = "F";
								$res['logisysextid'] = $val['logisysextid'];
								$res['msg'] = "Updatedtion Failed";
								$error++;
							}

						}
					}
				}else 
				{
					$res['status'] = "F";
					$res['logisysextid'] = $val['logisysextid'];
					$res['msg'] = "Subject Master Not Mached";
					$error++;
				}
			}else 
			{
				$res['status'] = "F";
				$res['logisysextid'] = $val['logisysextid'];
				$res['msg'] = "College Master Not Mached";
				$error++;
			}
		}else
		{
			$res['status'] = "F";
			$res['logisysextid'] = $val['logisysextid'];
			$res['msg'] = "Degree Master Not Mached";
			$error++;
		}
		// var_dump($res);
		// die();
		$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;
	
}

?>