<style>
.control-label {  
  padding-top: 0 !important;
}
.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {
  max-width: 100px !important;  
}
</style>
<div class="page-content-wrapper">
                <div class="page-content">
                    <div class="page-bar">
                        <div class="page-title-breadcrumb">
                            <div class=" pull-left">
                                <div class="page-title">View Staff</div>                                
                            </div>
                            <ol class="breadcrumb page-breadcrumb pull-right">
                                <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index.php?page=home">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li><a class="parent-item" href="index.php?page=manage_staff">Staff</a>&nbsp;<i class="fa fa-angle-right"></i></li><li class="active">View Staff</li>
                            </ol>
                        </div>
                    </div>
<div class="row">
                        <div class="col-md-12 col-sm-12">
                            <div class="card card-box">
                                <div class="card-head">
                                    <header>View Staff</header>  
                                    <div style="margin-left:20px;">
	                                	<a class="btn btn-info" href="index.php?page=manage_staff">Back</a>&nbsp;
	                                	<a class="btn btn-info" href="index.php?page=add_staff&id=<?php echo $editId; ?>">Edit</a>
	                                	<a class="btn btn-info" href="index.php?page=add_salary&staff_id=<?php echo $editId; ?>">Add Salary</a>
	                                	<a class="btn btn-info" href="index.php?page=add_salary_advance&staff_id=<?php echo $editId; ?>">Add Advance Salary</a>
	                                	<a class="btn btn-info" href="index.php?page=add_leave&staff_id=<?php echo $editId; ?>">Add Leave</a>
	                                	<a class="btn btn-info" href="index.php?page=add_overtime&staff_id=<?php echo $editId; ?>">Add Overtime</a>
	                                	<?php if($resEdit['status']=='Active'){ ?>
	                                		<a class="btn btn-info" href="index.php?page=view_staff&action=disable&id=<?php echo $editId; ?>">Disable</a>
	                                	<?php } else { ?>                   
	                                		<a class="btn btn" href="index.php?page=view_staff&action=enable&id=<?php echo $editId; ?>">Enable</a>          	
	                                	<?php } ?>
	                                </div>                                  
                                </div>
                                <div class="card-body" id="bar-parent1">                                	
                                	   
                                	<?php if(isset($error) && $error!=''){ ?>
									<div class="alert alert-danger mt-1" role="alert"><?php echo $error; ?></div>
									<?php } else if(isset($success) && $success!=''){ ?>
									<div class="alert alert-success mt-1" role="alert"><?php echo $success; ?></div>
									<?php } else if(isset($_REQUEST['success']) && $_REQUEST['success']!=''){ ?>
									<div class="alert alert-success mt-1" role="alert"><?php echo urldecode($_REQUEST['success']); ?></div>
									<?php } ?>                             		
                                		                                      	                          	                                	
                                    <form action="" id="form_staff_add" class="form-horizontal" method="post">
                                    	<div class="form-body div-right">
                                        	<?php if(isset($resEdit['image']) && $resEdit['image']!=''){ ?>                                            
		                                        	<img src="<?php echo STAFF_IMG_URL.$resEdit['image']; ?>" style="width:150px;" >		                                        	
		                                    <?php } ?>
                                        </div>
                                        <div class="form-body div-left">                                        	                                        	 
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Staff Name</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo $resEdit['name'];?>
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Email Address</label>
                                                <div class="col-md-4">                                                                                                                                                                   
                                                    <?php echo $resEdit['email'];?>
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Phone Number</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo $resEdit['phone'];?>
                                                </div>
                                            </div>                                            
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Address</label>
                                                <div class="col-md-4">        
                                                	<?php echo $resEdit['address'];?>                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Designation</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo $resEdit['designation'];?>   
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Salary</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo $resEdit['salary'];?>   
                                                </div>
                                            </div>                                              
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Date of Joining</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo getFormattedDate($resEdit['date']);?>   
                                                </div>
                                            </div> 
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Added By</label>
                                                <div class="col-md-4">                                                    
                                                    <?php if($resEdit['added_by']>0){ echo getAdminUserName($resEdit['added_by']); }?>   
                                                </div>
                                            </div>
                                            <?php if($resEdit['updated_by']>0){ ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Updated By</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo getAdminUserName($resEdit['updated_by']); if($resEdit['updated_on'] != '0000-00-00 00:00:00'){ echo ' on '.getFormattedDate($resEdit['updated_on']);} ?>   
                                                </div>
                                            </div>
                                            <?php } ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Casual Leaves Taken</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo $casualCount;?>   
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Sick Leaves Taken</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo $sickCount;?>   
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-4">Deductions for this month</label>
                                                <div class="col-md-4">      
                                                	<?php $curYear = date('Y'); $curMonth = date('m');?>                                              
                                                    <?php echo getStaffDeductions($editId, $curYear, $curMonth);?>   
                                                </div>
                                            </div>                                           
                                            
                                        </div>  
                                                                              
                                      	
                                    </form>
                                </div>
                            </div>
                        </div>
                        
                        <?php if(isset($advanceRs) && mysqli_num_rows($advanceRs)>0){ ?>
	                        <div class="col-md-12">
	                            <div class="card card-topline-red">
	                                <div class="card-head">
	                                    <header>Advance Report</header>
	                                    <div class="tools">
	                                        <!--<a class="fa fa-repeat btn-color box-refresh" href="javascript:;"></a>-->
		                                    <a class="t-collapse btn-color fa fa-chevron-down" href="javascript:;"></a>
		                                    <a class="t-close btn-color fa fa-times" href="javascript:;"></a>
	                                    </div>
	                                </div>
	                                <div class="card-body ">
	                                    <div class="row p-b-20">                                        
	                                        
	                                    </div>  	                                                                      
	                                    <table class="table table-striped table-bordered table-hover table-checkable order-column" style="width: 100%" id="example4">
	                                        <thead>
	                                            <tr>                                                                                                
	                                                <!--<th> Staff Name </th>-->
	                                                <th> Date </th>
	                                                <th> Amount </th>
	                                                <th> Advance / Return </th>
	                                                <th> Description </th>                                                
	                                                <th> Actions </th>
	                                            </tr>
	                                        </thead>
	                                        <tbody>
	                                        	<?php                                        	
													while($resDetails = mysqli_fetch_array($advanceRs)) {	
														if($resDetails['deducted']=='yes' && $resDetails['advance_return']>0){
															$type = 'Return';
															$amount = $resDetails['advance_return'];
														} else {
															$type = 'Advance';
															$amount = $resDetails['amount'];
														}
														
														?>
	                                            <tr class="odd gradeX">                                                
	                                                <!--<td><?php echo getStaffName($resDetails['staff_id']); ?></td>-->
	                                                <td><?php echo getFormattedDate($resDetails['date']); ?></td>
	                                                <td><?php echo $amount; ?></td> 
	                                                <td><?php echo $type; ?></td>     
	                                                <td><?php echo $resDetails['description']; ?></td>                                                                                              
	                                                <td class="valigntop">
	                                                    <div class="btn-group">
	                                                        <button class="btn btn-xs deepPink-bgcolor dropdown-toggle no-margin" type="button" data-toggle="dropdown" aria-expanded="false"> Actions
	                                                            <i class="fa fa-angle-down"></i>
	                                                        </button>
	                                                        <ul class="dropdown-menu pull-left" role="menu">
	                                                            <!--<li>
	                                                                <a href="index.php?page=add_salary&staff_id=<?php echo $resDetails['id']; ?>">
	                                                                    <i class="icon-docs"></i> Edit Salary </a>
	                                                            </li>-->                                                            
	                                                        </ul>
	                                                    </div>
	                                                </td>
	                                            </tr>
	                                            <?php } ?>                                            
	                                        </tbody>
	                                    </table>
	                                    <!--<div style="float: left; width: 25%;"> <?php echo $pageNums; ?> </div>-->	                                    
	                                </div>
	                            </div> 
	                    	</div>                        
                        <?php } else { ?>
	                        <div style="width:100%;" class="alert alert-danger">The staff has not yet taken any salary advances</div>					        		
						<?php }	?> 
						
						<?php //if($_SERVER['REMOTE_ADDR']=='202.88.237.77'){?>
						<?php if(isset($salaryRs) && mysqli_num_rows($salaryRs)>0){ ?>
							<div class="col-md-12">
	                            <div class="card card-topline-red">
	                                <div class="card-head">
	                                    <header>Salary Report</header>
	                                    <div class="tools">	                                        
		                                    <a class="t-collapse btn-color fa fa-chevron-down" href="javascript:;"></a>
		                                    <a class="t-close btn-color fa fa-times" href="javascript:;"></a>
	                                    </div>
	                                </div>
	                                <div class="card-body ">
	                                    <div class="row p-b-20">                                       
	                                        
	                                    </div>	
	                                    <table class="table table-striped table-bordered table-hover table-checkable order-column" style="width: 100%" id="example4">
	                                        <thead>
	                                            <tr>   
	                                                <th> Salary Date </th>
	                                                <th> Salary </th>
	                                                <th> Incentives </th>
	                                                <th> Deductions </th>
	                                                <th> Advances </th>
	                                                <th> Advance Return </th>
	                                                <th> Net Amount </th>
	                                                <!--<th> Actions </th>-->
	                                            </tr>
	                                        </thead>
	                                        <tbody>
	                                        	<?php                                        	
													while($resDetails = mysqli_fetch_array($salaryRs)) {	?>
	                                            <tr class="odd gradeX">
	                                                <td><?php echo getFormattedDate($resDetails['salary_date']); ?></td>
	                                                <td><?php echo $resDetails['basic']; ?></td>
	                                                <td><?php echo $resDetails['insentives']; ?></td>
	                                                <td><?php echo $resDetails['deductions']; ?></td> 
	                                                <td><?php echo $resDetails['advances']; ?></td> 
	                                                <td><?php echo $resDetails['advance_return']; ?></td> 
	                                                <td><?php echo $resDetails['gross_salary']; ?></td>                                             
	                                                <!--<td class="valigntop">
	                                                    <div class="btn-group">
	                                                        <button class="btn btn-xs deepPink-bgcolor dropdown-toggle no-margin" type="button" data-toggle="dropdown" aria-expanded="false"> Actions
	                                                            <i class="fa fa-angle-down"></i>
	                                                        </button>
	                                                        <ul class="dropdown-menu pull-left" role="menu">
	                                                            <li>
	                                                                <a onclick="return confirm('Are you sure to delete this item? If advance return exists in this record, that will also be deleted!!!');" href="index.php?page=salary_report&action=delete&del_id=<?php echo $resDetails['id']; ?>">
	                                                                    <i class="icon-docs"></i> Delete </a>
	                                                            </li>                                                            
	                                                        </ul>
	                                                    </div>
	                                                </td>-->
	                                            </tr>
	                                            <?php } ?>                                            
	                                        </tbody>
	                                    </table>
	                                    <!--<div style="float: left; width: 25%;"> <?php echo $pageNums; ?> </div>-->
	                                    
	                                </div>
                            </div>
						<?php } else { ?>
	                        <div style="width:100%;" class="alert alert-danger">The staff was not paid any salary till now</div>					        		
						<?php }	?> 	
						<?php //} ?>
                        
                    </div>
	</div>
</div>
