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

<form name="<?php echo $this->form->getName(); ?>" id="<?php echo $this->form->getId(); ?>"	action="<?php echo $this->form->getAction();?>"	method="<?php echo $this->form->getMethod(); ?>">
<div class="background-check-div">
<div class="separetor-heading"><span class="required">Employee Configuration</span></div>
    <div class="emp-check-div-inputs">
        <?php echo $this->form->checktype; ?>
    </div>
	<?php if(isset($this->msgarray['checktype'])){?>
        <span class="errors" id="errors-<?php echo $this->form->checktype->getId(); ?>"><?php echo $this->msgarray['checktype'];?></span>
    <?php }
    ?>
</div>
<div class="emp-check-div-inputs mrgetop20">
    <label><?php echo $this->form->checkall; ?>
        <?php echo $this->form->checkall->getLabel(); ?>
    </label>
</div>

<div class="new-form-ui-submit mrgetop20">
	<?php echo $this->form->submit;?>
	<button	onclick="window.location.href='<?php echo BASE_URL; ?>empconfiguration';" type="button" id="Cancel" name="Cancel">Cancel</button>
</div>


</form>

<script type='text/javascript'>
$(document).ready(function(){

	$("#checkall").change(function() { 
	    if(this.checked) {
	    	$("input[name='checktype[]']").each(function(idx, elem) {		    		
		    		var elemid = $(elem).attr('id');		    		
		    		document.getElementById(elemid).checked = true;	    		   
	    		});
	     }else{
	    	$('.empconfigcheckbox').removeAttr('checked');
		}
	});

	$(".empconfigcheckbox").change(function() { 
	    if(!(this.checked)) {
	    		    	
	    	$('#checkall').removeAttr('checked');
		}
	    else
	    {
	    	var is_checked_flag = true;
	    	$("input[name='checktype[]']").each(function(idx, elem) {

	    		var is_checked = $(this).prop("checked");
    		   	if(!is_checked) is_checked_flag = false;
    		});
	    
    		if(!is_checked_flag) 
        		$('#checkall').removeAttr('checked');
    		else
        		document.getElementById('checkall').checked = true;
        		
	    }
	});	
});   
</script>