 <?php include('header.php');?>
 <?php include('sidebar.php');?>
 <?php $page="documents.php";?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <?php echo AL_DASHBOARD;?>
        <small><?php echo AL_CONTROLPANEL;?></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> <?php echo AL_HOME;?></a></li>
        <li class="active"><?php echo AL_DASHBOARD;?></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <!-- Small boxes (Stat box) -->
      <div class="row">
      <!--- Expired Documents--->
      <div class="col-xs-12">
         <div class="box box-info">
            <div class="box-header with-border">
              <?php /*?><h3 class="box-title"><?php echo AL_ADD;?> <?php echo $maintitle;?></h3><?php */?>
            </div>
            
            
            <div class="nav-tabs-custom">
           
             <form class="form-horizontal" action="reports.php" method="post" enctype="multipart/form-data">
             <input type="hidden" name="userid" value="<?php echo $_REQUEST['userid'];?>"/>
             <div class="form-group">
             <div class="col-sm-4">
                <label for="inputEmail3" class="col-sm-4 control-label">Start Date</label>
				<div class="col-sm-6">
                <div class="input-group date">
                  <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input name="fromdate" type="text" value="<?php echo $_REQUEST['fromdate'];?>" class="form-control pull-right" id="datepicker">
                </div>
                </div>
                <!-- /.input group -->
              </div>
              <div class="col-sm-4">
                <label for="inputEmail3" class="col-sm-4 control-label">End Date</label>
				<div class="col-sm-6">
                <div class="input-group date">
                  <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input name="todate" type="text" value="<?php echo $_REQUEST['todate'];?>" class="form-control pull-right" id="datepicker2">
                </div>
                </div>
                <!-- /.input group -->
              </div>
              <div class="col-sm-4">
                
				<div class="col-sm-6">
                 <input type="submit" name="submit" value="SEARCH" class="btn btn-info pull-left"/>
                </div>
                <!-- /.input group -->
              </div>
              </div>
             </form>
             </div>
             </div>
         
       
          </div>    
       <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title">Leaves</h3>
 
            </div>
            <?php
			$fromdate= $_REQUEST['fromdate']; 
			$todate= $_REQUEST['todate'];
			$reports=$helper->selectleaves($fromdate,$todate,$_REQUEST['userid']);
			$memberdetails=$helper->select("tbl_members","*",array("memberid"=>$_REQUEST['userid']));
			 
		    ?>
           <table id="print" width="100%">
           <tr><td> 
            <table class="table table-hover" cellpadding="20" cellspacing="20" border="1" bordercolor="#ccc" style="width:600px;margin:auto;">
            <tr>
            <td colspan="2" style="text-align:left;">
           Leaves taken from <br/> <?php echo $_REQUEST['fromdate'];?> to <?php echo $_REQUEST['todate'];?>
            </td>
            <td colspan="3">
            <p>
            <?php
			if($memberdetails[0]['image']!=""){
			?>
              <img align="right" class="profile-user-img img-responsive img-circle" src="<?php echo $site_url;?>thumb.php?src=<?php echo $site_url;?>images/users/<?php echo $memberdetails[0]['image'];?>&w=50&h=50" alt="<?php echo $memberdetails[0]['firstname'];?>"><br/>
              <?php
			} 
			?>            
			<?php echo $memberdetails[0]['firstname']." ".$memberdetails[0]['middlename']." ".$memberdetails[0]['lastname'];?>
            <br/><?php echo $memberdetails[0]['email'];?><br/><?php echo $memberdetails[0]['phone'];?></p>
            </td>
            
            </tr>
            <tr><th>No.</th>
            <th>Leaves</th>
            <th>From Date</th>
            <th>To Date</th>
            <th>No of days</th>
            </tr>
            <?php
			$i=1;
			foreach($reports as $report){
				if($todate>$report['todate']){
					 $enddate=$report['todate'];
				  }else {
					  $enddate=$todate;
				  }
			?>
             <tr><td><?php echo $i;?></td>
              <?php
                  $leavetype= $helper->select("tbl_leaves","title",array("leaveid"=>$report['leaveid']));
		      ?>
            <td><?php echo $leavetype[0]['title'];?></td>
            <td><?php echo $report['fromdate'];?></td>
            <td><?php echo $enddate;?></td>
             <?php
				  
                  $expirydate  =date_create($enddate);
				  
                  $current_date =date_create($report['fromdate']);
                //$date_to_compare = date("Y-m-d",time()+86400); //1 day later
                  $diff=date_diff($current_date,$expirydate);
                  $expirestatus=$diff->format("%a")+1;
                  $expires= $expirestatus." days";
                  ?>
            <td><?php echo $expires;?></td>
            </tr>
            <?php
			$i=$i+1;	
			}
			?>
            </table>
            </td></tr></table>
            <p style="text-align:center;padding:10px;"><button class="btn btn-info" onclick="javascript:printDiv('print')" />Print</button></p>
<script language="javascript" type="text/javascript">
        function printDiv(divID) {
            var divElements = document.getElementById(divID).innerHTML;
            var oldPage = document.body.innerHTML;
            document.body.innerHTML = 
              "<html><head><title></title></head><body>" + 
              divElements + "</body>";
            window.print();
            document.body.innerHTML = oldPage;
        }
    </script>
            <!-- /.box-header -->
            
            
          </div>
          
        </div> 
       
      
        
        
      </div>
      

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  
  <?php
  include('footer.php');
  ?>>>>>