

 
 <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"> View documents</span>					                     
						 <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Add General documents </a>
 <a href="<?php echo base_url();?>user/viewmaincategoryofdocuments" class="btn btn-info"> Add Document Category</a>	
						 						 <a data-toggle='modal' data-target='#IncomingCategoryModal' class="btn btn-default">Search By Category</a>


            	</div>
            </div>
			<div class="panel-body">
 <?php 
		// echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchdocuemnts", $attr);?>
            <div class="form-group">
			
                <div class="col-md-5">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="Search for documents.." 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/viewdocuments"; ?>" class="btn btn-primary">Refresh</a>
                </div>
				 
            </div>
        <?php echo form_close(); ?>
				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP
 $mydate = date('Y-m-d 23:59:59');
   $fromdate=date("Y-m-d 00:00:00");

				echo $this->session->flashdata('msg'); 
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
    
     <th>Name/title</th>
	 <th>Date Posted</th>
	 <th>No</th>
	  <th>Category</th>
	     <th>Comment</th>
		 <th>Added By?</th>
<th>View</th>		 
		 
	

                 </tr>
             </thead>
<?php
 if(!is_array($viewdocuments)) {
				    echo '<div class="alert alert-danger text-center">There was no document found in the system. Feel free to add many documents.</div>';

			 }else{
 if(!is_array($viewdocuments)) 

 {


   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 ($viewdocuments as $c): 

		 

             ?>



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

?>

              

  <td><?php echo $c->documentname ; ?></td>
  <td><?php echo $c->entrydate ; ?></td>
    <td><?php echo $c->idno ; ?></td>
	   <td><?php echo $c->category ; ?></td>
     <td><?php echo $c->description ; ?></td>
   <td><?php ; 
   $userid=$c->userid;
   if($userid!=""){
	  
      $myname = $this->usermodel->geteuser($userid);
  
     $fname=$myname[0]['firstname']; 
echo $names= $fname; 
	
   }else{
	    echo "No Sender";  
   }
  
  
  ?></td>
 
	  <td>
	 <a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/viewmoredocuments?randomitemidentifier=<?php   {echo  $img_id;}  ?>&type=document">Document  </a>
	 <a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/viewmytasks?randomitemidentifier=<?php   {echo  $c->idno;}  ?>&type=document">Task  </a>

	  </td>
	  	  <td>

	  </td>
			
             </tr>

	<?php endforeach;} ?>

              <?php }?>

        </table>
  <div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Document(s) in the system. " ;?>    </span>

        
        </div>
									
									
									
					</div>	
					
					
					
			<div id="IncomingCategoryModal" 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">Search Document by Category</h4>
      </div>
      <div class="modal-body">
      
	  	

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


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/searchdocuemntsbycategory' , 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="inputbranchname" class="col-sm-2 control-label">Branch / Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchname"  id="branchname" required>
	
	
	<option value=""  >-Select Branch--</option>
						<option value="all" selected="selected" >All branches/Counters</option>


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


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

		
	</div>
  </div>
	
	  <div class="form-group">
    <label for="inputcategory" class="col-sm-2 control-label">Document Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="category" required>
	
	<option value=""  >---Select Category---</option>
						<option value="all" selected="selected" >--I want view all/any Category---</option>

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


	
if(is_array($category)) {

   foreach($category as $categoryrow){

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



	<?php

}} else {
    echo 'No category available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('category'); ?>

	</div>
  </div>
  
  <div class="form-group">
    <label for="inputdaterange" class="col-sm-2 control-label">Use Date Range?</label>
    <div class="col-sm-10">
	<select class="form-control" name="daterange" required>
	
	<option value=""  >---Select---</option>
		<option value="yes" selected  >Yes</option>
		<option value="no"  >No</option>


</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',$fromdate); ?>" 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',$mydate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
  
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="document" name="btn_searchdocument" class="btn btn-primary"> View  </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 documents</h4>
      </div>
      <div class="modal-body">
      
	  	

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

$img_id = rand(100, 9900000).time();

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/adddocuments' , 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="inputphoto" class="col-sm-2 control-label">	Upload Document</label>
    <div class="col-sm-10">
	<input type="hidden" name="img_id"   value="<?php if(isset($img_id)) {echo $img_id; }?>"  class="form-control">
<input type="hidden" name="view" value="user/viewdocuments"id="view" class="form-control" required placeholder="Enter status">
	<input type="hidden" name="mydocuments"   value=""  class="form-control">


	<input type="file" required name="photo" value="<?php echo set_value('photo'); ?>"id="photo" class="form-control"  multiple="multiple" placeholder="Please upload image if any">
			<span class="text-danger"> <?php echo form_error('photo'); ?>
		
		</span>
	</div>		
</div>





	  		
	<div class="form-group">
    <label for="inputdocumentname" class="col-sm-2 control-label">	document name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="documentname" value="<?php echo set_value('documentname'); ?>" class="form-control" required placeholder="Enter document name">
		 
				
		<span class="text-danger"> <?php echo form_error('documentname'); ?>
		
		</span>
	</div>
  </div>

  
  
  
  	<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">	Doc Number/ code </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno'); ?>" class="form-control"  placeholder="Enter idno/ code/ transaction code if any">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
  <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"  required>
	
	<option value=""  >--Select Category-</option>
	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('documentcategory','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

}} else {
    echo 'No Branch/Counter.';
}
	
?>
</select>
		

		
	</div>
  </div>
  
  
  
  
  
  
  
  
  
   	<div class="form-group">
    <label for="inputentrydate" class="col-sm-2 control-label">	Entry Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="entrydate" value="<?php echo set_value('entrydate'); ?>" class="form-control"  required placeholder="Enter entrydate">
		 
				
		<span class="text-danger"> <?php echo form_error('entrydate'); ?>
		
		</span>
	</div>
  </div>
  
  
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Comment</label>
    <div class="col-sm-10">

				<textarea name="description" value="<?php echo set_value('description'); ?>"  class="form-control"  placeholder="Enter Comment "></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="documents" name="btn_adddocuments" class="btn btn-primary"> Add documents   </button>

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

    

				</div>

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









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

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

 
</div>


















