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

<?php 
if($this->nodata != '')
{
?>
<div class="ml-alert-1-info">
    <div class="style-1-icon info"></div>
       No data found.
</div>
<?php 
}
else 
{
sapp_Global::generateClientValidations($this->form);

?>
<div id="error_message" style="display:none;"></div>

<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(); ?>">
		<?php echo $this->form->id; ?>

<div class="total-form-controller">
	<div class="separetor-heading"><span class="required">Configure <?php echo $this->form->identitydoc->getLabel(); ?></span></div>
			<div class="new-form-ui fullwidth inputheight-1">
				<div class="division id-text"><?php echo $this->form->identitydoc; ?></div>
				<?php if(isset($this->msgarray['identitydoc'])){?>
				   <span class="errors" id="errors-<?php echo $this->form->identitydoc->getId(); ?>"><?php echo $this->msgarray['identitydoc'];?></span>
				<?php }?>
			</div>
			
			<div class="new-form-ui inputheight width120">
				  <label>Other Document</label>
				<div class="division"><?php echo $this->form->othercheck; ?></div>
				<?php if(isset($this->msgarray['othercheck'])){?>
				   <span class="errors" id="errors-<?php echo $this->form->othercheck->getId(); ?>"><?php echo $this->msgarray['othercheck'];?></span>
				<?php }?>
			</div>
			
			<div class="new-form-ui inputheight" style="display:none;"  id="otherdocumentdiv">
				  <label class="required"><?php echo $this->form->otherdocument->getLabel(); ?></label>
				<div class="division"><?php echo $this->form->otherdocument; ?></div>
				   <span class="errors" id="errors-<?php echo $this->form->otherdocument->getId(); ?>"><?php echo isset($this->msgarray['otherdocument'])?$this->msgarray['otherdocument']:'';?></span>
			</div>
			
			
		<div class="new-form-ui-submit">
		<?php echo $this->form->submit; ?>
		<button onclick="window.location.href='<?php echo BASE_URL; ?>identitydocuments';" type="button" id="Cancel" name="Cancel">Cancel</button>
		</div>
       </div>
</form>

<script type='text/javascript'>
$(document).ready(function(){
        <?php if(isset($this->data[0]['others']) && $this->data[0]['others'] !='') {?>
              $('#otherdocumentdiv').show();
        <?php }?>  		
		
        <?php if (isset($this->msgarray['otherdocument'])) {?>
		setTimeout(function(){
      		$('#otherdocumentdiv').show();
		},0300);	
        <?php }?>  

		<?php if (isset($_POST))
			{
		    if(isset($_POST['othercheck']) && isset($_POST['otherdocument']))
				{
				if($_POST['othercheck'] == 1 && $_POST['otherdocument'] !='')
				 {
				?>
      		$('#otherdocumentdiv').show();
        <?php 	 }else {
					if (!isset($this->msgarray['otherdocument']))
					{
		?>
		    $('#otherdocumentdiv').hide();
		<?php 		}}
				}
			}
		?>	
	
});
 
</script>

<?php } ?>