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


Current Path : /var/www/html/collportal/src/
Upload File :
Current File : /var/www/html/collportal/src/iamarksentry.php

<?php
	function getDegreeFOrIAMarks($aobj_context){
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		$collcode = $aobj_context->mobj_data['collcode'];

		$qry = "SELECT DISTINCT IFNULL(m.fdegree,'') AS `key`,IFNULL(m.fdegree,'') AS `value`, 
		        CONCAT(m.fdegree,' - ',d.FDESCPN) AS label FROM marks m LEFT JOIN degree d
				ON m.fdegree=d.fdegree AND m.`FEXAMNO`=d.`FEXAMNO` 
				WHERE m.fdegree <> ''";
	    $res = $aobj_context->mobj_db->GetAll($qry);			
		if($res){
            echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success"); 
        }else{
            $arr['msg'] = "failed to load";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
            return;
        }
	}

	function getSemOnDeg($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		$collcode = $aobj_context->mobj_data['collcode'];
		$degree= $aobj_context->mobj_data['degree'];

		$qry = "SELECT DISTINCT IFNULL(m.FEXAMNO,'') AS `key`,IFNULL(m.FEXAMNO,'') AS `value`, 
				CONCAT(m.FEXAMNO,' - ',d.fexamname) AS label FROM marks m LEFT JOIN degree d
				ON m.fdegree=d.fdegree AND m.`FEXAMNO`=d.`FEXAMNO` 
				WHERE m.fdegree='{$degree}' AND  d.fexamname IS NOT NULL AND m.FEXAMNO <> ''";
	     $res = $aobj_context->mobj_db->GetAll($qry);
		 if($res){
            echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success"); 
        }else{
            $arr['msg'] = "failed to load";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
            return;
        			
	}}

	function iaMarksEntryView($aobj_context){ 
		$collcode = $aobj_context->mobj_data['collcode'];
		$degree= $aobj_context->mobj_data['degree'];
		$sem= $aobj_context->mobj_data['sem'];
		
        $qry = "SELECT s.FCSUBCODE,s.FSUBNAME,COUNT(fregno) AS cnt,s.FVALMAX,m.fmarks,COUNT(fmarks)AS entered,ca.ffreezed 
		        FROM subject s INNER JOIN collexam c ON s.fdegree=c.fdegree AND s.fexamno=c.fexamno
				INNER JOIN marks m ON s.fdegree=m.fdegree AND s.fexamno=m.fexamno AND s.fcsubcode=m.fsubcode AND c.fcollcode=m.fcollcode
				INNER JOIN collia ca ON m.fdegree=ca.fdegree AND m.fexamno=ca.fexamno AND m.fsubcode=ca.fsubcode AND m.fcollcode=ca.fcollcode
				WHERE NOW() BETWEEN c.fiafrom AND c.fiato AND fintass='T' AND c.fcollcode='{$collcode}' AND c.fdegree='{$degree}'AND c.fexamno='{$sem}'
				GROUP BY m.fsubcode";

				
        $res = $aobj_context->mobj_db->GetAll($qry);  
		if($res){
            echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success"); 
        }else{
            $arr['msg'] = "failed to load";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
            return;		
	}
	}

	function enterIAMarks($aobj_context){
		$collcode = $aobj_context->mobj_data['collcode'];
		$degree= $aobj_context->mobj_data['degree'];
		$sem= $aobj_context->mobj_data['sem'];
		$subcode= $aobj_context->mobj_data['subcode'];
		$status=$aobj_context->mobj_data['status'];
		
   $qry = "SELECT DISTINCT m.fregno,s.fname,ifnull(m.fmarks,'')as fmarks FROM marks m INNER JOIN student s ON m.fdegree=s.fdegree  
           AND m.fexamno=s.fexamno AND m.fregno=s.fregno 
           WHERE m.fdegree='{$degree}' AND m.fexamno='{$sem}' AND m.fsubcode='{$subcode}' AND m.fcollcode='{$collcode}'";
   $res = $aobj_context->mobj_db->GetAll($qry);
   if($res){
		echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success"); 
	}else{
		$arr['msg'] = "failed to load";
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
		return;		
	}
	}
	
	function saveIAmarks($aobj_context){
		$data = $aobj_context->mobj_data["data"];
		$array = json_decode($data,true);

		$collcode=$aobj_context->mobj_data['collcode'];
		$user=$aobj_context->mobj_data['fuser'];
		$subcode=$aobj_context->mobj_data['subcode'];
		$degree=$aobj_context->mobj_data['degree'];
		$sem=$aobj_context->mobj_data['sem'];
		$status=$aobj_context->mobj_data['status'];
		$ip = $_SERVER['REMOTE_ADDR'];
		
		// $freeze = $aobj_context->mobj_data["freeze"];
		// $freezed = json_decode($freeze,true);

		
		// foreach($freezed as $val){
		// if($val['fstatus'] == "T"){
		// 	$query1="UPDATE collia
		// 			  SET ffreezed='{$val['fstatus']}',ffreezeuser='{$user}',ffreezedate=now(),ffreezeip='{$ip}'
		// 			  WHERE fdegree='{$degree}' AND fexamno='{$sem}' AND fsubcode='{$val['FCSUBCODE']}' AND fcollcode='{$collcode}'";
		// }else{
		// 	$query1="UPDATE collia
		// 			  SET ffreezed='{$val['ffreezed']}',ffreezeuser='{$user}',ffreezedate=now(),ffreezeip='{$ip}'
		// 			  WHERE fdegree='{$degree}' AND fexamno='{$sem}' AND fsubcode='{$val['FCSUBCODE']}' AND fcollcode='{$collcode}'";
		// }
        //     $res1=$aobj_context->mobj_db->Execute($query1);	
		// 	if($res1){
		// 		$arr['msg'] = "Successfully Saved";
		// 		echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success"); 
		// 	}else{
		// 		$arr['msg'] = "failed to load";
		// 		echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
		// 		return;		
		// 	}
		
		// }

	
		foreach($array as $value){
			$qry = "UPDATE marks 
					SET fmarks='{$value['fmarks']}',flogname='{$user}',flogdate=now()
					WHERE fdegree='{$degree}' AND fexamno='{$sem}' AND fregno='{$value['fregno']}' AND fsubcode='{$subcode}'";
            $res = $aobj_context->mobj_db->Execute($qry);

			$query = "UPDATE collia
					  SET ffreezed='{$status}',ffreezeuser='{$user}',ffreezedate=now(),ffreezeip='{$ip}'
					  WHERE fdegree='{$degree}' AND fexamno='{$sem}' AND fsubcode='{$subcode}' AND fcollcode='{$collcode}'";
				
			$result=$aobj_context->mobj_db->Execute($query);
		
			if($res || $result){
				$arr['msg'] = "Successfully Saved";
				echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success"); 
			}else{
				$arr['msg'] = "failed to load";
				echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
				return;		
			}
		
		}
		
	}

	function freezeSujects($aobj_context){
		$collcode=$aobj_context->mobj_data['collcode'];
		$user=$aobj_context->mobj_data['fuser'];
		$subcode=$aobj_context->mobj_data['subcode'];
		$degree=$aobj_context->mobj_data['degree'];
		$sem=$aobj_context->mobj_data['sem'];
		$status=$aobj_context->mobj_data['status'];
		$ip = $_SERVER['REMOTE_ADDR'];
		
		if($status =="true"){
			$query1 = "UPDATE collia
				       SET ffreezed='T',ffreezeuser='{$user}',ffreezedate=now(),ffreezeip='{$ip}'
					   WHERE fdegree='{$degree}' AND fexamno='{$sem}' AND fsubcode='{$subcode}' AND fcollcode='{$collcode}'";
					   $res1=$aobj_context->mobj_db->Execute($query1);	
		}else {
			$query1 = "UPDATE collia
				       SET ffreezed='',ffreezeuser='{$user}',ffreezedate=now(),ffreezeip='{$ip}'
					   WHERE fdegree='{$degree}' AND fexamno='{$sem}' AND fsubcode='{$subcode}' AND fcollcode='{$collcode}'";
					   $res1=$aobj_context->mobj_db->Execute($query1);
		}
		
			if($res1){
				$arr['msg'] = "Successfully Saved";
				echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success"); 
			}else{
				$arr['msg'] = "failed to load";
				echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
				return;		
			}
		
	}
?>