<?php
$pgMod="add_subject";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);



if(isset($_POST['update_photos'])){
    
    $resulr1=$_POST['subjectid'];

    foreach($resulr1 as $x => $x_value) {
	     $base_name = $_FILES['photo']['name'][$x];

         $lfilename = basename($base_name);
		 $lext = strtolower(substr($lfilename, strrpos($lfilename, '.')+1));
		 $lnewfile=md5(microtime()).".".$lext;
		 $getoldimage = $db->getVal("select subject_image from subject_new where id='".$_POST['subjectid'][$x]."' and session='".$_SESSION["admin"]["session"]."' and type='subject' ");
		 
		if(move_uploaded_file($_FILES['photo']['tmp_name'][$x],"uploads/subjectimage/".$lnewfile))
		{
        unlink("uploads/subjectimage/$getoldimage");
		$saveAry=array("subject_image"=>$lnewfile,);	
        $flgUp=$db->updateAry("subject_new", $saveAry,"where id='".$_POST['subjectid'][$x]."' and session='".$_SESSION["admin"]["session"]."' and type='subject' ");
		}

    }
		redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Notice", "page_id"=>$pgMod)));
}


if(isset($_POST['update_chapter'])){
    
    $resulr1=$_POST['subjectid'];

    foreach($resulr1 as $x => $x_value) {
	  
		$saveAry=array("subject"=>$_POST["subject"][$x]);
		$_POST['subjectid'][$x];

        $flgUp=$db->updateAry("subject_new", $saveAry,"where id='".$_POST['subjectid'][$x]."' and session='".$_SESSION["admin"]["session"]."' and type='chapter' ");
		

    }
		redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Notice", "page_id"=>"add_subject","action"=>"edit","id"=>$_GET['id'])));
}




if($_POST)
{
	$_SESSION['form']=$_POST;
	$flgEr=FALSE;
	if(!isset($_POST['class']) || trim($_POST['class'])=='')
	{
		$flgEr=TRUE;
		array_push($alert_err,"Please select Class.");
	}elseif(!isset($_POST['subject']) || trim($_POST['subject'])=='')
	{
		$flgEr=TRUE;
		array_push($alert_err,"Please enter subject.");
	}
	if($flgEr!=TRUE && $pgAct=="add")
	{
		$_POST["session"]=$_SESSION["admin"]["session"];
		$_POST["school_id"]=$_SESSION["admin"]["school_id"];
        $_POST["added_by"]=$_SESSION["admin"]["uid"];
		$subject=explode(",",$_POST["subject"]);
		unset($_POST["subject"]);
		if(is_array($subject) && count($subject)>0){
			foreach($subject as $sub){
				$_POST["subject"]=$sub;
				$flgIn=$db->insertAry("subject_new",$_POST);
			}
			redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Notice", "page_id"=>$pgMod)));
		}
		array_push($alert_err,$db->getErMsg());
	}
	elseif($pgAct=="edit" && isset($_GET['id']) && trim($_GET['id'])!='')
	{
//		$_POST["subject"]=$_POST["subject"];
//		unset($_POST["subject"]);
		$flgUp=$db->updateAry("subject_new",$_POST,"where id='".$_GET['id']."'");
		if(!is_null($flgUp))
		{
			$_SESSION['msg']='update Successfully';
			unset($_SESSION['form']);
			redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Notice", "page_id"=>$pgMod)));
		}
		else
		{
			array_push($alert_err,$db->getErMsg());
		
		}
	}
	
	

    
    
    
	
}

// elseif($pgAct=="addimages")
// {
//     $resulr1=$_POST['subjectid'];
//     print_r($resulr1);
    // foreach($resulr1 as $x => $x_value) {
    //     $base_name= $_FILES['photo']['name'][$x];

    //     $lfilename = basename($base_name);
    //     $lext = strtolower(substr($lfilename, strrpos($lfilename, '.')+1));
    //     $lnewfile=md5(microtime()).".".$lext;
    //     if(move_uploaded_file($_FILES['photo']['tmp_name'][$x],"media/photo/".$lnewfile))
    
    //     {
    
    //         $_POST["photo"]=$lnewfile;
            
    //         $saveAry=array("photo"=>$lnewfile,);	
    //         $flgUp=$db->updateAry("student",$saveAry,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_POST['idno'][$x]."' and session='".$_SESSION["admin"]["session"]."'");
    
    //     }
    
    // }

// }

elseif($pgAct=="delete" && isset($_GET['id']) && trim($_GET['id'])!='')
{
	$res=$db->delete("subject_new","where school_id='".$_SESSION["admin"]["school_id"]."' and (id='".$_GET['id']."' OR parent_subject='".$_GET['id']."') ");
	if(!is_null($res)) { $_SESSION['msg']='Deleted Successfully'; }
	else { array_push($alert_err,$db->getErMsg()); }
	redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Notice", "page_id"=>$pgMod)));
}

elseif($pgAct=="deletes" && isset($_GET['id']) && trim($_GET['id'])!='')
{
     	$val=$db->getVal("select parent_subject from  subject_new where id='".$_GET['id']."'");
    
    //echo $ss="select parent_subject from  subject_new where id='".$_GET['id']."'";


    
	$res=$db->delete("subject_new","where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$_GET['id']."'  ");
	if(!is_null($res)) { $_SESSION['msg']='Deleted Successfully'; }
	else { array_push($alert_err,$db->getErMsg()); }
	//redirect(URL_ADMIN_HOME.getQueryString(array("page_id"=>$pgMod)));
	

		redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Notice", "page_id"=>"add_subject","action"=>"edit","id"=>$val)));
	
}


if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
?>
<div class="alert alert-success">
 <a class="close" data-dismiss="alert">×</a>
 <i class="icon icon-thumbs-up-alt"></i> <b></b><?php echo $_SESSION['msg'] ?></i>
</div>
<?php
unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
?>
<div class="alert alert-error">
 <a class="close" data-dismiss="alert">×</a>
 <i class="icon icon-warning-sign"></i> <b></b> <?php echo $alert_err[0] ?></i>
</div>
<?php

}


if($pgAct=="edit" && $_GET["id"]!="")
{
	$aryForm=$db->getRow("SELECT * FROM subject_new WHERE school_id='".$_SESSION["admin"]["school_id"]."' and id='".$_GET['id']."'");
}

if($pgAct=="add" ){
?>

<input type="hidden" name="page_id" value="<?php echo $pgMod; ?>" />
<div class="row-fluid">
            <div class="span12">
            <div class="top-bar">
<h3><i class="icon-cog"></i>Add Subject</h3>
<div>
<!--<button type="button" onclick="printDiv('printDiv2')" class="btn btn-primary " style="float:right !important; margin-top:5px ">Print</button>-->
</div>
</div>
<div class="well no-padding"  id="printDiv2">
<div class="controls controls-row">

<div style="padding:20px;">
  <form class="login-form" method="post" novalidate>

    <div class="control-group">
    <label class="control-label">Select Class</label>
      <div  class="controls">
      <select name="class" id="class" style="width:100%;" onchange="filterSubject()">
      <option value="">--Select Class--</option>
      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
            foreach($allClasses as $class){
                ?>
                <option <?php if($class["class"]==$aryForm["class"])echo 'selected';?> value="<?php echo $class['class']; ?>"><?php echo $class['class']; ?></option>
                <?php
                }
            ?>
        </select>
      </div>
      </div>

    <div class="control-group">
    <label class="control-label">Type</label>
      <div  class="controls">
        <select id="mySelect" name="type" style="width:100%" onchange="changeType()">
            <option <?php if($aryForm["type"]=="subject")echo 'selected';?> value="subject">Subject</option>
            <option <?php if($aryForm["type"]=="sub_subject")echo 'selected';?> value="sub_subject">Sub - subject</option>
            <option <?php if($aryForm["type"]=="chapter")echo 'selected';?> value="chapter">Chapter</option>
        </select>
      </div>
    </div>


    <div class="control-group" id="newsubjectdiv" style="display:none;">
    <label class="control-label">Select Main Subject</label>
      <div  class="controls" id="parent_subject">
        <select id="mySelect1" name="parent_subject" style="width:100%;" onchange="changeSubject()">
           <option value="">--Select Main Subject--</option>
            <?php $allSubjects = $db->getRows("select * from subject_new where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and parent_subject=0 and type='subject' ");
            foreach($allSubjects as $sub){
                ?>
                <option value="<?php echo $sub['id']; ?>"><?php echo $sub['subject']; ?></option>
                <?php
                }
            ?>
        </select>
      </div>
    </div>
    
    <div class="control-group" id="newchapterdiv" style="display:none;">
    <label class="control-label">Select Subject</label>
      <div  class="controls" id="sub_subject">
        <select name="sub_subject" style="width:500px;">
           <option value="">--Select Sub-subject --</option>
        </select>
      </div>
    </div>
    
    <div class="control-group">
        <label class="control-label">Enter <br>Subject/Chapter</label>
      <div  class="controls">
      <input type="text" name="subject" placeholder="math,physics,hindi" value="<?php if($_POST)echo $_POST["subject"]; else echo $aryForm["subject"] ?>" style="width:100%;height:150px;"/><br>
      use comma seprate for add multiple subject
      </div>
  </div><br>
      
        <div class="form-actions">
			<button type="submit" class="btn btn-primary"> Save</button>
			<button type="button" class="btn"> Cancel</button>
		</div>
    </form>
    
</div>

        </div>
        <br>
</div>
<!-- / Forms: Content -->
</div>
    </div>

<?php
}


elseif($pgAct=="edit" && isset($_GET['id']) && trim($_GET['id']) !=''){
?>

<?php
	$aryPgAct=array("page_id"=>$pgMod,"action"=>"add");
	$aryList=$db->getRows("SELECT * FROM subject_new where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and parent_subject='".$_GET['id']."' and type='chapter'  order by id"); $i=0;
	//echo $ss="SELECT * FROM subject_new where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and parent_subject='".$_GET['id']."' and type='chapter'  order by id";
	if(is_array($aryList) && count($aryList)>0)
	{
		?>
	  <form class="login-form" method="post" enctype="multipart/form-data">
        <table class="table" > 
            <thead>
                <tr>
                    <th>S.No.</th>
                    <th>chapter</th>
                   
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
            <?php foreach($aryList as $clist){ $i++; 
            $aryPgAct["id"]=$clist['id'];
            ?>
				<input type="hidden" name="subjectid[]" required  value="<?php echo $clist["id"] ?>" readonly="readonly" />
                <tr class="grade<?php if($i%2==0)echo "C";else "U";?>">
                    <td><?php echo $i; ?></td>
                    <td>	<div class="controls">
								<input type="text" id="subject" name="subject[]" class="input-block-level" value="<?php echo $clist["subject"]; ?>" >
							</div></td>
                    
                     <td>
                        <button type="submit" name="update_chapter" class="btn btn-primary"> Save  </button>

                    <?php //$aryPgAct['action']="save"; ?>
                       <!-- <a style="float:left" href="<?php echo URL_ADMIN_HOME.getQueryString($aryPgAct); ?>"><button type="button" class="btn btn-info">Edit</button></a>!-->
                    <?php $aryPgAct['action']="deletes"; ?>
                         <a href="javascript:;" onclick="del('<?php echo URL_ADMIN_HOME.getQueryString($aryPgAct); ?>')" class="confirmation"><button type="button" class="btn btn-danger">Delete</button></a>  
                    </td>

                </tr>
            <?php } } ?>
            </tbody>
            <tfoot>
                <tr>
                	<th></th>
                    <th colspan="3"></th>
                </tr>
            </tfoot>
        </table>
     
    </form>

<?php
}


elseif($pgAct=="addimages"){

	?>
	
	
	
	
	<div class="row-fluid"><div class="span12"><div class="top-bar">
    <h3><i class="icon-eye-open"></i> <?php echo ucwords($pgAct." ".$pgMod); ?></h3>
    <button style="float:right;margin-top:5px;margin-left:10px;" onClick="window.location='./?src=Notice&page_id=<?php echo $pgMod; ?>&action=addimages'" class="btn" type="button">Add Subject Images</button>
    <button style="float:right; margin-top:5px" onClick="window.location='./?src=Notice&page_id=<?php echo $pgMod; ?>&action=add'" class="btn" type="button">Add <?php echo $pgMod; ?></button>
    </div>
    <div class="well no-padding">
     
       <div style="z-index: 99999;margin: 30px;">

        <table>
            <tr>
                <td>
                    <label class="control-label">Select Class</label>
                    <select name="class" id="class" style="width:100%;" onchange="filterSubject()">
                      <option value="">--Select Class--</option>
                      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
                        foreach($allClasses as $class){
                            ?>
                            <option <?php if($class["class"]==$aryForm["class"])echo 'selected';?> value="<?php echo $class['class']; ?>"><?php echo $class['class']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                </td>
                <td>
                    <label class="control-label">Subject</label>
                    <div  class="controls" id="parent_subject">

                    <select id="mySelect1" name="parent_subject" style="width:100%;"  onchange="changeSubject()">
                        <option value="">--Select Subject--</option>
                      <?php $allSubjects = $db->getRows("select * from subject_new where class='$aryForm[class]' and session='".$_SESSION["admin"]["session"]."' and type='subject' order by id ASC ");
                            foreach($allSubjects as $sub){
                            ?>
                            <option <?php if($sub["id"]==$aryForm["parent_subject"])echo 'selected';?> value="<?php echo $sub['id']; ?>"><?php echo $sub['subject']; ?></option>
                            <?php
                            }
                        ?>
                    </select>  
                    </div>
                </td>
             
                <td>
                    <label></label>
                    <button class="btn" style="margin-top:20px;font-size:15px;padding:3px 8px;" onclick="filterRecord_image()">Search</button>
                </td>
            </tr>
        </table>

    </div>  
       <div id="filterdata_image">  
	<?php
	$aryPgAct=array("src"=>"Notice", "page_id"=>$pgMod,"action"=>"add");
	$aryList=$db->getRows("SELECT * FROM subject_new where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and parent_subject=0 and type='subject' order by id"); $i=0;
	if(is_array($aryList) && count($aryList)>0)
	{
		?>
	  <form class="login-form" method="post" enctype="multipart/form-data">
        <table class="table" > 
            <thead>
                <tr>
                    <th>S.No.</th>
                    <th>Class</th>
                    <th>Subject</th>
                    <th>Image</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
            <?php foreach($aryList as $clist){ $i++; 
            $aryPgAct["id"]=$clist['id'];
            ?>
				<input type="hidden" name="subjectid[]" required  value="<?php echo $clist["id"] ?>" readonly="readonly" />
                <tr class="grade<?php if($i%2==0)echo "C";else "U";?>">
                    <td><?php echo $i; ?></td>
                    <td><?php echo $clist["class"]; ?></td>
                    <td><?php echo $clist["subject"] ?></td>
                    <td><input type="file" id="photo" name="photo[]" class="input-block-level" ></td>
                    <td>
                        <?php if($clist["subject_image"]!="") { ?>
                        <img src="uploads/subjectimage/<?php echo $clist['subject_image']; ?>" style="width:50px;height:50px;" />
                        <a href='uploads/subjectimage/<?php echo $clist['subject_image']; ?>' download><button type="button" class="btn" style="background:green;color:white;width:80px;padding:3px;font-size:12px;">Download</button></a>
                        <a href="javascript:;" onclick="delete_subjectimage('<?php echo $clist['id']; ?>')" class="confirmation"><button type="button" class="btn btn-danger" style="width:80px;padding:3px;font-size:12px;">Delete</button></a> 
                        <?php } ?>
                    </td>
                </tr>
            <?php } ?>
            </tbody>
            <tfoot>
                <tr>
                	<th></th>
                    <th colspan="3"></th>
                </tr>
            </tfoot>
        </table>
        <div class="form-actions">
			<button type="submit" name="update_photos" class="btn btn-primary"> Save</button>
			<button type="button" class="btn"> Cancel</button>
		</div>
    </form>
		<?php
	}
	else{
		?>
        <div class="alert alert-info">
          <a class="close" data-dismiss="alert">×</a>
          <i class="icon icon-warning-sign"></i> <b>Notice</b> Record not found </i>
        </div>
        <?php
	}
	?>
	</div>
	</div></div></div>
	<?php


    
}

else {
    
	?>
	<div class="row-fluid"><div class="span12"><div class="top-bar">
    <h3><i class="icon-eye-open"></i> <?php echo ucwords($pgAct." ".$pgMod); ?></h3>
    <button style="float:right;margin-top:5px;margin-left:10px;" onClick="window.location='./?src=Notice&page_id=<?php echo $pgMod; ?>&action=addimages'" class="btn" type="button">Add Subject Images</button>
    <button style="float:right; margin-top:5px" onClick="window.location='./?src=Notice&page_id=<?php echo $pgMod; ?>&action=add'" class="btn" type="button">Add <?php echo $pgMod; ?></button>
    </div>
    <div class="well no-padding">

       <div style="z-index: 99999;margin: 30px;">

        <table>
            <tr>
                <td>
                    <label class="control-label">Select Class</label>
                    <select name="class" id="class" style="width:100%;" onchange="filterSubject()">
                      <option value="">--Select Class--</option>
                      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
                        foreach($allClasses as $class){
                            ?>
                            <option <?php if($class["class"]==$aryForm["class"])echo 'selected';?> value="<?php echo $class['class']; ?>"><?php echo $class['class']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                </td>
                <td>
                    <label class="control-label">Subject</label>
                    <div  class="controls" id="parent_subject">

                    <select id="mySelect1" name="parent_subject" style="width:100%;"  onchange="changeSubject()">
                        <option value="">--Select Subject--</option>
                      <?php $allSubjects = $db->getRows("select * from subject_new where class='$aryForm[class]' and session='".$_SESSION["admin"]["session"]."' and type='subject' order by id ASC ");
                            foreach($allSubjects as $sub){
                            ?>
                            <option <?php if($sub["id"]==$aryForm["parent_subject"])echo 'selected';?> value="<?php echo $sub['id']; ?>"><?php echo $sub['subject']; ?></option>
                            <?php
                            }
                        ?>
                    </select>  
                    </div>
                </td>
             
                <td>
                    <label></label>
                    <button class="btn" style="margin-top:20px;font-size:15px;padding:3px 8px;" onclick="filterRecord()">Search</button>
                </td>
            </tr>
        </table>

    </div>   
        <div id="filterdata"> 
	<?php
	$aryPgAct=array("src"=>"Notice", "page_id"=>$pgMod,"action"=>"add");
	$aryList=$db->getRows("SELECT * FROM subject_new where school_id='".$_SESSION["admin"]["school_id"]."'  and parent_subject=0 and type='subject' order by id"); $i=0;
	if(is_array($aryList) && count($aryList)>0)
	{
		?>
        <table  id="example" class="table table-striped table-bordered"> 
            <thead>
                <tr>
                    <th>S.No.</th>
                    <th>Class</th>
                    <th>Subject</th>
                    <th>Sub-subjects</th>
                    <th>Chapters</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
            <?php foreach($aryList as $clist){ $i++; 
            $aryPgAct["id"]=$clist['id'];
            ?>
                <tr class="grade<?php if($i%2==0)echo "C";else "U";?>">
                    <td><?php echo $i; ?></td>
                    <td><?php echo $clist["class"] ?></td>
                    <td><?php echo $clist["subject"] ?><br>
                        <?php if($clist["subject_image"]!=""){ ?>
                        <a href="uploads/subjectimage/<?php echo $clist['subject_image']; ?>" download>
                            <img src="uploads/subjectimage/<?php echo $clist['subject_image']; ?>" style="width:50px;height:50px;"/>
                        </a>
                        <?php } ?>
                    </td>

                        <?php
                        $temp = ''; $k='';
                        $subSubjects = $db->getRows("SELECT * FROM subject_new where session='".$_SESSION["admin"]["session"]."' and parent_subject='".$clist["id"]."' and sub_subject=0 order by id ASC");
                        // print_r($subSubjects);
                        foreach($subSubjects as $ss){
                            $temp .= $ss['subject'].", ";
                            
                            $chapters = $db->getRows("select * from subject_new where sub_subject='".$ss[id]."' and type='chapter' order by id ASC ");
                            //print_r($chapters);
                            
                            foreach($chapters as $ch){
                                $k .= $ch['subject'].", ";
                            }
                            
                        }
                        ?>
                    <td>
                        <?php echo $temp;  ?>
                    </td>
                    <td>
                        <?php echo $k; ?>
                    </td>
                    <td>
                    <?php $aryPgAct['action']="edit"; ?>
                        <a style="float:left" href="<?php echo URL_ADMIN_HOME.getQueryString($aryPgAct); ?>"><button type="button" class="btn btn-info">Edit</button></a>
                    <?php $aryPgAct['action']="delete"; ?>
                         <a href="javascript:;" onclick="del('<?php echo URL_ADMIN_HOME.getQueryString($aryPgAct); ?>')" class="confirmation"><button type="button" class="btn btn-danger">Delete</button></a>  
                    </td>
                    
                    
                </tr>
            <?php } ?>
            </tbody>
            <tfoot>
                <tr>
                	<th></th>
                    <th colspan="3"></th>
                </tr>
            </tfoot>
        </table>
		<?php
	}
	else{
		?>
        <div class="alert alert-info">
          <a class="close" data-dismiss="alert">×</a>
          <i class="icon icon-warning-sign"></i> <b>Notice</b> Record not found </i>
        </div>
        <?php
	}
	?>
	</div>
	</div></div></div>
	<?php

}
?>
    
    <!--</form>-->


<style type="text/css">
@media print {
    #myPrntbtn {
        display :  none;
    }
}

@media screen {
   #myPrntbtn1 {
        display: none;
    }
}
</style>

<script type="text/javascript">
	$(document).ready(function(e) {
		var oTable = $('.table').dataTable( {
			"bPaginate": false,
			"bLengthChange": false,
			"bFilter": true,
			"bSort": true,
			"bInfo": true,
			"bAutoWidth": false
		});
	});
	
	</script>
	
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>




<script>

function changeType(){
    
    var x = document.getElementById("mySelect").value;
    if(x=='sub_subject' || x=='chapter'){
       document.getElementById("newsubjectdiv").style.display = "block";
       document.getElementById("newchapterdiv").style.display = "none";
    }
    else {
         document.getElementById("newsubjectdiv").style.display = "none";
         document.getElementById("newchapterdiv").style.display = "none";
    }

}

function changeSubject(){
    var x = document.getElementById("mySelect").value;

    if(x=='chapter'){
      document.getElementById("newchapterdiv").style.display = "block";
    }
    else {
         document.getElementById("newchapterdiv").style.display = "none";
    }
    
    var subject = document.getElementById("mySelect1").value;
    $.post( "Notice/ajax.php", { type: "filter_sub_subject" ,subject: subject } , function( data ) {
            if(x=='chapter'){
        document.getElementById("sub_subject").innerHTML = data;
            }
	});
    
}

function filterSubject(){

   	var classname = document.getElementById("class").value;

            $.post( "Notice/ajax.php", { type: "filter_subject" ,classname: classname } , function( data ) {
                // alert(data);
                document.getElementById("parent_subject").innerHTML = data;
        	});

}
	
	
function delete_subjectimage(id){
  var r = confirm("Are you sure want to delete?");
  if (r == true) {
    $.post( "Notice/ajax.php", { type: "delete_subjectimage" , id: id } , function( data ) {
        location.reload();

	});
  }

}


function filterRecord(){

 var classname = document.getElementById("class").value;
 var subject = document.getElementById("mySelect1").value;

    $.post( "Notice/ajax.php", { type: "filterRecord_subject" ,classname: classname ,subject: subject } , function( data ) {
        document.getElementById('filterdata').innerHTML = data;
    });
}



function filterRecord_image(){

 var classname = document.getElementById("class").value;
 var subject = document.getElementById("mySelect1").value;
 //alert(subject);
 //var subsubject = document.getElementById("subSubjectid").value;  
 //var chapter = document.getElementById("chapter").value;   
//alert(chapter);

    $.post( "Notice/ajax.php", { type: "filterRecord_image" ,classname: classname ,subject: subject } , function( data ) {
//alert(data);
  document.getElementById('filterdata_image').innerHTML = data;
    });
}

//	$(document).ready(function() {
   // $('#example').DataTable();
//} );
</script>

<style>
a {
    color: blue;
    text-decoration: none;
}
</style>
