<style>.top-bar-minimize{display:none;}
thead, tfoot {display: table-header-group;}
.top-bar+.well,.accordion .accordion-heading+.accordion-body{display: inline-block !important;width: 100% !important;overflow: inherit !important;} .check{ width: 133px; padding: 5px; display: inline-block; border-right: 1px dotted;}
.check input[type="checkbox"] { margin: 0 6px;}
</style>
<?php
$pgMod="student_day_wise";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
		$pgAct=strtolower($_GET['action']);

if($_POST){
    
    if(isset($_POST["save"])){
     $month =  date("F");
	if(is_array($_POST["student"]) && count($_POST['student'])>0){ $i=0;
		foreach($_POST["student"] as $idno){

            $db->delete("attandenc", " where session='".$_SESSION["admin"]["session"]."' and date='".$_GET['date']."' and idno='".$idno."' ");

            if($_POST['stud'.$idno]){

                $array=array("idno"     =>  $idno,
                            "date"      =>  $_GET['date'],
                            "month"     =>  $month,
							"school_id" =>  $_SESSION["admin"]["school_id"],
							"added_by"  =>  $_SESSION["admin"]["uid"],
							"session"   =>  $_SESSION["admin"]["session"],
							"type"      =>  2,
							"status"    =>  0
							);

                $db->insertAry("attandenc", $array);

            }

            $i++;
            
		}
		
	 }
        
    }
       
}

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
}
if($pgAct=="edit" && $_GET["id"]!="")
{
	$aryForm=$db->getRow("SELECT * FROM student WHERE school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET['id']."'");
}
?>

<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 style="float:right; width:228px; margin-top:5px">
    <!--<button onclick="printDiv('CalenderAttandencDetail')" type="button" class="btn btn-primary">Print</button>-->
    </div>
    </div>
    <div class="well no-padding">
    <div class="control-group">

		<form method="get" action="">
 		     <input type="hidden" name="src" value="Attendance" />
		     <input type="hidden" name="page_id" value="<?php echo $pgMod; ?>" />
		     <input type="hidden" name="attendance_day_wise" />
        <label class="control-label" for="rollno">Class</label>
        <div class="controls">
            <select onchange="getAttandencCalender()" class="span4" name="class" id="class">
             <?php
			 	$clsses=$db->getRows("select * from class where school_id='".$_SESSION["admin"]["school_id"]."' and status=1");
                foreach($clsses as $cla){
					$clas=$cla["class"];?>
                    <option value='<?php echo $clas; ?>'  <?php if($_GET['class']==$clas ) echo "selected" ?> >
                        <?php echo $clas; ?>
                    </option>
                    
                    <?php
                }
             ?> 
            </select>
            <select onchange="getAttandencCalender()" class="span4" name="section" id="section">
                <option value="">Section</option>
                <?php 
                    $class=$db->getRows("select * from section where school_id='".$_SESSION["admin"]["school_id"]."'");
                    foreach($class as $cla){
                        ?>
                        <option value="<?php echo $cla["name"] ?>" <?php if($_GET['section']==$cla["name"] ) echo "selected" ?> >
                            <?php echo $cla["name"] ?>
                        </option>
                        <?php
                    }
                ?>
            </select>
        </div>
        <br/>
        <label class="control-label" for="rollno">Select Date</label>
        <div class="controls">
            <input type="date" name="date" value="<?php if($_GET['date']!=""){echo $_GET['date']; } else { echo date("Y-m-d"); } ?>" />
            <input type="submit" class="btn btn-primary" value="Proceed" style="margin-left:100px;" />
            
        </div>

        </form>        

    </div>

	</div></div></div>

<?php
	if(isset($_GET["attendance_day_wise"])){
	    $where = "";
	    if(isset($_GET["class"]) && trim($_GET["class"])!=""){
			$where .=" and class='".$_GET["class"]."' ";
		}
		if(isset($_GET["section"]) && $_GET["section"]!=""){
			$where .=" and section='".$_GET["section"]."' ";
		}
		
		$totalpresent = $totalabsent = 0;
		?>
		<form method="post" action="">
		<div class="row-fluid">
        <div class="span12">
            
            <div class="top-bar">
                <h3><i class="icon-cog"></i> Detail</h3>
                <div style="float:right; margin-top:5px">
				<!--<input  class="btn btn-primary" type="button"  onclick="$('.table').tableExport({type:'excel',escape:'false'});" id="btnExport" value=" Export To Excel " />-->
                    <button type="button" onclick="printDiv('printDiv2')" class="btn btn-primary">Print</button>
                    <input type="submit" value="save" name="save" class="btn btn-default pull-right" >
                </div>
            </div>
            
            <div class="well no-padding" id="printDiv2">
                
                <h4 style="text-align:center;color:crimson;">Mark Absent Day Wise</h4>
                <h5 style="float:right;margin:0px;">Date: <?php echo date('d-M-Y', strtotime($_GET['date'])); ?></h5>
                <h5 style="float:left;margin:0px;">
                    Class: <?php echo $_GET['class'];
                    if($_GET['section']!=""){ echo " - ".$_GET['section']; } ?>
                </h5>
                <h5 style="float:left;margin:0px;width:100%;">
                    Total Present: <span id="total_present"></span> &emsp;&emsp;
                    Total Absent: <span id="total_absent"></span>
                </h5>

            	<table class="table" cellspacing="0">
                    <thead>
                        <tr>
                            <th>S.No</th>
                            <th>Name</th>
                            <th>Father Name</th>
                            <th>Admission No.</th>
                            <th>Roll No.</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $studentList = $db->getRows("select * from student where school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and status=1 $where ");
                        $i=1;
                        foreach($studentList as $student){
                            
                            $checkvalue=$db->getVal("select count(*) from attandenc where idno='".$student['idno']."' and date='$_GET[date]' and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."'   ");
                            
                            ?>
                            <input type="hidden" name="student[]" value="<?php echo $student['idno'] ;?>" />
                            <tr>
                                <td><?php echo $i; ?></td>
                                <td><?php echo $student['name']; ?></td>
                                <td><?php echo $student['fname']; ?></td>
                                <td><?php echo $student['admissionno']; ?></td>
                                <td><?php echo $student['fincome']; ?></td>
                                <td><input name="stud<?php echo $student['idno']; ?>" type="checkbox" style="width:20px;height:20px;" <?php if($checkvalue > 0){ echo "checked"; $totalabsent++; } else { $totalpresent++;  } ?>  /></td>
                            </tr>
                        <?php
                            $i++;
                        }
                        ?>        
        
                    </tbody>
                    </table>
                </div>
                </div>
                </form>
		<?php
	}
?>


<script>
    $("#total_present").html(<?php echo $totalpresent; ?>);
    $("#total_absent").html(<?php echo $totalabsent; ?>);
</script>



