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


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

<?php

include 'sendGridMail.php';
header('Access-Control-Allow-Origin: *');

function getgrvlst($aobj_context){

  //API :http://arun/univadmin/app.php?a=getgrvlst&fgroup='250'&fusername='rashmi'
  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
  $fgroup = $aobj_context->mobj_data["fgroup"];
  $fusername = $aobj_context->mobj_data["fusername"];
  $fuserid = $aobj_context->mobj_data["fuserid"];
  $type = $aobj_context->mobj_data["type"];

  if($type == "ineedhelp") {
    $query1 = "select funivshort,fgrvid,fregno, fgrvdate, lcase(fgrvfrom) as fgrvfrom,
    fgrvmobile, fgrvsub, fgrvuser
    from logisys3_grv.grvhead g
    inner join logisys3_grv.masuniv m on m.funivcode = g.funivcode 
    where  fregno = {$fuserid}
    order by fgrvdate desc limit 10";
  } else {
    $query1 = "select funivshort,fgrvid,fregno, fgrvdate, ucase(fgrvfrom) as fgrvfrom,
    fgrvmobile, fgrvsub, fgrvuser
    from logisys3_grv.grvhead g
    inner join logisys3_grv.masuniv m on m.funivcode=g.funivcode 
    where g.funivcode = '041' and ifnull(fgrvstatus,'') <> 'C' #and fgrvgroup = {$fgroup}
    and fgrvid not in (select fgrvid from logisys3_grv.masuser 
    where fusername <> '{$fusername}' and ifnull(fgrvid ,'') <> '') 
    order by fgrvdate desc limit 10";
  }

  // var_dump($query1);

  $result1 = $aobj_context->mobj_db->GetAll($query1);

  if(!$result1 && gettype($result1) == 'boolean')
  {
    $arr['msg'] = "Error while fetching Greviences";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"); 
    return;
  }

  if(count($result1) >= 0){

    echo $aobj_context->mobj_output->ToJSONEnvelope($result1,0,"success"); 
    return;
  }

}

function getgrv($aobj_context){
  
  // var_dump('$query1');

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
  
  $fusername = $aobj_context->mobj_data["username"];
  $univcode = $aobj_context->mobj_data["univcode"];
  $userid = $aobj_context->mobj_data["userid"];
  $fgrvid = $aobj_context->mobj_data["fgrvid"];
  $fparamgrvid = $aobj_context->mobj_data["fparamgrvid"];
// var_dump($fparamgrvid);

  if($fparamgrvid != ''){
    
    $query1 = "SELECT UCASE(funivname) AS funivname, LCASE(funivshort) as funivshort, g.fgrvid, g.fregno,
    DATE_FORMAT(g.fgrvdate, '%d/%m/%Y, %l:%i%p') AS grvdate, 
    UCASE(fgrvfrom) AS fgrvfrom, g.fgrvemail, g.fgrvmobile, g.fgrvsub, 
    g.fgrvmsg, g.fgrvuser, g.fgrvmode, 
    g.funivcode, fstudemail, g.fgrvstatus,
    IF(IFNULL(g.ffilepath,'') = '', '', CONCAT('https://university-group-attachment.s3.ap-south-1.amazonaws.com/', g.ffilepath)) AS fgrvtranfile       
    FROM logisys3_grv.grvhead g
    INNER JOIN logisys3_grv.masuniv m ON m.funivcode = g.funivcode 
    WHERE IFNULL(fgrvstatus,'') IN ('A','','R','C') AND g.funivcode = '{$univcode}' and g.fgrvid = '{$fparamgrvid}'
    limit 1";

    
    
   $result1 = $aobj_context->mobj_db->GetRow($query1);
    // var_dump($result1);
   if(count($result1)>0){
    $fgrvid = $result1['fgrvid'];
    $query2 = "select upper(ffromuser) as ffromuser, date_format(fgrvtrandate, '%d/%m/%Y, %l:%i%p') as fgrvtrandate,
    fgrvtranmsg,ifnull(fgrvtranfile,'') as fgrvtranfile, ifnull(fgrvtrantype,'RES') as fgrvtrantype 
    from logisys3_grv.grvdetl where fgrvid = '{$fgrvid}'  order by fgrvtranid";
    // var_dump($query2);
    $result2 = $aobj_context->mobj_db->GetAll($query2);
    // var_dump($result2);
    

    $query3 = "select count(*) as cnt from grvhead where funivcode = '{$univcode}' and ifnull(fgrvstatus,'') = ''";
    // var_dump($query2);
    $result3 = $aobj_context->mobj_db->GetRow($query3);

    
    // die();

    $res['header'] = $result1;
    $res['txns'] = $result2;
    $res['cnt'] = $result3;


    echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
    return;
  }
  else {
    $arr['msg'] = "Grevience not found..!";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"); 
    return;
  }
  return;

  }
  

  $query1 = "SELECT UCASE(funivname) AS funivname, LCASE(funivshort) as funivshort, g.fgrvid, g.fregno,
  DATE_FORMAT(g.fgrvdate, '%d/%m/%Y, %l:%i%p') AS grvdate, 
  UCASE(fgrvfrom) AS fgrvfrom, g.fgrvemail, g.fgrvmobile, g.fgrvsub, 
  g.fgrvmsg, g.fgrvuser, g.fgrvmode, 
  g.funivcode, fstudemail, g.fgrvstatus, g.ffilepath
  FROM logisys3_grv.grvhead g
  INNER JOIN logisys3_grv.masuniv m ON m.funivcode = g.funivcode 
  WHERE IFNULL(fgrvstatus,'') = '' AND g.funivcode = '{$univcode}'
  limit 1";
  // var_dump($query1);
 $result1 = $aobj_context->mobj_db->GetRow($query1);



 if(!$result1 && gettype($result1) == 'boolean'){
    $arr['msg'] = "Error while fetching Greviences";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"); 
    return;
  }
  if(count($result1)>0){
    $fgrvid = $result1['fgrvid'];
    $query2 = "select upper(ffromuser) as ffromuser, date_format(fgrvtrandate, '%d/%m/%Y, %l:%i%p') as fgrvtrandate,
    fgrvtranmsg,ifnull(fgrvtranfile,'') as fgrvtranfile, ifnull(fgrvtrantype,'RES') as fgrvtrantype 
    from logisys3_grv.grvdetl where fgrvid = '{$fgrvid}'  order by fgrvtranid";
    // var_dump($query2);
    $result2 = $aobj_context->mobj_db->GetAll($query2);


    // var_dump($result2);
    

    $query3 = "select count(*) as cnt from grvhead 
    where funivcode = '{$univcode}' and ifnull(fgrvstatus,'') = ''";
    // var_dump($query2);
    $result3 = $aobj_context->mobj_db->GetRow($query3);

    $query4 = "select fgrvmode,count(*) as pendcnt from logisys3_grv.grvhead
    where ifnull(fgrvstatus,'') = ''
    and funivcode = '{$univcode}'
    group by fgrvmode";

    $result4 = $aobj_context->mobj_db->GetAll($query4);

    $res['header'] = $result1;
    $res['txns'] = $result2;
    $res['cnt'] = $result3;
    $res['grivcnt'] = $result4;
    // var_dump($result1['fgrvstatus']);
    if(count($result1) !=0){
      // var_dump($result1);
      $qry = "update logisys3_grv.grvhead set fgrvstatus='A' where fgrvid='{$fgrvid}'";
      $result = $aobj_context->mobj_db->Execute($qry);
    }
    

    echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
  }
  else {
    $arr['msg'] = "No Greviences received";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"); 
    return;
  }

}


function grvForward($aobj_context){

//API : http://arun/univadmin/app.php?a=grvForward&fgroup='230'

//fgrvid, along with replies of staff to be inserted in grvdetl

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
  $fgroup = $aobj_context->mobj_data["fgroup"];
  $fgrvid = $aobj_context->mobj_data["fgrvid"];
  $ffromuser = $aobj_context->mobj_data["ffromuser"];
  $ftouser = $aobj_context->mobj_data["ftouser"];
  $fgrvtranto = $aobj_context->mobj_data["fgrvtranto"];
  $fgrvtrancc = $aobj_context->mobj_data["fgrvtrancc"];
  $fgrvtransub = $aobj_context->mobj_data["fgrvtransub"];
  $fgrvtranmsg = $aobj_context->mobj_data["fgrvtranmsg"];
  

  $query = "SELECT * FROM logisys3_grv.masuser WHERE  fgroup < {$fgroup} ORDER BY CAST(fgroup AS INT) DESC LIMIT 1";
  $result = $aobj_context->mobj_db->GetAll($query);

  $query1 = "SELECT * FROM logisys3_grv.grvhead WHERE  
  fgrvid = '{$fgrvid}'";
  $result1 = $aobj_context->mobj_db->GetRow($query1);
  
  $funivcode = $result1['funivcode'];
  $fregno = $result1['fregno'];

  if(!$result && gettype($result) == 'boolean')
  {
    $arr['msg'] = "Error while Fetching Greviences";
    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"); 
    return;
  }

  if(count($result) >= 0){

    foreach($result as $key => $value){
      $username = $value['fusername'];
        $fgrvgroup = $value['fgroup'];
    }

    $query = "update logisys3_grv.grvhead set fattenduser='{$username}' and fattenddate=now() 
    and fgrvgroup={$fgrvgroup} 
    where fgrvgroup={$fgroup} and fgrvid={$fgrvid}";//

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

    if($output){
      $query = "insert into logisys3_grv.grvdetl (fgrvid, fgrvtrandate, ffromuser, ftouser, fgrvtranto, fgrvtrancc, fgrvtransub, ifnull(fgrvtranfile,'') as fgrvtranfile, fgrvtrangroup, fgrvtranmsg)
      values ({$fgrvid}, now(), '{$ffromuser}','{$ftouser}','{$fgrvtranto}','{$fgrvtrancc}','{$fgrvtransub}','{$fgrvtranfile}',{$fgroup},'{$fgrvtranmsg}')";
      // var_dump($query);
      $res= $aobj_context->mobj_db->Execute($query);

      $query1 = "insert ignore into logisys3_comexam.pushnotif(funivcode,fmobileno,fmobappid, fregno, fenttype, fsubcode, ftitle, fbody, fstatus, fyear, fexamtype, fpushdate)
      select distinct m.FUNIVCODE, m.fmobileno, m.FAPPMOBID,  m.fregno, '{$fgrvid}', '{$fgrvid}',  
      '{$fgrvtransub}' as ftitle,
      '{$fgrvtranmsg}' AS fmessage,
      'F', '2020', '1',NOW()
      FROM logisys3_comexam.masuser m 
      where m.funivcode = '{$funivcode}' and ifnull(fappmobid,'') <> ''
      and m.fregno = '{$fregno}'";
      $res1 = $aobj_context->mobj_db->Execute($query1);

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


function grvSend($aobj_context){

  //API : http://arun/univadmin/app.php?a=grvSend&fgroup='230'

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
  
  $data = $aobj_context->req_body['data'];
  // var_dump($data);
  // return;
  //store file in a folder and insert
  //==insert the qry replies to grvdetl tbl and update grvhead tbl with status 'R'==//
  $qry ="insert into logisys3_grv.grvdetl (fgrvid, fgrvtrandate, ffromuser, fgrvtranmsg, fgrvtrantype)
  values ('{$data['grvid']}', now(), '{$data['fusername']}','{$data['frply']}', 'RES')";
  // var_dump($qry);
  $result = $aobj_context->mobj_db->Execute($qry);

  if($data['stt'] == 'C'){
    // var_dump('hii');
    $sttqry ="update logisys3_grv.grvhead set 
    fgrvstatus='{$data['stt']}' 
    where fgrvid='{$data['grvid']}'";    
    $resultstt = $aobj_context->mobj_db->Execute($sttqry);
    var_dump($sttqry,$resultstt);

    $msg = "Query closed..!";
    echo $aobj_context->mobj_output->ToJSONEnvelope($msg,0,"success"); 
    return;

  }



  
  if($result){

    $qry = "update logisys3_grv.grvhead set fgrvstatus='R' where fgrvid='{$data['grvid']}'";
    $res = $aobj_context->mobj_db->Execute($qry);
    if($res) {
      $msg = "Reply Message Sent";
      echo $aobj_context->mobj_output->ToJSONEnvelope($msg,0,"success"); 
    }else{
      $msg = "Msg Not Sent";
      echo $aobj_context->mobj_output->ToJSONEnvelope($msg,0,"failure"); 
    }
  }

}

function grvClr($aobj_context){

    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
    $data = $aobj_context->req_body['data'];
    

    $query1 = "SELECT UCASE(funivname) AS funivname, funivshort, g.fgrvid, g.fregno,
    DATE_FORMAT(g.fgrvdate, '%d/%m/%Y, %l:%i%p') AS grvdate, 
    UCASE(fgrvfrom) AS fgrvfrom, g.fgrvemail, g.fgrvmobile, g.fgrvsub, 
    g.fgrvmsg, g.fgrvuser, g.fgrvmode, 
    g.funivcode, fstudemail, g.fgrvstatus, g.ffilepath
    FROM logisys3_grv.grvhead g
    INNER JOIN logisys3_grv.masuniv m ON m.funivcode = g.funivcode 
    WHERE IFNULL(fgrvstatus,'') IN ('A','','R','C') AND g.funivcode = '{$data['univcode']}' and g.fgrvid = '{$data['fgrvid']}'
    limit 1";
    
   $result1 = $aobj_context->mobj_db->GetRow($query1);
   
  //  var_dump($result1);
  //   die();  
    if($result1['fgrvstatus'] != 'C'){

      $qry = "update logisys3_grv.grvhead set fgrvstatus='{$data['fgrvstatus']}' where fgrvid='{$data['fgrvid']}' and funivcode = '{$data['univcode']}'";
      $result = $aobj_context->mobj_db->Execute($qry);
      // var_dump($result);
    }
    if($result || $result1 ){
      $msg = "Query Cleared";
      echo $aobj_context->mobj_output->ToJSONEnvelope($msg,0,"success"); 
    }
}

function getsearchgrv($aobj_context){

  $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
  $univcode = $aobj_context->mobj_data["univcode"];
  $grvid = $aobj_context->mobj_data["grvid"];
  $regno = $aobj_context->mobj_data["regno"];
  if($grvid == '' && $regno != ''){
    $cnd = "and fregno = '{$regno}'";
  }else if($grvid != '' && $regno == ''){
    $cnd = "and fgrvid = '{$grvid}'";
  }

  $qry = "SELECT * FROM logisys3_grv.grvhead WHERE funivcode = '{$univcode}' {$cnd} ";
  // var_dump($qry);
  $result = $aobj_context->mobj_db->GetAll($qry);


  if($result){    
    echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
  }else{
    $msg = "No Data Found..!";
    echo $aobj_context->mobj_output->ToJSONEnvelope($msg,-1,"failure"); 

  }

}