<?php 
/********************************************************************************* 
 *  This file is part of Sentrifugo.
 *  Copyright (C) 2014 Sapplica
 *   
 *  Sentrifugo is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Sentrifugo is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Sentrifugo.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Sentrifugo Support <support@sentrifugo.com>
 ********************************************************************************/
?>

<?php if($this->rowexist == 'norows'){?>
	No data found.
<?php } else {?>

<div id="leave_success_div" class="ml-alert-1-success" style="display:none;">
	<div class="style-1-icon success"></div>
</div>

<div id="error_message" style="display:none;"></div>

<div class="poc-ui-data-control">
<form name="<?php echo $this->form->getName(); ?>" id="<?php echo $this->form->getId(); ?>" action="<?php echo $this->form->getAction();?>" method="<?php echo $this->form->getMethod(); ?>">

<?php if($this->approve_flag=='true' || $this->reject_flag=='true' || $this->cancel_flag=='true') { ?>
<div class="new-form-ui inputheight_lq"  id="leaveaction">

<div class="leaves_rq_new_pop">
	
   <div class="leaves_rq_new_pop_left">
    	 <!--	<label>Status</label>
            <ul id="leaves_request_ul">
          <?php //if($this->user_logged_in=='true' && $this->manager_logged_in!='true') 
          		//{ 
          			//if($this->cancel_flag=='true') {				
          ?>
          		<li>
          			<a><span class="fa fa-times-circle"></span><span>Cancel</span></a>
          		</li>
          <?php //}} 
          ?> 
          
          <?php //if($this->manager_logged_in=='true') { ?>
          		<?php //if($this->approve_flag=='true') {?>
          			<li id="manager_approve" onclick="changeLeaveStatus('<?php //echo sapp_Global::_encrypt('Approved');?>',this.id)">
          				<a><span class="fa fa-check"></span><span>Approve</span></a>
          			</li>		
          		<?php //}else{?>
          			<li id="manager_approve">
          				<a class="dis"><span class="fa fa-check"></span><span>Approve</span></a>
          			</li>
          		<?php //}?>
          		
          		<?php //if($this->reject_flag=='true') {?>
          			<li id="manager_reject" onclick="changeLeaveStatus('<?php //echo sapp_Global::_encrypt('Rejected');?>',this.id)">
          				<a class="dis"><span class="fa fa-ban"></span><span>Reject</span></a>
          			</li>		
          		<?php //}else{?>
          			<li id="manager_reject">
          				<a class="dis"><span class="fa fa-ban"></span><span>Reject</span></a>
          			</li>
          		<?php //}?>
          		
          		<?php //if($this->cancel_flag=='true') {?>
          			<li id="manager_cancel" onclick="changeLeaveStatus('<?php //echo sapp_Global::_encrypt('Cancel');?>',this.id)">
          				<a class="dis"><span class="fa fa-times-circle"></span><span>Cancel</span></a>
          			</li>		
          		<?php //}?>
          <?php //}?>
            </ul>-->
    
    
    
    	<label>Status</label>
	  	<select id="leaveactionid" name="leaveactionid" class="select2-offscreen" tabindex="-1">
	  	<?php if($this->user_logged_in=='true' && $this->manager_logged_in!='true') { ?>
		  	<?php if($this->cancel_flag=='true') {?>
		    	<option label="Cancel" value="<?php echo sapp_Global::_encrypt('Cancel');?>">Cancel</option>
		    <?php }?>
		<?php } ?>    
	    
	    <?php if($this->manager_logged_in=='true') { ?>
	    	<?php if($this->approve_flag=='true') {?>
		    <option label="Approve" value="<?php echo sapp_Global::_encrypt('Approved');?>">Approve</option>	
		    <?php } ?>
		    
		    <?php if($this->reject_flag=='true') {?>
			 <option label="Reject" value="<?php echo sapp_Global::_encrypt('Rejected');?>">Reject</option>
			<?php } ?> 
			
			<?php if($this->cancel_flag=='true') {?>
		    	<option label="Cancel" value="<?php echo sapp_Global::_encrypt('Cancel');?>">Cancel</option>
		    <?php }?>
		<?php } ?>
	    </select>
	</div>
    
    <?php if($this->manager_logged_in=='true') { ?>
    <div class="leaves_rq_new_pop_right">
    		<label>Comments</label>
            <textarea maxlength="50" cols="50" rows="10" id="comments" name="comments"></textarea>
    </div>
    <?php }?>
    
    <input type="hidden" value='<?php echo sapp_Global::_encrypt('Cancel');?>' id="leaveactionid" name="leaveactionid">
    
    <div class="new-form-ui-submit"><input type="button" onclick="updateleavedetails('<?php echo $this->leave_details['id']?>','<?php echo $this->controllername; ?>');" value="Save" id="submitbutton" name="submit"></div>



</div>
</div>
<?php } ?>

</form>
<div style="clear:both;">
<?php 
	sapp_Helper::viewHeader();
	sapp_Helper::viewBody('nor','Employee',$this->leave_details['user_name'],'Leave Type',$this->leave_details['leavetype_name']);
	sapp_Helper::viewBody('alt','From',sapp_Global::change_date($this->leave_details['from_date'],'view'),'To',sapp_Global::change_date($this->leave_details['to_date'],'view'));
	sapp_Helper::viewBody('nor','Leave For',$this->leave_details['leaveday']==1?'Full Day':'Half day','Days',$this->leave_details['appliedleavescount']);
	if($this->leave_details['leavestatus']=='Approved') {
		sapp_Helper::viewBody('alt','Approved On',sapp_Global::change_date($this->leave_details['modifieddate'],'view'),'Comments',$this->leave_details['approver_comments']);
	}else if($this->leave_details['leavestatus']=='Pending for approval') {
		if($this->manager_logged_in=='true') {
			sapp_Helper::viewBody('alt','Applied On',sapp_Global::change_date($this->leave_details['createddate'],'view'),'','');
		}else if($this->user_logged_in=='true' && $this->manager_logged_in!='true'){
			sapp_Helper::viewBody('alt','Reporting Manager',$this->leave_details['rep_manager_name'],'','');
		}	
	}
	sapp_Helper::viewFooter();
?>
</div>
</div>
<?php } ?>

<script type="text/javascript">
/*function changeLeaveStatus(value,ele){
	$('#leaveactionid').val(value);
	$('#leaves_request_ul li a').addClass('dis');
	$("#"+ele+" a").removeClass('dis');
}*/
$(document).ready(function(){
	<?php //if($this->manager_logged_in=='true') { 
			//if($this->approve_flag=='true') { 
	?>
				//$("#leaveactionid").val('<?php //echo sapp_Global::_encrypt('Approved');?>');
	<?php //} elseif($this->cancel_flag=='true') { ?>
				//$("#manager_cancel a").removeClass('dis');
	<?php //}}?>
			
});
</script>
