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


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

<?php

function getCreditMaster($aobj_context){

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
  
  $fdegree = $aobj_context->mobj_data["fdegree"];
  $fexamno = $aobj_context->mobj_data["fexamno"];
  
  $query = "select * from mascredits where fdegree = '{$fdegree}' 
  and fexamno = '{$fexamno}' and ifnull(fdeleted,'') <> 'T'";
  $result = $aobj_context->pobj_db->GetAll($query);

  if(!$result && gettype($result) == 'boolean')
  {
    $arr['msg'] = "Please try after some time";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"); 
    return;
  }

  if(count($result) >= 0){
    echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
    return;
  }

}

function saveCreditMaster($aobj_context){

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 

  $req = $aobj_context->req_body;  
  $data = $req['data'];

  if(!array_key_exists('credits', $data) || !array_key_exists('fdegree', $data)|| !array_key_exists('fexamno', $data) )
  {
    $arr['msg'] = 'Invalid Params';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,1,"failure");
    return;
  }

  if(count($data['credits']) == 0 || $data['fdegree'] == '' || $data['fexamno'] == '' )
  {
    $arr['msg'] = 'Invalid Params data';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,1,"failure");
    return;
  }
  $values = '';
  foreach( $data['credits'] as $k => $v )
  {
    $deleted = $v['FDELETED'] == 'true' ? 'T' : 'F';
    
    $values .= "('{$data['fdegree']}','{$data['fexamno']}','".$v['FFROMMARK']."','".$v['FTOMARK']."','".$v['FCREDIT']."','".$v['FGRADE']."','{$deleted}'),";
  }

  $values = rtrim($values, ','); 

  $query = "insert into mascredits(FDEGREE, FEXAMNO, FFROMMARK,FTOMARK,FCREDIT,FGRADE,FDELETED) values ".$values."
          ON DUPLICATE KEY UPDATE
          FFROMMARK = VALUES(FFROMMARK), FTOMARK = VALUES(FTOMARK),
          FCREDIT = VALUES(FCREDIT),
          FGRADE = VALUES(FGRADE),
          FDELETED = VALUES(FDELETED)";
  //var_dump($query);
  $result = $aobj_context->pobj_db->Execute($query);

  if($result)
  {
    $arr['msg'] = 'Successfully Updated';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
    return;
  }
  else
  {
    $arr['msg'] = 'Insertion / Updation Failed';
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
    return;
  }
}