
  <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		   

		  
		  	   
        });
		  $(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); 
		  
		  
		   
        });
		
		
		
		
    </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
	 function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}	
 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];

 $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'); 
								?>	
										
					Task Performance 
									
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
			  <tr>
								
								<td colspan="11" ><center  >
								
						
									

										<?php $bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
										
									
					 $periods= $this->usermodel->populateallarray('periods','id',$period);
			$periodname=$periods[0]['name'];	

										
										?>
												<span id="mytitle"></br><b> <?PHP echo $periodname ?> Performance Report between  <?PHP echo $fromdate ?> and <?PHP echo $todate ?></b>		
								
								<br>Name----------------------Date--------------------Signature----------------</span>

								</center></td>
								
								
							</tr>
         <tr>
    
     <th>Staff Name</th>
	      
	     <th>Task Name</th>


	     <th>Achieved</th>
		 	     <th>Target</th>
		 	     <th>Performance</th>

		 	     <th>Comments</th>
		 	
  <th>Task Date</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 
   $target=0;
   $ttachieved=0;$tttarget=0;$ttperformance=0;
$counter=count($dailytasks);
  	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'];	


					 
?>
												 
	 </td>	 
			
   
	    <td><?php echo $c->achieved ; ?></td>
	    <td><?php  
		
$mytask = $this->usermodel->populatealldataarrayfour('assigntask', 'companyid',$companyid,'taskid',$c->taskid,'employeeid',$c->userid,'period',$period);
		$target=$mytask[0]['target'];	

	if(isset($target)) {
					echo$target=$mytask[0]['target'];	

	}else{
		echo "No target";
	}

		 ?>
		
		</td>

			    <td><?php 
				$myperformance=0;
				
				
				if(isset($target)) {
				$myperformance=( ($c->achieved/$target)*100);

				}else{
				$myperformance=( ($c->achieved/1)*0);

				}				
				
				
				
				
				
				
				
				
				
				if($myperformance>100){
					$performance=100;
				}else{
					$performance=$myperformance;
				}
echo formatMoney($performance, true);


   $ttachieved= $ttachieved+$c->achieved;
   
   $tttarget=$tttarget+$target;
   
   $ttperformance=$ttperformance+$performance;

				?></td>


	
		
		

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




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

 
    
	
		
             </tr>

	<?php endforeach; ?>
	


              <?php }?>
			  
			 				<tr  background="green">
				<td colspan="2"><b>Performance</b></td>

			<td>  <b><?php if(isset($ttachieved)) {echo formatMoney($ttachieved, true);  }?><b></td>
	<td>  <b><?php if(isset($tttarget)) {echo formatMoney($tttarget, true);  }?><b></td>
				<td>  <b><?php if(isset($ttperformance)) {echo formatMoney(($ttperformance/$counter), true);  }?>  %<b></td>
			<td>  
			</td>
	 </tr>
			  
			  
			  
			  
			  
			  

        </table>

									
									
									
					</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', 'userid',$userid,'status',1,'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">

    <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="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="taskid" value=""id="taskid" class="form-control" required placeholder="Enter taskid">
		
				<input type="hidden" name="myview" value=""id="myview" class="form-control" required placeholder="Enter myview">

		<input type="hidden" name="page" value="<?php 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"  id="comment"class="form-control"><?php echo set_value('comment'); ?></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"  id="challanges"class="form-control"><?php echo set_value('challanges'); ?></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"  id="recommendation"class="form-control"><?php echo set_value('recommendation'); ?></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>


















