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


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/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){

  $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"];
  

  $query1 = "select ucase(funivname) as funivname, funivshort, g.fgrvid, g.fregno,
  date_format(g.fgrvdate, '%d/%m/%Y, %l:%i%p') as fgrvdate, 
  ucase(fgrvfrom) as fgrvfrom, g.fgrvemail, g.fgrvmobile, g.fgrvsub, 
  g.fgrvmsg, g.fgrvuser, g.fgrvmode, 
  g.funivcode, fstudemail, fgrvstatus, ffilepath
  from logisys3_grv.grvhead g
  inner join logisys3_grv.masuniv m on m.funivcode = g.funivcode 
  where ifnull(fgrvstatus,'') = '' and g.funivcode = '{$univcode}'
  union
  select ucase(funivname) as funivname, funivshort, g.fgrvid, g.fregno,
  date_format(g.fgrvdate, '%d/%m/%Y, %l:%i%p') as fgrvdate, 
  ucase(fgrvfrom) as fgrvfrom, g.fgrvemail, g.fgrvmobile, g.fgrvsub, 
  g.fgrvmsg, g.fgrvuser, g.fgrvmode, 
  g.funivcode, fstudemail, fgrvstatus, ffilepath
  from logisys3_grv.grvhead g
  inner join logisys3_grv.masuniv m on m.funivcode = g.funivcode 
  where ifnull(fgrvstatus,'') <> 'C' and ifnull(fgrvstatus,'') <> 'A' and g.funivcode = '{$univcode}'
  limit 1";
  // var_dump($query1);
 $result1 = $aobj_context->mobj_db->GetRow($query1);

 if($fgrvid != "") {
  $qry = "update logisys3_grv.grvhead set fgrvstatus='' where fgrvid='{$fgrvid}'";
  $result = $aobj_context->mobj_db->Execute($qry);
 }

 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,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);
    
    $res['header'] = $result1;
    $res['txns'] = $result2;

    $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);

  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, fgrvtranfile, fgrvtrangroup, fgrvtranmsg)
      values ({$fgrvid}, now(), '{$ffromuser}','{$ftouser}','{$fgrvtranto}','{$fgrvtrancc}','{$fgrvtransub}','{$fgrvtranfile}',{$fgroup},'{$fgrvtranmsg}')";
      // var_dump($query);
      $res= $aobj_context->mobj_db->Execute($query);
    }
    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($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'];
    $qry = "update logisys3_grv.grvhead set fgrvstatus='{$data['fgrvstatus']}' where fgrvid='{$data['fgrvid']}'";
    $result = $aobj_context->mobj_db->Execute($qry);
    if($result){
      $msg = "Query Cleared";
      echo $aobj_context->mobj_output->ToJSONEnvelope($msg,0,"success"); 
    }
}