{% extends '@RxConnexion/Admin/content.html.twig' %}
{% block content %}
    <form method="POST" action="{{ path('transfer_inventory_form', {action: action, id: id, pm: projectManagement.idEncoded|default(0)}) }}">
        <div class="row max-width-initial">
            <div class="large-5 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.transferDate) }}
                    </div>
                    <div class="large-8 columns">
                        {{ form_widget(form.transferDate) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.branchFrom_description) }}
                    </div>
                    <div class="large-8 columns">
                        {#{% if action == 'n' and projectManagement_type == 'i' and projectManagement and branch_projectEvents and branch_rccCenter %}#}
                            {#{{ form_widget(form.branchFrom_description, {value: branch_rccCenter.description}) }}#}
                            {#{{ form_widget(form.branchFrom_id, {value: branch_rccCenter.id}) }}#}
                            {#{{ form_widget(form.locationFrom_description, {attr: {class: (form.branchFrom_description.vars.value != 'Project/Events') ? 'hide' : ''}}) }}#}
                            {#{{ form_widget(form.locationFrom_id) }}#}
                        {#{% else %}#}
                            {{ form_widget(form.branchFrom_description) }}
                            {{ form_widget(form.branchFrom) }}
                            {{ form_widget(form.locationFrom_description, {attr: {class: (form.branchFrom_description.vars.value != 'Project/Events') ? 'hide' : ''}}) }}
                            {{ form_widget(form.locationFrom) }}
                        {#{% endif %}#}
                    </div>
                </div>
                <div class="row">
                    <div class="large-4 large-text-right columns">
                        {{ form_label(form.branchTo_description) }}
                    </div>
                    <div class="large-8 columns">
                        {#{% if action == 'n' and projectManagement_type == 'i' and projectManagement and branch_projectEvents and branch_rccCenter %}#}
                            {#{{ form_widget(form.branchTo_description, {value: branch_projectEvents.description}) }}#}
                            {#{{ form_widget(form.branchTo, {value: branch_projectEvents.id}) }}#}
                            {#{{ form_widget(form.locationTo_description, {value: projectManagement.location.description ~ ' - ' ~ branch_projectEvents.description}) }}#}
                            {#{{ form_widget(form.locationTo, {value: projectManagement.location.id}) }}#}
                        {#{% else %}#}
                            {{ form_widget(form.branchTo_description) }}
                            {{ form_widget(form.branchTo) }}
                            {{ form_widget(form.locationTo_description, {attr: {class: (form.branchTo_description.vars.value != 'Project/Events') ? 'hide' : ''}}) }}
                            {{ form_widget(form.locationTo) }}
                        {#{% endif %}#}
                    </div>
                </div>
                {#<div class="row">#}
                    {#<div class="large-4 large-text-right columns">#}
                        {#{{ form_label(form.department) }}#}
                    {#</div>#}
                    {#<div class="large-8 columns">#}
                        {#{{ form_widget(form.department) }}#}
                    {#</div>#}
                {#</div>#}
                <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="large-7 columns">#}
                {#<h5>Reference Purchase Requests</h5>#}
                {#<p class="form-hint-text">Enter reference purchase requests below</p>#}
                {#<table width="100%" id="table-reference-mr">#}
                    {#<thead>#}
                    {#<tr>#}
                        {#<th>Control No.</th>#}
                        {#<th>Request Date</th>#}
                        {#<th>Branch</th>#}
                        {#<th>Department</th>#}
                        {#<th>Purpose</th>#}
                        {#<th>Specific Purpose</th>#}
                        {#<th></th>#}
                    {#</tr>#}
                    {#</thead>#}
                    {#<tbody>#}
                    {#{% if transferInventory %}#}
                        {#{% for timr in transferInventory.transferInventoryMatReqs %}#}
                            {#{% set mr = timr.materialRequisition %}#}
                            {#<tr id="tr-reference-mr-{{ mr.id }}">#}
                                {#<td>{{ mr.materialRequisitionNo }}</td>#}
                                {#<td>{{ mr.requestDateAsString }}</td>#}
                                {#<td>{{ mr.branch.description }}</td>#}
                                {#<td>{{ mr.department.description }}</td>#}
                                {#<td>{{ mr.purpose.description|default('') }}</td>#}
                                {#<td>{{ mr.specificPurpose }}</td>#}
                                {#<td>#}
                                    {#<input type="hidden"#}
                                           {#name="otherForm[mrs][{{ mr.id }}][id]"#}
                                           {#id="otherForm-mrs-id-{{ mr.id }}"#}
                                           {#value="{{ mr.id }}"#}
                                           {#>#}
                                    {#<a href="javascript:void(0)"#}
                                       {#class="href-remove-reference-mr"#}
                                       {#data-idx="{{ mr.id }}">X</a>#}
                                {#</td>#}
                            {#</tr>#}
                        {#{% endfor %}#}
                    {#{% endif %}#}
                    {#</tbody>#}
                {#</table>#}
                {#<div class="text-right">#}
                    {#<a href="javascript:void(0)" class="href-new-action" data-open="modal">Add Reference PR</a>#}
                {#</div>#}
            {#</div>#}
            <div class="small-12 columns">
                <hr class="max-width-initial">
                <div class="button-container">
                    <button type="submit" class="button just-continue" name="action" value="{{ action }}"
                            data-message="Are you sure you want to save this information?"
                    >Save</button>
                    {% if action == 'u' and (userData.type == 'Super Admin' or 'Admin Transfer Inventory 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('transfer_inventory') }}" class="button secondary">Back</a>
                </div>
            </div>
        </div>
        {{ form_widget(form.action) }}
        {{ form_widget(form.id) }}
        {{ form_widget(form._token) }}
    </form>
    {#<div class="reveal large" id="modal" data-reveal>#}
        {#<br/>#}
        {#<table class="display responsive" id="materialRequisition-datalist" width="100%">#}
            {#<thead>#}
            {#<tr>#}
                {#<th>Control No.</th>#}
                {#<th>Request Date</th>#}
                {#<th>Branch</th>#}
                {#<th>Department</th>#}
                {#<th>Purpose</th>#}
                {#<th>Specific Purpose</th>#}
                {#<th>Requested By</th>#}
                {#<th>Status</th>#}
                {#<th>No. of Items</th>#}
            {#</tr>#}
            {#</thead>#}
            {#<tbody></tbody>#}
        {#</table>#}
        {#<button class="close-button" data-close aria-label="Close modal" type="button">#}
            {#<span aria-hidden="true">&times;</span>#}
        {#</button>#}
    {#</div>#}
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script language="javascript">
        //<![CDATA[
        {#transferInventory_form.settings.mrAjaxUrl = '{{ path('material_requisition_ajax_list_for_transfer') }}';#}
        transferInventory_form.settings.branch_autocomplete_url = '{{ path('health_facility_autocomplete') }}';
        transferInventory_form.settings.branch_allActive_autocomplete_url = '{{ path('health_facility_autocomplete', {allActive: true}) }}';
        transferInventory_form.settings.location_autocomplete_url = '{{ path('location_autocomplete') }}';
        jQ(document).ready(transferInventory_form.init);
        //]]>
    </script>
{% endblock %}