<div class="container-fluid" style="padding-bottom: 2rem;">
    <div class="row">
        <div class="col-md-8">
            <div class="card bg-light-transparent" style="margin-bottom: 2rem;">
                <div class="card-header bg-white">
                    <div class="float-left">
                        <h5 class="card-title">Calendar</h5>
                    </div>
                </div>
                <div class="card-body">
                    <div class="card bg-white no-shadow">
                        <div class="card-body">
                            <div class="row">
                                <div class="col-2">
                                    <?php foreach ($carbooking as $type) { ?>
                                        <br><div data-trigger="hover" data-tooltip="tooltip" title="<?php echo $type['car_name']; ?>" class="text-center mt-2 text-white" style="background-color: <?php echo '#'.$type['color_code']; ?>;-webkit-border-radius:8px; -moz-border-radius:8px; border-radius:8px; border:1px solid #ccc; height:28px;"><?php echo $type['short_name']; ?></div>
                                    <?php } ?> 
                                </div>
                                <div class="col-10">
                                    <div id="calendar"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card bg-light-transparent" style="margin-bottom: 2rem;">
                <div class="card-header bg-white">
                    <h5 class="card-title">Car Booking Request Summary</h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-12">
                            <a class="btn btn-block btn-dark add-shadow" href="<?php echo base_url('hr/serviceform/car_booking_form'); ?>" style="padding-top: 1rem; padding-bottom: 1rem;">New Request</a>
                        </div>
                    </div>
                    <br>
                    <div class="card bg-white no-shadow">
                        <div class="card-body">
                            <h6>Total Booking (<?php echo date('Y') ?>)</h6>
                            <br>
                            <div class="row">
                                <table id="table_carbooking" class="table table-bordered table-striped table-hover mx-1">
                                    <thead class="text-center">
                                        <th>Car Type</th>
                                        <th>Total Booking</th>
                                    </thead>
                                    <tbody class="text-center">
                                        <?php foreach($car_type as $type): ?>
                                            <tr>
                                                <td  data-trigger="hover" data-tooltip="tooltip" title="<?php echo $type['car_name']; ?>"><?php echo $type['car_name']; ?></td>
                                                <td><?php echo $type['total_booking']; ?></td>
                                            </tr>
                                        <?php endforeach; ?>
                                    </tbody>
                                </table>
                            </div>
                        </div> 
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="container-fluid">
        <div class="card bg-light-transparent">  
            <div class="card-header bg-white">
                <h4>Car Booking Request List</h4>
                <a href="<?php echo base_url('hr/serviceform/car_booking_form'); ?>" class="btn btn-outline-dark btn-sm" title="Add New Car Booking"><i class="fa fa-plus"></i> Add New Booking</a>

                <a href="<?php echo base_url('hr/Serviceform_report/car_booking_print')?>" target="_blank" class="btn btn-outline-dark btn-sm" title="Print"><i class="fa fa-print"></i>Print</a>

                <a id="btnShowFilters" type="button" class="btn btn-outline-dark btn-sm collapsed" data-trigger="hover" title="Show Filters Box" data-toggle="collapse" data-target="#collapseFilter" aria-expanded="false"><i class="fas fa-filter"></i>Show Filters</a>
            </div>

            <div class="collapse" id="collapseFilter">
                <div class="card-header">
                    <div class="row">
                        <div class="col">
                            <div class="card no-shadow">
                                <div class="card-body">
                                    <input type="hidden" name="user_id" id="user_id" value="<?php echo $_SESSION['user']['id']; ?>">
                                    <?php if($_SESSION['all_modules_access'][0]['access_lvl'] == 'admin' || $_SESSION['user']['division_id'] == 4){ ?>
                                        <div class="form-group row">
                                            <label for="sv_carbooking_filter_dept" class="col-lg-3">
                                                Department
                                            </label>                           
                                            <div class="col-lg-4" >
                                                <select class="custom-select" name="sv_carbooking_filter_dept" id="sv_carbooking_filter_dept">
                                                    <option value="-1">[All]</option>
                                                    <?php if($department) foreach($department as $row){ ?>
                                                        <option value="<?php echo $row['id']; ?>"><?php echo $row['name'].' ['.$row['branch_name'].']'; ?></option> 
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div>
                                    <?php } ?>
                                    <div class="form-group row">
                                        <label for="filterCar" class="col-lg-3">
                                            Car Type
                                        </label>
                                        <div class="col-lg-4">
                                            <select class='custom-select' id="sv_carbooking_filter_cartype" name="sv_carbooking_filter_cartype">
                                                <option value="-1">[All]</option>
                                                <?php if($car_type) foreach($car_type as $type){ ?>
                                                    <option value="<?php echo $type['ID'];?>"><?php echo $type['car_name'];?></option>
                                                <?php } ?>
                                            </select>
                                        </div>                                         
                                    </div>     
                                    <div class="form-group row">
                                        <label for="sv_carbooking_filter_status" class="col-lg-3">
                                            Status
                                        </label>                           
                                        <div class="col-lg-4" >
                                            <select class="custom-select" id="sv_carbooking_filter_status" name="sv_carbooking_filter_status">
                                                <option value="-1">[All]</option>
                                                <option value="Pending">Pending</option>
                                                <option value="In_progress">In Progress</option>
                                                <option value="Verified">Verified</option>
                                                <option value="Completed">Completed</option>
                                                <option value="Rejected">Rejected</option>
                                                <option value="Cancel">Cancel</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="sv_carbooking_filter_year" class="col-lg-3">
                                            Year
                                        </label>                           
                                        <div class="col-lg-4" >
                                            <input type="text" name="sv_carbooking_filter_year" id="sv_carbooking_filter_year" class="form-control datepicker-yyyy">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="sv_carbooking_filter_month" class="col-lg-3">
                                            Requested Month
                                        </label>                           
                                        <div class="col-lg-4" >
                                            <input type="text" name="sv_carbooking_filter_month" id="sv_carbooking_filter_month" class="form-control datepicker-mm">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col d-print-none">
                                            <button class="btn btn-info" id="searchBtn">Search</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="tab-content">
                <div class="tab-pane fade active show" id="tableView" role="tabpanel" aria-labelledby="nav-table-tab">
                    <div class="card-body">
                        <div class="card no-shadow">
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table id = "filter_table_carbooking" class="table table-bordered p-0 m-0" width="100%">
                                        <thead>
                                            <th width="5%">#</th>
                                            <th width="15%">Requestor</th>
                                            <th width="10%">Booking Car</th>
                                            <th width="15%">Location</th>
                                            <th width="15%">Purpose</th>
                                            <th width="10%">Booking Start Date and Start Time</th>
                                            <th width="10%">Booking End Date and End Time</th>
                                            <th width="10%">Status</th>
                                            <th width="5%">Action</th>
                                        </thead>

                                        <tbody>
                                            <?php if(!empty($rsCarBookingList)) { ?> 
                                                <?php foreach($rsCarBookingList as $key => $row) { //debug($row); ?>
                                                    <tr>
                                                        <td class="text-center"><?php echo $key+1; ?></td>
                                                        <td>
                                                            <b>Requested By : </b><br><?php echo $row['userName'].' ['.$row['userEmail'].']'; ?>
                                                            <br><br>
                                                            <b>Created By : </b><br><?php echo $row['created_name'].' ['.$row['created_email'].']' ?>
                                                        </td>
                                                        <td><?php echo $row['car_type_name']; ?></td>
                                                        <td><?php echo $row['location']; ?></td>
                                                        <td><?php echo $row['purpose']; ?></td>
                                                        <td class="text-center"><?php echo date ('d-m-Y', strtotime($row['start_date'])) . ' / ' . $row['start_time']; ?></td>
                                                        <td class="text-center"><?php echo date ('d-m-Y',strtotime($row['end_date'])) . ' / ' . $row['end_time']; ?></td>
                                                        <td class="text-center">
                                                            <?php 
                                                            if(($row['status_app']==null || $row['status_app']=='Pending'))
                                                            {
                                                                $status = 'Pending <i class="fa fa-exclamation-circle" style="color: #FFC107;"></i>';
                                                                $disabled = '';
                                                            }
                                                            if($row['status_app'] == 'In_progress')
                                                            {
                                                                $status = str_replace('_', ' ', $row['status_app']).' <i class="fa fa-hourglass-start" style="color: grey;"></i>';
                                                                $disabled = 'disabled style="cursor: not-allowed;"';
                                                            }
                                                            if($row['status_app'] == 'Verified')
                                                            {
                                                                $status = $row['status_app'].' <i class="fa fa-check-circle" style="color: green;"></i><p style="font-style: italic; font-size: 13px;">'.$row['status_reason'].'</p>';
                                                                $disabled = '';
                                                            }
                                                            if($row['status_app'] == 'Completed')
                                                            {
                                                                $status = $row['status_app'].' <i class="fa fa-check-circle" style="color: green;"></i>';
                                                                $disabled = 'disabled style="cursor: not-allowed;"';
                                                            }
                                                            if($row['status_app'] == 'Rejected')
                                                            {
                                                                $status = $row['status_app'].' <i class="fa fa-times-circle" style="color: red;"></i>';
                                                                $disabled = 'disabled style="cursor: not-allowed;"';
                                                            }
                                                            if($row['status_app'] == 'Cancel')
                                                            {
                                                                $status = $row['status_app'].' <i class="fa fa-times-circle" style="color: red;"></i>';
                                                                $disabled = 'disabled style="cursor: not-allowed;"';
                                                            }

                                                            echo $status;
                                                            ?>
                                                        </td>

                                                        <td class="text-center"> 
                                                            <div class="btn-group btn-group-sm" role="group">
                                                                <button type="button" class="btn btn-outline-dark" data-toggle="modal" data-target="#viewDetails" data-trigger="hover" data-tooltip="tooltip" 
                                                                title="View Detail" 
                                                                data-name="<?php echo $row['userName']; ?>" 
                                                                data-dept="<?php echo $row['dept_name'].'/'.$row['branchName']; ?>" 
                                                                data-datereq="<?php echo date('d-m-Y',strtotime($row['createdTS'])); ?>" 
                                                                data-car_type="<?php echo $row['car_type_name']; ?>" 
                                                                data-location="<?php echo $row['location']; ?>" 
                                                                data-start_date="<?php echo date('d-m-Y',strtotime($row['start_date'])); ?>" 
                                                                data-start_time="<?php echo $row['start_time']; ?>" 
                                                                data-end_date="<?php echo date('d-m-Y',strtotime($row['end_date'])); ?>" 
                                                                data-end_time="<?php echo $row['end_time']; ?>" 
                                                                data-purpose="<?php echo $row['purpose']; ?>" 
                                                                onclick="open_view_modal(this)">
                                                                <i class="far fa-eye"></i></button>

                                                                <?php if($_SESSION['all_modules_access'][0]['access_lvl'] == 'admin' || $_SESSION['user']['division_id'] == 4){ ?>
                                                                    <a href="<?php echo base_url('hr/serviceform/car_booking_form/'.$row['ID']); ?>" target="_blank" class="btn btn-outline-dark" onclick="" data-trigger="hover" data-tooltip="tooltip" title="Edit"><i class="far fa-edit"></i></a>
                                                                <?php } else { ?>
                                                                    <?php if($disabled == ''){ ?>
                                                                        <a href="<?php echo base_url('hr/serviceform/car_booking_form/'.$row['ID']); ?>" target="_blank" class="btn btn-outline-dark" onclick="" data-trigger="hover" data-tooltip="tooltip" title="Edit"><i class="far fa-edit"></i></a>
                                                                    <?php }else{ ?>
                                                                        <button class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Edit" disabled style="cursor: not-allowed;"><i class="far fa-edit"></i></button>
                                                                    <?php } ?>
                                                                <?php } ?>

                                                                <a href="<?php echo base_url('hr/serviceform_report/car_booking_print/'.$row['ID']); ?>" class="btn btn-outline-dark" target="_blank" date-trigger="hover" data-tooltip="tooltip" title="Print Detail"><i class="fa fa-print"></i></a>

                                                                <?php if(($_SESSION['user']['id'] == $row['user_id']) || ($_SESSION['user']['id'] == $row['createdBY'])){ ?>
                                                                    <button id="deleteButton" type="button" class="btn btn-outline-dark" onclick="deleteData(<?php echo $row['ID']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete" <?php echo ($disabled == '')?'':'disabled style="cursor: not-allowed;"'; ?>><i class="far fa-trash-alt"></i></button>
                                                                <?php } ?>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                <?php }
                                            }
                                            ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div> 
        </div>
    </div>
</div>

<!-- modal view detail -->

<div class="modal fade d-print-none" id="viewDetails" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLongTitle">Car Booking Request Detail</h5>&emsp;
                <!-- <a href="javascript:window.print()" class="btn btn-outline-dark btn-sm" title="Print"><i class="fa fa-print"></i>Print</a> -->
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>

            <div class="modal-body">
                <div class="row">
                    <div class="col-6">
                        <label>Name</label>
                        <input type="text" class="form-control" name="modal_view_name" id="modal_view_name" disabled>
                    </div>
                    <div class="col-6">
                        <label>Department</label>
                        <input type="text" class="form-control" name="modal_view_dept" id="modal_view_dept" disabled>
                    </div>
                </div>
                <div class="row">
                    <div class="col-6">
                        <label>Date Request</label>
                        <input type="text" class="form-control" name="modal_view_date_req" id="modal_view_date_req" disabled>
                    </div>
                    <div class="col-6">
                        <label>Car Type</label>
                        <input type="text" class="form-control" name="modal_view_car_type" id="modal_view_car_type" disabled>
                    </div>  
                </div>

                <div class="row">
                    <div class="col-6">
                        <label>Start Date</label>
                        <input type="text" class="form-control" name="modal_view_start_date" id="modal_view_start_date" disabled>
                    </div>
                    <div class="col-6">
                        <label>Start Time</label>
                        <input type="text" class="form-control" name="modal_view_start_time" id="modal_view_start_time" disabled>
                    </div>
                </div>

                <div class="row">
                    <div class="col-6">
                        <label>End Date</label>
                        <input type="text" class="form-control" name="modal_view_end_date" id="modal_view_end_date" disabled>
                    </div>
                    <div class="col-6">
                        <label>End Time</label>
                        <input type="text" class="form-control" name="modal_view_end_time" id="modal_view_end_time" disabled>
                    </div>
                </div>

                <div class="row">
                    <div class="col-6">
                        <label>Location</label>
                        <input type="text" class="form-control" name="modal_view_location" id="modal_view_location" disabled>
                    </div>
                    <div class="col-6">
                        <label>Purpose</label>
                        <input type="text" class="form-control" name="modal_view_purpose" id="modal_view_purpose" disabled>
                    </div>
                </div>
                <br>
                <div class="float-right">
                </div>
            </div>
        </div>
    </div>
</div>

<!-- modal view detail -->


<style type="text/css">
    .tooltipevent
    {
        width:auto;
        height:auto;
        background:rgba(0,0,0,0.75);
        position:absolute;
        color: #fff;
        z-index:10001;
        padding:10px 10px 10px 10px ;  
        line-height: 200%;
    }
</style>


<script>
    function open_view_modal(elem) 
    {
        let name        = $(elem).data('name');
        let dept        = $(elem).data('dept');
        let datereq     = $(elem).data('datereq');
        // console.log(dept);
        let car_type     = $(elem).data('car_type');
        let location    = $(elem).data('location');
        let start_date  = $(elem).data('start_date');
        let start_time  = $(elem).data('start_time');
        let end_date    = $(elem).data('end_date');
        let end_time    = $(elem).data('end_time');
        let purpose     = $(elem).data('purpose');

        /* view modal */
        $('#modal_view_name').val(name);
        $('#modal_view_dept').val(dept);
        $('#modal_view_date_req').val(datereq);
        $('#modal_view_car_type').val(car_type);
        $('#modal_view_location').val(location);
        $('#modal_view_start_date').val(start_date);
        $('#modal_view_start_time').val(start_time);
        $('#modal_view_end_date').val(end_date);
        $('#modal_view_end_time').val(end_time);
        $('#modal_view_purpose').val(purpose);
    }

    function deleteData(ID) 
    {
        validateForm("#deleteButton", "Delete this list?", function() {
           $.ajax({
            url:'<?php echo base_url('hr/serviceform/deleteCarBookingList') ?>',
            data: {
             carBookingID : ID,
         },
         type: 'post',
         dataType: 'json',
         success: (data) => {
             if(data.status == "Success") {

                 localStorage.setItem("status", data.status);
                 localStorage.setItem("msg", data.msg);

                 location.reload();

					//redirect(base_url('hr/serviceform/car_booking'));
                }
            }
        });
       });
    }

    $(document).ready(function()
    {
        $('#table_carbooking').DataTable().destroy();

        var fc_event= '';
        var resource = <?php echo $resource;?>;

        var fullcalendar = $('#calendar').fullCalendar({ 
            themeSystem: 'bootstrap4',
            header: 
            {
                left: 'prev,next today',
                center: 'title',
                right: 'month,listMonth'
            },
            buttonText: {
                today: 'Today',
                month: 'Calendar',
                listMonth: 'List'
            },

            navLinks: true, // can click day/week names to navigate views
            editable: true,
            eventLimit: true, // allow "more" link when too many events
            events: <?php echo $fc_event; ?>,

            eventMouseover: function (data, event, param, resource = <?php echo $resource;?>) {
                var js_res = JSON.parse(JSON.stringify(resource));
                var hover_item = js_res[data.id];
                var title = JSON.stringify(data.title);
                var start_date = moment(hover_item.start_date).format('DD-MM-YYYY');
                var end_date = moment(hover_item.end_date).format('DD-MM-YYYY');
                var start_time = moment(hover_item.start_time).format('00-00-00');
                var end_time = moment(hover_item.end_time).format('00-00-00');

                tooltip = '<div class="tooltipevent"> Car Type : '+hover_item.car_type_name+' <br/> Location : '+hover_item.location+'<br/> Purpose : '+hover_item.purpose+'<br/> Start Date : '+start_date+'<br/> End Date : '+end_date+'<br/>Start Time : '+hover_item.start_time+' <br/> End Time : '+hover_item.end_time+' </div>';

                $("body").append(tooltip);
                $(this).mouseover(function (e) {
                    $(this).css('z-index', 10000);
                    $('.tooltipevent').fadeIn('500');
                    $('.tooltipevent').fadeTo('10', 1.9);
                }).mousemove(function (e) {
                    $('.tooltipevent').css('top', e.pageY + 10);
                    $('.tooltipevent').css('left', e.pageX + 20);
                });
            },

            eventMouseout: function(data, event) {
                $(this).css('z-index', 8);
                $('.tooltipevent').remove();
            },
        });

        fullcalendar.fullCalendar();

        //getData();

        $('#searchBtn').click(function(){
            getData();
        });

        <?php $this->session->unset_userdata('sv_carbooking_filter_dept'); ?>
        <?php $this->session->unset_userdata('sv_carbooking_filter_cartype'); ?>
        <?php $this->session->unset_userdata('sv_carbooking_filter_year'); ?>
        <?php $this->session->unset_userdata('sv_carbooking_filter_month'); ?>
        <?php $this->session->unset_userdata('sv_carbooking_filter_status'); ?>
        <?php $this->session->unset_userdata('sv__car_booking'); ?>

    });

    function getData() {
        var table = $('#filter_table_carbooking').DataTable();
        table.clear().draw();
        var frmData = new FormData();

        frmData.append('sv_carbooking_filter_dept',$('#sv_carbooking_filter_dept').val());
        frmData.append('sv_carbooking_filter_cartype',$('#sv_carbooking_filter_cartype').val());
        frmData.append('sv_carbooking_filter_status',$('#sv_carbooking_filter_status').val());
        frmData.append('sv_carbooking_filter_year',$('#sv_carbooking_filter_year').val());
        frmData.append('sv_carbooking_filter_month',$('#sv_carbooking_filter_month').val());
        frmData.append('user_id',$('#user_id').val());

        $.ajax({
            url:"<?php echo base_url('/hr/api/serviceform/get_carbooking_filter'); ?>",
            type:'post',
            dataType:'json',
            data:frmData,
            processData: false,
            contentType: false,
            success:function(data){

                iziToast.success({
                    position: 'bottomRight',
                    message: 'filtering data',
                });

                let car_booking = data.table;

                if(car_booking != null){
                    var index = 1;
                    $.each(car_booking,function(key,content)
                    {
                        var i = key + 1;
                        // console.log(content);

                        if(content.start_date != '0000-00-00'){
                            var start_date = moment(content.start_date).format('DD-MM-YYYY');;
                        }
                        if(content.end_date != '0000-00-00'){
                            var end_date = moment(content.end_date).format('DD-MM-YYYY');;
                        }

                        if(content.status_app == null || content.status_app == 'Pending')
                        {
                            var status      = 'Pending <i class="fa fa-exclamation-circle" style="color: #FFC107;"></i>';
                            var disabled    = '';
                        }
                        if(content.status_app == 'In_progress')
                        {
                            var status      = ((content.status_app).replace('_',' '))+' <i class="fa fa-hourglass-start" style="color: grey;"></i>';
                            var disabled    = 'disabled style="cursor: not-allowed;"';
                        }
                        if(content.status_app == 'Verified')
                        {
                            var status      = content.status_app+' <i class="fa fa-check-circle" style="color: green;"></i><p style="font-style: italic; font-size: 13px;">'+content.status_reason+'</p>';
                            var disabled    = '';
                        }
                        if(content.status_app == 'Completed')
                        {
                            var status      = content.status_app+' <i class="fa fa-check-circle" style="color: green;"></i>';
                            var disabled    = 'disabled style="cursor: not-allowed;"';
                        }
                        if(content.status_app == 'Rejected')
                        {
                            var status      = content.status_app+' <i class="fa fa-times-circle" style="color: red;"></i>';
                            var disabled    = 'disabled style="cursor: not-allowed;"';
                        }
                        if(content.status_app == 'Cancel')
                        {
                            var status      = content.status_app+' <i class="fa fa-times-circle" style="color: red;"></i>';
                            var disabled    = 'disabled style="cursor: not-allowed;"';
                        }

                        if("<?php echo $_SESSION['all_modules_access'][0]['access_lvl']; ?>" == 'admin' || "<?php echo $_SESSION['user']['division_id']; ?>" == 4)
                        {
                            var btn_edit = '<a type="button" class="btn btn-outline-dark" href="<?php echo base_url();?>hr/serviceform/car_booking_form/'+content.ID+'" data-trigger="hover" data-tooltip="tooltip" title="Edit"><i class="far fa-edit"></i></a>';
                        } else {
                            if(disabled == '')
                            {
                                var btn_edit = '<a type="button" class="btn btn-outline-dark" href="<?php //echo base_url();?>hr/serviceform/car_booking_form/'+content.ID+'" data-trigger="hover" data-tooltip="tooltip" title="Edit"><i class="far fa-edit"></i></a>';
                            }else{
                                var btn_edit = '<button class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Edit" '+disabled+'><i class="far fa-edit"></i></button>';
                            }
                        }

                        var btn_view = '<button type="button" class="btn btn-outline-dark" data-toggle="modal" data-target="#viewDetails" data-trigger="hover" data-tooltip="tooltip" title="View Detail" data-name="'+content.userName+'" data-dept="'+content.dept_name+'/'+content.branchName+'" data-datereq="'+moment(content.createdTS).format('DD-MM-YYYY')+'" data-car_type="'+content.car_type_name+'" data-location="'+content.location+'" data-start_date="'+start_date+'" data-start_time="'+content.start_time+'" data-end_date="'+end_date+'" data-end_time="'+content.end_time+'" data-purpose="'+content.purpose+'" onclick="open_view_meeting_modal(this)"> <i class="far fa-eye"></i> </button>';

                        var btn_print = '<a type="button" class="btn btn-outline-dark" href="<?php echo base_url();?>hr/serviceform_report/car_booking_print/'+content.ID+'" target="_blank" data-trigger="hover" data-tooltip="tooltip" title="Print Detail"><i class="fa fa-print"></i></a>';


                        var btn_delete = '<button type="button" class="btn btn-outline-dark" onclick="deleteButton('+content.ID+')" data-trigger="hover" data-tooltip="tooltip" title="Delete" '+disabled+'><i class="far fa-trash-alt"></i></button>';

                        if(('<?php echo $_SESSION['user']['id']; ?>' == content.user_id) || ('<?php echo $_SESSION['user']['id']; ?>' == content.createdBY))
                        {
                            var btn = btn_view+btn_edit+btn_print+btn_delete;
                        }else{
                            var btn = btn_view+btn_edit+btn_print;
                        }

                        var requestor_name = '<b>Requested By : </b><br>'+content.userName+' ['+content.userEmail+']'
                        var creator_name = '<b>Created By : </b><br>'+content.created_name+' ['+content.created_email+']'

                        // console.log(requestor_name);
                        table.row.add({
                            0   : '<div class="text-center">'+i+'</div>',
                            1   : requestor_name+'<br><br>'+creator_name,
                            2   : content.car_type_name,
                            3   : content.location,
                            4   : content.purpose,
                            5   : '<div class="text-center">'+start_date+' / '+content.start_time+'</div>',
                            6   : '<div class="text-center">'+end_date+' / '+content.end_time+'</div>',
                            7   : '<div class="text-center">'+status+'</div>',
                            8   : '<div class="text-center"><div class="btn-group btn-group-sm" role="group">'+btn+'</div></div>',
                        }).draw();
                    });
                }
            },
            error:function(){
                iziToast.warning({
                    position: 'bottomRight',
                    message: '500 Internal Server Error.'
                });
            }
        });
    }
</script>
