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


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

<?php 

function getCombinations($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
    
    $degree = $aobj_context->mobj_data["deg"];
    
    $query = "select distinct fcombcode, fcombdesc from mascomb where fdegree = '{$degree}'
    order by fcombcode ";
    
    $result = $aobj_context->pobj_db->GetAll($query);

    if (!$result && gettype($result) == 'boolean') {
        $arr['msg'] = "Error while fetching Data";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
        return;
    }

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

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

    $req = $aobj_context->req_body;

    $comb = $req['comb'];

    if($comb['fdegree']=="" || $comb['fcombcode']=="" || 
    $comb['fcombdesc']=="" || count($comb['combsubs'])==0)
    {
        $arr['msg'] = 'Invalid data';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }

    $combsubs = $comb['combsubs'];

    $values = "";

    $query = "delete from mascomb where fcombcode = '{$comb['fcombcode']}' 
    and fdegree = '{$comb['fdegree']}'";
    // var_dump($query);
    $result = $aobj_context->pobj_db->Execute($query);
    // var_dump($result);
    if(!$result)
    {
        $arr['msg'] = 'Error While saving Combination';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }

    foreach($combsubs as $k => $v)
    {
        if($v['fdeleted'] != 'true' )
            $values .= "('{$comb['fcombcode']}', '{$comb['fcombdesc']}', '{$comb['fdegree']}', '{$v['fsubcode']}'),";
    }
    $values = rtrim($values, ',');

    $query = "insert into mascomb(fcombcode, fcombdesc, fdegree, fsubcode) 
                values {$values}";

    $result = $aobj_context->pobj_db->Execute($query);
    // var_dump($query);
    // var_dump($result);
    if($result)
    {
        $res['msg'] = "Combination Added Successfully";
        echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
        return;
    }
    else
    {
        $arr['msg'] = 'Error While saving Combination';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }

}

function getCombinationEdit($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
    
    $degree = $aobj_context->mobj_data["deg"];

    $comb = $aobj_context->mobj_data["comb"];

    $query = "select distinct s.fsubcode, s.fsubname, 
    if(s.fsubcode=m.fsubcode, 'T', 'F') as fcombsub,
    ifnull(m.fcombcode,'') as fcombcode, ifnull(m.fcombdesc,'') as fcombdesc
    from subject s left join mascomb m
    on s.fsubcode = m.fsubcode and m.fcombcode = '{$comb}'
    where s.fdegree = '{$degree}' and ifnull(s.fcombsub,'') = 'T'
    order by fcombsub desc, fsubcode";
    // var_dump($query);
    $result = $aobj_context->pobj_db->GetAll($query);

    if(count($result) > 0)
    {
        $i = 0;
        $data = array();
        $data['fcombcode'] = $result[0]['fcombcode'];
        $data['fcombdesc'] = $result[0]['fcombdesc'];
        foreach($result as $k => $v)
        {
            $data[$i]['fsubcode'] = $v['fsubcode'];
            $data[$i]['fsubname'] = $v['fsubname'];
            $data[$i]['fcombsub'] = $v['fcombsub'];
            $i++;
        }
        $res['combEdit'] = $data;
        echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
        return;
    }
    else
	{
		$arr['msg'] = 'Combination not found for the Combination';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
	}
    
}

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

    $degree = $aobj_context->mobj_data["deg"];
    $combcode = $aobj_context->mobj_data["combcode"];
    // 

    $query = "select distinct fsubcode, fsubname from subject 
    where fdegree = '{$degree}' and fexamno = 'A'";
    // var_dump($query);
    $result = $aobj_context->pobj_db->GetAll($query);
    
    if (!$result && gettype($result) == 'boolean') {
        $arr['msg'] = "Error while fetching Data";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
        return;
    }
    // var_dump($result);
    if(count($result) == 0)
    {
        $arr['msg'] = 'No data found';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }
    $res['optsubs'] = $result;
    
    $query = "select fsubcode, 'false' as fdeleted from mascomb where fcombcode = '{$combcode}' 
    and fdegree = '{$degree}' and ifnull(fsubcode,'')<> ''";
    $result = $aobj_context->pobj_db->GetAll($query);

    if (!$result && gettype($result) == 'boolean') {
        $arr['msg'] = "Error while fetching Data";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
        return;
    }
    $res['combsubs'] = $result;

    echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
    return;
}

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

    $req = $aobj_context->req_body;

    $comb = $req['comb'];

    if($comb['fdegree']=="" || $comb['fcombcode']=="")
    {
        $arr['msg'] = 'Invalid data';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }

    $query = "delete from mascomb where fcombcode = '{$comb['fcombcode']}' 
    and fdegree = '{$comb['fdegree']}'";
    $result = $aobj_context->pobj_db->Execute($query);

    if(!$result)
    {
        $arr['msg'] = 'Error While deleting Combination';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        return;
    }

    $res['msg'] = "Combination deleted Successfully";
    echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
    return;


}