<?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>
 ********************************************************************************/
?>

  <div class="table-header">
		    <div class="config-choose config-up" onclick="displaymanagementtabs()" id="selectfields"></div>
			<span>Leave Management Options</span>
		    <div id="leavemmanagementtabdiv" class="columnsdiv" style="display:none;">
			<i>Columns :</i>
			<?php 
				$checked = '';
				if(!empty($this->leavesheaderarr))
				{
					foreach($this->leavesheaderarr as $key => $val) 
					{
						if(!empty($this->selectColumnLabels))
						{
							if(array_key_exists($key,$this->selectColumnLabels))
								$checked = 'checked';
							else 
								$checked = '';
						}		
					?>
					
						<p><input type="checkbox" <?php echo $checked;?> id="leavemanagementcheckbox_<?php echo $key;?>"name="leavemanagementtabcheckbox" value="<?php echo $key;?>"><b><?php echo $val;?></b></p>
				  <?php
					}
				}?>
				
				<div class="new-form-ui-submit mrgetop10">
				 <input type="button" value="Apply" onclick="setleavemanagementtab()">
				 <button name="Cancel" id="Cancel" type="button" onclick="cancelleavemanagementtab()">Cancel</button>
				</div>
            </div>
		</div>
    <?php 
	      if(!empty($this->selectColumnLabels))
		  {
			  foreach($this->selectColumnLabels as $header => $label)
			  {
				  $selectcolumnsArr[] = $header;
			  }
			  $selectcolumns = implode(",",$selectcolumnsArr);
		  }
	?>	
    <input type="hidden" value="<?php echo $selectcolumns;?>" id="selectedleavecheckbox"/>

  


	<div class="details_data_display_block newtablegrid" id="reportgrid">
		<table class='grid' align='center'  width='100%' cellspacing='0' cellpadding='4' border='0'>
		    <thead>
		        <tr>
				    <?php if(array_key_exists('cal_startmonthname',$this->selectColumnLabels) !== false){?>
				      <th id = "startmonth" >
					    <a onclick="sortmanagementcolumn('l.cal_startmonthname','startmonth')" href="javascript:void(0);">Start Month</a>
					  </th>
					<?php }?>  
					<?php if(array_key_exists('weekend_startday',$this->selectColumnLabels) !== false){?>  
		              <th id = "weekendstartday">
					    <a onclick="sortmanagementcolumn('l.weekend_startdayname','weekendstartday')" href="javascript:void(0);">Week-end 1</a>
					  </th>        
					<?php }?>
                    <?php if(array_key_exists('weekend_endday',$this->selectColumnLabels) !== false){?>					
		               <th id = "weekendday">
					     <a onclick="sortmanagementcolumn('l.weekend_enddayname','weekendday')" href="javascript:void(0);">Week-end 2</a>
					   </th>
					<?php }?>
                    <?php if(array_key_exists('department_name',$this->selectColumnLabels) !== false){?>					
					   <th id = "departmentname">
					     <a onclick="sortmanagementcolumn('l.department_id','departmentname')" href="javascript:void(0);">Department</a>
					   </th>
					<?php }?>
                    <?php if(array_key_exists('hours_day',$this->selectColumnLabels) !== false){?>  					
					   <th id = "hours">
					     <a onclick="sortmanagementcolumn('l.hours_day','hours')" href="javascript:void(0);"> Hours</a>
					   </th>
					<?php }?>  
                    <?php if(array_key_exists('is_halfday',$this->selectColumnLabels) !== false){?>					
		               <th id = "halfday" >
					     <a onclick="sortmanagementcolumn('l.is_halfday','halfday')" href="javascript:void(0);"> Half Day</a>
					   </th>    
					<?php }?>
                    <?php if(array_key_exists('is_leavetransfer',$this->selectColumnLabels) !== false){?>					
		               <th id = "leavetransfer">
					      <a onclick="sortmanagementcolumn('l.is_leavetransfer','leavetransfer')" href="javascript:void(0);"> Leave transferable</a>
					   </th> 
					<?php }?>   
					<?php if(array_key_exists('is_skipholidays',$this->selectColumnLabels) !== false){?>
		               <th id = "skipholidays">
					   	  <a onclick="sortmanagementcolumn('l.is_skipholidays','skipholidays')" href="javascript:void(0);"> Skip Holidays</a>
					   </th>
					<?php }?>  
                      
		                    
		        </tr>
		    </thead>
		    <tbody>
		    <?php if(!empty($this->leavemgmtArr)){ 
		    	foreach($this->leavemgmtArr as $key => $status){ 
		        	
		        	if($key%2 == 0){
		        		$classColor = 'row1';
		        	}else{
		        		$classColor = 'row2';
		        	}
			 ?>
		        <tr class="<?php echo $classColor;?>"  onclick="selectrow('userlogpreview',this);">
				    <?php if(array_key_exists('cal_startmonthname',$this->selectColumnLabels) !== false){?>
		               <td>
					        <span title="<?php echo $status['cal_startmonthname']; ?>"><?php echo $status['cal_startmonthname']; ?></span>
					   </td> 
                    <?php }?>					   
                    <?php if(array_key_exists('weekend_startday',$this->selectColumnLabels) !== false){?> 					   
		              <td>
					  <span title="<?php echo $status['weekend_startdayname']; ?>"><?php echo $status['weekend_startdayname']; ?></span>
					  </td>
					<?php }?>
					<?php if(array_key_exists('weekend_endday',$this->selectColumnLabels) !== false){?>
		              <td>
					  <span title="<?php echo $status['weekend_enddayname']; ?>"><?php echo $status['weekend_enddayname']; ?></span>
					  </td>
					<?php }?>
					<?php if(array_key_exists('department_name',$this->selectColumnLabels) !== false){?>
					  <td>
					  <span title="<?php echo ($status['businessunit_name']!=''?$status['businessunit_name']:'').$status['department_name']; ?>">
					   <?php echo ($status['businessunit_name']!=''?$status['businessunit_name']:'').$status['department_name']; ?>
					  </span>
					  </td>
					<?php }?>
					<?php if(array_key_exists('hours_day',$this->selectColumnLabels) !== false){?>
		              <td>
					  <span title="<?php echo $status['hours_day']; ?>">
					  <?php echo $status['hours_day']; ?>
					  </span>
					  </td>
					<?php }?>
					<?php if(array_key_exists('is_halfday',$this->selectColumnLabels) !== false){?>
		              <td>
					  <span title="<?php echo $status['halfday']; ?>">
					  <?php echo $status['halfday']; ?>
					  </span>
					  </td>
                    <?php }?>					
					<?php if(array_key_exists('is_leavetransfer',$this->selectColumnLabels) !== false){?>
		              <td>
					  <span title="<?php echo $status['leavetransfer']; ?>">
					  <?php echo $status['leavetransfer']; ?>
					  </span>
					  </td>
                    <?php }?> 					
					<?php if(array_key_exists('is_skipholidays',$this->selectColumnLabels) !== false){?>
		              <td>
					  <span title="<?php echo $status['skipholidays']; ?>">
					  <?php echo $status['skipholidays']; ?>
					  </span>
					  </td>	
					<?php }?>
										
		        </tr>
		        <?php }
		        
		    }else{ ?>
			   <tr>
			      <td class="no-data-td" colspan="11"><p class="no-data">No data found</p></td>
			   </tr>
			<?php }?>   
		    </tbody>
		</table>
	</div>
	 
	<div class="table-btm">
				<div class="pagination_block">
					<div class="records_block">
					<?php if(!empty($this->leavemgmtArr)){ ?>
						<div class="page_txt">
							<span>Records per page</span>
							<div class="records_number-drop-down">
								    <select id="perpagetext" onchange="displayleavemanagementreportajax('perpage');">
										<option value="20" <?php echo ($this->perpage == 20)?"selected":"" ;?>>20</option>
										<option value="50" <?php echo ($this->perpage == 50)?"selected":"" ;?>>50</option>
										<option value="100" <?php echo ($this->perpage == 100)?"selected":"" ;?>>100</option>
										<option value="150" <?php echo ($this->perpage == 150)?"selected":"" ;?>>150</option>
										<option value="200" <?php echo ($this->perpage == 200)?"selected":"" ;?>>200</option>
									</select>
							</div>
						</div>
					<?php }?>	
					</div>
                                    <?php 
                            if($this->lastpage > 1)
                            {
?>
        		    <div class="pagination_view">
		 				<?php sapp_Global::pagination_html(); ?>
					</div>
                                    <?php 
                            }
?> 
				</div>
			</div>
			
<?php //}else{ echo 'norecord'; }?>

<script type='text/javascript'>

$(document).ready(function(){
<?php if(empty($this->leavemgmtArr)){ ?>
        $("#pdf").hide();
		$("#excel").hide();
<?php } else {?>
	$("#pdf").show();
	$("#excel").show();
<?php }?>
<?php 
if($this->lastpage > 1)
{
?>
$('.pagination').jqPagination({
    link_string	: '/?page={page_number}',
    current_page    : parseInt(<?php echo $this->pageno;?>),
    max_page	: parseInt(<?php echo $this->lastpage;?>),
    paged		: function(page) {
           $('#pageno').val(page);
           displayleavemanagementreportajax('pagination');
    }
});
<?php 
}
?>  

$('#perpagetext').val('<?php echo $this->perpage;?>');
	var column = $('#columnid').val();		
	var cby = $('#columnby').val();
	
	if(column !='')
	{
		if(cby == 'Desc')
		{
			$('#'+column).append('<span class="s-ico"><span class="ui-icon-asc  ui-icon ui-icon-triangle-1-s"></span></span>');
		}			
		else
		{
			$('#'+column).append('<span class="s-ico"><span class="ui-icon-desc ui-icon ui-icon-triangle-1-n"></span></span>');
		}
	}
	
	
	$('#reportgrid').slimScrollHorizontal({
		alwaysVisible: false,
		start: 'left',
		position: 'bottom',
	}).css({ background: '#ccc', paddingBottom: '10px' }); 
});
</script>

	