  <script type="text/javascript">
  
		

		  $(document).on("click", "#editbtn", function()
        {
          var taskid = $(this).data('id');
		  $("#taskid").val(taskid); 
		   
 
		    var createdate = $(this).data('createdate');
		   $("#createdate").val(createdate); 
		   
		     var comment = $(this).data('comment');
		   $("#comment").val(comment); 
		 
		    var challanges = $(this).data('challanges');
		   $("#challanges").val(challanges); 
		   
		     var recommendation = $(this).data('recommendation');
		   $("#recommendation").val(recommendation); 
		 
		    var status =  $(this).data('status');
		   $("#status").val(status); 
		   
		     var comments = $(this).data('comments');
		   $("#comments").val(comments); 
		   var achieved = $(this).data('achieved');
		   $("#achieved").val(achieved); 
		     var mykey = $(this).data('mykey');
		   $("#mykey").val(mykey);
		  
		  
		   
        });
		
		
		
		
    </script>   
  <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		   

		  
		  	   
        });
		
		
    </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"> Task history</span>	
                        <a  id="more" target="blank" class="btn btn-primary" href="<?php echo base_url();?>user/viewtasks">back  </a>
						  <a data-toggle='modal' data-target='#purchaseModal' class="btn btn-default">View Performance Report</a>


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

				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP
 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
 echo $this->session->flashdata('deletemsg'); 

 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];
			    $viewalltasks=$this->usermodel->populatuserpermissionsdataarray('task','viewall',$userid);

				echo $this->session->flashdata('msg'); 
								?>	
										
					
									
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
    
     <th>Staff Name</th>
	      
	     <th>Task Name</th>


	     <th>Achieved</th>
		 	     <th>Comments</th>
		 	
	 	 <th>Status</th>
  <th>Task Date</th>
			<th> Date Posted</th>
			<th> Status</th>

	 	 <th>More:</th>


                 </tr>
             </thead>
<?php

 if(!is_array($dailytasks)) 

 {


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

		 

             ?>



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


?>

 <td>
												 
	<?php 
					// $branch="";
					 $employeeid=$c->userid;

					 $employee= $this->usermodel->populateallarray('people','id',$employeeid);
			echo$employeename=$employee[0]['firstname'];	


					 
?>
												 
	 </td>				








 <td>
												 
	<?php 
					// $branch="";
					 $taskid=$c->taskid;

					 $mytask= $this->usermodel->populateallarray('tasktype','id',$taskid);
			echo$taskname=$mytask[0]['name'];	
								 $mykey=$c->mykey;

								 $taskdata= $this->usermodel->populateallarray('taskdata','mykey',$mykey);

								 $mychallanges=$taskdata[0]['challanges'];
								 $mycomments=$taskdata[0]['comments'];

								 
			
			


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


	
		
		

		    <td><?php echo $c->comment ; 
			
			
if($c->updatedby !=0){
	$updatedby=$c->updatedby;
			$myuser = $this->usermodel->populateallarray('people', 'id',$updatedby);
				
			
			if($c->comment !=""){
				echo "<br>:By ".$myuser[0]["firstname"]; 
			}
			
	}
			
			
			
			?></td>



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

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

 
    <td><?php echo $c->createdate ; ?></td>
    <td><?php echo $c->approval ; ?></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='#myModal2<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                     	  <li> 


									<?php
									


									
										if($usertype=="admin"){
											
											?>
                                        
                                       
									   

										 <a class="btn btn-primary editbtn" id="editbtn" data-mykey='<?php echo  $c->mykey;?>' data-achieved='<?php echo  $c->achieved;?>' data-status='<?php echo  $c->status;?>'  data-comment='<?php echo  $c->comment;?>'data-description='<?php echo  $c->description;?>'     data-challanges='<?php echo  $mychallanges;?>'data-createdate='<?php echo  $c->createdate;?>' data-description='<?php echo  $c->description;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Update
                                                </a>
                                     
											<?php
										}else  if($userid==$manager){
											?>
											
										 <a class="btn btn-primary editbtn" id="editbtn"  data-mykey='<?php echo  $c->mykey;?>'data-achieved='<?php echo  $c->achieved;?>' data-status='<?php echo  $c->status;?>'  data-comment='<?php echo  $c->comment;?>'data-description='<?php echo  $c->description;?>'     data-challanges='<?php echo  $mychallanges;?>'data-createdate='<?php echo  $c->createdate;?>' data-description='<?php echo  $c->description;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Update
                                                </a>	
												
											
										<?php	
											
										}
										?>
										
                                                        </li>
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</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. "   Records in the system. " ;?>    </span>

        
        </div>
									
									
									
					</div>	

			
			</div>
		</div>
		
		
		
						
					
					

			
<div id="purchaseModal" 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">Task Report</h4>
      </div>
      <div class="modal-body">
      
	  
	  
	  
	  
	  
	  
	  
	  	

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

         $YEAR = date('Y');
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewtaskreport' , 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="inputperiod" class="col-sm-2 control-label">Target Periods </label>
    <div class="col-sm-10">
		<select class="form-control" name="period" required >
	
	<option value=""  >---Select specifi Target Periods---</option>

<?php 
					 
		
									 			$periods = $this->usermodel->populatealldatanoarraythree('periods', 'companyid',$companyid,'id >',0,'status','active');


if(is_array($periods)) {

   foreach($periods as $periodsrow){

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




	<?php

}} else {
    echo 'No Period created.';
}
	
?>
		</select>
		
		
		</span>
	</div>
		</div>


 <div class="form-group">
    <label for="inputuser" class="col-sm-2 control-label">User?</label>
    <div class="col-sm-10">
	<select class="form-control" name="user" required>
	
	<option value=""  >---Select user---</option>

						<?php
		
		 if($viewalltasks==true){
			 					//$allusers = $this->usermodel->populatealldatanoarraythree('productlist','expdate <>', '0000-00-00','expdate <', $currentdate,'companyid', $companyid);			   

			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');
			?>
						<option value="all"  >All 	users</option>
<?php


 }else{
	 			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'id',$userid,'id >',0,'category','user');

	 
			//$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$userid,'status',1);

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
						<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>




	<?php

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

	</div>
  </div>
  

	
	

  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Start Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="fromdate" value="<?php echo  date("Y-m-01"); ?>" 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="date" name="todate" value="<?php echo  date("Y-m-d"); ?>" class="form-control" required placeholder="Enter due date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
  	
   <div class="form-group">
    <label for="inputbranchid" class="col-sm-2 control-label">Counter</label>

    <div class="col-sm-10">     
	<select class="form-control" name="branchid"  id="branchid" required>
						<option selected="" value="all"> --All branches--</option>


	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','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="inputtype" class="col-sm-2 control-label">Report type</label>

    <div class="col-sm-10">     
	<select class="form-control" name="type"  required>
						<option value=""> --Select report type--</option>
						<option value="performance" selected="selected"  >Performance(Periodically)</option>
						<option value="general">General Report(History)</option>


</select>
		

    </div>
  </div>
  
  
  
  
     <div class="form-group">
    <label for="inputtasktype" class="col-sm-2 control-label">Task type</label>

    <div class="col-sm-10">     
	<select class="form-control" name="tasktype"  required>
						<option value=""> --Select Task type--</option>
												<option value="all"> -All/Everything-</option>

						<option value="General" selected="selected"  >General Task</option>
						<option value="Core">Core Task</option>


</select>
		

    </div>
  </div>
  
  
  
  
  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="task" name="btn_taskperformance" class="btn btn-primary"> View Task Performance </button>

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

    

				</div>

		</div>
	    </div>
    </div>	
	
	
	
					<div id="myModal2" 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('logged_in');

		
                 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="dailytasks">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewmydailyupdates">
 <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 id="editProductModel" 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">Update task feedback</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updatefeedback' , 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;?>



	  <input type="hidden" name="fromdate"  value="<?php if(isset($fromdate)) {echo $fromdate; }?>" class="form-control"   >
<input type="hidden" name="todate"  value="<?php if(isset($todate)) {echo $todate; }?>" class="form-control"   >
<input type="hidden" name="type"  value="<?php if(isset($type)) {echo $type; }?>" class="form-control"   >
<input type="hidden" name="period"  value="<?php if(isset($period)) {echo $period; }?>" class="form-control"   >
<input type="hidden" name="branchid"  value="<?php if(isset($branchid)) {echo $branchid; }?>" class="form-control"   >
<input type="hidden" name="companyid"  value="<?php if(isset($companyid)) {echo $companyid; }?>" class="form-control"   >
<input type="hidden" name="user"  value="<?php if(isset($user)) {echo $user; }?>" class="form-control"   >

	  




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

				<input type="hidden" name="myview" value="Systemusers/viewallotherdailyupdates/<?php if(isset($page)) {echo $page; }?>"id="myview" class="form-control" required placeholder="Enter myview">

		<input type="hidden" name="page" value="<?php if(isset($page)) {echo $page; }?>"id="page" class="form-control" required placeholder="Enter bookid">

		
    <div class="form-group">
    <label for="inputcreatedate" class="col-sm-2 control-label"> Date Posted </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="createdate" id="createdate" readonly value="" class="form-control" required placeholder="Enter  date posted">
		 
				
		<span class="text-danger"> <?php echo form_error('createdate'); ?>
		
		</span>
	</div>
  </div>
  
	
		<div class="form-group">
    <label for="inputachieved" class="col-sm-2 control-label">	Target Achieved</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="achieved" value="" id="achieved" class="form-control"  required placeholder="Enter  achieved target">
		 
				
		<span class="text-danger"> <?php echo form_error('achieved'); ?>
		
		</span>
	</div>
  </div>
	
	
	
	
	<div class="form-group">
    <label for="inputcomment" class="col-sm-2 control-label">	Task Comments</label>
    <div class="col-sm-10">

<textarea name="comment" value=""  id="comment"class="form-control"></textarea>		
		<span class="text-danger"> <?php echo form_error('comment'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">Challanges</label>
    <div class="col-sm-10">

<textarea name="challanges" value=""  id="challanges"class="form-control"></textarea>		
		<span class="text-danger"> Challanges and Recommendations<?php echo form_error('challanges'); ?>
		
		</span>
	</div>
  </div>
		
		
	
	<div class="form-group">
    <label for="inputrecommendation" class="col-sm-2 control-label">To dolist</label>
    <div class="col-sm-10">

<textarea name="recommendation" value="" id="recommendation"class="form-control"></textarea>		
		<span class="text-danger"> Work plans<?php echo form_error('recommendation'); ?>
		
		</span>
	</div>
  </div>
		

	

	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	 Supervisor Comments</label>
    <div class="col-sm-10">

<textarea name="description"  id="description"  class="form-control" placeholder="Enter your comments"><?php echo set_value('description'); ?></textarea>		
		<span class="text-danger"> Supervisor Comments regarding the task submitted<?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		<div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">	Status	 </label>
    <div class="col-sm-10">
	
	
	<select class="form-control" name="status" id="status" required>
		<option value="" selected="selected"></option>

	<option value=""  >---Select status--</option>
	<option value="Approved"  >Approved</option>
		<option value="Rejected"  >Rejected</option>
		<option value="Pending"  >Pending</option>
				<option value="Ongoing"  >Ongoing</option>
				<option value="Submitted"  >Submitted</option>

</select>
	
	
	
	
	
	
	

				
		<span class="text-danger"> <?php echo form_error('status'); ?>
		
		</span>
	</div>
  </div>
	
	
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="task" name="btn_updatefeedback" class="btn btn-default"> Update 	Feedback   </button>

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

    

				</div>

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



		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
  
  </div>
			
			
			
		
		
  

 
</div>


















