{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}

{% set active_menu = 'system' %}

{% block meta_title %}{{ 'SolusVM'|trans }}{% endblock %}

{% block breadcrumbs %}
    <ul>
        <li class="firstB"><a href="{{ '/'|alink }}">{{ 'Home'|trans }}</a></li>
        <li><a href="{{ 'system'|alink }}">{{ 'Settings'|trans }}</a></li>
        <li class="lastB">{{ 'SolusVM'|trans }}</li>
    </ul>
{% endblock %}

{% block content %}
    {% set params = admin.servicesolusvm_cluster_config %}

    {% if params.ipaddress %}
        {% set master_url = 'http://'~params.ipaddress~':'~params.port|default(5353)~'/admincp' %}
    {% endif %}

<div class="widget simpleTabs">

    <ul class="tabs">
        <li><a href="#tab-start">{{ 'SolusVM'|trans }}</a></li>
        <li><a href="#tab-index" id="open-index-tab">{{ 'API configuration'|trans }}</a></li>
    </ul>

    <div class="tabs_container">
        <div class="fix"></div>
        
        <div class="tab_content nopadding" id="tab-start">
            <div class="help">
                <img src="/bb-modules/Servicesolusvm/icon.png" alt="SolusVM logo" class="" style="width: 150px; float: right; margin: 0 5px 0 10px;"/>
                <h5>{{ 'Getting started with SolusVM'|trans }}</h5>
                <p>{{ 'This guide will help you to get started selling SolusVM virtual servers with BoxBilling.'|trans }}</p>
            </div>
            
            <div class="body">    
                <h2>{{ '1. Configure your SolusVM server'|trans }}</h2>
                <p>Make sure that your SolusVM master server is properly configured - has defined nodes, plans, free ip addresses, operating system templates.</p>
                {% if master_url %}
                <p><a href="{{master_url}}" class="btnIconLeft mr10 mt10" target="_blank"><span>Open SolusVm admin panel</span></a></p>
                {% endif %}
            </div>
            
            <div class="body">
                <h2>{{ '2. Configure API'|trans }}</h2>
                <p><a href="" onclick="$('#open-index-tab').click(); return false;">Configure SolusVM API</a> and test if BoxBilling can connect successfully. To create an API user login to SolusVM admin area and click Configuration > API Access from the top menu then select Add API User.</p>
            </div>
            
            <div class="body">    
                <h2>{{ '3. Create new product category'|trans }}</h2>
                <p>Create <a href="{{ 'product'|alink({ 'cat_title': 'VPS', 'cat_description': 'Virtual private servers' }) }}#tab-new-category" target="_blank">new product category</a> for VPS products. Category must contain only solusvm products otherwise order form might not work as expected.</p>
            </div>
            
            <div class="body list arrowBlue">
                <h2>{{ '4. Create SolusVM products'|trans }}</h2>
                <p>Imagine that product on BoxBilling is SolusVM plan.</p>
                <p><a href="{{'product'|alink({'type' : 'solusvm', 'title' : 'VPS-1'})}}#tab-new" target="_blank">Create products</a> in newly created category by selecting product type <strong>Solusvm</strong>.</p>
                <p>Define product prices and switch to "Configuration" tab:</p>
                <ul>
                    <li>Select virtualization type</li>
                    <li>Select node on which VPS will be created</li>
                    <li>Select plan</li>
                    <li>Define IPs amount for VPS server</li>
                    <li>Provide information about plan to BoxBilling so it can show these values to your clients. (SolusVM API does not provide this information)</li>
                    <li>Provide slider information to be displayed on order form</li>
                </ul>
                <p><a href="{{ 'order'|link }}" target="_blank">Check order page</a> while creating products to see slider changes</p>
            </div>
            
            <div class="body">
                <h2>{{ '5. Import data from SolusVM server'|trans }}</h2>
                <p>If you already have successfully connected to master server and have existing clients and server then you can import them using these tools:</p>
                {% if master_url %}
                    <a href="{{ 'servicesolusvm/import/clients'|alink }}" title="" class="btnIconLeft mr10 mt10"><span>5.1 Import clients</span></a>
                    <a href="{{ 'servicesolusvm/import/servers'|alink({'node_id' : 1}) }}" title="" class="btnIconLeft mr10 mt10"><span>5.2 Import servers</span></a>
                {% else %}
                    <p>Configure API before importing data. Refresh this page if you already confugured API.</p>
                {% endif %}
            </div>
        </div>
        
        <div class="tab_content nopadding" id="tab-index">
            <div class="help">
                <h5>{{ 'Connect to SolusVM master server via API'|trans }}</h5>
                <p>{{ 'To create an API user login to SolusVM admin area and click Configuration > API Access from the top menu then select Add API User.'|trans }}</p>
            </div>
            
            <div class="body">
                <div class="nNote nInformation first">
                    <p><strong>{{ 'INFORMATION'|trans }}: </strong>You need to specify IP <strong>{{ admin.system_env.ip }}</strong> in the SolusVM API user.</p>
                </div>
            </div>
            
            <form method="post" action="{{ 'api/admin/servicesolusvm/cluster_config_update'|link }}" class="mainForm api-form" data-api-msg="{{ 'Configuration updated'|trans }}">
                <fieldset>
                    <div class="rowElem noborder">
                        <label>{{ 'ID'|trans }}:</label>
                        <div class="formRight">
                            <input type="text" name="id" value="{{params.id}}" required="required" placeholder="Example: t5kGu4EZqAyRqh0ZlN2O"/>
                        </div>
                        <div class="fix"></div>
                    </div>
                    
                    <div class="rowElem">
                        <label>{{ 'Key'|trans }}:</label>
                        <div class="formRight">
                            <input type="password" name="key" value="{{params.key}}" required="required" placeholder="Example: XzTftPQTxEwRxHmTARIS"/>
                        </div>
                        <div class="fix"></div>
                    </div>
                    
                    <div class="rowElem">
                        <label>{{ 'Master server IP'|trans }}:</label>
                        <div class="formRight">
                            <input type="text" name="ipaddress" value="{{params.ipaddress}}" required="required" placeholder="Example: 123.123.123.123"/>
                        </div>
                        <div class="fix"></div>
                    </div>
                    
                    <div class="rowElem">
                        <label>{{ 'Secure connection'|trans }}:</label>
                        <div class="formRight">
                            <input type="radio" name="secure" value="1" {% if params.secure == "1" %}checked="checked"{% endif %}/><label>{{ 'Yes'|trans }}</label>
                            <input type="radio" name="secure" value="0" {% if not params.secure %}checked="checked"{% endif %}/><label>{{ 'No'|trans }}</label>
                        </div>
                        <div class="fix"></div>
                    </div>
                    
                    <div class="rowElem">
                        <label>{{ 'Custom port'|trans }}:</label>
                        <div class="formRight">
                            <input type="text" name="port" value="{{params.port}}" placeholder="{{ 'Leave blank to use default port 5353 and 5656 for secure connection'|trans }}"/>
                        </div>
                        <div class="fix"></div>
                    </div>
                    
                    <input type="hidden" name="cluster_id" value="1" />
                    <input type="button" value="2. {{ 'Test connection'|trans }}" class="greyishBtn submitForm" id="testconnection"/>
                    <input type="submit" value="1. {{ 'Update'|trans }}" class="greyishBtn submitForm" />
                    
                </fieldset>
            </form>

            <div class="fix"></div>

        </div>

    </div>
</div>
{% endblock %}

{% block js %}
{% autoescape "js" %}
<script type="text/javascript">
$(function() {
    $('#testconnection').click(function() {
        bb.post('admin/servicesolusvm/test_connection', null, function(result) {
            bb.msg('Successfully connected to SolusVM server');
        });

        return false;
    });
});
</script>
{% endautoescape %}
{% endblock %}
