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

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

        <div id="divSearch">
            <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>Ürün Grubu Seçiniz</label>
            <div id="productGroup"></div>
            <script type="text/javascript">
                $(document).ready(function () {
                    var ajax = getData("/7073a00e724bbda643cb7e2a85110640/home/productgroup/all", "GET", "text", "");
                    ajax.done(function (companies) {
                        var parsedArray = $.parseJSON(companies);
                        if (parsedArray.length == 0)return;
                        var selectString = "<select id='productgroup' name='productgroup'>\n";
                        selectString += "<option value=''>Seçiniz</option>\n";
                        var selectedId = "{{ app.request.get("productgroup")!=null? app.request.get("productgroup"):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>";
                        $("#productGroup").html(selectString);
                    });
                });
            </script>
        </div>
        <div>
            <label>KDV Türü Seçiniz</label>
            <div id="kdv"></div>
            <script type="text/javascript">
                $(document).ready(function () {
                    var ajax = getData("/7073a00e724bbda643cb7e2a85110640/home/kdv/all", "GET", "text", "");
                    ajax.done(function (kdvs) {
                        var parsedArray = $.parseJSON(kdvs);
                        if (parsedArray.length == 0)return;
                        var selectString = "<select id='kdv' name='kdv'>\n";
                        selectString += "<option value=''>Seçiniz</option>\n";
                        var selectedId = "{{ app.request.get("kdv")!=null? app.request.get("kdv"):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>";
                        $("#kdv").html(selectString);
                    });
                });
            </script>
        </div>
        <div>
            <label>Birim Seçiniz</label>
            <div id="measure"></div>
            <script type="text/javascript">
                $(document).ready(function () {
                    var ajax = getData("/7073a00e724bbda643cb7e2a85110640/home/measure/all", "GET", "text", "");
                    ajax.done(function (measures) {
                        var parsedArray = $.parseJSON(measures);
                        if (parsedArray.length == 0)return;
                        var selectString = "<select id='measure' name='measure'>\n";
                        selectString += "<option value=''>Seçiniz</option>\n";
                        var selectedId = "{{ app.request.get("measure")!=null? app.request.get("measure"):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>";
                        $("#measure").html(selectString);
                    });
                });
            </script>
        </div>
        <div>
            <label>Minimum Bakiye</label>
            <input type="number" value="{{ app.request.get("minBakiye")!=null? app.request.get("minBakiye"):0 }}"
                   name="minBakiye" title="Minimum Bakiye Giriniz"/>
        </div>
        <div>
            <input id="delivery__token" name="delivery[_token]" value="{{ token }}" type="hidden">
            <input type="submit" class="buttonSubmit" id="btnSearchDelivery" value="Arama Yap">
        </div>
    </form>
    {{ include('report/urunEnvanteriResult.html.twig') }}

{% endblock %}