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


Current Path : /var/www/oasis/src/
Upload File :
Current File : /var/www/oasis/src/SelectSubjType.php

<?php


function loadSemSubjType($aobj_context) {     
    $collcode = $_SESSION['collcode'];
    $degree = $aobj_context->mobj_data["degree"];

    $query = "select distinct fexamno,fexamname from degree where fdegree='{$degree}'";
    $result = $aobj_context->mobj_db->GetAll($query);

    if ($result) {
        echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
    } else {
        $arr['msg'] = "Data not found";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "error");
        return;
    }
}

function ViewSubjDet_SubType($aobj_context){
    session_start();
    $collcode=$_SESSION['collcode'];

    $degree = $aobj_context->mobj_data["degree"];
    $examno = $aobj_context->mobj_data["examno"];
    $element = $aobj_context->mobj_data["element"];

    if($element=="mainsubj"){
        $elementwise="";
        $cond = "fsubcode";
        $cond2 = "fsubname";
    }else{
        $elementwise="and fintass='F'";
        $cond = "fcsubcode";
        $cond2 = "concat(fsubname ,' - ', fssubname) as fsubname";
    }

    $subjquery="select fsubcode,fcsubcode,$cond2,fqpcode,COALESCE(fsubtype, '') AS fsubtype,
                COALESCE(FPARENTSUB, '') AS FPARENTSUB,COALESCE(fattent, '') AS fattent  from subject 
                where fdegree='{$degree}' and fexamno='{$examno}' $elementwise 
                group by fdegree,fexamno,$cond;";

    $resultsubj=$aobj_context->mobj_db->GetAll($subjquery);

    $subjtypequery=" select fsubtype from subtype where fdegree='{$degree}'";

    $resulttype=$aobj_context->mobj_db->GetAll($subjtypequery);

    $combinedResult = array(
        "resultsubj" => $resultsubj,
        "resulttype" => $resulttype,
    );

if($resultsubj){
		echo $aobj_context->mobj_output->ToJSONEnvelope($combinedResult,0,"success"); 
	}
	else{
		$data['msg'] = 'Failed to load';
		echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
	}
}

function SaveSubjType($aobj_context){

    $dataToSave = json_decode($aobj_context->mobj_data['dataToSave'], true);

    $degree = $aobj_context->mobj_data["degree"];
    $examno = $aobj_context->mobj_data["examno"];
    $element = $aobj_context->mobj_data["element"];
   
    if($element=="mainsubj"){
        $elementwise="";
    }else{
        $elementwise="and fintass='F'";
    }

        foreach($dataToSave as $key => $value){
            $query=" UPDATE subject
                    SET fsubtype = '{$value['fsubtype']}',
                    FPARENTSUB='{$value['FPARENTSUB']}',
                    fattent='{$value['fattent']}'
                    WHERE fdegree = '{$degree}' AND fexamno = '{$examno}' AND 
                    fcsubcode = '{$value['fcsubcode']}'
                     $elementwise ";
                    
            $results = $aobj_context->mobj_db->Execute($query);
        }
    
    if($results){
    $rdata = "Updated Successfully.";
        echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"); 
    }
    else{
        $arr['msg'] = "Could Not Update";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
    return;
    }
}
?>