{% extends '@RxConnexion/Admin/content.html.twig' %}
{% block content %}
    <form method="POST" action="{{ path('supplier_form', {action: action, id: id}) }}" enctype="multipart/form-data">
        <div class="row max-width-initial">
            <div class="large-6 columns">
                <h5>Basic information</h5>
                <p class="form-hint-text">Enter basic information below</p>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.code) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.code) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.description) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.description) }}
                    </div>
                </div>
                <h5>Address</h5>
                <p class="form-hint-text">Enter address below</p>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.street) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.street) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.city_description) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.city_description) }}
                        {{ form_widget(form.city) }}
                    </div>
                </div>
                <h5>Payment information</h5>
                <p class="form-hint-text">Enter payment information below</p>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.payment_type) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.payment_type) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.payment_term) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.payment_term) }}
                    </div>
                </div>
                <h5>File(s) <a href="javascript:void(0)" id="href-new-file-field"><i class="fa fa-plus"></i></a></h5>
                <p class="form-hint-text">Upload file(s) below</p>
                <div id="file-field-container">
                    {% if supplier %}
                        {% for key,sf in supplier.supplierFiles %}
                            <div class="input-group no-margin-bottom">
                                <input type="hidden" name="otherForm[files][{{ key }}]" value="{{ sf.idencoded }}" />
                                <a href="{{ path('supplier_file_download', {id: sf.idencoded}) }}">{{ sf.filedesc }}</a>
                                <div class="input-group-button">
                                    <button type="button" class="button secondary file-field-remove"><i class="fa fa-remove"></i></button>
                                </div>
                            </div>
                        {% endfor %}
                    {% endif %}
                </div>
            </div>
            <div class="large-6 columns">
                <h5>Contact Information</h5>
                <p class="form-hint-text">Enter contact information below</p>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.mobile_no) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.mobile_no) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.phone_no) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.phone_no) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.email) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.email) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.fax) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.fax) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.tin_no) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.tin_no) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.contact_person) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.contact_person) }}
                    </div>
                </div>
                {% if userData.type == 'Super Admin' or 'Admin Supplier Active' in userData.accesses %}
                    <div class="row">
                        <div class="large-4 large-text-right columns">
                            {{ form_label(form.start_date) }}
                        </div>
                        <div class="large-8 columns">
                            {{ form_widget(form.start_date) }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="large-4 large-text-right columns">
                            {{ form_label(form.end_date) }}
                        </div>
                        <div class="large-8 columns">
                            {{ form_widget(form.end_date) }}
                        </div>
                    </div>
                {% endif %}
                <h5>Other Information</h5>
                <p class="form-hint-text">Enter other information below</p>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.note) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.note) }}
                    </div>
                </div>
            </div>
            <div class="small-12 columns">
                <hr class="max-width-initial">
                <div class="button-container">
                    {% if userData.type == 'Super Admin' or (form.vars.value.status == 'Pending Approval' or form.vars.value.status == null) %}
                        <button type="submit" class="button just-continue" name="action" value="{{ action }}"
                                data-message="Are you sure you want to save this information?"
                        >Save</button>
                    {% endif %}
                    {% if action == 'u' and (userData.type == 'Super Admin' or 'Admin Supplier Delete' in userData.accesses) %}
                        <button type="submit" class="ask-continue button alert" name="action" value="d"
                                data-message="Are you sure you want to delete this record?"
                        >Delete</button>
                    {% endif %}
                    <a href="{{ path('supplier') }}" class="button secondary">Back</a>
                </div>
            </div>
        </div>
        {{ form_widget(form.action) }}
        {{ form_widget(form.id) }}
        {{ form_widget(form._token) }}
    </form>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script language="javascript">
        //<![CDATA[
        jQ(document).ready(function(){
            supplier_form.city_autocomplete_url = '{{ path('city_autocomplete') }}';
            supplier_form.init();
        });
        //]]>
    </script>
{% endblock %}