

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">العملاء</a></li>
            <li><a href="closingAccountController.php?do=show">اغلاق حساب عميل</a></li>
            <li class="active">عرض التقرير</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير  المخزون
                <a href="{$youtubes[164]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>
            </div>
            <div class="panel-body">

                <form class="form-inline hidden-print " action="savedailyController.php?do=show" method="post">


                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker searchdata" id="fromdate"   data-date-format="yyyy-mm-dd"  >
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker searchdata"  id="todate"   data-date-format="yyyy-mm-dd"  >
                    </div>
                    
                    <div class="form-group" style="min-width: 219px;">
                        <label class="sr-only">العملاء</label>
                        <input type="text" class="searchdata wdt100" id="select2client" data-placeholder="اختر " />
                    </div>
                </form>

            </div>

            <div class="clearfix"></div>
            <hr/>
            <table class="table table-bordered border-primary" id="getajaxdata">
                <thead>
                    <tr>
                        <th scope="col">رقم</th>
                        <th scope="col">العميل</th>
                        <th scope="col"> تاريخ الاغلاق</th>
                        <th scope="col">المستخدم</th>
                        <th scope="col">تاريخ الاضافه</th>
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>

        </div>
    </div>
</div>
{literal}
<script type="text/javascript">


    $(document).ready(function () {
        var formatResult;
        formatResult = function (data) {
            return  data.text;
        }


        $("#select2client").select2({
            placeholder: "إسم  المشروع",
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "closingAccountController.php?do=select2client",
                type: "post",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        searchTerm: term,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: formatResult,
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });

         




        fetch_data();
        function fetch_data(fromdate = '', todate = '', data1 = '')
        {

            var dataTable = $('#getajaxdata').DataTable({
                "lengthMenu": [[20, 40, 60, 80, 100, -1], [20, 40, 60, 80, 100, "All"]],
                dom: 'Bfrtip',
                buttons: [
                    {
                        extend: 'copyHtml5',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7]
                        }
                    },
                    {
                        extend: 'csvHtml5',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7]
                        }
                    },
                    {
                        extend: 'print',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7]
                        }
                    },
                    {
                        extend: 'excelHtml5',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7]
                        }
                    },
                    {
                        extend: 'pdfHtml5',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7]
                        }
                    },
                    'colvis'
                ],
                "dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
                "order": [[0, "desc"]],
                "displayLength": 20,
                "ajax": {
                    url: 'closingAccountController.php?do=showajax',
                    type: "POST",
                    data: {
                        fromdate: fromdate,
                        todate: todate,
                        data1: data1,
                    }
                },

            });

        }


        $('.searchdata').change(function () {
            var fromdate = $('#fromdate').val();
            var todate = $('#todate').val();
            var data1 = $('#select2client').val();

            $('#getajaxdata').DataTable().destroy();
            fetch_data(fromdate, todate, data1);

        });


      

    });







</script>
{/literal}
