{% extends 'base.html.twig' %}

{% block body %}
    <form id="frmProductMoveReport" action="{{ path('product_move') }}" method="post">

        <div id="divSearch">
            <div>
                <label>Sevk veya Firma (Birden fazla seçmek için Ctrl tuşu ile birlikte basınız)</label>
                <select multiple="multiple" name="sevkVeFirma[]">
                    <option value="1" selected="selected">Sevk</option>
                    <option value="2">Firma</option>
                </select>
            </div>
            <div class="clear"></div>
            <div>
                <input type="text" id="txtStartDate" name="txtStartDate"
                       style="width: 195px;float: left;margin-right: 10px"
                       placeholder="Başlangıç Tarihi"
                       value="{{ app.request.get('txtStartDate')!=null?app.request.get('txtStartDate'): 'now'|date('d.m.Y') }}"/>
                <input type="text" id="txtEndDate" name="txtEndDate"
                       style="width: 195px;float: left;margin-right: 10px"
                       placeholder="Bitiş Tarihi"
                       value="{{ app.request.get('txtEndDate')!=null?app.request.get('txtEndDate'): 'now'|date('d.m.Y') }}"/>
            </div>
            <div class="clear"></div>
        </div>

        {{ include('delivery/location.html.twig') }}
        <div>
            <label>Şube Seçiniz</label>
            <div style="display: none" id="delivery_location">
            </div>
            <div style="display: none" id="divBolge">
            </div>
            <div style="display: none" id="divEkipler"></div>
        </div>
        <div>
            <label>Firma Seçiniz</label>
            <div id="companies"></div>
            <script type="text/javascript">
                $(document).ready(function () {
                    var ajax = getData("/7073a00e724bbda643cb7e2a85110640/home/company/all", "GET", "text", "");
                    ajax.done(function (companies) {
                        var parsedArray = $.parseJSON(companies);
                        if (parsedArray.length == 0)return;
                        var selectString = "<select id='company' name='company'>\n";
                        selectString += "<option value=''>Seçiniz</option>\n";
                        var selectedId ="{{ app.request.get("company")!=null? app.request.get("company"):0}}";
                        for (var i = 0; i < parsedArray.length; i++) {
                            if (selectedId == parsedArray[i].id)
                                selectString += "<option selected value='" + parsedArray[i].id + "'>" + parsedArray[i].name + "</option>\n";
                            else
                                selectString += "<option value='" + parsedArray[i].id + "'>" + parsedArray[i].name + "</option>\n";
                        }
                        selectString += "</select>";
                        $("#companies").html(selectString);
                    });
                });
            </script>
        </div>
        <div>
            {{ include('delivery/urunarama.html') }}
            <div id="divFoundProductList" style="max-width: 400px;margin-top:20px;display: none">
                <h1 style="border-bottom: none!important;"></h1>
                <table id="tblFoundProductList">
                    <tbody></tbody>
                </table>
            </div>
        </div>
        <div class="clear"></div>
        <div>
            <label for="txtSearchDelivery">Arama Yap:</label>
            <input type="text" id="txtSearchDelivery" name="txtSearchDelivery"
                   value="{{ app.request.get("txtSearchDelivery") }}"/>
            <input id="delivery__token" name="delivery[_token]" value="{{ token }}" type="hidden">
            <input type="submit" class="buttonSubmit" id="btnSearchDelivery" value="Arama Yap">
        </div>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txtStartDate").datepicker();
            $("#txtEndDate").datepicker();
            $(document).on('click', '.btnUseFoundProduct', function () {
                var productName = $(this).data('productName');
                $("#txtSearchDelivery").val(productName);
            });
        });
    </script>


    {{ include('report/urunGecmisi.html.twig') }}
{% endblock %}