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 : 52.15.233.83


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

<?php
  function getEvents($aobj_context)
  {
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $fsendto = $aobj_context->mobj_data['fsendto'];
    $fevttype = $aobj_context->mobj_data['fevttype'];

    $query = "select fevent, ftitle, ifnull(fmessage,'') as fmessage,ifnull(ftemplate,'') as ftemplate, ifnull(fedit,'F') as fedit from masevent where fsendto = '{$fsendto}' 
    and fevttype = '{$fevttype}'
    and ifnull(fdeleted,'') <> 'T' order by fevent";
    // var_dump($query);
    $result = $aobj_context->mobj_db->GetAll($query);
    // var_dump($result);
    if($result)
    {
      echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"); 
    }
    else
    {
      $arr['msg'] = 'No details found';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 	
    }
  }

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

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

    $univcode = $aobj_context->mobj_data['univcode'];
    // $fdeggrp = $aobj_context->mobj_data['fdeggrp'];
    
    $commondb ="logisys3_comexam";
  

    $smstype = $req['fmsgtype'];

    if (!array_key_exists('fsendto', $req) || !array_key_exists('fevent', $req)
    || !array_key_exists('fmsg', $req) || !array_key_exists('deggrp', $req))
    {
      $arr['msg'] = 'Invalid Params';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
      return;
    }
    $deggrp = implode("','", $req['deggrp']);
    $result = false;
   
    if($req['fsendto'] == 'ST') {
      
        switch($req['fevent']) {
          case 'GEN':
            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];
            $ffeepaid = $req['ffeepaid'];
            $timestamp = date("Ymdhis");
            $entype = "ST".$timestamp;
            $cond = "";
            if($ffeepaid == "PEND"){
              $cond = "and ifnull(ftotalfee,0) = 0 and ifnull(frecptdate,'') = ''";
            } else if( $ffeepaid == "PAID" ) {
              $cond = "and ifnull(ftotalfee,0) > 0 and ifnull(frecptdate,'') <> ''";
            }

            $query ="INSERT IGNORE INTO {$commondb}.sendsms(funivcode, fregno, fmobileno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype)
            SELECT DISTINCT '{$univcode}', m.fregno, m.fmobileno, '{$entype}', '{$entype}', 
            CONCAT('{$req['fmsg']}') AS fmessage, 
            'F', 'F', YEAR(NOW()), '2', NOW(), 'G', '900' 
            FROM {$commondb}.masuser m  inner join candsum cd on  m.funivcode = '{$univcode}' 
            and m.fregno = cd.fregno
            and cd.fregno between '{$fregfrom}' and '{$fregto}'
            and fcollcode between '{$fcollfrom}' and '{$fcollto}'
            and fdegree between '{$fdegfrom}' and '{$fdegto}' 
            {$cond}
            and cd.fdegree in (select distinct fdegree from degree where fdeggrp in ('{$deggrp}'))";
            // var_dump($query);
            // return;
            $result = $aobj_context->pobj_db->Execute($query);
            $req['fevent'] = $entype;
            break;
          case 'SSREA' : 
            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];
            // $db = "logisys3_comexam";

            if($snd=="sendsms")
            {
              $deggrp = $req['deggrp'] == 'C' ? "and x.fdegree in(select distinct fdegree from degree where fdeggrp = '{$fdeggrp}')": "";
              $query = "insert ignore into {$commondb}.sendsms(funivcode, fregno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype)
              select distinct '{$univcode}', x.fregno, 'SSREA', x.fexamno, 
              concat('Dear ', st.fname,' (',x.fregno ,')',', your result for ',d.fexamname, ' ', 
                d.fexamdate, ' exam has been announced. Result : ',
                y.fclass,'. Visit student portal studentportal.universitysolutions.in for details.') as fmessage, 'F', 'F', x.fyear, x.fexamtype, now(), 'G', '900' 
              from res_fee x
              inner join resmarks y
              on  x.fdegree = y.fdegree
              and x.fexamno = y.fexamno
              and x.fregno = y.fregno
              inner join degree d
              on x.fdegree = d.fdegree and x.fexamno = d.fexamno
              inner join student st 
                on x.fregno = st.fregno 
              where x.fresultdate = date_format(now(),'%Y-%m-%d') 
              and ifnull(x.frespush,'') <> 'T'
              and x.fcollcode between '{$fcollfrom}' and '{$fcollto}'
              and x.fregno between '{$fregfrom}' and '{$fregto}'
              and x.fdegree between '{$fdegfrom}' and '{$fdegto}'";
              $result = $aobj_context->pobj_db->Execute($query);
          
              $query = "update {$commondb}.sendsms x, {$commondb}.masuser y 
              set x.fmobileno = y.fmobileno
              where x.funivcode = y.funivcode and x.fregno = y.fregno and
              ifnull(x.fmobileno,'') = ''
              and x.funivcode = '{$univcode}' and y.funivcode = '{$univcode}' and x.fenttype = 'SSREA'";
              $result = $aobj_context->pobj_db->Execute($query);        
            
              $query1 = "update res_fee x set x.frespush = 'T'
              where x.fresultdate = date_format(now(),'%Y-%m-%d')
              and ifnull(x.frespush,'') <> 'T'";
              $result1 = $aobj_context->pobj_db->Execute($query1);
            }
            break;
          case 'RVR':

            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];
            $enttype = 'RVR'.date('Ymd');
            
              $deggrp = $req['deggrp'] == 'C' ? "and x.fdegree in(select distinct fdegree from degree where fdeggrp = '{$fdeggrp}')": "";
              $query = "insert ignore into logisys3_comexam.sendsms(funivcode, fregno, fenttype,fmobileno,fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype)
              select distinct '{$univcode}',x.fregno,'{$enttype}' as fenttype,m.fmobileno, x.fexamno,
              concat('Dear ', st.fname,' (',x.fregno ,')',', your',if(x.FCORRTYPE='RV', ' revaluation ', ' challenge valuation '), 'result for ',d.fexamname, ' ', 
                 ' exam has been announced. Result : ',
                y.fclass,'. Visit student portal studentportal.universitysolutions.in for details.') as fmessage, 
            'F','F', x.fyear, x.fexamtype, now(), 'G', '900' 
              from res_fee x inner join resmarks y on  x.fdegree = y.fdegree
              and x.fexamno = y.fexamno and x.fregno = y.fregno
              inner join logisys3_comexam.masuser m on m.fregno = x.fregno
              and m.funivcode = '{$univcode}'	
              inner join degree d on x.fdegree = d.fdegree and x.fexamno = d.fexamno
              inner join student st on x.fregno = st.fregno 
              and x.fcollcode between '{$fcollfrom}' and '{$fcollto}'
              and x.fregno between '{$fregfrom}' and '{$fregto}'
              and x.fdegree between '{$fdegfrom}' and '{$fdegto}'
              and ifnull(x.frvpush,'') <> 'T'
              {$deggrp}
              where ifnull(x.FCORRTYPE,'') in ('RV','CV')";
            
              $result = $aobj_context->pobj_db->Execute($query);

              if($result)
              {
                $query2 = "update res_fee x set x.frvpush = 'T'
                where ifnull(x.frvpush,'') <> 'T' 
                and ifnull(x.FCORRTYPE,'') in ('RV','CV')
                {$deggrp}";
                $result2 = $aobj_context->pobj_db->Execute($query2);
              }  
            
            break;

          case 'student_register_no' : 
            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];

            $enttype = 'ADA'.date('Ymd');

            $query = "insert ignore into {$commondb}.sendsms(funivcode, fmobileno, fregno, 
            fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype)
            select distinct c.funivcode, st.fcontact_no, st.faregno,'{$enttype}', st.fexamno,
            concat('From ',c.ffolder,': Your Reg. No. is ',st.faregno,'. Download Uniclare App at http://bit.ly/2KNOubT and login with admission credentials to receive notifications - Uniclare') as fmessage,
            'F','F', d.fadyear, d.fadexamtyp, now(), 'G', '900'
            from control c, studadm st
            inner join degree d on st.fdegree = d.fdegree and st.fexamno = d.fexamno
            where st.fcollcode between '{$req['fcollfrom']}' and '{$req['fcollto']}'
            and st.fdegree between '{$req['fdegfrom']}' and '{$req['fdegto']}'
            and ifnull(st.faregno,'') <> ''
            and ifnull(st.fapprstatus,'') = 'APPROVED'
            and ifnull(st.fdeleted,'') <> 'T'
            and ifnull(st.fappstatus,'') = 'verified'
            and ifnull(st.fapprpush,'') <> 'T'
            and ifnull(d.fdeggrp,'') in ('{$deggrp}')
            and st.fcollcode between '{$fcollfrom}' and '{$fcollto}'
            and st.faregno between '{$fregfrom}' and '{$fregto}'
            and st.fdegree between '{$fdegfrom}' and '{$fdegto}'";
            
            $result = $aobj_context->pobj_db->Execute($query);
            
            if($result) {
              $query = "update studadm st, degree d 
              set st.fapprpush = 'T'
              where st.fdegree = d.fdegree
              and st.fexamno = d.fexamno
              and d.fdeggrp in ('{$deggrp}')
              and st.fcollcode between '{$req['fcollfrom']}' and '{$req['fcollto']}'
              and st.fdegree between '{$req['fdegfrom']}' and '{$req['fdegto']}'
              and st.faregno between '{$fregfrom}' and '{$fregto}'
              and ifnull(st.faregno,'') <> ''
              and ifnull(st.fapprstatus,'') = 'APPROVED'
              and ifnull(st.fdeleted,'') <> 'T'
              and ifnull(st.fappstatus,'') = 'verified'
              and ifnull(st.fapprpush,'') <> 'T'";
              // var_dump($query);
              $result = $aobj_context->pobj_db->Execute($query);
              // var_dump($result);
            }
          case 'Marks Card Dispatch':
            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];

            $enttype = 'MC'.date('Ymd');

   
            
            $query = "INSERT IGNORE INTO logisys3_comexam.sendsms(funivcode, fregno, fmobileno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate,fmsgtype, fusertype)
            SELECT DISTINCT '{$univcode}', m.fregno, m.fmobileno, '{$enttype}', '{$enttype}', 
            concat('From ',c.ffolder,': Dear Student (Reg. No. : ',mc.fregno,'), Your ',d.fexamname,' Marks Card has been printed and dispatched. Marks Card number is : ',mc.fmcno,' - Uniclare')  AS fmessage, 
            'F', 'F', year(now()), '1', NOW(),'G', '900'
            FROM control c, mcmsg mc inner join degree d on mc.fdegree = d.fdegree 
            and mc.fexamno = d.fexamno
            inner join logisys3_comexam.masuser m on m.fregno = mc.fregno
            where m.funivcode = '{$univcode}'
            and ifnull(m.fappmobid,'') = ''
            and ifnull(mc.fstatus,'F') = 'F'";
            $result = $aobj_context->pobj_db->Execute($query);
            //var_dump($query);
            if($result) {
              
              $query = "insert ignore into logisys3_comexam.pushnotif(funivcode,fmobileno,fmobappid, fcollcode, fregno, fdegree, fenttype, fsubcode, ftitle, fbody, fstatus, fyear, fexamtype, fpushdate)
              select distinct '{$univcode}',m.fmobileno,m.FAPPMOBID,mc.fdegree, m.fregno, mc.fdegree, '{$enttype}', '{$enttype}',  
              'Marks Card has been printed and dispatched' as ftitle,
              concat('From ',c.ffolder,': Dear Student (Reg. No. : ',mc.fregno,'), Your ',d.fexamname,' Marks Card has been printed and dispatched. Marks Card number is : ',mc.fmcno,' - Uniclare')  AS fmessage, 
              'F', year(now()), '1',NOW()
              from control c, mcmsg mc inner join degree d on mc.fdegree = d.fdegree 
              and mc.fexamno = d.fexamno
              inner join logisys3_comexam.masuser m on m.fregno = mc.fregno
              where m.funivcode = '{$univcode}'
              and ifnull(m.fappmobid,'') <> ''
              and ifnull(mc.fstatus,'F') = 'F'";

              $result = $aobj_context->pobj_db->Execute($query);

              $query = "update mcmsg set fstatus = 'T'
              where ifnull(fstatus,'') = ''";
              $result = $aobj_context->pobj_db->Execute($query);


            }
          case 'SSPC':
            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];

            $query ="INSERT IGNORE INTO {$commondb}.sendsms(funivcode, fregno, fmobileno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate,fmsgtype, fusertype)
            SELECT DISTINCT '{$univcode}', m.fregno, m.fmobileno, 'SSPC', 'SSPC', 
            CONCAT('{$req['fmsg']}') AS fmessage, 
            'F', 'F', YEAR(NOW()), '2', NOW(), 'G', '900' 
            FROM {$commondb}.masuser m where m.funivcode = '' 
            and fregno in (select distinct fregno from res_stud 
            where ifnull(fxrpath, '') <> '' and ifnull(fpaymentstatus,'') = 'success'
            and fregno between '{$fregfrom}' and '{$fregto}'
            and fcollcode between '{$fcollfrom}' and '{$fcollto}'
            and fdegree between '{$fdegfrom}' and '{$fdegto}'
            )";
            $result = $aobj_context->pobj_db->Execute($query);
            
          default:
            break;
        }
      
    }
    else if($req['fsendto'] == 'CL') {

      $query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
      from {$commondb}.dbname 
      where funivcode = '{$univcode}'";
      $comexamRes = $aobj_context->mobj_db->GetRow($query);
    
      $db = $comexamRes['fdbname'];
      $funivname = $comexamRes['funivname'];
      $stafmobile = $comexamRes['fstaffmobileno'];
      $msgno = $comexamRes['fgenmsgno'];
      $timestamp = date("dmY");
      $entype = "CM".$msgno.$timestamp;

      $message = $req['fmsg'];

      
      $query = "insert ignore into {$commondb}.sendsms (funivcode, fregno, fmobileno, fenttype, 
          fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype)
          select distinct '{$univcode}', fmobile, fmobile, '{$entype}', '{$entype}', 
          '{$message}', 'F', 'F', dg.fyear, dg.fexamtype, NOW(), 'G', '500' 
          from college c, control ct, deggrp dg
          where IFNULL(c.fdeleted,'') <> 'T' and IFNULL(fmobile,'') <> '' 
          and instr(ffaculty, dg.fdeggrp) > 0
          and c.fcollcode between '{$req['fcollfrom']}' and '{$req['fcollto']}'
          and fdeggrp in ('{$deggrp}')";	
      $result = $aobj_context->pobj_db->Execute($query); 
      $req['fevent'] = $entype;
      if($result) {
        $query = "update logisys3_comexam.dbname set fgenmsgno = fgenmsgno+1 where funivcode = '{$univcode}'";
        $update = $aobj_context->mobj_db->Execute($query);
      }
    }
    else if($req['fsendto'] == 'CT') {

      $query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
      from logisys3_comexam.dbname 
      where funivcode = '{$univcode}'";
      $comexamRes = $aobj_context->mobj_db->GetRow($query);
    
      $db = $comexamRes['fdbname'];
      $funivname = $comexamRes['funivname'];
      $stafmobile = $comexamRes['fstaffmobileno'];
      $msgno = $comexamRes['fgenmsgno'];
      $timestamp = date("dmY");
      $entype = "CM".$msgno.$timestamp;

      $message = $req['fmsg'];
      
      $query = "insert ignore into logisys3_comexam.sendsms (funivcode, fregno, fmobileno, fenttype, fsubcode, 
      fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype)
        select '{$univcode}', fmobile, fmobile, '{$entype}', '{$entype}', 
        '{$message}', 'F', 'F', dg.fyear,dg.fexamtype, NOW(), 'G', '500' 
        from college c, deggrp dg, degcntr dc where dg.fdeggrp = dc.fdeggrp and dc.fyear = dg.fyear
        and dc.fexamtype = dg.fexamtype and c.fcollcode = dc.fexamcodet
        and IFNULL(c.fdeleted,'') <> 'T' and IFNULL(c.fmobile,'') <> '' 
        and c.fcollcode between '{$req['fcollfrom']}' and '{$req['fcollto']}'
        and dg.fdeggrp in ('{$deggrp}')
        group by dc.fexamcodet";
      // var_dump($query);  
      $result = $aobj_context->pobj_db->Execute($query);

      $req['fevent'] = $entype;
      if($result) {
        $query = "update logisys3_comexam.dbname set fgenmsgno = fgenmsgno+1 where funivcode = '{$univcode}'";
        $update = $aobj_context->mobj_db->Execute($query);
      }
    } else if($req['fsendto'] == 'TH') {

      $query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
      from logisys3_comexam.dbname 
      where funivcode = '{$univcode}'";
      $comexamRes = $aobj_context->mobj_db->GetRow($query);
    
      $db = $comexamRes['fdbname'];
      $funivname = $comexamRes['funivname'];
      $stafmobile = $comexamRes['fstaffmobileno'];
      $msgno = $comexamRes['fgenmsgno'];
      $timestamp = date("dmY");
      $entype = "TH".$msgno.$timestamp;

      $message = "[{$msgno}]".$req['fmsg'];

      $boardCond = "";

      if($req['fboardfrom'] > '000'){
        $boardCond = "and mq.fboard between '{$req['fboardfrom']}' and '{$req['fboardto']}'";
      }
      
      $query = "insert ignore into logisys3_comexam.sendsms(funivcode, fregno, fmobileno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype)
        select distinct '{$univcode}', fmobile, fmobile, '{$entype}', '{$entype}', 
        '{$message}', 'F', 'F', dg.fyear,dg.fexamtype, NOW(), 'G', '600' 
        from masteach c inner join deggrp dg on dg.fdeggrp in ('{$deggrp}')
        left join teachsub ts on ts.fteachcode = c.fteachcode
        left join masqp mq on mq.fqpcode = ts.fqpcode
        where IFNULL(c.fdeleted,'') <> 'T' and IFNULL(c.fmobile,'') <> '' 
        and c.fcollcode between '{$req['fcollfrom']}' and '{$req['fcollto']}' 
        and c.fteachcode between '{$req['fteachfrom']}' and '{$req['fteachto']}'
        {$boardCond}";
      // var_dump($query);  
      $result = $aobj_context->pobj_db->Execute($query);

      $req['fevent'] = $entype;
      if($result) {
        $query = "update logisys3_comexam.dbname set fgenmsgno = fgenmsgno+1 where funivcode = '{$univcode}'";
        $update = $aobj_context->mobj_db->Execute($query);
      }
    }

    if($result)
    {
      $rows = $aobj_context->pobj_db->affected_rows();
      $arr['msg'] = "{$rows} Records Inserted. Press send button.";
      $arr['event'] = $req['fevent'];
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 

    }
    else
    {
      $arr['msg'] = 'DATA Push Failed';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 	
    }
  }

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

    $fenttype = $aobj_context->req_body['fenttype'];
    $fusertype = $aobj_context->req_body['fusertype'];
    $univcode = $aobj_context->mobj_data['univcode'];

    if ($fenttype == "" || $fusertype == "")
    {
      $arr['msg'] = 'Invalid Params';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
      return;
    }
    
    $query = "delete from logisys3_comexam.sendsms  
    where funivcode = '{$univcode}' and fusertype = '{$fusertype}' 
    and fenttype = '{$fenttype}' and fstatus = 'F' ";
    $result = $aobj_context->mobj_db->Execute($query);

    if($result)
    {
      $rows = $aobj_context->mobj_db->affected_rows();
      $arr['msg'] = "{$rows} Records deleted.";
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
    }
    else
    {
      $arr['msg'] = 'deletion Failed.';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 	
    }
  }

  

?>