{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% set active_menu = 'order' %}
{% import "macro_functions.phtml" as mf %}

{% block meta_title %}{% trans 'Create new order' %}{% endblock %}

{% block content %}
{% set product = admin.product_get({"id":request.product_id}) %}
{% set client = admin.client_get({"id":request.client_id}) %}
<div class="widget first">
    <div class="head"><h5 class="iFrames">{% trans 'Create new order' %}</h5></div>
            <div class="help">
                <h2>"{{ product.title }}" {% trans 'for' %} {{ client.first_name }} {{ client.last_name }}</h2>
            </div>
    <form method="get" action="admin/order/create" class="mainForm api-form" data-api-jsonp="onAfterOrderPlaced">
        <fieldset>

            <div class="rowElem">
                <label>{% trans 'Invoice option' %}</label>
                <div class="formRight noborder">
                    {{ mf.selectbox('invoice_option', admin.order_get_invoice_options, order.invoice_option) }}
                </div>
                <div class="fix"></div>
            </div>
            
            <div class="rowElem">
                <label>{% trans 'Activate' %}:</label>
                <div class="formRight">
                    <input type="radio" name="activate" value="1" checked="checked"/><label>Yes</label>
                    <input type="radio" name="activate" value="0" /><label>No</label>
                </div>
                <div class="fix"></div>
            </div>
            
            {% if product.pricing.type == 'recurrent' %}
            <div class="rowElem">
                <label>{% trans 'Period' %}</label>
                <div class="formRight">
                    {{ mf.selectbox('period', guest.system_periods, request.period, 1) }}
                </div>
                <div class="fix"></div>
            </div>
            {% endif %}
            
            {% set product_order = 'mod_service'~product.type~'_order.phtml' %}
            {% if admin.system_template_exists({"file":product_order}) %}
                {% include product_order %}
            {% endif %}
            
            <input type="submit" value="{% trans 'Place new order' %}" class="greyishBtn submitForm" />
            <input type="hidden" name="client_id" value="{{ request.client_id }}" />
            <input type="hidden" name="product_id" value="{{ request.product_id }}" />
        </fieldset>
    </form>
</div>

{% endblock %}

{% block js%}
<script type="text/javascript">

    function onAfterOrderPlaced(id) {
        bb.redirect("order/manage/"+id);
    }
    
</script>
{% endblock %}