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


Current Path : /var/www/html/univadmin/src/
Upload File :
Current File : /var/www/html/univadmin/src/avlQP.php

<?php
    function getAvailableQp($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $data = json_decode($aobj_context->mobj_data["data"], true);

        $split = explode('*', $data['exam']);
        $deggrp = $split[0];

        $data['sem'] === "All" ? $sem = "" : $sem = "and s.fexamno='{$data['sem']}'";
        $data['degree'] === "All" ? $degree = "" : $degree = "and s.fdegree='{$data['degree']}'";
        $data['qpcode'] === "All" ? $qpcode = "" : $qpcode = "and q.fqpcode='{$data['qpcode']}'";
        $data['avilQPLess'] === "" || $data['avilQPLess'] === NULL ? $avilQPLess = "" : $avilQPLess = "having SUM(CASE WHEN IFNULL(q.FFINALPAPER, '') = '' THEN 1 ELSE 0 END) < '{$data['avilQPLess']}'";

        $query = "select s.fdegree, s.fexamno, s.fdeggrp, q.fqpcode,
                count(q.fset) as fset, 
                concat(s.fsubshort,' - ',s.fsubname) as fsubname, 
                sum(case when ifnull(q.FFINALPAPER, '') = '' then 1 else 0 end)as available, 
                sum(case when ifnull(q.FFINALPAPER, '') = 'T' then 1 else 0 end)as used,
                s.fsubshort,s.FELIGQP
                from qpseterdet q inner join (select distinct s.fdegree, s.fexamno, s.fqpcode, s.fsubname, 
                s.fsubshort, dg.fdeggrp,ifnull(s.FELIGQP,'F')as FELIGQP from subject s 
                inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
                inner join deggrp dg on dg.fdeggrp = d.fdeggrp		
                where ifnull(fqpcode,'') <> '' 
                {$degree} and dg.fdeggrp='{$deggrp}' {$sem}
                group by fqpcode) s on s.fqpcode = q.fqpcode 
                where ifnull(fqpfilepath, '')<>'' {$qpcode}  and ifnull(fdeleted, '') <> 'T'
                group by fqpcode {$avilQPLess}";
// var_dump($query);die();
        $result = $aobj_context->pobj_db->GetAll($query);
        if($result){
            echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
        }else{
            $arr['msg'] = "No data found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }

    }

    function getDetailedAvailableQpData($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $data = json_decode($aobj_context->mobj_data["data"], true);
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $fdegree = $aobj_context->mobj_data["fdegree"];
        $fdeggrp = $aobj_context->mobj_data["fdeggrp"];
        $fexamno = $aobj_context->mobj_data["fexamno"];
        
        $query = "select  s.fdegree, s.fdeggrp, s.fexamno, q.fteachcode, m.fteachname, s.fsubname, 
                s.fsubshort, q.fqpcode, fset, fyear, fexamtype,
                concat(fyear,' / ',fexamtype) fyears,
                if(ifnull(q.fqpfilepath, '')<>'', 'Yes', 'No')as fqpupdstatus,
                date_format(q.fqpdtme, '%d/%m/%Y %h:%m:%s')as fqpdtme,
                if(ifnull(q.fmodqpupd, '') <> '', 'Yes', 'No')as fmodstatus,
                date_format(q.fmodqpdate, '%d/%m/%Y %h:%m:%s')as fmodtme,
                if(ifnull(q.ffinalpaper, '') = 'T', 'Used', '')as used,
                date_format(q.ffinalpaperdate, '%d/%m/%Y %h:%m:%s')as ffinalpaperdate,
                ifnull(q.fteachcode,'') as fteachcode
                from qpseterdet q
                inner join (
                select distinct s.fdegree, s.fexamno, s.fqpcode, s.fsubname, s.fsubshort, dg.fdeggrp from subject s 
                inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
                inner join deggrp dg on dg.fdeggrp = d.fdeggrp		
                where ifnull(fqpcode,'') <> '' 
                and s.fdegree='{$fdegree}' and dg.fdeggrp='{$fdeggrp}' and s.fexamno='{$fexamno}'
                group by fqpcode)s on s.fqpcode = q.fqpcode 
                inner join masteach m on m.fteachcode = q.fteachcode
                where ifnull(fqpfilepath, '')<>'' and q.fqpcode='{$qpcode}'
                and ifnull(q.fdeleted, '') <> 'T'";

            // $query = "select  s.fdegree, s.fdeggrp, s.fexamno, q.fteachcode, m.fteachname, s.fsubname, 
            // s.fsubshort, q.fqpcode, fset, fyear, fexamtype,
            // concat(fyear,' / ',fexamtype) fyears,
            // if(ifnull(q.fqpfilepath, '')<>'', 'Yes', 'No')as fqpupdstatus,
            // date_format(q.fqpdtme, '%d/%m/%Y %h:%m:%s')as fqpdtme,
            // if(ifnull(q.fmodqpupd, '') <> '', 'Yes', 'No')as fmodstatus,
            // date_format(q.fmodqpdate, '%d/%m/%Y %h:%m:%s')as fmodtme,
            // if(ifnull(q.ffinalpaper, '') = 'T', 'Used', '')as used,
            // date_format(q.ffinalpaperdate, '%d/%m/%Y %h:%m:%s')as ffinalpaperdate,
            // ifnull(q.fteachcode,'') as fteachcode
            // from qpseterdet q
            // inner join (
            // select distinct s.fdegree, s.fexamno, s.fqpcode, s.fsubname, s.fsubshort, dg.fdeggrp from subject s 
            // inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
            // inner join deggrp dg on dg.fdeggrp = d.fdeggrp		
            // where ifnull(fqpcode,'') <> '' 
            // and s.fdegree='{$data['fdegree']}' and dg.fdeggrp='{$data['fdeggrp']}' and s.fexamno='{$data['fexamno']}'
            // group by fqpcode)s on s.fqpcode = q.fqpcode 
            // inner join masteach m on m.fteachcode = q.fteachcode
            // where ifnull(fqpfilepath, '')<>'' and q.fqpcode='{$data['fqpcode']}'";

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

    }

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

        foreach($finData as $val){
            $query = "update subject set FELIGQP = '{$val['FELIGQP']}'
            where FDEGREE = '{$val['fdegree']}' and FEXAMNO = '{$val['fexamno']}' 
            and FSUBSHORT = '{$val['fsubshort']}' and FQPCODE = '{$val['fqpcode']}'";
            
            $result = $aobj_context->pobj_db->Execute($query);
        }
        
        if($result){
            $arr['msg'] = "Successfully Updated";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
        }else{
            $arr['msg'] = "No data found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }

    }
?>