<?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 name=$("#name").val();
	$.post( "<?php echo URL_ROOT ?>Attendance/ajax.php", { type: "getHolidayCalender_faculty", year: year ,cls:name } , function( data ) {
	  	$("#CalenderHolidayDetail").html(data);
	});
}

function add_staff_Holiday(date,cls,t){
    
  var name=$("#name").val();
    var year = $("#byear").val(); 
	if($(t).hasClass('btn-default')){
		var name = 'School Holiday';
		$.post( "<?php echo URL_ROOT ?>Attendance/ajax.php", { type: "add_staff_Holiday", date:date, cls:cls, reasion:name, status:'3', year: year } , function( data ) {
		   // alert(data);
			$(t).removeClass('btn-default');
			$(t).addClass('btn-info');
			if(data!="")alert(data);
		});
	}else{
		$.post( "<?php echo URL_ROOT ?>Attendance/ajax.php", { type: "remove_staff_Holiday", 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">Faculty</label>
            <div class="controls">
            <select onchange="getHolidayCalender()" class="span6" name="name" id="name">
                <option value="ALL">ALL</option>
             <?php
			 	$clsses=$db->getRows("select * from staff where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
                foreach($clsses as $cla){
					$name=$cla["name"];
						$id=$cla["idno"];
                    echo "<option $selected value='$id'>$name</option>"; 
                }
             ?> 
            </select>     
            </div>
        </div>

    <div class="control-group">
        <label class="control-label" for="rollno">Holiday Year</label>
        <div class="controls">
            <select onchange="getHolidayCalender()" class="span6" name="byear" id="byear">
                <option value="2022" <?php if(date('Y') == 2022) echo "selected"; ?> >2022</option>
                <option value="2023" <?php if(date('Y') == 2023) echo "selected"; ?> >2023</option>
                <option value="2024" <?php if(date('Y') == 2024) echo "selected"; ?> >2024</option>
                <option value="2025" <?php if(date('Y') == 2025) echo "selected"; ?> >2025</option>
            </select>
         </div>
    </div>
    <div id="CalenderHolidayDetail">
	
    </div>
	</div></div></div>
	<?php

?>


