<?php $__env->startSection("content"); ?>
    <div class="content-header row">
        <div class="content-header-left col-md-6 col-12 mb-1 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-block">Haberler</h3>
            <div class="row breadcrumbs-top d-inline-block">
                <div class="breadcrumb-wrapper col-12">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(url('panel')); ?>">Anasayfa</a>
                        </li>
                        <li class="breadcrumb-item active">Haberler
                        </li>
                    </ol>
                </div>
            </div>
        </div>
        <div class="content-header-right col-md-6 col-12">
            <div class="">
                <div class="btn-group float-md-right" role="group" aria-label="Basic example">
                    <a href="<?php echo e(url('panel/haberler/ekle')); ?>" class="btn btn-success">+ Yeni Haber Ekle</a>
                </div>
            </div>
        </div>
    </div>
    <div class="content-body">
        <div class="card d-none d-sm-block">
            <div class="card-body">
                <form id="filter" method="get">
                <div class="row">
                    <div class="col-md-2">
                        <select id="kategorif" name="kategorif" class="form-control">
                            <option value="">Tüm Kategoriler</option>
                            <?php $__currentLoopData = $kategoriler; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $kategori): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($kategori->id); ?>"><?php echo e($kategori->baslik); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-md-2">
                        <select id="konumf" name="konumf" class="form-control">
                            <option value="">Tüm Konumlar</option>
                            <option value="anamanset">Ana Manşet</option>
                            <option value="spot">Spot</option>
                            <option value="yataymanset">Büyük Manşet</option>
                            <option value="sondakika">Son Dakika</option>
                            <option value="ozellink">Özel Link</option>
                            <option value="sitemap">Sadece Sitemap</option>
                        </select>
                    </div>
                    <div class="col-md-2">
                        <select id="editorf" name="editorf" class="form-control">
                            <option value="">Tüm Editörler</option>
                            <?php $__currentLoopData = $editorler; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $editor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($editor->id); ?>"><?php echo e($editor->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div class="col-md-4">
                        <div class='input-group'>
                            <input type="text" autocomplete="off" name="datefilter" id="datefilter" class="form-control showdropdowns" value="" />
                            <div class="input-group-append">
                            <span class="input-group-text">
                              <span class="la la-calendar"></span>
                            </span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2 text-right">
                        <button type="submit" class="btn btn-dark square btn-min-width">Filtrele</button>
                    </div>
                </div>
                </form>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">

            </div>
        </div>

        <div class="row">
            <div id="recent-sales" class="col-12 col-md-12">
                <div class="card">
                    <div class="card-content">
                        <div class="table-responsive mt-1 pb-1">
                            <table class="table table-striped table-bordered mb-0 datatable" >
                                <thead>
                                <tr>
                                    <th class="border-top-0 px-1">ID</th>
                                    <th class="border-top-0 px-1">Tarih</th>
                                    <th class="border-top-0 px-1" data-toggle="tooltip" title="Normal Manşet">NM</th>
                                    <th class="border-top-0 px-1" data-toggle="tooltip" title="Sür Manşet">SM</th>
                                    <th class="border-top-0 px-1" data-toggle="tooltip" title="Son Dakika">SD</th>
                                    <th class="border-top-0 px-1" data-toggle="tooltip" title="Editörün Seçtikleri">ES</th>
                                    <th class="border-top-0 px-1">Kategori</th>
                                    <th class="border-top-0 px-1">Başlık</th>
                                    <th class="border-top-0 px-1">Editör</th>
                                    <th class="border-top-0 px-1">Hit</th>
                                    <th class="border-top-0 px-1">İşlemler</th>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="set-01-options" class="toolbar-icons hidden">
        <a href="#" class="facebookLink"><i class="la la-facebook"></i></a>
        <a href="#"><i class="la la-twitter"></i></a>
    </div>
    <input type="hidden" id="status" value="<?php echo e($status); ?>">
<?php $__env->stopSection(); ?>
<?php $__env->startPush("customJs"); ?>
    <script src="<?php echo e(asset('assets/backend/app-assets/vendors/js/pickers/dateTime/moment-with-locales.min.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/backend/app-assets/vendors/js/pickers/daterange/daterangepicker.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('assets/backend/app-assets/vendors/js/tables/datatable/datatables.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('assets/backend/app-assets/vendors/js/extensions/jquery.toolbar.min.js')); ?>" type="text/javascript"></script>
    
    <script>
        $('.showdropdowns').daterangepicker({
            showDropdowns: true,
            autoApply : true,
            autoUpdateInput: false,
            locale: {
                format: 'DD-MM-YYYY',
                firstDay:1,
                separator: " - ",
                applyLabel: "Onayla",
                cancelLabel: "İptal",
                daysOfWeek: ["Paz", "Pzt", "Sal", "Çar", "Per", "Cum", "Cmt"],
                monthNames: ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos","Eylül","Ekim","Kasım","Aralık"]
            },
            timePicker24Hour: true
        });
        $('input[name="datefilter"]').on('apply.daterangepicker', function(ev, picker) {
            $(this).val(picker.startDate.format('DD-MM-YYYY') + ' / ' + picker.endDate.format('DD-MM-YYYY'));
        });
        $('input[name="datefilter"]').on('cancel.daterangepicker', function(ev, picker) {
            $(this).val('');
        });

        let oTable = $('.datatable').DataTable( {
            "order": [[ 0, "desc" ]],
            "displayLength": 25,
            "language": {
                "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Turkish.json"
            },
            processing : true,
            serverSide: true,
            columnDefs: [
                {
                    "targets": [2,3,4,5,7],
                    "orderable": false
                }
            ],
            ajax:{
                type: 'POST',
                headers: {'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>'},
                url: 'https://yeniistiklal.com/panel/haberler/getNews',
                //data:{status:$('#status').val()}
                data:function(data){
                    data.kategorif = $('#kategorif').val();
                    data.editorf = $('#editorf').val();
                    data.konumf = $('#konumf').val();
                    data.datefilter = $('#datefilter').val();
                    data.status = $('#status').val();
                }
            },
            columns: [
                {data: 'id', name: 'haberler.id', class:'px-1 text-center', searchable: false},
                {data: 'tarih', name: 'haberler.tarih', class:'px-1'},
                {data: 'anamanset', name: 'haberler.anamanset', class:'px-1 text-center', searchable: false},
                {data: 'spot', name: 'haberler.spot', class:'px-1 text-center', searchable: false},
                {data: 'sondakika', name: 'haberler.sondakika', class:'px-1 text-center', searchable: false},
                {data: 'flashaber', name: 'haberler.flashaber', class:'px-1 text-center', searchable: false},
                {data: 'haberkat.baslik', name: 'haberkat.baslik', class:'px-1'},
                {data: 'baslik', name: 'haberler.baslik', class:'px-1'},
                {data: 'habereditoru.name', name: 'habereditoru.name', class:'px-1'},
                {data: 'hit', name: 'haberler.hit', class:'px-1 text-center', searchable: false},
                {data: 'islemler', name: 'islemler', class:'px-1', orderable: false, searchable: false}
            ],
            initComplete: function () {
                var id     = [];
                var baslik = [];

                oTable.column(7).data().each(function(d,j) {
                    baslik.push(d);
                });

                oTable.column(0).data().each(function(d,j) {
                    id.push(d);
                });


                $.each(id,function (key,item) {

                });

                //console.log(id)

            }
        } );

        $('table').on('draw.dt', function() {
            $('[data-toggle="tooltip"]').tooltip();
            $('div[data-toolbar="set-01"]').toolbar({
                content: '#set-01-options',
                position: 'top',
            });

            /*$('.editable').editable({
                url: '/post'
            });*/

            $(".btn-outline-danger").on("click",function () {
                let id = $(this).data('id');
                let catTitle = $(this).data('title');
                //let Data = "id:"+id;
                swal({
                        title: "Emin misiniz?",
                        text: "<strong>" + catTitle + " haberi silinecektir!</strong>",
                        type: "warning",
                        html: true,
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "Evet, silinsin!",
                        cancelButtonText: "Hayır, vazgeç!",
                        closeOnConfirm: false,
                        closeOnCancel: true
                    },
                    function(isConfirm){
                        if (isConfirm) {
                            $.ajax({
                                headers: {
                                    'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>'
                                },
                                type: "POST",
                                url: "/panel/haberler/sil/"+id,
                                data: {
                                    "id": id
                                },
                            });
                            swal({
                                    title: "Silindi!",
                                    text: "<strong>Haber Başarıyla Silindi.</strong>",
                                    type: "success",
                                    html: true,
                                    timer: 1000},
                                function(){
                                    location.reload();
                                }
                            );
                        }
                    });
            })
        });

        $(document).ready(function(){
            $("#filter").submit(function(){
                oTable.ajax.reload();
                return false;
            });
        });

        function haberDegistir(id,type,status){
            let statusTitle = '';
            switch (type) {
                case 'nm':
                    if(status == 1){
                        statusTitle = 'normal manşet aktif edilecektir.'
                    }else{
                        statusTitle = 'normal manşet pasif edilecektir.'
                    }
                    break;
                case 'sm':
                    if(status == 1){
                        statusTitle = 'sür manşette gösterilecektir.'
                    }else{
                        statusTitle = 'sür manşette gizlenecektir.'
                    }
                    break;
                case 'sd':
                    if(status == 1){
                        statusTitle = 'sondakika da gösterilecektir.'
                    }else{
                        statusTitle = 'sondakika da gizlenecektir.'
                    }
                    break;
                case 'fd':
                    if(status == 1){
                        statusTitle = 'flaş haber de gösterilecektir.'
                    }else{
                        statusTitle = 'flaş haber de gizlenecektir.'
                    }
                    break;
                default:
                    break;
            }

            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>'
                },
                type: "POST",
                url: "/panel/haberler/durum-degistir/"+id,
                data: {
                    "type": type,
                    "status": status
                },
            });

            oTable.ajax.reload();
            return false;
        }
    </script>


<?php $__env->stopPush(); ?>

<?php $__env->startPush("customCss"); ?>
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/backend/app-assets/vendors/css/pickers/daterange/daterangepicker.css')); ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/backend/app-assets/vendors/css/tables/datatable/datatables.min.css')); ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/backend/app-assets/vendors/css/extensions/jquery.toolbar.css')); ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/backend/app-assets/js/scripts/css/bootstrap-editable.css?v=1.1')); ?>">
    <style>
        .px-1 {
            padding-left: 0.5rem !important;
            padding-right: 0.5rem !important;
        }
        .table td {
            padding: 0.5rem 2rem;
        }
    </style>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backend.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/yeniistik/public_html/resources/views/backend/haberler/index.blade.php ENDPATH**/ ?>