

 <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>
				Post your leave application
				
								                   <span class="pull-right">  <a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/viewleaves">Go back  </a>

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

			
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
					
	
				<?PHP


$session_data = $this->session->userdata('logged_in');

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

 $email=$data['email'];
$id=$data['id'];
$mydate=date("d-m-Y");

$imgid = rand(100, 990000).time();
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/postmyleave' , 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="applicationid" value="<?php   if(isset($applicationid)) {  echo $applicationid; }  ?>" id="applicationid" class="form-control"  placeholder="Enter application id">
	<input type="hidden" name="userid" value="<?php   if(isset($userid)) {  echo $userid; }  ?>" id="applicationid" class="form-control"  placeholder="Enter userid">

	
	    		<div class="form-group">

    <label for="inputtype" class="col-sm-2 control-label">	Leave Type</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" required>
	
	<option value=""  >---Select Leave Type---</option>
	
	<?php 
			 if(isset($type)) {  echo $type; 
			 
			 		 $mytype=$type;

					 $leavetype= $this->usermodel->populateall('leavegroup','id',$mytype);



if(is_array($leavetype)) {

   foreach($leavetype as $leavetyperow){

  // echo $leavetyperow->name;
  ?>
  			 								<option selected="selected" value="<?php echo $type;   ?>"><?php echo $leavetyperow->name;   ?></option>

 <?php
}} else {
    echo 'No type';
}
			 
			 
			
			 

			  } 
	
$biodata= $this->usermodel->populateallarray('people','id',$id);
		
$group=$biodata[0]['leavegroup'];
		
	
		$announcement = $this->usermodel->GetBalanceDaysByGroup($id,$group);
					 
			//$leavetypes = $this->usermodel->populatealldata('leavetypes','id','DESC');

	
if(is_array($announcement)) {

   foreach($announcement as $announcementrow){

   		 $mytype=$announcementrow->type;

					 $leavetype= $this->usermodel->populateall('leavegroup','id',$mytype);



if(is_array($leavetype)) {

   foreach($leavetype as $leavetyperow){


  ?>
					<option value="<?=  $leavetyperow->id;   ?>"><?=  $leavetyperow->name; ?></option>



	<?php

 
}} else {
    echo 'No type';
}

   
}} else {
    echo 'No group available.';
}
	
   



   


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

	</div>
  </div>
  
  
  		
  
  
 	<div class="form-group">
    <label for="inputincharge" class="col-sm-2 control-label">Employee Cover </label>
    <div class="col-sm-10">
	<select class="form-control" name="incharge" required>
	
								<option value="">---Please select Employee to cover you when you are on leave  </option>

	
	<?php 
			 if(isset($incharge)) {  echo $incharge;

	 $myincharge=$incharge;

					 $myenployee= $this->usermodel->populateall('people','id',$myincharge);



if(is_array($myenployee)) {

   foreach($myenployee as $myenployeerow){

    
  ?>
  			 								<option selected="selected" value="<?php echo $incharge;   ?>"><?php echo $myenployeerow->lastname." ".$myenployeerow->firstname."(".$myenployeerow->number.")";  ?></option>

 <?php
}} else {
    echo 'No Employee';
}


			
			 

			  } 


			 $biodata= $this->usermodel->populateallarray('people','id',$id);
		
$mydepartment=$biodata[0]['department'];


				
			//$manager = $this->usermodel->populatealldata('people','department',$mydepartment);
									 			$manager = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'category',"user",'status',1);

	


if(is_array($manager)) {

   foreach($manager as $managerrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $managerrow->id;   ?>"><?=  $managerrow->firstname." ".$managerrow->number."(".$managerrow->number.")"; ?></option>



	<?php

}} else {
    echo 'No incharge  available.';
}
	
   


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

	</div>
  </div>
  
 
  

     
  

 
  
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">	Start Date </label>
    <div class="col-sm-10">

	<input type="date" name="startdate" value="<?php    if(isset($startdate)) {  echo $startdate; }else{ echo $mydate;}  ?>"id="startdate" class="form-control" required placeholder="Enter start date(yyy-mm-dd) ">
			<span class="text-danger"> <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputenddate" class="col-sm-2 control-label">	End Date </label>
    <div class="col-sm-10">

	<input type="date" name="enddate" value="<?php    if(isset($enddate)) {  echo $enddate; }else{ echo $mydate;}  ?>"id="enddate" class="form-control" required placeholder="Enter end date(yyy-mm-dd) ">
			<span class="text-danger"> <?php echo form_error('enddate'); ?>
		
		</span>
	</div>
  </div>
   <div class="form-group">
    <label for="inputduration" class="col-sm-2 control-label">	Duration </label>
    <div class="col-sm-10">

	<input type="text" name="duration" readonly value="<?php    if(isset($duration)) {  echo $duration; }  ?>"id="duration" class="form-control"  placeholder="Leave days automatic">
			<span class="text-danger"> <?php echo form_error('duration'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Reason/Description</label>
    <div class="col-sm-10">

	<textarea name="description" class="form-control" placeholder="You can type the reasons here"><?php    if(isset($description)) {  echo $description; }  ?></textarea> 
			<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
  
  
    <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Leave status</label>
    <div class="col-sm-10">
	<select class="form-control" name="status" readonly required>
	
	<option value="1" select="selected">New</option>
			<span class="text-danger"><?php echo form_error('status'); ?>
</select>
	</div>
  </div>
  
  
  
  
  
  


  


  
  
  
   
  
  
  
  
 <div class="form-group">
    <label for="inputcontroller" class="col-sm-2 control-label">Approver?</label>
    <div class="col-sm-10">
	<select class="form-control" name="controller" required>
	
	<option value=""  >---Select Hod---</option>
	<option value="Pick"  >Pick My Hod from ERP</option>

	
	
	
	
	<?php 
	
	
		 if(isset($controller)) {  echo $controller; 
			 
			 		 

					 $supervisors= $this->usermodel->populateall('people','id',$controller);



if(is_array($supervisors)) {

   foreach($supervisors as $userrows){

  // echo $leavetyperow->name;
  ?>
  						<option  selected="selected" value="<?=  $userrows->id;   ?>"><?=  $userrows->firstname ."(". $userrows->email.")"; ?></option>


 <?php
}} else {
    echo 'No type';
}
			 
			 
			
			 

			  } 
	
	
	
	
	
	
				
					$allusers = $this->usermodel->populatealldatanoarraythree('supervisor', 'companyid',$companyid,'status',"active",'id >',0);

	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){
	   
	   $biodata= $this->usermodel->populateallarray('people','id',$userrow->employeeno);
		
$name=$biodata[0]['firstname'] ."  "  .$biodata[0]['surname'];

$email=$biodata[0]['email'] ;

    ?>
						<option value="<?=  $userrow->employeeno;   ?>"><?=  $name ."(". $email.")"; ?></option>




	<?php

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

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

    <div class="col-sm-offset-2 col-sm-10">
     	         <button type="submit"  name="btn_confirmleave"  value="confirm"  class="btn btn-primary"> Confirm Leave Days First </button>

	         <button type="submit"  name="btn_leave"  value="leave"  class="btn btn-primary"> Apply Leave  </button>

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

								
			
			
			
			
			
			
		
		</div>
  
  </div>

</div>
















