<?php 
include("../db.php");
$ch=$_REQUEST["type"];$status="";


if($ch=="get_budget"){
    $name = $_POST['name'];

	$budget = $db->getVal("select budget from mode where school_id='".$_SESSION["admin"]["school_id"]."' and mode='$name' and head_type='Head' ");
	$remaining = $db->getVal("select sum(budget) from mode where mode_type='$name' and head_type='Sub Head' ");
    // echo "Max Budget : ".$budget."<br>Remainig Budget : ". $budget - $remaining;
    $rem = $budget - $remaining;
    echo "Max Budget : <input id='maxbudget' value='$budget' style='border:none;font-weight:800;' readonly> <br>Remainig Budget : <input id='rembudget' value='$rem' style='border:none;font-weight:800;' readonly> ";
}



if($ch=="delete_file"){
	$id = $_POST['id'];

    $image = $db->getRow("select * from assignment_files where id='".$id."' and session='".$_SESSION["admin"]["session"]."' ");

    $img = $image['name'];
    $type = $image['type'];

    if($type == "key_terms"){
        unlink("../uploads/keyterms/$img");
    }
    
    if($type == "mind_map"){
        unlink("../uploads/mindmap/$img");
    }

    if($type == "key_notes"){
        unlink("../uploads/keynotes/$img");
    }
    
    if($type == "practical_projects"){
        unlink("../uploads/practicalprojects/$img");
    }
    
    if($type == "videos"){
        unlink("../uploads/videos/$img");
    }
    
    $res=$db->delete("assignment_files","where session='".$_SESSION["admin"]["session"]."' and id='".$id."' ");
//    echo json_encode($res);

}

if($ch=="delete_question"){
	$qid = $_POST['qid'];
    $res=$db->delete("assignment_questions","where id='$qid' ");
}




?>

