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



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>Notice</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>Notice</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}


	?>
<script>
$(document).ready(function(){
	getHolidayCalender()	
});
var root='<?php echo URL_ROOT; ?>';
function getHolidayCalender(){
	$("#CalenderHolidayDetail").html('<center><img src="'+root+'assets/icon/load.gif" /></enter>');
	var year=$("#byear").val();
    var cls=$("#class").val();
   
	$.post( "<?php echo URL_ROOT ?>Attandence/ajax.php", { type: "getHolidayCalender", year: year ,cls:cls } , function( data ) {
	  	$("#CalenderHolidayDetail").html(data);
	});
}
function addHoliday(date,cls,t){
 
	if($(t).hasClass('btn-default')){
		var name = 'School Holiday';
		$.post( "<?php echo URL_ROOT ?>Attandence/ajax.php", { type: "addHoliday", date:date, cls:cls, reasion:name, status:'3' } , function( data ) {
		   // alert(data);
			$(t).removeClass('btn-default');
			$(t).addClass('btn-info');
			if(data!="")alert(data);
		});
	}else{
		$.post( "<?php echo URL_ROOT ?>Attandence/ajax.php", { type: "removeHoliday", date:date } , function( data ) {
			$(t).addClass('btn-default');
			$(t).removeClass('btn-info');
			if(data!="")alert(data);
		});

		//alert("This is Holiday or already add Attandenc for this date")
	}
}
</script>
	<div class="row-fluid"><div class="span12"><div class="top-bar">
    <h3><i class="icon-eye-open"></i> <?php echo ucwords($pgAct." ".$pgMod); ?></h3>
    </div>
    <div class="well no-padding"> 
         <div class="control-group">
    <label class="control-label" for="rollno">Class</label>
        <div class="controls">
            <select onchange="getHolidayCalender()" class="span6" name="class" id="class">
                <option value="ALL">ALL</option>
             <?php
			 	$clsses=$db->getRows("select * from class where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
                foreach($clsses as $cla){
					$clas=$cla["class"];
                    echo "<option $selected value='$clas'>$clas</option>"; 
                }
             ?> 
            </select>     
        </div>
        </div>
        
    <div class="control-group">
        <label class="control-label" for="rollno">Holiday Year</label>
        <div class="controls">
            <?php
            $years=explode("-",$_SESSION["admin"]["session"]);
            if(is_array($years) && count($years)>0){
                ?><select onchange="getHolidayCalender()" class="span6" name="byear" id="byear"><?php
                foreach($years as $y){
                    echo "<option value='$y'>$y</option>"; 
                }
                ?></select><?php
            }
            ?>
         </div>
    </div>
    <div id="CalenderHolidayDetail">
	
    </div>
	</div></div></div>
	<?php

?>


