 <?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--->
      <?php
      if($_REQUEST['expired']==0){
           
			$listtypes=$helper->selectexpired("tbl_documents");
			if(count($listtypes)>0){			 
			?>
       <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right" data-toggle="tooltip" title="Add <?php echo $maintitle;?>">
                <div class="btn-group">
                <a><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i> Expired Documents</button></a>
                   
                </div>
              </div>
            </div>
            
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
              <table class="table table-hover">
                <tr>
                  <th><?php echo AL_SERIALNO;?></th>
                  <th><?php echo AL_DOCUMENTS;?></th>
                  <th><?php echo AL_NAME;?></th>
                   <th><?php echo AL_EXPIRYDATE;?></th> 
                  <th><?php echo AL_STATUS;?></th>
                  <th><?php echo AL_ACTION;?></th>
                </tr>
                <?php
				$i=($start*$limit)+1;
				foreach($listtypes as $type){
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
                    
				  ?>
                <tr>
                  <td><?php echo $i;?></td>
                  <?php
                  $doctype= $helper->select("tbl_document_type","title",array("documenttypeid"=>$type['documenttypeid']));
		 ?>
        <?php
				  
                  $expirydate  =date_create($type['expiredate']);
                  $current_date =date_create(date("Y-m-d"));
                //$date_to_compare = date("Y-m-d",time()+86400); //1 day later
                  $diff=date_diff($current_date,$expirydate);
                  $expirestatus=$diff->format("%a");
                  if ($expirydate<$current_date) {
                   $expires= AL_EXPIRED;
                  }
                  else {
                       $expires= $expirestatus.AL_DAYSTOEXPIRE;
                  }
                    ?>
                  <td><b><?php echo $doctype[0]['title'];?></b><br/><?php echo $type['title'];?></td>
                   <?php
                  $membername= $helper->select("tbl_members","firstname,middlename,lastname",array("memberid"=>$type['memberid']));
		   ?>
                  <td><?php echo $membername[0]['firstname']." ".$membername[0]['middlename']." ".$membername[0]['lastname'];?></td>
                  <td><?php echo $type['expiredate'];?></td>
                  <td>	  
                 <a href="#"><span class="label label-danger"><?php echo $expires ; ?></span></a>
                  </td>
                  <td>
                  <a href="<?php echo $site_url;?><?php echo $page;?>?mode=edit&contentid=<?php echo $type['documentid'];?>&start=<?php echo $limitpage;?>"><span class="label label-primary"><i class="fa fa-edit"></i> <?php echo AL_EDIT;?></span></a>
                   
                   </td>
                </tr>
                 
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
             <?php /*?> <?php
			   $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>"ASC"));
			  include('pagination/pagination.php');
			  ?><?php */?>
            </div>
            
          </div>
          
        </div> 
        <?php
                        }
			}
			?>
       <!---End of Expired Docs-->
        <!--- Expired Between 0-15--->
          <?php
          if($_REQUEST['expired']==15){
			$listtypes1=$helper->selectexpiredin15("tbl_documents");	
			if($listtypes1>0){		 
			?>
       <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right" data-toggle="tooltip" title="Add <?php echo $maintitle;?>">
                <div class="btn-group">
                <a><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i> Expired with in 15 days</button></a>
                   
                </div>
              </div>
            </div>
            
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
              <table class="table table-hover">
                <tr>
                  <th><?php echo AL_SERIALNO;?></th>
                  <th><?php echo AL_DOCUMENTS;?></th>
                  <th><?php echo AL_NAME;?></th>
                   <th><?php echo AL_EXPIRYDATE;?></th> 
                  <th><?php echo AL_STATUS;?></th>
                  <th><?php echo AL_ACTION;?></th>
                </tr>
                <?php
				$i=($start*$limit)+1;
				foreach($listtypes1 as $type){
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
                    
				  ?>
                <tr>
                  <td><?php echo $i;?></td>
                  <?php
                  $doctype= $helper->select("tbl_document_type","title",array("documenttypeid"=>$type['documenttypeid']));
		 ?>
        <?php
				  
                  $expirydate  =date_create($type['expiredate']);
                  $current_date =date_create(date("Y-m-d"));
                //$date_to_compare = date("Y-m-d",time()+86400); //1 day later
                  $diff=date_diff($current_date,$expirydate);
                  $expirestatus=$diff->format("%a");
                  if ($expirydate<$current_date) {
                   $expires= AL_EXPIRED;
                  }
                  else {
                       $expires= $expirestatus.AL_DAYSTOEXPIRE;
                  }
                    ?>
                  <td><b><?php echo $doctype[0]['title'];?></b><br/><?php echo $type['title'];?></td>
                   <?php
                  $membername= $helper->select("tbl_members","firstname,middlename,lastname",array("memberid"=>$type['memberid']));
		   ?>
                  <td><?php echo $membername[0]['firstname']." ".$membername[0]['middlename']." ".$membername[0]['lastname'];?></td>
                  <td><?php echo $type['expiredate'];?></td>
                  <td>	  
                 <a href="#"><span class="label label-danger"><?php echo $expires ; ?></span></a>
                  </td>
                  <td>
                  <a href="<?php echo $site_url;?><?php echo $page;?>?mode=edit&contentid=<?php echo $type['documentid'];?>&start=<?php echo $limitpage;?>"><span class="label label-primary"><i class="fa fa-edit"></i> <?php echo AL_EDIT;?></span></a>
                   
                   </td>
                </tr>
                 
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
             <?php /*?> <?php
			   $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>"ASC"));
			  include('pagination/pagination.php');
			  ?><?php */?>
            </div>
            
          </div>
          
        </div> 
        <?php
			}
          }
			?>
       <!---End of Expired Between 0-15-->
           <!--- Expired Between 15-30--->
           <?php
           if($_REQUEST['expired']==30){
			$listtypes2=$helper->selectexpiredin30("tbl_documents");
			if($listtypes2>0){			 
			?> 
       <div class="col-xs-6">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right" data-toggle="tooltip" title="Add <?php echo $maintitle;?>">
                <div class="btn-group">
                <a><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i> Expired with in 15-30 days</button></a>
                   
                </div>
              </div>
            </div>
           
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
              <table class="table table-hover">
                <tr>
                  <th><?php echo AL_SERIALNO;?></th>
                  <th><?php echo AL_DOCUMENTS;?></th>
                  <th><?php echo AL_NAME;?></th>
                   <th><?php echo AL_EXPIRYDATE;?></th> 
                  <th><?php echo AL_STATUS;?></th>
                  <th><?php echo AL_ACTION;?></th>
                </tr>
                <?php
				$i=($start*$limit)+1;
				foreach($listtypes2 as $type){
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
                    
				  ?>
                <tr>
                  <td><?php echo $i;?></td>
                  <?php
                  $doctype= $helper->select("tbl_document_type","title",array("documenttypeid"=>$type['documenttypeid']));
		 ?>
        <?php
				  
                  $expirydate  =date_create($type['expiredate']);
                  $current_date =date_create(date("Y-m-d"));
                //$date_to_compare = date("Y-m-d",time()+86400); //1 day later
                  $diff=date_diff($current_date,$expirydate);
                  $expirestatus=$diff->format("%a");
                  if ($expirydate<$current_date) {
                   $expires= AL_EXPIRED;
                  }
                  else {
                       $expires= $expirestatus.AL_DAYSTOEXPIRE;
                  }
                    ?>
                  <td><b><?php echo $doctype[0]['title'];?></b><br/><?php echo $type['title'];?></td>
                   <?php
                  $membername= $helper->select("tbl_members","firstname,middlename,lastname",array("memberid"=>$type['memberid']));
		   ?>
                  <td><?php echo $membername[0]['firstname']." ".$membername[0]['middlename']." ".$membername[0]['lastname'];?></td>
                  <td><?php echo $type['expiredate'];?></td>
                  <td>	  
                 <a href="#"><span class="label label-danger"><?php echo $expires ; ?></span></a>
                  </td>
                  <td>
                  <a href="<?php echo $site_url;?><?php echo $page;?>?mode=edit&contentid=<?php echo $type['documentid'];?>&start=<?php echo $limitpage;?>"><span class="label label-primary"><i class="fa fa-edit"></i> <?php echo AL_EDIT;?></span></a>
                   
                   </td>
                </tr>
                 
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
             <?php /*?> <?php
			   $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>"ASC"));
			  include('pagination/pagination.php');
			  ?><?php */?>
            </div>
            
          </div>
          
        </div> 
        <?php
			}
           }
			?>
       <!---End of Expired Between 15-30-->
        <!--- Expired Between 30-45--->
        <?php
        if($_REQUEST['expired']==45){
			$listtypes3=$helper->selectexpiredin45("tbl_documents");
			if($listtypes3>0){			 
			?>
       <div class="col-xs-6">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right" data-toggle="tooltip" title="Add <?php echo $maintitle;?>">
                <div class="btn-group">
                <a><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i> Expired with in 30 - 45 days</button></a>
                   
                </div>
              </div>
            </div>
            
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
              <table class="table table-hover">
                <tr>
                  <th><?php echo AL_SERIALNO;?></th>
                  <th><?php echo AL_DOCUMENTS;?></th>
                  <th><?php echo AL_NAME;?></th>
                   <th><?php echo AL_EXPIRYDATE;?></th> 
                  <th><?php echo AL_STATUS;?></th>
                  <th><?php echo AL_ACTION;?></th>
                </tr>
                <?php
				$i=($start*$limit)+1;
				foreach($listtypes3 as $type){
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
                    
				  ?>
                <tr>
                  <td><?php echo $i;?></td>
                  <?php
                  $doctype= $helper->select("tbl_document_type","title",array("documenttypeid"=>$type['documenttypeid']));
		 ?>
        <?php
				  
                  $expirydate  =date_create($type['expiredate']);
                  $current_date =date_create(date("Y-m-d"));
                //$date_to_compare = date("Y-m-d",time()+86400); //1 day later
                  $diff=date_diff($current_date,$expirydate);
                  $expirestatus=$diff->format("%a");
                  if ($expirydate<$current_date) {
                   $expires= AL_EXPIRED;
                  }
                  else {
                       $expires= $expirestatus.AL_DAYSTOEXPIRE;
                  }
                    ?>
                  <td><b><?php echo $doctype[0]['title'];?></b><br/><?php echo $type['title'];?></td>
                   <?php
                  $membername= $helper->select("tbl_members","firstname,middlename,lastname",array("memberid"=>$type['memberid']));
		   ?>
                  <td><?php echo $membername[0]['firstname']." ".$membername[0]['middlename']." ".$membername[0]['lastname'];?></td>
                  <td><?php echo $type['expiredate'];?></td>
                  <td>	  
                 <a href="#"><span class="label label-danger"><?php echo $expires ; ?></span></a>
                  </td>
                  <td>
                  <a href="<?php echo $site_url;?><?php echo $page;?>?mode=edit&contentid=<?php echo $type['documentid'];?>&start=<?php echo $limitpage;?>"><span class="label label-primary"><i class="fa fa-edit"></i> <?php echo AL_EDIT;?></span></a>
                   
                   </td>
                </tr>
                 
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
             <?php /*?> <?php
			   $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>"ASC"));
			  include('pagination/pagination.php');
			  ?><?php */?>
            </div>
            
          </div>
          
        </div> 
        <?php
			}
        }
			?>
       <!---End of Expired Between 30-45-->
        
      </div>
      

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

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