
<html>
    <head>
        <title><?php echo $b_header['title']; ?></title>
         <style>
            @media print
            {
                * {-webkit-print-color-adjust:exact;}
                @page {margin:0in 0.10in 0in 0in; }
                .super_container
                {
                    page-break-after: always;
                    margin-top:0.25in;
                    position:relative;
                    width:100vw;
                    height:710px;
                }
            }
            body {margin: 0.25in 0.25in 0.63in 0.25in; box-sizing:border-box;width:100vw; height:100vh;padding-bottom:0.63in;}
            *{margin:0;padding:0;font-family:calibri;}
            .clear:after{content:"";clear:both;display:block;}
            .left{float:left;}
            .right{float:right;}
            .wd-5{width:5%;}
            .wd-10{width:10%;}
            .wd-20{width:20%;}
            .wd-30{width:30%;}
            .wd-40{width:40%;}
            .wd-50{width:50%;}
            .wd-60{width:60%;}
            .wd-70{width:70%;}
            .wd-80{width:80%;}
            .wd-90{width:90%;}
            .wd-100{width:100%;}
            .wd-15{width:15%;}
            .wd-25{width:25%;}
            .wd-35{width:35%;}
            .wd-45{width:45%;}
            .wd-55{width:55%;}
            .wd-65{width:65%;}
            .wd-75{width:75%;}
            .wd-85{width:85%;}
            .wd-95{width:95%;}
            .wd-100{width:100%;}
            .title{font-size:35px;}
            .super_container
            {
                margin-bottom:200px;
                position:relative;
                width:100vw;
                height:710px;
            }
            .wrapper{
                border:4px transparent #18a05e;
                
                outline-offset: 5px;
                box-sizing: border-box;
                padding:5px;
            }
            .super_wrapper
            {
                position:absolute;
                top:0;
                left:0;
                width:100%;
                z-index:120;
                margin:0;
                padding:0;
            }
            /*.watermark*/
            /*{*/
            /*    height:200px;*/
            /*    width:300px;*/
            /*    margin:auto;*/
            /*    padding-top:50px;*/
            /*    padding-left:100px;*/
            /*    opacity:0.1;*/
            /*    background:url("<?php echo base_url().$b_header['logo1']; ?>");*/
            /*    background-size:100% 100%;*/
            /*}*/
            /*.watermark_wrapper*/
            /*{*/
            /*    height:470px;*/
            /*    width:100%;*/
            /*    margin-top:50px;*/
            /*    display:inline-flex;*/
            /*    display:-webkit-inline-flex;*/
            /* }*/
            .wrapper.left2{
                width: calc(90vw);
                margin-right: 20px;
                margin-left: 20px;
            }
            h1,h2,h3,h4,p{
                color:#191970;
                font-family:calibri;
                text-align:center;
            }
            .boxed{color:#000000;width:80%;margin:0 auto;}
            .header{
                width:100%;
                border-bottom:4px solid #191970;            
            }
            .body{
                padding:10px;
            }
            .row{
                width:100%;
                margin: 0px auto;  
            }
            .text-center{text-align:center;}
            .bold{font-weight:bold;}
            .b-u-l{
                border-bottom: 1px solid #000;
                height:inherit;
            }
            .x-small{
                font-size: 12px;
            }
            .x-x-small{
                font-size: 9px;
            }
            .page_break{
                width: 100vw;
                height: 100vh;
                padding: 10px 0px;
                box-sizing: border-box;
            }
            .tbl1
            {
                border: 1px solid #000;
                text-align:center;
                width:100%;
                min-height:20px;
            }
            th{
                font-size: 12px;
                border: 1px solid #000;
                  border-right: 0px;
                border-bottom: 0px; 
                background-color:#ccccb3; 
                padding: 3px !important;
            }
            td{
                font-size:12px;
                border: 1px solid #000;
                text-align: left;
                  border-right: 0px;
                border-bottom: 0px; 
                padding: 2px !important;
            }
            .normal{
                font-weight: normal !important;
            }
            .text-right{
                text-align: right !important;
            }
            .text-left{
                text-align: left !important;
            }
            .margin-a{margin: 30px auto 0px auto;}
        </style>
    </head>
    <body class="clear">
        <?php date_default_timezone_set("Asia/Karachi"); ?>
        <div class="super_container">
            <div class="page_break clear">
                <div class="watermark_wrapper">
                    <div class="watermark"></div>
                </div>
                <div class="super_wrapper">
                    <div class="wrapper left2 left">
                        <div class="header">
                            <div class="wd-100 clear">
                                <div class=" text-left left">
                                    <img src="<?php echo base_url().$b_header['logo1']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div class=" text-left right ">
                                    <img src="<?php echo base_url().$b_header['logo2']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div style="">
                                    <center><h1><?php echo $b_header['title']; ?></h1></center>
                                    <center><h3 style="color:#000 !important;"><i><?php echo $b_header['tagline']; ?></i></h3></center>
                                    <center><i><h3 style="color:#000 !important;font-weight:normal;"><?php echo $b_header['short_address']; ?></h3></i></center>
                                    <!--<center><h4>Contact# <?php //echo $b_header['phone_no']; ?> / <?php //echo $b_header['email']; ?></h4></center>-->
                                    <center><h3 class="boxed" style="margin-top:0px !important;font-size:23px;">Section Wise  Attendance for <?= $month = date('F-Y',strtotime($month));?></h3></center>
                                </div>
                            </div>
                            <br>
                            <br>
                            <?php    
                            
                            // $totaldays=$totaldays['totaldays'];   
                            //echo'<pre>'; print_r($totaldays);die;
                             $tdays=$totaldays[0]['totaldays'];
                            
                                $c=0;
                            ?>
                            <div class="wd-100 clear">
                               
                                    <h3 style="color: #000000" class="wd-01 left">Class:<span><?= $student[0]['class_name'] ?></span></h3>
                               
                                <div>
                                    <h3 style="color: #000000" class="wd-01 right">Section:<span><?= $student[0]['section_name'] ?></span></h3>
                                </div>
                            </div>
                        </div>
                        <div class="body">
                        <?php
                            $Month = date('m',strtotime($month));
                            $year = date('Y',strtotime($month));
                            unset($list);
                            for($d=1; $d<=31; $d++)
                            {
                               
                                $time=date('d-m-Y',mktime(12, 0, 0, $Month, $d, $year));
                                if ((date('m', strtotime($time))==$Month) && strtotime($time) <= time())       
                                    $list[]=date('d', strtotime($time));
                            }
                            
                        $dateHTML = '';
                        $statusHTML = '';
                        foreach ($list as $value) {
                            $dateHTML .= '<th style="padding:0px;width:0.2px;"><b>'.$value.'</th><b>';
                        }
                        ?>

                        <table class="tbl1">
                            <thead>
                                <tr>
                                    <th><h5>#</h5></th>
                                    <th><h5>S.ID</h5></th>
                                    <th><h5>Student Name</h5></th>
                                     <th><h5>Parent Name</h5></th>
                                     
                                    <?= $dateHTML ?>
                                    <th>Total Present</th>
                                     <th>Total Absent</th>
                                      <th>Total Leave</th>
                                       <th>Total Late</th>
                                        <th>Total Holiday</th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                                <?php   $absent=0;
                                   $present=0;
                                   $leave=0;
                                    $holiday=0;
                                   $tardy=0;?>
                                <?php foreach ($student as $key => $value) { 
                                      $totalpresent=  @$present[$c]['present'];
                                       $totalabsnt=  @$absent[$c]['absent'];
                                        $totalleave=  @$leave[$c]['leav'];
                                         $totaltardy=  @$tardy[$c]['tardy'];
                                          $totalholiday=  @$holiday[$c]['holiday'];
                                  //var_dump($value['dates']);die;
                                $c=$c+1;
                                 //echo'<pre>'; print_r($value);die;  
                                   $a = 0;
                                   $p =0;
                                   $l =0;
                                   $t =0;
                                    $h =0;
                                 
                                    $count = 0;
                                    $statusHTML = ''; 
                                    
                                    foreach ($list as $k => $v) {
                                 //echo'<pre>'; print_r($list);die;
                                        $d_date= $v."-".$Month."-".$year;
                            
                                       if(date('D', strtotime($d_date))=='Sun')
                                            {
                                                $statusHTML .= '<td style="color:black;text-align: center"><b>Sun</b></td>';$count++;
                                                
                                            }
                                        else{
                                            foreach($value['dates'] as $dval){
                                            
                                            if(date('d',strtotime($dval['date'])) == $v){
                                                if($dval['status']=='A')
                                                    {
                                                        $statusHTML .= '<td style="color:e60000;text-align: center"><b>'.$dval['status'].'</b></td>';$count++;
                                                        $a=$a+1;
                                                        $absent++;
                                                        
                                                    }
                                                else{
                                                    
                                                            if($dval['status']=='P')
                                                            {
                                                                $p++;
                                                                $present++;
                                                                $statusHTML .= '<td style="color:00cc00;text-align: center"><b>'.$dval['status'].'</b></td>';$count++;
                                                                
                                                            }
                                                        else{
                                                             if($dval['status']=='L')
                                                            {
                                                            $l++;
                                                            $leave++;
                                                            $statusHTML .= '<td style="color:0033cc;text-align: center"><b>'.$dval['status'].'</b></td>';$count++;
                                                            }
                                                             else{
                                                             if($dval['status']=='HD')
                                                            {
                                                            $h++;
                                                            $holiday++;
                                                            $statusHTML .= '<td style="color:0033cc;text-align: center"><b>'.$dval['status'].'</b></td>';$count++;
                                                            }
                                                            elseif($dval['status']=='T')
                                                            {
                                                            $t++;
                                                            $tardy++;
                                                            $statusHTML .= '<td style="color:cc3300;text-align: center"><b>'.$dval['status'].'</b></td>';$count++;
                                                            }
                                                             }
                                                            }
                                                    
                                                    
                                                    }
                                            }
                                        }
                                        }
                                        if($count == 0)
                                        {
                                            //var_dump("fa");die;
                                            $statusHTML .= '<td style="background:;padding:0px;width:1px;">-</td>';
                                        }
                                        $count = 0;
                                    }
                                    ?>
                                    <tr>
                                        <td><?= ++$key ?></td>
                                        <td><?= $value['sid'] ?></td>
                                        <td ><?= $value['student_name'] ?></td>
                                        <td ><?= $value['father_name'] ?></td>
                                       
                                        <?= $statusHTML ?>
                                         <td style="text-align: right"><?php echo $p ?></td>
                                         <td style="text-align: right"><?php echo $a ?></td>
                                         <td style="text-align: right"><?php echo $l ?></td>
                                         <td style="text-align: right"><?php echo $t ?></td>
                                          <td style="text-align: right"><?php echo $h ?></td>
                          
                         
                                    </tr>
                                    <?php } ?>
                            
                            </tbody>
                        </table>
                        <tr style="margin-top:50px;">
                                        <td colspan="11" style="border:0px;">
                                            <div class="wd-100 clear">
                                                <center>
                                                    <h1 class="ctitle" style="color:#000080">
                                                        Attendance Statistics
                                                    </h1>
                                                </center>
                                                <br>
                                                <div class="wd-100 clear">
                                                    <center>
                                                        <div class="wd-100 left">
                                                        <div id="chartContainer" style="height: 400px; width: 800px;">
                                                            
                                                        </div>
                                                        </div>
                                                    </center>
                                                </div>
                                            </div>
                                        </td>
                               </tr>
                               <div id="chartContainer" style="height: 300px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>


                     <script>
        window.print();
    </script>
   
    </body>
</html>
 <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>

<script src="<?php echo base_url(); ?>assets/js/jquery.canvasjs.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/canvasjs.min.js"></script>

  <script>
window.onload = function () {

var chart = new CanvasJS.Chart("chartContainer", {
	animationEnabled: true,
	title:{
		text: " ",
		horizontalAlign: "left"
	},
	data: [{
		type: "doughnut",
		startAngle: 60,
// 		innerRadius: 40,
		indexLabelFontSize: 17,
		indexLabel: "{label} - #percent%",
		toolTipContent: "<b>{label}:</b> {y} (#percent%)",
		dataPoints: [
	 { label: 'Present: '+ <?php echo $present ?> +'', y: <?php echo empty($present)? 0 : $present ?> },
         { label: 'Absent: '+ <?php echo $absent ?> +'', y: <?php if(empty($absent)){ echo '0'; }else{echo $absent; } ?> },
        { label: 'Leave: '+ <?php echo $leave ?> +'', y: <?php echo empty($leave)? 0 :$leave ?> },
        { label: 'Tardy: '+ <?php echo $tardy ?> +'', y: <?php echo empty($tardy)? 0 :$tardy ?> },
         { label: 'Holiday: '+ <?php echo $holiday ?> +'', y: <?php echo empty($holiday)? 0 :$holiday ?> }
       
		]
	}]
});
chart.render();

}
</script>