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 : 13.59.35.116


Current Path : /var/www/oasis/src/
Upload File :
Current File : /var/www/oasis/src/principalFreeze.php

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

    $usertype = $_SESSION['user_type'];
    $usr = $_SESSION['usr'];	
    $cnd = '';
    if(strtolower($usertype) == 'user')
    {
        $cnd = "and m.fteachcode = '{$usr}'";   
    }

    $query = "select ifnull(m.FTEACHCODE, '')as FTEACHCODE, 
              ifnull(m.FTEACHNAME, '')as FTEACHNAME 
              from masteach m inner join attclass a on a.fteachcode = m.fteachcode 
              where a.fcollcode = '{$collcode}' {$cnd}  group by m.FTEACHCODE";
    $result = $aobj_context->mobj_db->GetAll($query);
    if($result){
        echo($aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"));
			return $result;
    }else{
            $arr['msg'] = "No data found..!";
			echo($aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"));  
			return $arr;
    }
}

function loadClassNamePrincipal($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $collcode = $_SESSION['collcode'];
    $teachcode = trim($aobj_context->mobj_data["teachcode"]);
    $query = "select ifnull(ac.fclassid,'')as fclassid, 
              ifnull(ac.fclassname, '')as fclassname, 					
              ifnull(at.fdegree, '')as fdegree, 
              ifnull(at.fexamno, '')as fexamno
              from attclass ac inner join attendsum at on 
              ac.fteachcode = at.fteachcode and ac.fclassid = at.fclassid 
              where ac.fteachcode = '{$teachcode}' and ac.fcollcode = '{$collcode}' 
              group by ac.fclassid";
    $result = $aobj_context->mobj_db->GetAll($query);
    if($result){
        echo($aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"));
			return $result;
    }else{
            $arr['msg'] = "No data found..!";
			echo($aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"));  
			return $arr;
    }
}

function loadSubjectNamePrincipal($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $collcode = $_SESSION['collcode'];
    $teachcode = trim($aobj_context->mobj_data["teachcode"]);
    $classid = trim($aobj_context->mobj_data["classcode"]);

    $split = explode(" - ",$classid);
    $classcode = $split[0];
    
     $query = "select s.fcsubcode as fsubcode,s.FSSUBNAME, s.fexamno,s.fdegree,
    c.fiateachfreez, c.fiapricfreez 
    from attendsum a 
    inner join degree d on a.fdegree = d.fdegree and a.fexamno = d.fexamno 
    inner join subject s on a.fdegree = s.fdegree and a.fexamno = s.fexamno 
    and left(a.fsubcode,4) = s.fsubcode 
    left join classfreez c on c.fteachcode = a.fteachcode and c.fclassid = a.fclassid
    and left(c.fsubcode,4) = left(a.fsubcode,4)
    and c.fsubcode = s.fcsubcode
    where a.fteachcode = '{$teachcode}' and ifnull(s.FRETAIN,'') = 'T' 
    and ifnull(s.FINTASS,'') = 'T' and a.fclassid = '{$classcode}'
    group by s.fcsubcode";
	
    
    $result = $aobj_context->mobj_db->GetAll($query);
    if($result){
        echo($aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"));
			return $result;
    }else{
            $arr['msg'] = "No data found..!";
			echo($aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"));  
			return $arr;
    }
}

function savePrincipalFreeze($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $collcode = $_SESSION['collcode'];
    $teachcode = trim($aobj_context->mobj_data["teachcode"]);
    $classid = trim($aobj_context->mobj_data["classcode"]);
    $split = explode(" - ",$classid);
    $classcode = $split[0];
    $degree = $split[1];
    $examno = $split[2];
    $user_id = $_SESSION['user_id'];
    $data = $aobj_context->mobj_data["data"];
    $array = json_decode($data,true);
    $format_file= $aobj_context->main_src."/src/format.php";
	include($format_file);
    include("error_log.php");
	$clientIp ='';
	
		if (!empty($_SERVER['HTTP_X_REAL_IP'])) 
			 $_SERVER['HTTP_X_REAL_IP'];
		else if (!empty($_SERVER['HTTP_CLIENT_IP'])) 
			 $clientIp = $_SERVER['HTTP_CLIENT_IP'];
		else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
				$clientIp = $_SERVER['HTTP_X_FORWARDED_FOR'];
		else 
			 $clientIp = $_SERVER['REMOTE_ADDR'];

    $qry = "select fclassid from classfreez
             where fteachcode = '{$teachcode}'";             
    $resqry = $aobj_context->mobj_db->GetRow($qry);

    
    
    foreach($array as $key=>$value){
        $qrey = "select fiapricfreez from classfreez
                 where fclassid = '{$classcode}' and fsubcode = '{$value['subcode']}' and fteachcode = '{$teachcode}'";
        $resqrey = $aobj_context->mobj_db->GetRow($qrey);

        $prevPrincFreeze = $resqrey['fiapricfreez'];

        if(count($resqry) == 0){
            $currPrincFreeze = $value['princfreeze'];
            $subcode = $value['subcode'];
            $str = "PRINCIPAL FREEZE: USER : $user_id, COLLCODE: $collcode, TEACHCODE : $teachcode, CLASSID : $classcode, SUBCODE : $subcode, FREEZED : $currPrincFreeze";
            $remark = $str;
            $enttype = "PRINCIPAL";
            $res = error_logs($aobj_context,$univcode,$remark,$college_code,$enttype,$usr,$mob);

            $query = "insert into classfreez (fteachcode,fcollcode,fclassid,
                      fsubcode,fiateachfreez,fiatfreezdate,fiateachfreezuser,fiapricfreez,
                      fiapfreezdate,fiapfreezuser)
            values ('{$teachcode}','{$collcode}','{$classcode}','{$value['subcode']}',
            '{$value['teacherfreeze']}',now(),'{$user_id}', 
            '{$value['princfreeze']}', now(),'{$user_id}' )";
    
            $result = $aobj_context->mobj_db->Execute($query);   
        }else{
            // $currTeachFreeze = $value['teacherfreeze'];
            $currPrincFreeze = $value['princfreeze'];
            $subcode = $value['subcode'];
            $str = "UPDATED PRINCIPAL FREEZE: USER : $user_id, COLLCODE: $collcode, TEACHCODE : $teachcode, CLASSID : $classcode, SUBCODE : $subcode, PREVFREEZE : $prevfreeze, UPDFREEZE : $currfreeze";
            $remark = $str;
            $enttype = "UPDPRINCIPAL";
            $res = error_logs($aobj_context,$univcode,$remark,$college_code,$enttype,$usr,$mob);

            $query = "update classfreez set fiateachfreez='{$value['teacherfreeze']}',
                     fiateachfreezuser='{$user_id}',fiatfreezdate =now(), 
                     fiapricfreez='{$value['princfreeze']}', fiapfreezdate=now(), fiapfreezuser='{$user_id}'
                     where fcollcode = '{$collcode}'  
                     and fteachcode = '{$teachcode}' and fclassid = '{$classcode}'
                     and fsubcode = '{$value['subcode']}'";

            $result = $aobj_context->mobj_db->Execute($query);
        }

                       
    }
    if($result){
        $arr='Updated Successfully';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
        return;
    }else{
        $arr='Updatation Failed';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
		return;
    }
}
?>