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

if($this->ermsg !='')
{
?>
    <div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>No data found.</div>
<?php 
}
else
{
    $appraisal_data = $this->appraisal_data;
    $appraisal_id = $this->appraisal_id;
    $manager_id = $this->manager_id; 
    $app_text = $this->app_text;
    $counter = 0;
?>

<?php if($appraisal_data['enable_step'] == 2) { ?>
		<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>Appraisal is enabled to employees.</div>
<?php } else { ?>
    <script type="text/javascript" src="<?php echo MEDIA_PATH;?>js/pa.js"></script>
    <div id="error_message" style="display:none;"></div>
    <?php //echo $app_text; ?>
	<div class="requisitions-block">
        <div class="total-form-controller cancel-set data-view-details">
            
           <div class="cofig_title"  style="margin-left: 0px;"><span id="info_message">Initialization Details</span> 
                <div class="new-form-ui-submit "  style="margin-top: 0px; float: right; width: auto;">
	           		<div class="back-to-page" style="position: relative; float: right; top: 0px;">
								<input type="button" onclick="window.location.href='<?php echo BASE_URL; ?>appraisalmanager';" name="Back" value="Back"  style="margin-right: 0px;">
					</div>
	           </div> 
           </div>

        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="requisition-table view-table-data">
            <tr class="req-bg-form">
                <td width="20%"><span class="head_txt">Business Unit </span></td>
                <td width="30%"><?php echo $this->data['unitname'];?></td>
                <td width="20%"><span class="head_txt">Department </span></td>
                <td width="30%"><?php echo $this->data['deptname']!=''?$this->data['deptname']:"--";?></td>
            </tr>
            <tr  class="req-no-form">
                <td><span class="head_txt">Appraisal Mode</span></td>
                <td><?php echo $this->data['appraisal_mode'];?></td>
                <td><span class="head_txt">From Year </span></td>
                <td><?php echo $this->data['from_year'];?></td>
            </tr>
            <tr class="req-bg-form">
                <td><span class="head_txt">To Year </span></td>
                <td><?php echo $this->data['to_year'];?></td>
                <td><span class="head_txt">Period </span></td>
                <td><?php 
                if($this->data['appraisal_mode'] == 'Quarterly')
                    echo "Q".$this->data['appraisal_period'];
                else if($this->data['appraisal_mode'] == 'Half-yearly')
                    echo "H".$this->data['appraisal_period'];
                else echo "Yearly";
                ?></td>
            </tr>
            <tr class="req-no-form">
                <td><span class="head_txt">Appraisal Status </span></td>
                <td><?php echo $this->data['status'] == 1?"Open":"close";?></td>
                <td><span class="head_txt">Eligibility </span></td>
                <td><?php echo isset($this->data['eligibility_names'])?strtr($this->data['eligibility_names'], array (',' => ', ')):'';?></td>
            </tr>
            <tr class="req-bg-form">
                <td><span class="head_txt">Enabled To </span></td>
                <td><?php echo $this->data['enable_step'] == 1?"Managers":"Employees";?></td>
                <td><span class="head_txt">Parameters </span></td>
				<td><?php  echo isset($this->data['category_names'])?strtr($this->data['category_names'], array (',' => ', ')):''; ?></td>	
            </tr>
            <tr class="req-no-form">
            	<?php if(isset($this->data['managers_due_date']) && $this->data['managers_due_date']!=''){?>
	                <td><span class="head_txt">Managers Due Date </span></td>
	                <td><?php echo sapp_Global::change_date($this->data['managers_due_date'],'view');?></td>
                <?php $counter++;
            	}?>
                <?php if(isset($this->data['employees_due_date']) && $this->data['employees_due_date']!=''){?>
	                <td><span class="head_txt">Employees Due Date </span></td>
	                <td><?php echo sapp_Global::change_date($this->data['employees_due_date'],'view');?></td>
                <?php $counter++;
                }?>
                <?php if($counter<2){?>
                	  <td><span class="head_txt">Process Status </span></td>
	                  <td><?php echo $this->data['process_status'];?></td>	
                <?php }?>
            </tr>   
            <?php if($counter==2){?>
            <tr class="req-bg-form">
                <td><span class="head_txt">Process Status </span></td>
                <td><?php echo $this->data['process_status'];?></td>
                <td><span class="head_txt">Appraisal Ratings </span></td>
	            <td><?php echo $this->data['appraisal_ratings']==1?'1-5':'1-10';?></td>
            </tr> 
            <?php }else{ ?>
            	<tr class="req-bg-form">
	                <td><span class="head_txt">Appraisal Ratings </span></td>
	                <td><?php echo $this->data['appraisal_ratings']==1?'1-5':'1-10';?></td>
	                <td colspan="2"></td>
	            </tr>
            <?php }?>    
        </table>
        </div>
        <input type="hidden" id="group_cnt" value="<?php echo isset($appraisal_data['empcount'])?$appraisal_data['empcount']:0;?>" />
        
        <?php if(empty($this->questionsArr)){ ?>
        	<div style="clear: both;position: relative;top: 17px;width: 92%;" class="ml-alert-1-error">
						<div class="style-1-icon error"></div>
							Questions are not configured. <a href="<?php echo BASE_URL.'/appraisalquestions/add'?>" style="color:#A31414;text-decoration: none;font-weight: bold;"> Click here </a> to configure questions.
			</div>
        <?php } ?>
        		<div style="margin-left: 0px; padding-bottom: 0px;" class="cofig_title">Group Details</div>
				<div class="">
					<div id="iddiv_showgroups"></div>
					<div class="new-form-ui-submit" style="margin-left: 0px;margin-top: 20px;">
				<?php 
					$submit_value = "yes";
					if(!in_array($manager_id,array_unique(explode(',', $appraisal_data['manager_ids']))))
					{
						$submit_value = "no";
				?>
						<?php if(isset($appraisal_data['empcount']) && $appraisal_data['empcount'] > 0) {?>	
							<div class="create_new_group" id="iddiv_create" style=" margin-left: 0;">Create New Group</div>
						<?php } ?>
						<div class="create_new_group no_clear" id="iddiv_submit_init" style=" margin-left: 0;">Submit Initialization</div>
				<?php 
					}
				?>
						
							
						</div>
					<div class="invfrnds_confirm create_group_div per_steps" id="id_create_group" style="display:none; margin-left: 0px; background: none repeat scroll 0 0 #eee;"></div>
				</div>
		
    </div>
    
    
    
    <script type="text/javascript">
        $(document).ready(function(){
            show_groups('<?php echo $appraisal_id;?>');
    <?php 
        if($submit_value == 'no')
        {
    ?>
            $('#iddiv_create').click(function(){
                create_manager_group('<?php echo sapp_Global::_encrypt($appraisal_id);?>','<?php echo sapp_Global::_encrypt($manager_id);?>','add','');
            });
            $('#iddiv_submit_init').click(function(){
                submit_manager_initilisation('<?php echo sapp_Global::_encrypt($appraisal_id);?>','<?php echo sapp_Global::_encrypt($manager_id);?>');
            });
    <?php 
        }
    ?>
        });
    </script>
<?php } ?>    
<?php	
}	
?>