{if condition="isset($show_error_box)"}
    {include="message_box"}
{/if}
<style type="text/css">
<!--
.brand, .product {
    margin-top: 10px;
}
button {
    width: 90px;
}
button.wide {
    width: 140px;
}
button.double-wide {
    width: 160px;
}
-->
</style>
<script type="text/javascript" charset="utf-8">
    function check() {
        $('#spinner').toggle();
        document.check.submit();
    }
</script>
<center>
<form id='check' action='config.php?type=tool&amp;display=epm_config' method='POST'>
	<button type="submit" name="button_check_for_updates" class='double-wide' onclick="check();"><i class='icon-refresh blue'></i> <?php echo _('Check for Updates')?></button>
</form>
</center>

<br><br>

{if condition="1 == 0"}
<script type="text/javascript" src="/admin/modules/endpointman/templates/javascript/jquery.jstree.js"></script>
<script type="text/javascript" class="source">
$(function () {
	$("#demo1").jstree({
                 "core" : { "initially_open" : [ {loop name="brand2_list"}"brand_{$value.id}",{loop name="value.products"}"products_{$value.id}",{/loop}{/loop} ] },

		"plugins" : [ "themes", "html_data", "checkbox" ]
	});
         $("#frmTree").submit(function () { generateHiddenFieldsForTree("demo1"); });

});
</script>
<script>
function generateHiddenFieldsForTree(treeId) {
    var checked_ids = [];

    $("#demo1").jstree("get_checked").each(function () {
        var checkedId = this.id;
        $("<input>").attr("type", "hidden").attr("name", checkedId).val("on").appendTo("#" + treeId);
        checked_ids.push(this.id);
    });
    $("#hidden").val(checked_ids.join(","));
}

</script>
<form id="frmTree" action="#" method="POST">
{if condition="!isset($update_check)"}
    <div id="demo1" class="demo">
        <ul>
            {loop name="brand2_list"}
            <li id="brand_{$value.id}">
                <a href="#">{$value.name}</a>
                <ul>
                    {loop name="value.products"}
                    <li id="products_{$value.id}">
                        <a href="#">{$value.long_name}</a>
                        <ul>
                            {loop name="value.models"}
                            <li id="models_{$value.id}" {if condition="$value.enabled == '1'"}class="jstree-checked"{/if}>
                                <a href="#">{$value.model}</a>

                            </li>
                            {/loop}
                        </ul>
                    </li>
                    {/loop}
                </ul>
            </li>
            {/loop}
        </ul>
    </div>
    <input type="hidden" name="hidden" id="hidden" value="English">
    <input type="submit" name="install-jstree" value="Install/Uninstall">
{else}
    <div id="demo1" class="demo">
            <ul>
                {loop name="brand2_list"}
                <li id="brand_{$value.id}">
                    <a href="#">{$value.name} <i>(<?php echo _('Package Last Modified')?> [{$value.cfg_ver}])</i></a>
                    <ul>
                        {loop name="value.products"}
                        <li id="products_{$value.id}">
                            <a href="#">{$value.long_name}</a>
                        </li>
                        {/loop}
                    </ul>
                </li>
                {/loop}
            </ul>
        </div>
        <input type="hidden" name="hidden" id="hidden" value="English">
        <input type="submit" name="install-jstree" value="Update Checked">
{/if}

</form>
{/if}
{if condition="isset($installer)"}
<script>
var box;
function process_module_actions(actions) {
    $(document).ready(function() {
	urlStr = "config.php?display=epm_config&amp;quietmode=1&amp;handler=file&amp;file=installer.html.php&amp;module=endpointman&amp;type={$installer.type}&amp;id={$installer.id}";
	urlStr += "&amp;rand="+Math.random ( );
        for (var i in actions) {
            urlStr += "&amp;moduleaction["+i+"]="+actions[i];
        }
        box = $('<div></div>')
        .html('<iframe height="100%" frameBorder="0" src="'+urlStr+'"></iframe>')
        .dialog({
            title: 'Status - Please Wait',
            resizable: false,
            modal: true,
            position: ['center', 50],
            width: '400px',
            height: 230,
            close: function (e) {
                close_module_actions(true);
                $(e.target).dialog("destroy").remove();
            }
        });
    });
}
function close_module_actions(goback) {
        box.dialog("destroy").remove();
        if (goback) {
            location.href = 'config.php?display=epm_config';
        }
}
process_module_actions();
</script>
<div id="moduleBox" style="display:none;"></div>
{/if}
{if condition="1 == 1"}
    {loop name="brand2_list"}
        <form action='config.php?type=tool&amp;display=epm_config' method='POST'><input type="hidden" name="brand" value="{$value.id}"><button type="submit" name="button_{if condition="$value.installed == '1'"}uninstall{else}install{/if}" class="button_{if condition="$value.installed == '1'"}Disable{else}Enable{/if}">{if condition="$value.installed == '1'"}<i class='icon-remove red'></i> <?php echo _('Uninstall')?>{else}<i class='icon-plus green'></i> <?php echo _('Install')?>{/if}</button>{if condition="array_key_exists('update',$value)"}{if condition="$value.update == 1"}New Package Modified [{$value.update_vers}]<input type="submit" name="button_update" class="button_update" value="<?php echo _('Update')?>">{/if}{/if}<font style='font-size: 1.2em; vertical-align: middle'><b>{$value.name}</b></font>
        <div style='vertical-align: middle; float: right'>{if condition="$value.installed == '1'"}(<font size="-1"><?php echo _('Package Last Modified')?> [{$value.cfg_ver}]</font>) {/if}{if condition="$value.installed == '1'"}<input type="checkbox" name="vehicle" value="Bike" disabled {if condition="$value.local == 0"}checked{/if}/>Check Online{/if}</div></form>

        <table width="100%" class="brand" border="0" cellspacing="0" cellpadding="0">
            <tr>
            </tr>
            <tr>
                <td width="3%">&nbsp;</td>
                <td width="97%">{loop name="value.products"}
                    <table width="100%" class="product alt_table" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td colspan="2">{if condition="$value.cfg_ver != ''"}{/if} <form action='config.php?type=tool&amp;display=epm_config' method='POST'><input type="hidden" name="product" value="{$value.id}">{if condition="array_key_exists('update',$value)"}{if condition="$value.update == 1"}<button type="submit" name="button_update" class="button_update"><i class='icon-refresh green'></i>Update</button>{/if}{/if}{if condition="$value.fw_type == 'install'"}<button type="submit" name="button_install_firmware" class="button_update button_Enable wide"><i class='icon-plus green'></i> <?php echo _('Install Firmware')?></button>{elseif condition="$value.fw_type == 'remove'"}<button type="submit" name="button_remove_firmware" class="button_update button_Disable wide"><i class='icon-remove red'></i> <?php echo _('Remove Firmware')?></button>{/if}{if condition="array_key_exists('update_fw',$value)"}{if condition="$value.update_fw == 1"}<button type="submit" name="button_update_firmware" class="button_update"><i class='icon-refresh blue'></i> <?php echo _('Update Firmware')?>">{/if}{/if}<font style='vertical-align: middle'><b>{$value.long_name}</b></font></form></td>
                        </tr>
                        <tr>
                            <td width="4%">&nbsp;</td>
                            <td width="96%">{loop name="value.models"}
                                <table width="100%" class="model" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td><form action='config.php?type=tool&amp;display=epm_config' method='POST'><input type="hidden" name="model" value="{$value.id}"><button type="submit" name="button_{if condition="$value.enabled == '1'"}disable{else}enable{/if}" class="button_{if condition="$value.enabled == '1'"}Disable{else}Enable{/if}">{if condition="$value.enabled == '1'"}<i class='icon-remove red'></i> <?php echo _('Disable')?>{else}<i class='icon-plus green'></i> <?php echo _('Enable')?>{/if}</button> <font style='vertical-align: middle'>{$value.model}</font></form></td>
                                    </tr>
                                </table>{/loop}</td>
                        </tr>
                    </table>{/loop}</td>
            </tr>
        </table>
        <br />
        <br />
    {/loop}
{/if}
<hr>
<h6 align='center'>Want to participate? Add new phones? Join us at <a href="http://provisioner.net" target="_blank">http://www.provisioner.net</a></h6>
{include="global_footer"}
