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

$init_data = $this->init_data;
$init_id = $this->init_id;
$context = $this->context;
$line1_id = $this->line1_id;
$levels = $this->levels;
$employees_cnt = $this->employees_cnt;
$app_levels = $this->app_levels;
$employeeid = $this->employeeid;
?>

<input type="hidden" id="appstatus" name="appstatus" value="<?php echo $app_levels;?>" >

<?php if($app_levels == 6)
{
?>	
	<div style="clear: both;position: relative;top: 17px; width: 92%;  margin: 0 auto;" class="ml-alert-1-error">
						<div class="style-1-icon error"></div>
							Line Manager cannot be changed as the appraisal process is completed.
	</div>
<?php 
}
else 
{
	if($employees_cnt > 0)
	{
	?>
		<div style="clear: both; position: relative; top: 17px; width: 92%; margin: 0px auto 24px; height: auto; line-height: 23px;" class="ml-alert-1-info">
							<div class="style-1-icon info" style="margin-bottom: 40px; margin-top: 4px;"></div>
								You are trying to change the line manager(s) for the selected employee. 
								In case a line manager has submitted his ratings, you will not be able to edit the respective line manager.
		</div>
	
	<div class="total-form-controller ">
	<?php
	if($context != 'view')
	{
	?>
	    <div class="new-form-ui">
	        <label>Select Appraisal Levels</label>
	        <div class="division">
	            <select name="sel_levels" id="idsel_levels">
	                <option value="">Select levels</option>
	<?php 
	        for($i=$app_levels;$i<=5;$i++)
	        {
	?>
	            <option value="<?php echo $i;?>"><?php echo $i;?></option>
	<?php
	        }
	?>
	            </select>
	        </div>
	    </div>
	<?php 
	}
	?>
	
	</div>
	<div id="iddiv_managers" style="display:none;margin-top: 30px;" class="clear"></div>
	<div class="clear"></div>
	<script type="text/javascript">
	$(document).ready(function(){        
	    $('#idsel_levels').change(function(){
	        var val = $(this).val();
	        $('#iddiv_managers').html('');
	        
	        if(val !== '')
	        {            
	            $('#iddiv_managers').show();
	            displayindividualmanagers('<?php echo $init_id;?>','edit','<?php echo $line1_id;?>','<?php echo $employeeid;?>');
	        }
	        else
	        {            
	            $('#iddiv_managers').hide();
	        }
	    });
	<?php 
	if($context == 'edit')
	{
	?> 
	    $('#iddiv_managers').show();
	    $('#idsel_levels').val('<?php echo $levels;?>');
	    displayindividualmanagers('<?php echo $init_id;?>','<?php echo $context;?>','<?php echo $line1_id;?>','<?php echo $employeeid;?>');
	<?php        
	}
	?> 
	    apply_select2();
	});//end of ready function
	</script>
	<?php 
	}
	else 
	{
	?>
	<div class="ml-alert-1-info m1-info-set-2">
	    <div class="style-1-icon info"></div>
	       No employees to add.
	</div>
	<?php
	}
}
?>
