{if condition="isset($show_error_box)"}
    {include="message_box"}
{/if}
<h4><?php echo _("File Configuration Editor")?></h4>
<form method="post" action="config.php?type=tool&amp;display=epm_advanced&amp;subpage=poce">
  <button type="submit" name="button_select"><i class="icon-retweet"></i> <?php echo _('Select')?></button>
  <select name="product_select" id="product_select">
	{loop name="product_list"}
	<option value="{$value.value}" {if condition="isset($value.selected)"}selected='selected'{/if}>{$value.text}</option>
	{/loop}
  </select>
</form>
<form method="post" action="config.php?type=tool&amp;display=epm_advanced&amp;subpage=poce&amp;product_select={$product_selected}&amp;phone_options=true">
{if condition="isset($options)"}	
{$options}
{/if}
</form>
<table width="97%" border="0" cellspacing="4" cellpadding="4">
  <tr>
    <td width="150px" align='right'>{if condition="isset($location)"}<b>File:</b>{/if}</td>
    <td>{if condition="isset($location)"}<code class='inline'>{$location}</code>{/if}</td>
  </tr>
  <tr>
    <td valign="top" width="150px">
        <!--
        <u><?php echo _("Custom Template Files")?></u><br />
	{loop name="template_file_list"}
	<a href="config.php{$web_vars}&display=epm_advanced&subpage=poce&product_select={$product_selected}&temp_file={$value.value}">{$value.text}</a><br />
	{/loop}
	<hr>
        -->
	<h5><?php echo _("Local File Configs")?></h5>
	{loop name="file_list"}
	<a href="config.php?type=tool&amp;display=epm_advanced&amp;subpage=poce&amp;product_select={$product_selected}&amp;file={$value.value}"><code style="font-size: 0.8em">{$value.text}</code></a><br />
	{/loop}
	<h5><?php echo _("User File Configs")?></h5>
	{if condition="isset($sql_file_list)"}
		{loop name="sql_file_list"}
		<a href="config.php?type=tool&display=epm_advanced&subpage=poce&product_select={$product_selected}&sql={$value.value}"><code style="font-size: 0.8em">{$value.text}</code></a> <a href="config.php?type=tool&amp;display=epm_advanced&amp;subpage=poce&product_select={$product_selected}&amp;sql={$value.value}&amp;delete=yes"><i class='icon-remove red' alt='<?php echo _('Delete')?>'></i></a>
        <br><font style="font-size:0.8em"> [ref: <code>{$value.ref}</code>]</font>
		<br />
		{/loop}
	{/if}
	</td>
    <td>
      <form method="post" action="">
        <label>
          <textarea name="config_text" id="textarea" cols="100" rows="30" wrap="off">{if condition="isset($config_data)"}{$config_data}{/if}</textarea>
        </label>
        <p>
          <label>
            <button type="submit" name="button_save"><i class="icon-save blue"></i> <?php echo _('Save')?></button> <i class='icon-warning-sign'></i><font style="font-size: 0.8em; font-style: italic;">NOTE: File may be over-written during next package update. We suggest also using the <b>Share</b> button below to improve the next release.</font>
          </label>
        </p><p>
        {if condition="!isset($temp_file)"}
        <label>
          <button type="submit" name="button_save_as"><i class="icon-save blue"></i> <?php echo _('Save As')?>...</button>
        </label>
        <label>
          <input type="text" name="save_as_name" id="save_as_name" value="{if condition="isset($save_as_name_value)"}{$save_as_name_value}{/if}">
        </label> <i class='icon-warning-sign'></i><font style="font-size: 0.8em; font-style: italic;">NOTE: File is permanently saved and not over-written during next package update.</font>
        {/if}
        {if condition="isset($type)"}
        </p><p>
          <a href="config.php?type=tool&amp;display=epm_advanced&amp;subpage=poce&sendid={$sendid}&amp;filename={$filename}&amp;product_select={$product_selected}&amp;{if condition="$type == 'sql'"}sql={$sendid}{else}file={$sendid}{/if}">
          <button type="button" class="button_Enable"><i class="icon-upload-alt green"></i> Share</button></a> Upload this configuration file to the <b>Provisioner.net Team</b>. Files shared are confidential and help improve the quality of releases.
        {/if}
        </p>
      </form>
    </td>
  </tr>
</table>
<script>
    $(document).ready(function() {
        var editor = CodeMirror.fromTextArea(document.getElementById("textarea"), {lineWrapping: true, lineNumbers: true, mode: {name: "xml", htmlMode: true}});
    });
</script>
