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


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/degcollege.php

<?php

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

    $univcode = $aobj_context->mobj_data["univcode"];
    $deggrp = $aobj_context->mobj_data["deggrp"];

    $query = "select distinct fcollcode, concat(fcollcode, ' - ',fcollname,', ',ftown) as fcollname from college 
    where ifnull(fdeleted,'') <> 'T' and ffaculty like '%{$deggrp}%'";
    // var_dump($query);
    $result = $aobj_context->pobj_db->GetAll($query);

    if (count($result) > 0) {
        $res['degcolldet'] = $result;
        echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
        return;
    } else {
        $arr['msg'] = 'Degree Group not defined';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        return;
    }
}


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

    $univcode = $aobj_context->mobj_data["univcode"];
    $deggrp = $aobj_context->mobj_data["deggrp"];
    $examcntr = $aobj_context->mobj_data["examcntr"];
    $thpr = $aobj_context->mobj_data["thpr"];

    $cnd = "";
    if ($thpr == 'TH') {
        $cnd = " and fexamcodet = '{$examcntr}'";
        $filed = 'fexamcodet';
    }

    if ($thpr == 'PR') {
        $cnd = " and fexamcodep = '{$examcntr}'";
        $filed = 'fexamcodep';
    }

    $query1 = "select * from degcntr where fcollcode = '{$examcntr}' and ifnull(fdeleted,'') <> 'T'";
    $result1 = $aobj_context->pobj_db->GetRow($query1);

    //var_dump($result1[$filed]);

    if ($result1) {
        if ($result1[$filed] == $examcntr) { } else {
            $arr['examcntrdet'] = 'Exam Center Alredy Tegged with : ' . $result1[$filed];
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }

    $query = "select fyear, fexamtype 
    from degcntr where fdeggrp = '{$deggrp}'";

    $result = $aobj_context->pobj_db->GetRow($query);
    $fyear = $result['fyear'];
    $fexamtype = $result['fexamtype'];

    $query = "select fcollcode, if(ifnull(fdeleted,'') = 'T', 'true', 'false') as fdeleted 
    from degcntr where fdeggrp = '{$deggrp}' and fyear = '{$fyear}' and fexamtype = '{$fexamtype}'
    $cnd and ifnull(fdeleted,'') <> 'T' and fcollcode <> '{$examcntr}'";

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

    if (count($result) >= 0) {
        $res['examcntrdet'] = $result;
        echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
        return;
    } else {
        $arr['examcntrdet'] = 'Center Details not Found';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
        return;
    }
}

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

    $req = $aobj_context->req_body;

    $data = $req['data'];

    if (count($data['examcntrlist']) == 0) {
        $arr['msg'] = 'Invalid Params data';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 1, "failure");
        return;
    }

    $examcntrlist = $data['examcntrlist'];
    $degGrp = $data['deggrp'];

    $examcntr = $data['examcntr'];
    $thpr = $data['thpr'];

    $values = '';

    if ($thpr == 'TH')
        $filed = "fexamcodet";
    if ($thpr == 'PR')
        $filed = "fexamcodep";

    $query = "select fmeyear,fmeexamtyp from degree where fdeggrp = '{$degGrp}'";
    $result = $aobj_context->pobj_db->GetRow($query);
    $fmeyear = $result['fmeyear'];
    $fmeexamtyp = $result['fmeexamtyp'];

    foreach ($examcntrlist as $k => $v) {

        $query1 = "select * from degcntr where $filed = '{$v['fcollcode']}' and $filed <> '{$examcntr}'
        and ifnull(fdeleted,'') <> 'T'";
        $result1 = $aobj_context->pobj_db->GetRow($query1);

        if ($result1) {
            if ($result1['fcollcode'] != $examcntr) {
                $arr['msg'] = 'College is Exam Center :' . $v['fcollcode'];
                echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
                return;
            }
        }

        $query1 = "select * from degcntr where fcollcode = '{$v['fcollcode']}' 
        and ifnull($filed,'') <> '' and ifnull($filed,'') <> '{$examcntr}'
        and ifnull(fdeleted,'') <> 'T'";
        $result1 = $aobj_context->pobj_db->GetRow($query1);
        // var_dump($query1);
        if ($result1) {
            if ($result1['fcollcode'] != $examcntr) {
                $arr['msg'] = 'College is tagged to Exam Center :' . $result1[$filed];
                echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
                return;
            }
        }

        $deleted = $v['fdeleted'] == 'true' ? 'T' : 'F';
        $values .= "('{$degGrp}','" . $v['fcollcode'] . "','{$examcntr}','{$deleted}','{$fmeyear}','{$fmeexamtyp}'),";
    }

    $values = rtrim($values, ',');

    $query = "delete from degcntr where $filed = '{$examcntr}' 
    and fyear = '{$fmeyear}' and fexamtype = '{$fmeexamtyp}' and fdeggrp = '{$degGrp}'";

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

    $query = "insert into degcntr(fdeggrp, fcollcode,$filed,fdeleted,fyear,fexamtype) values " . $values . "
    ON DUPLICATE KEY UPDATE
    $filed = VALUES($filed), fdeleted = VALUES(fdeleted)";

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

    if ($result) {
        $query = "update candsum c, degcntr d, degree g
        set c.fcntrcode = d.fexamcodet where c.fcollcode = d.fcollcode
        and c.fdegree = g.fdegree and d.fdeggrp = g.fdeggrp 
        and d.fdeggrp = {$degGrp} and d.fyear = '{$fmeyear}' 
        and d.fexamtype = '{$fmeexamtyp}' and ifnull(d.fdeleted,'') <> 'T'";

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

        $arr['msg'] = 'Successfully Updated';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
        return;
    } else {
        $arr['msg'] = 'Insertion / Updation Failed';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        return;
    }
}

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

    $req = $aobj_context->req_body;

    $data = $req['data'];

    if (
        !array_key_exists('deggrp', $data) || !array_key_exists('examcntr', $data)
        || !array_key_exists('thpr', $data)
    ) {
        $arr['msg'] = 'Invalid Params';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 1, "failure");
        return;
    }

    $degGrp = $data['deggrp'];

    $examcntr = $data['examcntr'];
    $thpr = $data['thpr'];

    $values = '';

    if ($thpr == 'TH')
        $filed = "fexamcodet";
    if ($thpr == 'PR')
        $filed = "fexamcodep";

    $query = "select fmeyear,fmeexamtyp from degree where fdeggrp = '{$degGrp}'";
    $result = $aobj_context->pobj_db->GetRow($query);
    $fmeyear = $result['fmeyear'];
    $fmeexamtyp = $result['fmeexamtyp'];

    $query = "delete from degcntr where $filed = '{$examcntr}' 
    and fyear = '{$fmeyear}' and fexamtype = '{$fmeexamtyp}' and fdeggrp = '{$degGrp}'";
    // var_dump($query);
    $result = $aobj_context->pobj_db->Execute($query);

    if ($result) {
        $arr['msg'] = 'Successfully Deleted';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
        return;
    } else {
        $arr['msg'] = 'Deletion Failed';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        return;
    }
}