<?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 m1-info-set-2">
    <div class="style-1-icon info"></div>
       Site preferences already configured.
</div>
<?php 
}
else 
{
$date_formats_arr = $this->date_formats_arr;
$time_formats_arr = $this->time_formats_arr;
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="new-form-ui clearb">
			  <label class="required">Date Format</label>
			<div class="division loca_state_div"><?php //echo $this->form->dateformatid; ?>
                            <select name="dateformatid" id="dateformatid">
                                <option value="" example="">Select Date Format</option>
                        <?php 
                            foreach($date_formats_arr as $id=>$date_format)
                            {
                                $selected = ($date_format['id'] == $this->form->dateformatid->getValue())?"selected":"";
                                
                        ?>
                                <option value="<?php echo $date_format['id'];?>" <?php echo $selected;?> example="<?php echo $date_format['example'];?>" ><?php echo htmlspecialchars($date_format['description']);?></option>
                        <?php
                            }
                        ?>
                            </select>
                           
                        </div>
			<?php if(isset($this->msgarray['dateformatid'])){?>
			   <span class="errors" id="errors-dateformatid"><?php echo $this->msgarray['dateformatid'];?></span>
			<?php }?>
            <span id="id_date_format_example" class="hint-new" ></span>
			</div>
			<div class="new-form-ui clearb">
			  <label class="required">Time Format</label>
			<div class="division"><?php //echo $this->form->timeformatid; ?>
                        <select name="timeformatid" id="timeformatid">
                                <option value="" example="">Select Time Format</option>
                        <?php 
                            foreach($time_formats_arr as $id=>$time_format)
                            {
                                $selected = ($time_format['id'] == $this->form->timeformatid->getValue())?"selected":"";
                        ?>
                                <option value="<?php echo $time_format['id'];?>" <?php echo $selected;?> example="<?php echo $time_format['example'];?>" ><?php echo htmlspecialchars($time_format['description']);?></option>
                        <?php
                            }
                        ?>
                            </select>
                        </div>
			<?php if(isset($this->msgarray['timeformatid'])){?>
			   <span class="errors" id="errors-timeformatid"><?php echo $this->msgarray['timeformatid'];?></span>
			<?php }?>
            
             <span id="id_time_format_example" class="hint-new"></span>
            
			</div>
			

            <div class="new-form-ui clearb">
			  <label class="required">Default Time Zone</label>
			<div class="division"><?php echo $this->form->timezoneid; ?>
			<?php if(isset($this->msgarray['timezoneid'])){?>
			   <span class="errors" id="errors-<?php echo $this->form->timezoneid->getId(); ?>"><?php echo $this->msgarray['timezoneid'];?></span>
			<?php }?>
			<?php if(in_array('timezone',$this->popConfigPermission)) { ?>	
				<span class="add-coloum" onclick="displaydeptform('<?php echo BASE_URL.'timezone/addpopup' ?>','Timezone');"> Add Time zone </span>			
			<?php } ?>
			</div>
			</div>
			
			<div class="new-form-ui clearb">
			  <label class="required">Default Currency</label>
			<div class="division"><?php echo $this->form->currencyid; ?>
			
				<?php if(isset($this->msgarray['currencyid'])){?>
				   <span class="errors" id="errors-<?php echo $this->form->currencyid->getId(); ?>"><?php echo $this->msgarray['currencyid'];?></span>
				<?php }?>
			
			   <?php if(in_array('currency',$this->popConfigPermission)) { ?>	
					<span class="add-coloum" onclick="displaydeptform('<?php echo BASE_URL.'currency/addpopup' ?>','Currency');"> Add Currency </span>			
				<?php } ?>
				</div>
			
			</div>
			<div class="clearall fullwidth"></div>
			<div class="new-form-ui">
			  <label class="required">Default Password</label>
			<div class="division"><?php echo $this->form->passwordid; ?></div>
			<?php if(isset($this->msgarray['passwordid'])){?>
			   <span class="errors" id="errors-<?php echo $this->form->passwordid->getId(); ?>"><?php echo $this->msgarray['passwordid'];?></span>
			<?php }?>
			</div>
			<div class="new-form-ui clearb textareaheight">
			  <label>Description</label>
			<div class="division"><?php echo $this->form->description; ?></div>
			</div>
	     	<?php
			   if(!empty($this->passworddata))
			   {
			     for($i=0;$i<sizeof($this->passworddata);$i++)
				  {
			?>	  
				    <div id="password_<?php echo $this->passworddata[$i]['id'];?>" class="password_hint" style="display:none;">
					     <?php  echo $this->passworddata[$i]['description']; ?>
					</div>
			<?php	  
				  } 
			   }
			?>
					
			

		<div class="new-form-ui-submit">
		<?php echo $this->form->submit; ?>
		<button onclick="window.location.href='<?php echo BASE_URL; ?>sitepreference';" type="button" id="Cancel" name="Cancel">Cancel</button>
		</div>
</div>
    <div id="currencyContainer"  style="display: none; overflow: auto;">
	<div class="heading">
		<a href="javascript:void(0)">
	    <img src="<?php echo $this->baseUrl().'/public/media/';?>images/close.png" name="" align="right" border="0" hspace="3" vspace="5" class="closeAttachPopup" style="margin: -24px 8px 0 0;"> </a>
	</div>

	<iframe id="currencyCont" class="business_units_iframe" frameborder="0"></iframe>
</div>
<div id="timezoneContainer"  style="display: none; overflow: auto;">
	<div class="heading">
		<a href="javascript:void(0)">
	    <img src="<?php echo $this->baseUrl().'/public/media/';?>images/close.png" name="" align="right" border="0" hspace="3" vspace="5" class="closeAttachPopup" style="margin: -24px 8px 0 0;"> </a>
	</div>

	<iframe id="timezoneCont" class="business_units_iframe" frameborder="0"></iframe>
</div>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
    $('#dateformatid').change(function(){
        var val = $(this).val();
        $('#id_date_format_example').html('');
        var example = $('#dateformatid option[value="'+val+'"]').attr('example');
        if(example!='')
        $('#id_date_format_example').html("Example: "+example);
    });
    
    $('#timeformatid').change(function(){
        var val = $(this).val();
        $('#id_time_format_example').html('');
        var example = $('#timeformatid option[value="'+val+'"]').attr('example');
        if(example!='')
        $('#id_time_format_example').html("Example: "+example);
    });
});
</script>    
</form>
<?php 
}
?>
