<?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;

if($employees_cnt > 0)
{
?>

<div class="total-form-controller">
<div class="up_arrow"></div>
<?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=1;$i<=5;$i++)
        {
?>
            <option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php
        }
?>
            </select>
        </div>
    </div>
<?php 
}
else
{
?>
    <input type="hidden" name="sel_levels" id="idsel_levels" value="<?php echo $levels;?>" />
    <div class="new-form-ui">
        <label>Appraisal Levels</label>
        <div class="division"><?php echo $init_data['manager_levels'];?></div>
    </div>
<?php     
}
?>
</div>
<div id="iddiv_managers" style="display:none;margin-top: 30px;"></div>
<div class="clear"></div>
<script type="text/javascript">
$(document).ready(function(){        
    $('#idsel_levels').change(function(){
        var val = $(this).val();
        $('#iddiv_managers').html('');
        var line_1_id = $("#id_mgr_value").val();
        if(val !== '')
        {            
            $('#iddiv_managers').show();
            display_managers('<?php echo $init_id;?>','<?php echo $context;?>',line_1_id);
        }
        else
        {            
            $('#iddiv_managers').hide();
        }
    });
<?php 
if($context == 'edit')
{
?> 
    $('#iddiv_managers').show();
    $('#idsel_levels').val('<?php echo $levels;?>');
    display_managers('<?php echo $init_id;?>','<?php echo $context;?>','<?php echo $line1_id;?>');
<?php        
}
?> 
    apply_select2();
});//end of ready function
</script>
<?php 
}
else 
{
?>
<div class="ml-alert-1-info m1-info-set-2" style="width: 100%;">
    <div class="style-1-icon info"></div>
       No employees to add.
</div>
<?php
}
?>
