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


Current Path : /var/www/html/admission/src/
Upload File :
Current File : /var/www/html/admission/src/tdvs_pergeval.php

<?php
    function tdvs_yearmode($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $deggrp = $aobj_context->mobj_data["deggrp"];

        $query = "select ifnull(FYEAR, '')as fyear, ifnull(FEXAMTYPE, '')as fexamtype from tdvs_deggrp 
                  where fdeggrp='{$deggrp}'";
        $res = $aobj_context->pobj_db->GetRow($query);
        if($res){
            echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
        } else {
            $arr['msg'] = 'No Data Found';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        }
    }

    function tdvs_getPergeValCount($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $deggrp = $aobj_context->mobj_data["deggrp"];
        $year = $aobj_context->mobj_data["year"];
        $mode = $aobj_context->mobj_data["mode"];
        $sem = $aobj_context->mobj_data["sem"];

        $sem_split = explode(",", $sem);
        foreach($sem_split as $key => $value){
            $sem_val .= "'".$value."',";
        }
        $sem_arr = substr_replace($sem_val ,"",-1);

        if($sem_arr === "'All'"){
            $semCon = " ";
        }else{
            $semCon = "and m.fexamno in ({$sem_arr})";
        }

       $query = "select t.fqpcode, m.fsubname, t.fyear, t.fexamtype, 
                sum(if(t.fvalno = 1,1,0)) as val1,
                sum(case when t.fvalno = '1' and ifnull(t.fstatus,'')='Final' then 1 else 0 end) as completed1,
                sum(if(t.fvalno = 2,1,0)) as val2,
                sum(case when t.fvalno = '2' and ifnull(t.fstatus,'')='Final' then 1 else 0 end) as completed2,
                sum(if(t.fvalno = 3,1,0)) as val3,
                sum(case when t.fvalno = '3' and ifnull(t.fstatus,'')='Final' then 1 else 0 end) as completed3,
                sum(if(t.fvalno = 4,1,0)) as val4,
                sum(case when t.fvalno = '4' and ifnull(t.fstatus,'')='Final' then 1 else 0 end) as completed4,
                sum(if(t.fvalno = 'D',1,0)) as valD,
                sum(case when t.fvalno = 'D' and ifnull(t.fstatus,'')='Final' then 1 else 0 end) as completedD,
                count(*) as totcnt, 
                sum(case when ifnull(t.fstatus,'')='Final' then 1 else 0 end)as totcomp,
                m.fdeggrp, m.fexamno
                from tdvs_tabsum t inner join tdvs_masqp m on m.fqpcode = t.fqpcode 
                where t.fexamtype = '{$mode}' and t.fyear = '{$year}' 
                and m.fdeggrp='{$deggrp}' {$semCon}
                group by t.fqpcode  order by fexamno";

                // var_dump($query);
                // die();
        $res = $aobj_context->pobj_db->GetAll($query);
        if($res){
            echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
        } else {
            $arr['msg'] = 'No Data Found';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        }
    }

    function tdvs_saveTdvsPergeVal($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $data = json_decode($aobj_context->mobj_data["data"], true);

        $fsuccess = [];
        $ffailure = [];
        foreach($data as $val){
            $condQry = "select count(*)as fcount from tdvs_tabsum where fqpcode='{$val['fqpcode']}' and
                        fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'
                        and ifnull(fstatus, '') <> 'final'";
            $res = $aobj_context->pobj_db->GetRow($condQry);

            if($res['fcount'] <= 0){    
                $query = "insert ignore into tdvs_tabsum_bkp 
                      select * from tdvs_tabsum where 
                      fqpcode = '{$val['fqpcode']}' and 
                      fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";      
                $res = $aobj_context->pobj_db->Execute($query);

                $delts = "delete from tdvs_tabsum where fqpcode = '{$val['fqpcode']}' and 
                        fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resdelts = $aobj_context->pobj_db->Execute($delts);

                $inshead = "insert ignore into tdvs_tabhead_bkp
                            select * from tdvs_tabhead where 
                            fqpcode = '{$val['fqpcode']}' and 
                            fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resinshead = $aobj_context->pobj_db->Execute($inshead);

                $delhead = "delete from tdvs_tabhead where fqpcode = '{$val['fqpcode']}' and 
                        fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resdelhead = $aobj_context->pobj_db->Execute($delhead);

                $insdetl = "insert ignore into tdvs_tabdetl_bkp
                            select * from tdvs_tabdetl where 
                            fqpcode = '{$val['fqpcode']}' and 
                            fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";            
                $restabdetl = $aobj_context->pobj_db->Execute($insdetl);

                $deldetl = "delete from tdvs_tabdetl where fqpcode = '{$val['fqpcode']}' and 
                        fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resdeldetl = $aobj_context->pobj_db->Execute($deldetl);

                $instabulate = "insert ignore into tdvs_tabulate_bkp
                            select * from tdvs_tabulate where 
                            fqpcode = '{$val['fqpcode']}' and 
                            fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $restabulate = $aobj_context->pobj_db->Execute($instabulate);

                $deltabulate = "delete from tdvs_tabulate where fqpcode = '{$val['fqpcode']}' and 
                        fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resdeltabulate = $aobj_context->pobj_db->Execute($deltabulate);


                $delmasrev = "INSERT ignore INTO tdvs_masrev_bkp (FQPCODE, FVALNO, FTEACHCODE, FREVCODE, FBOARD, FMAXSCR, FYEAR, FEXAMTYPE, FSUSPEND, FDELETED, FLASTDATE, fstartdate, FEMAILSENT, FEMAILDATE, FCREATEDATE, FUPDATEDATE, FCREATEUSER, FUPDATEUSER)
                select FQPCODE, FVALNO, FTEACHCODE, FREVCODE, FBOARD, FMAXSCR, FYEAR, FEXAMTYPE, FSUSPEND, FDELETED, FLASTDATE, fstartdate, FEMAILSENT, FEMAILDATE, FCREATEDATE, FUPDATEDATE, FCREATEUSER, FUPDATEUSER from tdvs_masrev  
                where fqpcode = '{$val['fqpcode']}' and fexamtype = '{$val['fexamtype']}' 
                and fyear = '{$val['fyear']}'";
                $resdelmasrev = $aobj_context->pobj_db->Execute($delmasrev);   

                $deltabulate = "delete from tdvs_masrev where fqpcode = '{$val['fqpcode']}' 
                and fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resdeltabulate = $aobj_context->pobj_db->Execute($deltabulate);

                $delmasrev = "INSERT ignore INTO tdvs_tabpkt_bkp (FBATCHNO, FDEGGRP, FQPCODE, FTEACHCODE, FVALNO, FISSUEDATE, FNOSCRIPT, FVALSCRIPT, FREVSCRIPT, FVALSTATUS, FREVSTATUS, FVALDATE, FREVDATE, FSYSDATE, FREVCODE, FPRINT, FPRINTDATE, fyear, fexamtype)
                select FBATCHNO, FDEGGRP, FQPCODE, FTEACHCODE, FVALNO, FISSUEDATE, FNOSCRIPT, FVALSCRIPT, FREVSCRIPT, FVALSTATUS, FREVSTATUS, FVALDATE, FREVDATE, FSYSDATE, FREVCODE, FPRINT, FPRINTDATE, fyear, fexamtype 
                from tdvs_tabpkt where fqpcode = '{$val['fqpcode']}' 
                and fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resdelmasrev = $aobj_context->pobj_db->Execute($delmasrev);   

                $deltabulate = "delete from tdvs_tabpkt where fqpcode = '{$val['fqpcode']}' 
                and fexamtype = '{$val['fexamtype']}' and fyear = '{$val['fyear']}'";
                $resdeltabulate = $aobj_context->pobj_db->Execute($deltabulate);


                $qpcode = "update tdvs_masqp set ftempcode = NULL, 
                ffreeze = NULL, fqppath = NULL,
                fschempath=NULL
                where fqpcode = '{$val['fqpcode']}'";
                $qpcode = $aobj_context->pobj_db->Execute($qpcode);


                $det['success'] = $val['fqpcode'];
                array_push($fsuccess, $det);
            } else{
                $arr['failure'] = $val['fqpcode'];
                array_push($ffailure, $arr);
            }
        }
        
        $newArr['fsuccess'] = $fsuccess;
        $newArr['ffailure'] = $ffailure;

        $resdeldetl = true;
        if($resdeldetl){
            $newArr['msg'] = 'Updated Successfully';
            echo $aobj_context->mobj_output->ToJSONEnvelope($newArr, 0, "success");
        }else {
            $arr['msg'] = 'Something went wrong';
            echo $aobj_context->mobj_output->ToJSONEnvelope($newArr, -1, "failure");
        }
    }

    function tdvs_getDevDet($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $board = $aobj_context->mobj_data["board"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        
        $qp_split = explode(",", $qpcode);
        foreach($qp_split as $key => $value){
            $qp_val .= "'".$value."',";
        }
        $qp_arr = substr_replace($qp_val ,"",-1);

        if($qp_arr === "'All'"){
            $qpCon = " ";
        }else{
            $qpCon = "and s.fqpcode in ({$qp_arr})";
        }

       $query = "select distinct s.fqpcode,concat(s.fsubname, ' - ', sub.fsubshort)as fsubname,s.fsmaxmarks, t.fregcode,t1.fvalno as fvalno1,t1.fteachcode as fteachcode1,m1.fteachname as fteachname1,t1.fsysmarks as fsysmarks1,
                t2.fvalno as fvalno2,t2.fteachcode as fteachcode2,m2.fteachname as fteachname2,t2.fsysmarks as fsysmarks2,
                ABS(t1.fsysmarks-t2.fsysmarks) as difmarks
                from tdvs_masqp s inner join tdvs_tabsum t on s.fqpcode = t.fqpcode and t.fvalno = 'D' 
                inner join tdvs_tabsum t1 on t.fqpcode = t1.fqpcode and t.fregcode = t1.fregcode and t1.fvalno = '1'
                inner join tdvs_masteach m1 on t1.fteachcode = m1.fteachcode
                inner join tdvs_tabsum t2 on t.fqpcode = t2.fqpcode and t.fregcode = t2.fregcode and t2.fvalno = '2'
                inner join tdvs_masteach m2 on t2.fteachcode = m2.fteachcode
                inner join subject sub on s.fqpcode = sub.fqpcode
                where t.fvalno = 'D' {$qpCon} and s.fboard = '{$board}';";

        $res = $aobj_context->pobj_db->GetAll($query);
        if($res){
            echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
        } else {
            $arr['msg'] = 'No Data Found';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        }
    }

    function tdvs_deleteTemplateCode($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $tempcode = $aobj_context->mobj_data["tempcode"];

        $sltQry = "select ftempcode from tdvs_masqp where ftempcode='{$tempcode}'";
        $res = $aobj_context->pobj_db->GetAll($sltQry);

        if(count($res) === 0){
            $query = "delete from tdvs_qptempdetl where ftempcode='{$tempcode}'";
            $result = $aobj_context->pobj_db->Execute($query);

            $query = "delete from tdvs_qptemphead where ftempcode='{$tempcode}'";
            $result = $aobj_context->pobj_db->Execute($query);
        }
        
        if($result){
            $arr['msg'] = 'Deleted Successfully';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
        } else {
            $arr['msg'] = 'Something Went wrong';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        }
    }


?>