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


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

<?php
    function getPrDegreeNames($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $collcode = $aobj_context->mobj_data["collcode"];
        $fusertype = $aobj_context->mobj_data["fusertype"];
        $fuserid = $aobj_context->mobj_data["fuserid"];
        
        if($fusertype !='A' && $fusertype !='S')
		{
			$ltable = "inner join usersub us on d.fdegree = us.fdegree
			and mp.fcollcode = us.fcollegecode
			and us.fuser = '{$fuserid}'";
		}
		

        $query ="select distinct d.fdegree as FDEGREE,d.FDESCPN
				from degree d
				inner join marks_pr mp on d.fdegree = mp.fdegree
				and d.fexamno = mp.fexamno and ifnull(d.FDELETED,'') <> 'T'
				and fcollcode = '{$collcode}' {$ltable}";							   

        $result = $aobj_context->mobj_db->GetAll($query);

        if($result)
        {
            echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
        }
        else
        {
            $data['msg'] = 'Faile to load';
            echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
        }
    }

    function getPrExamNo($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $degree = $aobj_context->mobj_data["fdegree"];

        $query="select distinct d.fexamno,d.fexamname 
		from degree d
		inner join marks_pr mp on d.fdegree = mp.fdegree
		and d.fexamno = mp.fexamno and ifnull(d.FDELETED,'') <> 'T'
		where d.fdegree = '{$degree}'
		ORDER BY fexamno";

        $result = $aobj_context->mobj_db->GetAll($query);
        if($result)	
            echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
        else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }

    function getPrSubjCodeDet($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexmNo"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];
        $fusertype = $aobj_context->mobj_data["fusertype"];
        $userID = $aobj_context->mobj_data["userID"];
		$date = date("Y-m-d");

		$qur = "select * from collexam
			where ifnull(c.FPRFROM,'0000-00-00') >= '{$date}'";

		$res = $aobj_context->mobj_db->GetAll($qur);

		if(count($res) == 0){
			$arr['msg'] = "Dates are not enable";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
		}

		if($fusertype !='A' && $fusertype !='S')
		{
			$ltable = "inner join usersub us on m.fdegree = us.fdegree 
			and instr(us.fprsubcode,mp.fsubcode) > 0 
            and m.fcollcode = us.fcollegecode and us.fuser = '{$userID}'";
		}

        $query = "select distinct fcsubcode as id,fcsubcode,fsubname,fssubname,
		concat(fshortname,'(',fsubshort,')') as fshortname,fvalmax as fsmaxmarks
		from subject s
		inner join marks_pr mp on s.fdegree = mp.fdegree
		and s.fexamno = mp.fexamno and s.fcsubcode = mp.fsubcode
		{$ltable}
		where s.fdegree = '{$fdegree}' and s.fexamno = '{$fexmNo}'
		ORDER BY fcsubcode";
        
        $result = $aobj_context->mobj_db->GetAll($query);

        if($result)	
            echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
        else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }

    function getPrVivaSubDetail($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexmNo"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];
        $fsubcode = $aobj_context->mobj_data["fsubcode"];  

        $query = "select pm.FVVCODE,s.FSUBNAME,fvalmax as fsmaxmarks 
        from practical_master pm
        inner join subject s on s.FEXAMNO=pm.FEXAMNO		
        and s.FDEGREE=pm.FDEGREE
        and s.FCSUBCODE=pm.FVVCODE
        where pm.FDEGREE='{$fdegree}' 
        and pm.FEXAMNO='{$fexmNo}' 
        and pm.FPRCODE='{$fsubcode}' 
        and pm.FVVCODE!=''";
        
        $result = $aobj_context->mobj_db->GetAll($query);

        if($result)	
            echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
        else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }

    function GetPrBatchWiseRegNos($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexmNo"];
        $subVal = $aobj_context->mobj_data["subVal"];
        $stdPerBt = $aobj_context->mobj_data["stdPerBt"];
        $startBat = $aobj_context->mobj_data["startBat"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];

        $query = "select ifnull(FPRACTIVE,'') as FPRACTIVE from control";
		$resuts = $aobj_context->mobj_db->GetRow($query);
		$fpractive =  $resuts['FPRACTIVE'];
		
		if($fpractive == 'T')
		{
			$get_records = "select stu.FREGNO, stu.FNAME, 
			IFNULL(mak.FMARKS11, -1) as FMARKS, 
			IFNULL(lpad(mak.FBATCH,2,'0'), '') AS FBATCH  
			FROM student stu inner join marks_pr mak ON  stu.FREGNO=mak.FREGNO 
			and mak.fdegree='{$fdegree}' and mak.Fexamno='{$fexmNo}' and mak.FCOLLCODE='{$fcollcode}'
			inner join subject sub on sub.fdegree = mak.fdegree and sub.fexamno = mak.fexamno and sub.FCSUBCODE = mak.FSUBCODE 
			and sub.FDEGREE = '{$fdegree}' and sub.FEXAMNO = '{$fexmNo}' and sub.FCSUBCODE = '{$subVal}' 
			inner join canddet cd on cd.fdegree = sub.fdegree and cd.fexamno = sub.fexamno and cd.fsubcode = sub.fsubcode
			and cd.fdegree = mak.fdegree and cd.fexamno = mak.fexamno and cd.fregno = mak.fregno and cd.fpresent = 'P'
			inner join candsum cs on cd.fdegree = cs.fdegree and cd.fregno = cs.fregno and ifnull(cs.frecptdate,'') <> '' and ifnull(cs.ftotalfee,0) > 0
			WHERE stu.FREGNO != ''
			group by stu.FREGNO  order by stu.FREGNO ";		
			
		}
		else
		{
			$get_records = "select stu.FREGNO, stu.FNAME, 
			IFNULL(mak.FMARKS11, -1) as FMARKS, 
			IFNULL(lpad(mak.FBATCH,2,'0'), '') AS FBATCH  
			FROM student stu inner join marks_pr mak ON stu.FREGNO=mak.FREGNO 
			and mak.fdegree='{$fdegree}' and mak.Fexamno='{$fexmNo}' and mak.FCOLLCODE='{$fcollcode}'
			inner join subject sub on sub.FCSUBCODE = mak.FSUBCODE 
			and sub.FCSUBCODE='{$subVal}' and sub.FDEGREE='{$fdegree}' and sub.FEXAMNO='{$fexmNo}' 
			left join attshort a on a.fregno = mak.fregno and sub.fsubcode = a.fsubcode
			WHERE stu.FREGNO != ''
			and ifnull(a.fregno,'') = ''
			group by stu.FREGNO  order by stu.FREGNO ";					
		}
        
		$lobj_get_records = $aobj_context->mobj_db->GetAll($get_records);
		$total_student_count = count($lobj_get_records);
	
		$lquery = "SELECT SUM(CASE WHEN IFNULL(Fbatch,'') != '' THEN 1 ELSE 0 END) AS fbatchstud 
			FROM marks_pr WHERE fcollcode = '{$fcollcode}' AND  fdegree = '{$fdegree}' AND fexamno = '{$fexmNo}' AND fsubcode = '{$subVal}'";
		$result = $aobj_context->mobj_db->GetRow($lquery);
        $batchno = $result['fbatchstud'];
        
        if($lobj_get_records){
            $arr['totcut'] = $total_student_count;
            $arr['data'] = $lobj_get_records;
            $arr['batchNo'] = $batchno;
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
            return;
        }else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }
    
    function savePrBatchWiseData($aobj_context){
        $data=json_decode($aobj_context->mobj_data["predata"],true);
        $univcode = $aobj_context->mobj_data["univcode"];
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexamno"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];
        $fsubcode = $aobj_context->mobj_data["fsubcode"];
        $viveSub = $aobj_context->mobj_data["viveSub"];
        $fbatch_no = $aobj_context->mobj_data["fbatch_no"];
        
        foreach($data as $val){
            
            if($viveSub != "" && $viveSub != undefined)
            {
                $update_record = " update marks_pr set FBATCH='{$val['fbatch']}' 
                                    where FCOLLCODE = '{$fcollcode}' and 
                                    FDEGREE = '{$fdegree}' and
                                    FEXAMNO = '{$fexmNo}' and
                                    FREGNO = '{$val['fregNo']}' and
                                    FSUBCODE = '{$viveSub}' ";

                $result = $aobj_context->mobj_db->Execute($update_record);	
            }
            
            $update_record = "update marks_pr set FBATCH='{$val['fbatch']}' 
                                where FCOLLCODE = '{$fcollcode}' and 
                                FDEGREE = '{$fdegree}' and
                                FEXAMNO = '{$fexmNo}' and
                                FREGNO = '{$val['fregNo']}' and
                                FSUBCODE = '{$fsubcode}' ";

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

        if($result)	
            echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
        else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }

    function getPrctEntrFrzeDet($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexmNo"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];
        $fsubcode = $aobj_context->mobj_data["subVal"];

        $query = "select fteachcode,fteachname from masteach
        where fcollcode = '{$fcollcode}'
        order by fteachname"; 
        $res = $aobj_context->mobj_db->GetAll($query);

        $get_subject = "select  s.FDEGREE,s.FEXAMNO,s.FSUBCODE,s.FBATCH,
                    ifnull(FFREEZED,'F') as FFREEZED,
                    ifnull(PRINTFREEZED,'F') as PRINTFREEZED,
                    count(s.fregno) as bcnt,
                    pf.froomname,
                    ifnull(pf.fexaminer1,'') as fexaminer1,
                    ifnull(pf.fexaminer2,'') as fexaminer2,
                    ifnull(pf.fexaminer3,'') as fexaminer3,
                    ifnull(pf.fexaminer4,'') as fexaminer4,
                    ifnull(pf.fexaminer5,'') as fexaminer5,
                    ifnull(pf.fexaminer6,'') as fexaminer6,
                    GROUP_CONCAT(distinct  if(abs(FMarks11)<1,0,abs(FMarks11)) separator '') as tot_marks,
                    sum(case when s.fmarks11 = -1 then 0 else 1 end) as marks_entered,	
                    pf.FBATCH as freezed_batch,ifnull(pf.FEXAMDATE,'0000/00/00') as FEXAMDATE,pf.FEXAMTIME 
                    from marks_pr  s  inner join  subject sub 
                    on s.FDEGREE=sub.FDEGREE and s.FEXAMNO=sub.FEXAMNO and s.FSUBCODE=sub.FCSUBCODE
                    left join practical_entry_freeze pf
                    on pf.FDEGREE=s.FDEGREE and pf.FEXAM=s.FEXAMNO and pf.FCSUBCODE=s.FSUBCODE 
                    and pf.FCOLLCODE=s.FCOLLCODE
                    and lpad(s.FBATCH,2,'0')=lpad(pf.FBATCH,2,'0')
                    where  s.fdegree =  '{$fdegree}'				   
                    and  s.fexamno='{$fexmNo}'
                    and  s.FSUBCODE='{$fsubcode}'
                    and s.FCOLLCODE='{$fcollcode}' and s.FBATCH>0
                    group by s.FDEGREE,s.FEXAMNO,s.FSUBCODE,s.FBATCH ";
        
        $obj_get_details = $aobj_context->mobj_db->GetAll($get_subject);
        
        if($obj_get_details){
            $arr['teachcode'] = $res;
            $arr['batchwsetme'] = $obj_get_details;
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
        }
        else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }

    function FreezePracticalMaks($aobj_context){
        $larr_output_details=json_decode($aobj_context->mobj_data["bathWsTTdata"],true);
        $univcode = $aobj_context->mobj_data["univcode"];
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexamno"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];
        $fsubval = $aobj_context->mobj_data["fsubcode"];
        $fsubcplit = explode('-',$fsubval);
        $fsubcode = $fsubcplit[0];

        $query = "select fyear,fexamtype from marks_pr where fdegree ='{$fdegree}'
        and fexamno = '{$fexmNo}'
        and fcollcode = '{$fcollcode}'
        and fsubcode = '{$fsubcode}'";
        $resuts1 = $aobj_context->mobj_db->GetRow($query);
        $fyear = $resuts1['fyear'];
        $fexamtype = $resuts1['fexamtype'];

        
        for( $i = 0; $i < count($larr_output_details); $i++ )
        {
            
            $query = "select * from practical_entry_freeze where fcollcode = '{$fcollcode}'
            and fdegree = '{$fdegree}' and FEXAM = '{$fexmNo}'
            and FBATCH = '{$larr_output_details[$i]['FBATCH']}'
            and FCSUBCODE = '{$fsubcode}'";
            
            $resuts1 = $aobj_context->mobj_db->GetRow($query);
            if($resuts1)
            {
                if($larr_output_details[$i]['fexaminer1'] == NULL || $larr_output_details[$i]['fexaminer1'] == '')
                {
                    $upd = "update practical_entry_freeze set FFREEZED = '{$larr_output_details[$i]["FFREEZED"]}',
                    PRINTFREEZED = '{$larr_output_details[$i]["PRINTFREEZED"]}',
                    FFREEZEDATE = now(),
                    FEXAMTIME = '{$larr_output_details[$i]["FEXAMTIME"]}',
                    froomname = '{$larr_output_details[$i]["froomname"]}',        
                    FEXAMDATE = '{$larr_output_details[$i]["FEXAMDATE"]}',
                    where fcollcode = '{$fcollcode}'
                    and fdegree = '{$fdegree}' and FEXAM = '{$fexmNo}'
                    and FBATCH = '{$larr_output_details[$i]['FBATCH']}'
                    and FCSUBCODE = '{$fsubcode}'";
                }else
                {
                    $upd = "update practical_entry_freeze set FFREEZED = '{$larr_output_details[$i]["FFREEZED"]}',
                    PRINTFREEZED = '{$larr_output_details[$i]["PRINTFREEZED"]}',
                    FFREEZEDATE = now(),
                    froomname = '{$larr_output_details[$i]["froomname"]}',
                    fexaminer1 = '{$larr_output_details[$i]["fexaminer1"]}',
                    fexaminer2 = '{$larr_output_details[$i]["fexaminer2"]}',
                    fexaminer3 = '{$larr_output_details[$i]["fexaminer3"]}',
                    fexaminer4 = '{$larr_output_details[$i]["fexaminer4"]}',
                    fexaminer5 = '{$larr_output_details[$i]["fexaminer5"]}',
                    fexaminer6 = '{$larr_output_details[$i]["fexaminer6"]}',
                    FEXAMDATE = '{$larr_output_details[$i]["FEXAMDATE"]}',
                    FEXAMTIME = '{$larr_output_details[$i]["FEXAMTIME"]}'
                    where fcollcode = '{$fcollcode}'
                    and fdegree = '{$fdegree}' and FEXAM = '{$fexmNo}'
                    and FBATCH = '{$larr_output_details[$i]["FBATCH"]}'
                    and FCSUBCODE = '{$fsubcode}'";
                }
                
                $lobj_insert_qty = $aobj_context->mobj_db->Execute($upd);
            }else
            {

                $insert_qty = "insert into practical_entry_freeze(
                    FCOLLCODE,
                    FDEGREE,
                    FEXAM,
                    FBATCH,
                    FCSUBCODE, FEXAMDATE,FEXAMTIME,FFREEZED,PRINTFREEZED,FFREEZEDATE,
                    fyear,fexamtype,froomname,fexaminer1,fexaminer2,fexaminer3,fexaminer4,fexaminer5
                    )
                    values(
                    '{$fcollcode}',
                    '{$fdegree}',
                    '{$fexmNo}',
                    '{$larr_output_details[$i]['FBATCH']}',
                    '{$fsubcode}',									
                    '{$larr_output_details[$i]["FEXAMDATE"]}',
                    '{$larr_output_details[$i]["FEXAMTIME"]}',
                    '{$larr_output_details[$i]["FFREEZED"]}',
                    '{$larr_output_details[$i]["PRINTFREEZED"]}',
                    now(),
                    '{$fyear}',
                    '{$fexamtype}',
                    '{$larr_output_details[$i]["froomname"]}',
                    '{$larr_output_details[$i]["fexaminer1"]}',
                    '{$larr_output_details[$i]["fexaminer2"]}',
                    '{$larr_output_details[$i]["fexaminer3"]}',
                    '{$larr_output_details[$i]["fexaminer4"]}',
                    '{$larr_output_details[$i]["fexaminer5"]}',
                    '{$larr_output_details[$i]["fexaminer6"]}')";
                    
                    $lobj_insert_qty = $aobj_context->mobj_db->Execute($insert_qty);

            }
            
            $upd = "update canddet cd, marks_pr m, practical_entry_freeze p set cd.fsdoe = date_format(p.fexamdate,'%d/%m/%Y'),
            cd.fssession = p.fexamtime
            where cd.fdegree = m.fdegree 
            and cd.fexamno = m.fexamno and cd.fsubcode = left(m.fsubcode,4)
            and cd.fregno = m.fregno
            and p.fdegree = m.fdegree and p.fexam = m.fexamno
            and p.fcsubcode = m.fsubcode
            and p.FBATCH = m.FBATCH
            and p.fyear = cd.fyear
            and p.fexamtype = cd.fexamtype
            and m.fdegree = '{$fdegree}' and m.fexamno = '{$fexmNo}' and m.fsubcode = '{$fsubcode}'
            and m.fcollcode = '{$fcollcode}'";
        
            $res1 = $aobj_context->mobj_db->Execute($upd);

        }
        
        if($res1)	{
            $arr['msg'] = "Successfully updated";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
        }
        else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }

    function GetPracticalMarksRegNos($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexmNo"];
        $subVal = $aobj_context->mobj_data["subVal"];
        $fusertype = $aobj_context->mobj_data["fusertype"];
        $batchNo = $aobj_context->mobj_data["batchNo"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];
        $vivaSubVal = $aobj_context->mobj_data["vivaSubVal"];
        
        $query = "select fexamdate,ffreezed,printfreezed,fbatch,fdegree from practical_entry_freeze 
			where fcollcode = '{$fcollcode}' and fdegree = '{$fdegree}' 
			and fexam = '{$fexmNo}' and fbatch = '{$batchNo}' and fcsubcode = '{$subVal}'";
	
        $result = $aobj_context->mobj_db->GetRow($query);
        $last_date = $result['fexamdate'];

        $query = "select sum(case when DATE_FORMAT(NOW(),'%Y-%m-%d') <> '{$last_date}' then 1 else 0 end) as flastdate 
                from practical_entry_freeze where fcollcode = '{$fcollcode}' and fdegree = '{$fdegree}' 
                and fexam = '{$fexmNo}' and fbatch = '{$batchNo}' and fcsubcode = '{$subVal}'";
        
        $result = $aobj_context->mobj_db->GetRow($query);	
        
        if($fusertype != 'A' && $fusertype != 'S'){
            if($result['flastdate'] > 0)
            {
                $arr = "Practical dates are not matching.";
                echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-2,"Failure");
                return;
            }
        }
        $get_freezed="select count(*) as freeze_cnt from practical_entry_freeze
						where FCOLLCODE='{$fcollcode}'
						and FDEGREE='{$fdegree}'
						and FEXAM='{$fexmNo}'
						and FCSUBCODE='{$subVal}'
						and lpad(FBATCH,2,'0')='{$batchNo}'
						and FFREEZED='T'";
		$lobj_get_freezed = $aobj_context->mobj_db->GetRow($get_freezed);
        
		if($lobj_get_freezed['freeze_cnt']>0)
		{
			$rdata='Mark Entry Subjectwise Freezed By Admin';
			echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
			return;	
		}

        $get_freezed="select * from practical_entry_freeze
						where FCOLLCODE='{$fcollcode}'
						and FDEGREE='{$fdegree}'
						and FEXAM='{$fexmNo}'
						and FCSUBCODE='{$subVal}'
						and lpad(FBATCH,2,'0')='{$batchNo}'";
		$lobj_get_freezed = $aobj_context->mobj_db->GetRow($get_freezed);
		$fexaminer1 = $lobj_get_freezed['fexaminer1']; 
		$fexaminer2 = $lobj_get_freezed['fexaminer2'];
        
		$qury = "select fteachcode, ifnull(FACCNO,'') as FACCNO,
		ifnull(FIFSCCODE,'') as FIFSCCODE
		From masteach where fteachcode = '{$fexaminer1}'";
		$res = $aobj_context->mobj_db->GetRow($qury);
        
		$qury = "select fteachcode, ifnull(FACCNO,'') as FACCNO,
		ifnull(FIFSCCODE,'') as FIFSCCODE
		From masteach where fteachcode = '{$fexaminer2}'";
		$res1 = $aobj_context->mobj_db->GetRow($qury);
		
		if($univcode == '040')
		{
			if($res)
			{
				$FACCNO = $res['FACCNO'];
				$FIFSCCODE = $res['FIFSCCODE'];

				$FACCNO1 = $res1['FACCNO'];
				$FIFSCCODE1 = $res1['FIFSCCODE'];

				if($FACCNO == '' || $FIFSCCODE == '')
				{
					$rdata='Enter Practical Examiner 1 Bank Details';
					echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
					return;
				}

				if($FACCNO1 == '' || $FIFSCCODE1 == '')
				{
					$rdata='Enter Practical Examiner 2 Bank Details';
					echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
					return;
				}

			}else
			{
				$rdata='Select Practical Examiner';
				echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
				return;	
			}
		}

        $get_records = "select stu.FREGNO, stu.FNAME, 
						IFNULL(mak.FMARKS11, '-1') as FMARKS, IFNULL(mak.FBATCH, '') AS FBATCH
						FROM student stu inner join marks_pr mak ON  stu.FREGNO=mak.FREGNO 
						and mak.Fdegree='{$fdegree}' and mak.Fexamno='{$fexmNo}' and mak.FCOLLCODE='{$fcollcode}'
						inner join subject sub on sub.FCSUBCODE = mak.FSUBCODE 
						and sub.FCSUBCODE='{$subVal}' and sub.FDEGREE='{$fdegree}' and sub.FEXAMNO='{$fexmNo}'
						WHERE stu.FREGNO != ''  and IFNULL(mak.FBATCH, '')='{$batchNo}' 
						and ifnull(stu.fdeleted,'') <> 'T'
						group by stu.FREGNO  order by stu.FREGNO limit 1000";					
		
		$lobj_get_records = $aobj_context->mobj_db->GetAll($get_records);
		
		$get_viva_records = "select stu.FREGNO, stu.FNAME, 
						IFNULL(mak.FMARKS11, '-1') as FMARKS, IFNULL(mak.FBATCH, '') AS FBATCH
						FROM student stu inner join marks_pr mak ON  stu.FREGNO=mak.FREGNO 
						and mak.Fdegree='{$fdegree}' and mak.Fexamno='{$fexmNo}' and mak.FCOLLCODE='{$fcollcode}'
						inner join subject sub on sub.FCSUBCODE = mak.FSUBCODE 
						and sub.FCSUBCODE='{$vivaSubVal}' and sub.FDEGREE='{$fdegree}' and sub.FEXAMNO='{$fexmNo}'
						WHERE stu.FREGNO != ''  and lpad(IFNULL(mak.FBATCH, ''),2,'0')='{$batchNo}'
						and ifnull(stu.fdeleted,'') <> 'T'
						group by stu.FREGNO  order by stu.FREGNO limit   300";					
		 
		$obj_get_viva_records = $aobj_context->mobj_db->GetAll($get_viva_records);
     
        if($lobj_get_records){
            $arr['batchNo'] = $lobj_get_records;
            $arr['vivaRecd'] = $obj_get_viva_records;
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
            return;
        }else{
            $arr['msg'] = "No Data Found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
            return;
        }
    }

    function savePrEntryMarks($aobj_context)
	{
		$data=json_decode($aobj_context->mobj_data["predata"],true);
        $univcode = $aobj_context->mobj_data["univcode"];
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fexmNo = $aobj_context->mobj_data["fexamno"];
        $fcollcode = $aobj_context->mobj_data["fcollcode"];
        $fsubcode = $aobj_context->mobj_data["fsubcode"];
        $viveSub = $aobj_context->mobj_data["viveSub"];
        $fbatch_no = $aobj_context->mobj_data["fbatch_no"];
		include("error_log.php");
	    
        for( $i = 0; $i<count($data); $i++ )
        {
            if(strtoupper($data[$i]['fmarks']) == "MP"){
                $marks = "-3";
            }else{
                $marks = $data[$i]['fmarks'];
            }
            
            $qry = "select FMARKS11 from marks_pr where 
                        fcollcode = '{$fcollcode}'
                        and fdegree = '{$fdegree}' 
                        and fexamno = '{$fexmNo}'
                        and fsubcode = '{$fsubcode}'
                        and fregno = '{$data[$i]['fregNo']}'";
            $res = $aobj_context->mobj_db->getRow($qry);
            
            $update_record = " update marks_pr set FMARKS11='{$marks}' ,
                                FLOGNAME = '{$User_code}', FLOGDATE = NOW()
                                where FCOLLCODE = '{$fcollcode}' and 
                                FDEGREE = '{$fdegree}' and
                                FEXAMNO = '{$fexmNo}' and
                                FREGNO = '{$data[$i]['fregNo']}' 
                                and FSUBCODE = '{$fsubcode}' ";
            								
            $lobj_insert_qry = $aobj_context->mobj_db->Execute($update_record);	
            
            if($data[$i]['fvivamarks'] != ""){
                if(strtoupper($data[$i]['fvivamarks']) == "MP"){
                    $marks = "-3";
                }else{
                    $marks = $data[$i]['fvivamarks'];
                }

                $vivaqry = "select FMARKS11 from marks_pr where 
                            fcollcode = '{$fcollcode}'
                            and fdegree = '{$fdegree}' 
                            and fexamno = '{$fexmNo}'
                            and fsubcode = '{$viveSub}'
                            and fregno = '{$data[$i]['fregNo']}'";
                $vivares = $aobj_context->mobj_db->getRow($qry);


                $update_viva_record = "update marks_pr set FMARKS11='{$marks}', 
                                        FLOGNAME = '{$User_code}', FLOGDATE = NOW()
                                        where FCOLLCODE = '{$fcollcode}' and 
                                        FDEGREE = '{$fdegree}' and
                                        FEXAMNO = '{$fexmNo}' and
                                        FREGNO = '{$data[$i]['fregNo']}' and
                                        FSUBCODE = '{$viveSub}'";
                $insert_viva_qry = $aobj_context->mobj_db->Execute($update_viva_record);	
            
                $oldmarks =  $res['FMARKS11'];
                $remark = "MEN - PR Marks Entry - $fdegree, $fexmNo, $viveSub, $fcollcode, ".$data[$i]['fregNo'].", Old: $oldmarks, New: ".$data[$i]['fvivamarks'];
                $res = error_logs($aobj_context,$univcode,$remark,$fcollcode,$enttype,$usr,$mob);
            }
            
            $oldmarks =  $res['FMARKS11'];
            $remark = "MEN - PR Marks Entry - $fdegree, $fexmNo, $fsubcode, $fcollcode, ".$data[$i]['fregNo'].", Old: $oldmarks, New: ".$data[$i]['fmarks'];
            $res = error_logs($aobj_context,$univcode,$remark,$fcollcode,$enttype,$usr,$mob);

        }	
            
        if(1)
        {
            $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;			
        }			
	}
?>