<div id="primary_header">
  <h1><?php print $this->translate('ArchiveVault Settings')?></h1>

</div>

<div id="primary_content">
  <div id="primary_content_inner">
  <div id="Flash" class="flash_notice"><?php print $this->translate('The settings have been updated') ?></div>

<?php if( empty($this->archivevault) ) :?>
<div id="licence-error"><img class="regerror" src="<?php echo $this->siteBaseUrl; ?>/images/icons/error.png"/><span><?php echo $this->translate("ArchiveVault not available for this installation. Upgrade to the Corporate Atmail edition, or purchase ArchiveVault separately via the <a href='http://order.atmail.com/' target='_blank'>online store</a>") ?></span></div>
<?php endif ?>

  <form id="settingsForm" method="post" action="<?php echo $this->moduleBaseUrl ?>/services/archivevaultsave">

    <input type="hidden" name="save" value="1" />
	<!-- Specify default settings not available to edit -->

    <table class="settings">

      <tr>
        <td class="label"><?php print $this->translate('Enable ArchiveVault')?></td>
        <td>
			<input name="fields[smtp_archivevault_enable]" type='hidden' value='0'/>
			<input name="fields[smtp_archivevault_enable]" type="checkbox" class="iphoneStyle" id="smtp_archivevault_enable" value="1" <?php echo ($this->exim['smtp_archivevault_enable']) ? 'checked' : '' ?><?php echo (empty($this->archivevault)?' disabled':'') ?>>
			<small><?php print $this->translate('Enable the ArchiveVault service - Archive all incoming/outgoing messages to the Atmail ArchiveVault server. Store and archive all emails for legal and policy requirements.')?></small>
		</td>
      </tr>

      <tr>
        <td class="label"><label class='settings_label'><?php print $this->translate('ArchiveVault Hostname')?></label></td>
        <td>
			<input class="medium" name="fields[smtp_archivevault_hostname]" type="text" id="smtp_archivevault_hostname" value="<?php echo ($this->exim['smtp_archivevault_hostname'])?>" />
			<small><?php print $this->translate('Specify the hostname or IP address to route messages to the ArchiveVault server')?></small>
		</td>
      </tr>

      <tr>
        <td class="label"><label class='settings_label'><?php print $this->translate('ArchiveVault Port')?></label></td>
        <td>
			<input class="small" name="fields[smtp_archivevault_port]" type="text" id="smtp_archivevault_port" value="<?php echo ($this->exim['smtp_archivevault_port'])?>" />
			<small><?php print $this->translate('Specify the port of the ArchiveVault server ( default 2500 or 25 )')?></small>
		</td>
      </tr>
	</table>

	<table class="settings">

      <tr>
        <td class="label"><?php print $this->translate('ArchiveVault Status')?></td>
        <td>
			<strong id='archivevaultStatus'><?php echo $this->archivevaultStatus ?></strong>
			<small><?php print $this->translate('Status of the ArchiveVault service')?></small>
		</td>
      </tr>
	
	</table>
	
	<div class="divider"></div>
	
	<table class="settings">

      	<tr>
	        <td class="label"><?php print $this->translate('ArchiveVault URL')?></td>
	        <td>
				<input class="large" name="fields[archiveVaultURL]" type="text" id="archiveVaultURL" value="<?php echo ($this->archiveVault['archiveVaultURL'])?>" />
				<small><?php print $this->translate('The primary URL for ArchiveVault. Make sure this is a hostname users can access outside of the localhost. e.g. http://server.com/archive')?></small>
			</td>
		</tr>
		<tr>
	        <td class="label"><?php print $this->translate('ArchiveVault API Key')?></td>
	        <td>
				<input class="large" name="fields[archiveVaultAPIKey]" type="text" id="archiveVaultAPIKey" value="<?php echo ($this->archiveVault['archiveVaultAPIKey'])?>" />
				<small><?php print $this->translate('You can generate a new key from ArchiveVault Admin')?></small>
			</td>
		</tr>
		<tr>
	        <td class="label"><?php print $this->translate('ArchiveVault API Status')?></td>
	        <td>
				<strong id='archiveVaultAPIStatus'><?php echo $this->archiveVaultAPIStatus ?></strong>
				<small><?php print $this->translate('Status of the ArchiveVault Admin API service')?></small>
			</td>
		</tr>
	
	</table>
	
	
  </div>
  </form>

	<table class="settings">

  <tr>
    <td class="label"></td>
    <td>
		<div id="back_button" style="margin-left:0px;">
			<a href="#">
				<span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span>
			</a>
		</div>
		</td>
  </tr>
	
	</table>



</div>

<script type="text/javascript">
$( function()
{
	var tabId = '#Archive_Vault';
	$('#settingsForm', tabId).submit(function()
	{
		$('#archiveVaultAPIStatus, #archivevaultStatus').html('Attempting to connect with new settings...');
		return false;
	});
	perform_service_common_binds(tabId);

	$("#smtp_archivevault_enable", tabId).change( function()
	{
		enableSettingsBox($("#smtp_archivevault_enable", tabId));
	});
	enableSettingsBox($("#smtp_archivevault_enable", tabId));
});
</script>
