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


Current Path : /proc/thread-self/root/var/www/oasis/src/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/src/copomarksexternal.php

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

  $qry1 = "select ifnull(sysusr,'') as fteachcode from s_sysdb
  where college_code = '{$collcode}' and sysusr = '{$usr}'";
  //var_dump($qry1);
  $lobj1 = $aobj_context->mobj_db->GetRow($qry1);  

  if($user_type == '14' || $user_type == '40'){
      $cnd = "";
  }else{
      $cnd = "where (fteachcode = '{$lobj1['fteachcode']}' or frevcode = '{$lobj1['fteachcode']}')";
      
  }


  $query = "select ifnull(t.fsubcode,'') as fsubcode, concat(ifnull(FSUBNAME, ''),' - ',fssubname) as fsubname 
  from
  tdvs_copomarks t
  inner join 
  subject s on t.fsubcode = s.fqpcode
  $cnd
  group by t.fsubcode";
    // var_dump($query);
  $result = $aobj_context->mobj_db->GetAll($query);

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


function loadcopopacketno($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $qpcode = $aobj_context->mobj_data["qpcode"];
  
    $user_type = $_SESSION['usrtype'];
    //var_dump($user_type);
    $user = $_SESSION['usr'];
    //$user_type = 40;
    $cnd = "and (t.fteachcode = '{$user}' or frevcode = '{$user}')";
    if($user_type == '14' || $user_type == '40')
      $cnd = "";



    $qry = "select ifnull(t.fcollcode,'') as fcollcode from tdvs_copomarks t
    where t.fsubcode = '{$qpcode}'  {$cnd}
    group by t.fcollcode";
  
    $result = $aobj_context->mobj_db->GetAll($qry);
  
    if($result){
          echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
      }else{
          $arr['msg'] = 'Failed to load';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
      }
  }


  function loadcopovalno($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $qpcode = $aobj_context->mobj_data["qpcode"];
    $packet = $aobj_context->mobj_data["packet"];
    $cnd = "";

    $user_type = $_SESSION['usrtype'];
    //var_dump($user_type);
    $user = $_SESSION['usr'];
    //$user_type = 40;
    $cnd = "and (fteachcode = '{$user}' or frevcode = '{$user}')";
    if($user_type == '14' || $user_type == '40')
      $cnd = "";


    $qry = "select ifnull(fvalno,'') as fvalno from tdvs_copomarks
    where fsubcode = '{$qpcode}' and fcollcode = '{$packet}' {$cnd}
    group by fvalno";
    
    $result = $aobj_context->mobj_db->GetAll($qry);
  
    if($result){
          echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
      }else{
          $arr['msg'] = 'Failed to load';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
      }
  }


//   function viewmarksentryexternal($aobj_context){
//     $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

//     $valno = $aobj_context->mobj_data["valno"];
//     $packet = $aobj_context->mobj_data["packet"];
//     $qpcode = $aobj_context->mobj_data["qpcode"];
//     $collcode=$_SESSION['collcode'];

//     $query = "select fqpcode from subject where fdegree = '{$degree}' and fexamno = '{$examno}' and fcsubcode = '{$qpcode}'";
//     $res1 = $aobj_context->mobj_db->Getrow($query); 
//     $fqpcode1 = $res1['fqpcode'];

//     $qry3 = "select fdegree,fexamno from tdvs_qpcopo where fqpcode = '{$qpcode}'";
//     $res3 = $aobj_context->mobj_db->Getrow($qry3); 
//     $degree = $res3['fdegree'];
//     $examno = $res3['fexamno'];

//     $query = "select p.fqncode,pd.fqnno,p.fmaxmarks
//     from   tdvs_qpcopo p 
//     inner join tdvs_qptempdetl_copo pd on p.ftempcode = pd.ftempcode
//     and p.fpartcode = pd.fpartcode and p.fqncode = pd.fqncode
//     where  p.fdegree = '{$degree}' and p.fexamno = '{$examno}'
//     and ifnull(p.fmaxmarks,0) >0
//     and p.fqpcode = '{$qpcode}'
//     order by pd.fqncode";


//     $res=$aobj_context->mobj_db->GetAll($query);
//     $oldqnno=$res[0]['fqnno'];
//     $split=explode(".", $oldqnno);
//     $oldqn = $split[0];
    
// 	$id = 4+count($res);

//     $e_data.="<table id = 'showteachsub' cellspacing='0' class='tr_ventor_row' cellpadding='0' border='0' >";
//     $e_data.="<thead style='position: sticky;top: 0;'>";
//     $e_data.="<th align='left' colspan='{$id}' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:12px; padding-left:6px; height:24px;'>Marks Entry</th>";			
//     $e_data.="<tr class='ui-state-default ui-jqgrid-hdiv'>";	
//     $e_data.="<td  style='padding:2px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Sl.<br>No.</center></td>";
//     $e_data.="<td  style='padding:2px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Script No.</center></td>";
//     $e_data.="<td  style='padding:2px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Tot.<br>Marks</center></td>";
    
//     $fileds = "";
//     $x =0;
//     $arry = [];
//     $qno = [];
    
//     foreach($res as $value)
//     {
//         $splitvalue = explode(".",$value['fqnno']);

//         // if($oldqn !== $splitvalue[0]){
//         //     $oldqn = $splitvalue[0];
//         //     $e_data.="<td  style='padding:2px; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>
//         //                {$oldqn} Total
//         //               </td>";
//         // }
//         $e_data.="<td  style='padding:2px; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>{$value['fqnno']}<br>({$value['fmaxmarks']})
//         <input type = 'hidden' value ='".$value['fmaxmarks']."' id = '$x".'qnmax'."'/>
//         </center></td>";
//         $fileds .= "ifnull(".'fq'.strtolower(str_replace(".","",$value['fqnno'])).",'-1') as ".'fq'.strtolower(str_replace(".","",$value['fqnno'])).", ";
//         $arry[$x] = 'fq'.strtolower(str_replace(".","",$value['fqnno']));
//         array_push($qno, $value['fqnno']);
        
//          $x++;
//     }
    
//     $e_data.="</tr>";
//     $e_data.="</thead>";

//     $query = "select $fileds fregno,ftotmarks from tdvs_copomarks 
//     where fcollcode = '{$packet}' and fvalno = '{$valno}'
//     and fsubcode = '{$qpcode}'";
//     // var_dump($query);
//     // die();
//     $res2= $aobj_context->mobj_db->GetAll($query);
//     $i = 1;

//     foreach($res2 as $val)
//     {
//         $e_data.="<tr>";
//         $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>$i</center></td>";
//         $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>{$val['fregno']}  
//         <input type = 'hidden' value ='".$val['fregno']."' id = '$i".'hregno'."'/>
//         <input type = 'hidden' value ='N' id = '$i".'hcregno'."'/>
//         <input type = 'hidden' value ='".count($arry)."' id = '$i".'totqp'."'/>
//         </center></td>";
//         $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align: center;' id = '$i".'totmarks'."'>{$val['ftotmarks']}</td>";
//         for($z =0;$z<count($arry);$z++)
//         {
//             $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align:center'><input type = 'text' value ='".$val[$arry[$z]]."'  style='width:30px;text-align: center;' onchange = 'getregupd(this),valmaxmarksExt(this)' id = '$i".'_qp_'."$z'/>
//             <input type = 'hidden' value ='".$arry[$z]."' id = '$i".'_hqp_'."$z'/>
//             </td>";    
//         }
//         $e_data.="</tr>";
//         $i++;
//     }

//     $e_data.="</table>";
//     $lob = true;
//     if($lob){

//         $arry['tabledata'] = $e_data;
//         $arry['qpcnt'] = $z;
//         $arry['tablecnt'] = count($res2);
//         $arry['qno'] = $qno;
//           echo $aobj_context->mobj_output->ToJSONEnvelope($arry,0,"success"); 
//       }else{
//           $arr['msg'] = 'Failed to load';
//       echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
//       }
//   }

  function viewmarksentryexternal($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $valno = $aobj_context->mobj_data["valno"];
    $packet = $aobj_context->mobj_data["packet"];
    $qpcode = $aobj_context->mobj_data["qpcode"];
    $collcode=$_SESSION['collcode'];


    $user_type = $_SESSION['usrtype'];
    //var_dump($user_type);
    $user = $_SESSION['usr'];
    //$user_type = 40;
    $cnd = false;
    if($user_type == '14' || $user_type == '40')
    {

    }else
    {
        $query = "select count(*) as cnt from tdvs_copomarks where frevcode = '{$user}' 
        and fsubcode = '{$qpcode}' and fvalno = '{$valno}'
        and fcollcode = '{$packet}'";
        $res9 = $aobj_context->mobj_db->Getrow($query); 
        if($res9['cnt'] >0)
        {
            $cnd = true;
        }
       
    }


    $query = "select fqpcode from subject where fdegree = '{$degree}' and fexamno = '{$examno}' and fcsubcode = '{$qpcode}'";
    $res1 = $aobj_context->mobj_db->Getrow($query); 
    $fqpcode1 = $res1['fqpcode'];

    $qry3 = "select fdegree,fexamno from tdvs_qpcopo where fqpcode = '{$qpcode}'";
    $res3 = $aobj_context->mobj_db->Getrow($qry3); 
    $degree = $res3['fdegree'];
    $examno = $res3['fexamno'];

    $query = "select p.fqncode,pd.fqnno,p.fmaxmarks
    from  tdvs_qpcopo p 
    inner join tdvs_qptempdetl_copo pd on p.ftempcode = pd.ftempcode
    and p.fpartcode = pd.fpartcode and p.fqncode = pd.fqncode
    where  p.fdegree = '{$degree}' and p.fexamno = '{$examno}'
    and ifnull(p.fmaxmarks,0) >0
    and p.fqpcode = '{$qpcode}'
    order by pd.fqncode";

    $res=$aobj_context->mobj_db->GetAll($query);  
    $oldqn = "";
    
	$id = 14+count($res);
    //var_dump($id);
    $e_data.="<table id = 'showteachsub' cellspacing='0' class='tr_ventor_row' cellpadding='0' border='0' >";
    $e_data.="<thead style='position: sticky;top: 0;'>";
    $e_data.="<th align='left' colspan='{$id}' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:12px; padding-left:6px; height:24px;'>Marks Entry</th>";			
    $e_data.="<tr class='ui-state-default ui-jqgrid-hdiv'>";	
    $e_data.="<td  style='padding:2px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Sl.<br>No.</center></td>";
    $e_data.="<td  style='padding:2px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Script No.</center></td>";
    $e_data.="<td  style='padding:2px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Tot.<br>Marks</center></td>";
    $e_data.="<td  style='padding:2px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>Online<br>Marks</center></td>";
    
    $fileds = "";
    $x =0;
    $arry = [];
    $qno = [];

    $qnArr = [];
        
   
    foreach($res as $value)
    {
        $splitvalue = explode(".",$value['fqnno']);
        
        if($oldqn !== $splitvalue[0]){
            $e_data.="<td  style='padding:2px; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>
                       {$splitvalue[0]} Total
                      </td>";
            $oldqn = $splitvalue[0];
            array_push($qnArr, $splitvalue[0]);
            $fileds .= "ifnull(".'fq'.$oldqn.",'-1') as ".'fq'.$oldqn.", ";    
            $arry[$x] = 'fq'.$oldqn;
            $x++;
        }

        
        $e_data.="<td  style='padding:2px; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>{$value['fqnno']}<br>({$value['fmaxmarks']})
        <input type = 'hidden' value ='".$value['fmaxmarks']."' id = '$x".'qnmax'."'/>
        </center></td>";
        $fileds .= "ifnull(".'fq'.strtolower(str_replace(".","",$value['fqnno'])).",'-1') as ".'fq'.strtolower(str_replace(".","",$value['fqnno'])).", ";
        $arry[$x] = 'fq'.strtolower(str_replace(".","",$value['fqnno']));
        array_push($qno, $value['fqnno']);
        
         $x++;
    }
    
    $e_data.="</tr>";
    $e_data.="</thead>";

    if($cnd)
    {
        $query = "select $fileds fregno,frevtotmarks as ftotmarks,ifnull(fonlinerevtot,'') as fonlinetot 
        from tdvs_copomarks 
        where fcollcode = '{$packet}' and fvalno = '{$valno}'
        and frevcode = '{$user}'
        and fsubcode = '{$qpcode}'";
        $res2 = $aobj_context->mobj_db->GetAll($query);

        $upd = "insert ignore into tdvs_copomarks_teach(fregno, fclassid, fclassname, fsection, fteachcode, fvalno, fcollcode, fdegree, fexamno, fsubcode, fyear, fexamtype, felement, fmaxmarks, ftotmarks, fmdocno, fmode, flogdate, fq1a, fq1b, fq1c, fq1d, fq1e, fq1, fq2a, fq2b, fq2c, fq2d, fq2e, fq2, fq3a, fq3b, fq3c, fq3d, fq3e, fq3, fq4a, fq4b, fq4c, fq4d, fq4e, fq4, fq5a, fq5b, fq5c, fq5d, fq5e, fq5, fq6a, fq6b, fq6c, fq6d, fq6e, fq6, fq7a, fq7b, fq7c, fq7d, fq7e, fq7, fq8a, fq8b, fq8c, fq8d, fq8e, fq8, fq9a, fq9b, fq9c, fq9d, fq9e, fq9, fq10a, fq10b, fq10c, fq10d, fq10e, fq10, fonlinetot, fupddate, ffreeze, ffreezedate, ffreezeusr, frevcode, frevtotmarks, fonlinerevtot, frevlogdate, fdeleted)
        select fregno, fclassid, fclassname, fsection, fteachcode, fvalno, fcollcode, fdegree, fexamno, fsubcode, fyear, fexamtype, felement, fmaxmarks, ftotmarks, fmdocno, fmode, flogdate, fq1a, fq1b, fq1c, fq1d, fq1e, fq1, fq2a, fq2b, fq2c, fq2d, fq2e, fq2, fq3a, fq3b, fq3c, fq3d, fq3e, fq3, fq4a, fq4b, fq4c, fq4d, fq4e, fq4, fq5a, fq5b, fq5c, fq5d, fq5e, fq5, fq6a, fq6b, fq6c, fq6d, fq6e, fq6, fq7a, fq7b, fq7c, fq7d, fq7e, fq7, fq8a, fq8b, fq8c, fq8d, fq8e, fq8, fq9a, fq9b, fq9c, fq9d, fq9e, fq9, fq10a, fq10b, fq10c, fq10d, fq10e, fq10, fonlinetot, fupddate, ffreeze, ffreezedate, ffreezeusr, frevcode, frevtotmarks, fonlinerevtot, frevlogdate, fdeleted from tdvs_copomarks 
        where fcollcode = '{$packet}' and fvalno = '{$valno}'
        and frevcode = '{$user}'
        and fsubcode = '{$qpcode}'";
        $res3 = $aobj_context->mobj_db->Execute($upd);

    }else
    {
        $query = "select $fileds fregno,ftotmarks,ifnull(fonlinetot,'') as fonlinetot 
        from tdvs_copomarks 
        where fcollcode = '{$packet}' and fvalno = '{$valno}'
        and fsubcode = '{$qpcode}'";
        
        $res2 = $aobj_context->mobj_db->GetAll($query);
    }
    
    $i = 1;
    $oldqn = "";

   // var_dump($arry);die();

    // $uniqueNumbers = array_unique(array_map(function($item) {
    //     return (int)filter_var($item, FILTER_SANITIZE_NUMBER_INT);
    // }, $inputArray));
    foreach($res2 as $val)
    {
        
        $e_data.="<tr id = 'td_$i'>";
        $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>$i</center></td>";
        $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><center>{$val['fregno']}  
        <input type = 'hidden' value ='".$val['fregno']."' id = '$i".'hregno'."'/>
        <input type = 'hidden' value ='N' id = '$i".'hcregno'."'/>
        <input type = 'hidden' value ='".count($arry)."' id = '$i".'totqp'."'/>
        </center></td>";
        $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align: center;' id = '$i".'totmarks'."'>{$val['ftotmarks']}</td>";
        $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align: center;' id = '$i".'onlinetot'."'>{$val['fonlinetot']}</td>";
        for($z =0;$z<count($arry);$z++)
        {

            preg_match_all('!\d+!', $arry[$z], $matches); 
            
            // print output of function 
            $qpno = $matches[0][0];
            
            if(substr($arry[$z], -1) == '1' || substr($arry[$z], -1) == '2' || substr($arry[$z], -1) == '3' || substr($arry[$z], -1) == '4' || substr($arry[$z], -1) == '5' || substr($arry[$z], -1) == '6' || substr($arry[$z], -1) == '7' || substr($arry[$z], -1) == '8' || substr($arry[$z], -1) == '9' || substr($arry[$z], -2) == '10')
            {
                $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align:center'>
                <input type = 'text' value ='".$val[$arry[$z]]."'  disabled style='width:30px;text-align: center;' onchange = 'getregupd(this),valmaxmarksNewExt(this)' id = '$i".'_'."$arry[$z]_$qpno'/>
                <input type = 'hidden' value ='".$arry[$z]."_".$qpno."' id = '$i".'_hqp_'."$z'/>
                </td>";    

            }else
            {
                $e_data.="<td  style='padding:2px;  border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;text-align:center'><input type = 'text' value ='".$val[$arry[$z]]."'  style='width:30px;text-align: center;' onchange = 'getregupd(this),valmaxmarksNewExt(this)' id = '$i".'_qp_'.$qpno."_$z'/>
                <input type = 'hidden' value ='".$arry[$z]."_".$qpno."' id = '$i".'_hqp_'."$z'/>
                </td>";    
            }
            
        }
        $e_data.="</tr>";
        $i++;
    }

    $e_data.="</table>";
    $lob = true;
    if($lob){

        $arry['tabledata'] = $e_data;
        $arry['qpcnt'] = $z;
        $arry['tablecnt'] = count($res2);
        $arry['qno'] = $qno;
          echo $aobj_context->mobj_output->ToJSONEnvelope($arry,0,"success"); 
      }else{
          $arr['msg'] = 'Failed to load';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
      }
  }

function SaveCopoMarkEntryExternal($aobj_context)
{
    $valno = $aobj_context->mobj_data["valno"];
    $packet = $aobj_context->mobj_data["packet"];
    $qpcode = $aobj_context->mobj_data["qpcode"];
    $submarks = $aobj_context->mobj_data["submarks"];
    $collcode=$_SESSION['collcode'];
    
    $user_type = $_SESSION['usrtype'];
    //var_dump($user_type);
    $user = $_SESSION['usr'];

    $fsubarry = json_decode($submarks);

    $fviewopt = $_SESSION['fviewopt'];

    if($fviewopt == 'T')
    {
        $rdata='Only View Option Enabled';
        echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
        return;	
    }


    $query = "select count(*) as cnt from tdvs_copomarks where frevcode = '{$user}' 
        and fsubcode = '{$qpcode}' and fvalno = '{$valno}'
        and fcollcode = '{$packet}'";
    $res9 = $aobj_context->mobj_db->Getrow($query); 
    if($res9['cnt'] >0)
    {
       
    }


    $queryFreeze = "select distinct ifnull(ffreeze, '')as ffreeze from tdvs_copomarks
                    where fcollcode='{$packet}' and fvalno='{$valno}' and fsubcode='{$qpcode}'";
    $resFreeze = $aobj_context->mobj_db->GetRow($queryFreeze);
    

    if($res9['cnt'] <= 0)
    {
        if($resFreeze['ffreeze'] == 'T'){
            $rdata = "Already freezed";
            echo($aobj_context->mobj_output->ToJSONEnvelope($rdata, -1, "Failure"));
            return;
        }
    }

    
    $qry3 = "select fdegree,fexamno from tdvs_qpcopo where fqpcode = '{$qpcode}'";
    $res3 = $aobj_context->mobj_db->Getrow($qry3); 
    $degree = $res3['fdegree'];
    $examno = $res3['fexamno'];

    $query = "select fcsubcode from subject where fdegree = '{$degree}' and fexamno = '{$examno}' and fqpcode = '{$qpcode}'";
    $res1 = $aobj_context->mobj_db->Getrow($query); 
    $fsubcode = $res1['fcsubcode'];

    foreach($fsubarry as $val)
    {
        $res = $val;
       foreach($res as $value)
       {
            $regno =  $value->regno;
            $totmarks =  $value->totmarks;
            $onlinetot =  $value->onlinetot;
            $maxmarks =  $value->maxmarks;
            $qp =  $value->qp;
            
            $cnd = "fonlinetot = '{$onlinetot}',";
            if($res9['cnt'] >0)
            {
                $upd = "update tdvs_copomarks set $qp = '{$maxmarks}',
                fonlinerevtot = '{$onlinetot}',
                frevlogdate=now()
                where fregno = '{$regno}'  and fvalno = '{$valno}'
                and fsubcode = '{$qpcode}'
                and fcollcode = '{$packet}'";
            }else
            {
                $upd = "update tdvs_copomarks set $qp = '{$maxmarks}',
                ftotmarks = '{$totmarks}', 
                fonlinetot = '{$onlinetot}',
                fupddate=now(),flogdate = now()
                where fregno = '{$regno}'  and fvalno = '{$valno}'
                and fsubcode = '{$qpcode}'
                and fcollcode = '{$packet}'";
            }
            $resupd = $aobj_context->mobj_db->Execute($upd);
       }
    }

    if($resupd)
    {
        $rdata = "Updated Successfully.";
        echo($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
        return;
    }
    else
    {
        $rdata = "No Updation / Add..!";
        echo($aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure"));  
        return;			
    }
   

}

function freezeCopoSeeMarksEntry($aobj_context){
    $valno = $aobj_context->mobj_data["valno"];
    $packet = $aobj_context->mobj_data["packet"];
    $qpcode = $aobj_context->mobj_data["qpcode"];
    $usr = $_SESSION['usr'];

    $queryFreeze = "select distinct ifnull(ffreeze, '')as ffreeze from tdvs_copomarks
                    where fcollcode='{$packet}' and fvalno='{$valno}' and fsubcode='{$qpcode}'";
    $resFreeze = $aobj_context->mobj_db->GetRow($queryFreeze);
    // var_dump($queryFreeze);
    // die();
    if($resFreeze['ffreeze'] == 'T'){
        $data = "Already freezed";
        echo($aobj_context->mobj_output->ToJSONEnvelope($data, -1, "Failure"));  
        return;	
    }

    $queryFreeze = "select distinct count(*) as cnt  from tdvs_copomarks
    where fcollcode='{$packet}'
    and ifnull(ftotmarks,'') <> ifnull(fonlinetot,'') 
    and fvalno='{$valno}' and fsubcode='{$qpcode}'";
    
    $res = $aobj_context->mobj_db->GetRow($queryFreeze);
    //var_dump($queryFreeze);
    //var_dump($res['cnt']);
    if($res['cnt'] == '0')
    {

    }else
    {
        $data = "Total Marks and Online Marks are not matching please check";
        echo($aobj_context->mobj_output->ToJSONEnvelope($data, -1, "Failure"));  
        return;	
    }

    $query = "update tdvs_copomarks set ffreeze='T', ffreezedate=now(), ffreezeusr='{$usr}'
              where fcollcode='{$packet}' and fvalno='{$valno}' and fsubcode='{$qpcode}'";

    $resupd = $aobj_context->mobj_db->Execute($query);

    if($resupd){
        $data = "Freezed Successfully.";
        echo($aobj_context->mobj_output->ToJSONEnvelope($data, 0, "success"));
        return;
    }else{
        $data = "Failed to freeze";
        echo($aobj_context->mobj_output->ToJSONEnvelope($data, -1, "Failure"));  
        return;	
    }
}

?>