<?PHP

 echo $this->session->flashdata('imagemsg1'); 
		 
		    
$session_data = $this->session->userdata('logged_in');
 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
$data['smstype'] = $session_data['smstype'];
	 $smstype = $data['smstype'];	
$data['surname'] = $session_data['surname'];
$data['id'] = $session_data['id'];
 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
$surname=$data['surname'];
   $userid=$data['id'];
   			          	


?>
<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

    // document.body.innerHTML = printContents.fontsize(12);
     window.print();

	 if( window.print()) {
         window.location.href = "../user/startsales";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../user/startsales";

		    // document.body.innerHTML = originalContents;

	}
}
	</script>
 
 <div class="row">
  
   	

   	<div class="col-md-12">

  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-right"> Biometric Registration</span>
				             <TD><a data-toggle='modal' data-target='#addModal' class="btn btn-info"> Add Manual Attenance   </a></TD>

				     <a data-toggle='modal' data-target='#viewattendanceModal' class="btn btn-primary">View attenance </a>

            	</div>
            </div>
			<div class="panel-body">

			
	<div class="widget-content nopadding table_holder table-responsive" >				
				<?PHP

 $finalendate=date("Y-m-d H:59:59");
  $finalstartdate=date("Y-m-d 00:00:00");
  
  
  




				echo $this->session->flashdata('msg'); 
								?>	
					<div class="row">
							 <div class="col-md-12">
        <?php 

 echo $this->session->flashdata('deletemsg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallfingers", $attr);?>
            <div class="form-group">
			
                <div class="col-md-5">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="Search for Enrolled staffs OR Students.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                <div class="col-md-4">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-success" value="Search" />
                    <a href="<?php echo base_url(). "user/allfingers"; ?>" class="btn btn-primary">Refresh</a>
                </div>
				   
            </div>
        <?php echo form_close(); ?>
        </div>		
						<div class="col-md-12">
							
							<div class="panel-body">
	
							   
					
			
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
     <th>Id/ Adm No</th>
     <th> Name</th>
	  <th>Attenance Date </th>
	  	  <th>Time in </th>
		    <th>Type </th>
		   <th>Sms status </th>
		   		   <th>Reasons </th>

<td> More</td>	


                 </tr>
             </thead>
<?php

 if(!is_array($allattendance)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='1'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  
  	foreach ($allattendance as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>

              
  <td><?php echo $c->idno ; ?></td>
     <td><?php 

		$myuserid=$c->idno; 
		$myuser=$this->usermodel->populateallarray('people','idno', $myuserid);
								$myfirstname=$myuser[0]['firstname']." " .$myuser[0]['lastname'];
							echo strtoupper($myfirstname);
							
							?>

  
  
  
  </td>
    <td><?php echo $c->date ; ?></td>
   <td><?php echo $c->timein ; ?></td>
 <td><?php echo $c->type ; ?></td>
  <td><?php  $status=$c->timediffrence; 
  if($status=="0"){
	  
	  echo "New";  
  }else{
	  
	  echo "Sent";
  }
  
  ; ?></td>
                  <td><?php echo $c->comment ; ?></td>

				  <td> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									<?php
										if($usertype=="admin"){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <! teacher EDITING LINK >
                                      
										
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#deleteModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                        <! teacher DELETION LINK >
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</td>
             </tr>

	<?php endforeach;} ?>

            

        </table>
		 <div class="row">
        <div class="col-md-12 text-center">    <?php if(isset($links)) {echo $links; }?>
					   		<span style="color:red; font-size:20px"><?php 
							if(isset($total_rows)) {echo $total_rows; } ."    " ;
							
							?>   </span>

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

	
	
	
	
	









<div id="viewattendanceModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Attenance Report</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/searchattendance' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

	
  <div class="form-group">
    <label for="inputcategory" class="col-sm-2 control-label">Category</label>
    <div class="col-sm-10">
	<select class="form-control" name="category"  id="category" required>
	
	
	<option value=""  >---Select All category--</option>

	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('category','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
		

		
	</div>
  </div>

  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$finalstartdate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="todate" value="<?php echo set_value('todate',$finalendate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  

  
    
       	 		  		<input type="hidden" name="type" value="all" class="form-control" required placeholder="Enter all">

   

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_attendance" class="btn btn-primary"> View Attenance  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

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

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	<div id="addModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <! Modal content>
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add new Manual Attenance</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
   $date = date('Y-m-d');
		$timein = date('H:i:sA');


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addattendance' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

	<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">ID /Adm Number </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno'); ?>" required class="form-control"  placeholder="Enter ID /Adm Number  of the person">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>

 
  
  	<div class="form-group">
    <label for="inputdate" class="col-sm-2 control-label">	Attenance Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="date" value="<?php echo set_value('date',$date); ?>" class="form-control" required placeholder="Enter Attenance Date ">
		 
				
		<span class="text-danger"> <?php echo form_error('date'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputtimein" class="col-sm-2 control-label">	Attenance Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="timein" value="<?php echo set_value('timein',$timein); ?>" class="form-control" required placeholder="Enter Attenance time ">
		 
				
		<span class="text-danger"> <?php echo form_error('timein'); ?>
		
		</span>
	</div>
  </div>
   
  
   <div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Attenance type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" required>
	
	<option value=""  >-Select attendance type</option>
	<option value="Check in"  >Check in   </option>
		<option value="Check out"  >Check out   </option>

</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
   
  
   
	<div class="form-group">
    <label for="inputcomment" class="col-sm-2 control-label"> Reasons for Check out/in</label>
    <div class="col-sm-10">

				<textarea name="comment" value="<?php echo set_value('comment'); ?>"  class="form-control"  placeholder="Enter the reason for check-out/ Check-in"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comment'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="attenance" name="btn_addattenance" class="btn btn-primary"> Post Attenance   </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>			
									
									
					<div id="deleteModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <! Modal content>
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('adminlogged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/deletebyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="attendance">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/allattendance">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

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

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

 
</div>


















