<?php $__env->startSection('content'); ?>




<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    <?php echo e($pageTitle); ?>

                </h2>

            </div>
            <div class="body">

                <div class="col-md-12">
                    <div class="form-line">
                        <select class="form-control select2_new" id="user_id">
                            <option value="">-- Pilih Pegawai --</option>
                            <?php $__empty_1 = true; $__currentLoopData = $member; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                            <option value="<?php echo e($item['id']); ?>">
                                <?php echo e($item['name']); ?></option>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <?php endif; ?>
                        </select>
                    </div>
                </div>
                <div id='calendar'></div>
            </div>
        </div>
    </div>


</div>






<?php $__env->stopSection(); ?>
<?php $__env->startSection('customjs'); ?>

<script>
var calendar = $('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,basicWeek,basicDay'
    },
    // editable: true,
    // events: "<?php echo route('partner.indexAjax'); ?>",
    // events: {
    //     url: "<?php echo route('partner.indexAjax'); ?>",
    //     type: 'POST',
    //     data: {
    //         "_token": "<?php echo csrf_token(); ?>",
    //         "start": "",
    //         "end": "",
    //         "user_id": $('#user_id').val(),
    //         // "xxx": "vvv",
    //     },
    //     error: function() {
    //         alert('there was an error while fetching events!');
    //     },
    //     success: function(data) {
    //         console.log(data)
    //     }
    // },

    events: function(start, end, timezone, callback) {
        jQuery.ajax({
            url: "<?php echo route('dashboard.indexAjax'); ?>",
            type: 'POST',
            dataType: 'json',
            data: {
                start: start.format(),
                end: end.format(),
                _token: "<?php echo csrf_token(); ?>",
                user_id: $('#user_id').val(),
            },
            success: function(doc) {
                // console.log(doc.result);
                var events = [];
                // if (!!doc.result) {
                $.map(doc, function(r) {
                    events.push({
                        id: r.id,
                        title: r.title,
                        start: r.start,
                        end: r.end,
                        description: r.description,
                        end_time: r.end_time
                    });
                });
                // }

                // $(doc).find('event').each(function() {
                //     events.push({
                //         title: $(this).attr('title'),
                //         start: $(this).attr('start'),
                //         end: $(this).attr('end')
                //     });
                // });

                callback(events);
            }
        });
    },
    displayEventTime: false,
    editable: false,
    // eventRender: function(event, element, view) {
    //     if (event.allDay === 'true') {
    //         event.allDay = true;
    //     } else {
    //         event.allDay = false;
    //     }
    // },
    selectable: true,
    selectHelper: true,

    // eventDrop: function(event, delta) {
    //     var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD");
    //     var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD");

    //     $.ajax({
    //         url: "<?php echo route('partner.ajax'); ?>",
    //         data: {
    //             title: event.title,
    //             start: start,
    //             end: end,
    //             id: event.id,
    //             type: 'update',
    //             "_token": "<?php echo csrf_token(); ?>",
    //         },
    //         type: "POST",
    //         success: function(response) {
    //             displayMessage("Event Updated Successfully");
    //         }
    //     });
    // },

    eventRender: function(event, element) {
        // console.log(event);
        element.find('.fc-title').append("<br/>" + new Date(event.description).getHours() +
            ':' + new Date(event.description).getMinutes() +
            '-' + new Date(event.end_time).getHours() + ':' + new Date(event.end_time)
            .getMinutes());
        element.find('.fc-title').attr('data-toggle', 'tooltip');

        element.find('.fc-title').attr('title', event.description);

    }

});

$('#user_id').on('change', function(events) {

    calendar.fullCalendar('refetchEvents');

});
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app2', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/sety4218/public_html/sim_pt_setia_raya/resources/views/dashboard/mitradashboard/jadwal.blade.php ENDPATH**/ ?>