<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 ($complain as $type) { ?>
                                        <br><div data-trigger="hover" data-tooltip="tooltip" title="<?php echo $type['Complaint']; ?>" 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">Maintenance 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/maintenance_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 Maintenance Request (<?php echo date('Y') ?>)</h6>
                            <br>
                            <div class="row">
                                <table id="table_maintenance" class="table table-bordered table-striped table-hover mx-1">
                                    <thead>
                                        <th class="text-center">Categories</th>
                                        <th class="text-center">Total Request</th>
                                    </thead>
                                    <tbody>
                                        <?php if($complain) foreach($complain as $cval){ ?>
                                            <tr>
                                                <td><?php echo $cval['Complaint']; ?></td>
                                                <td class="text-center"><?php echo $cval['total_request']; ?></td>
                                            </tr>
                                        <?php } ?>
                                    </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">
                <div class="float-left">
                    <h4>Maintenance Request List</h4>

                    <a href="<?php echo base_url('hr/serviceform/maintenance_form'); ?>" class="btn btn-outline-dark btn-sm" title="Add New Maintenance"><i class="fa fa-plus"></i> Add New Request</a>
                    <a href="<?php echo base_url('hr/Serviceform_report/maintenance_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>

            <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_maintenance_filter_dept" class="col-lg-3">
                                                Department
                                            </label>                           
                                            <div class="col-lg-4" >
                                                <select class="custom-select" name="sv_maintenance_filter_dept" id="sv_maintenance_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="filterofficeunit" class="col-lg-3">
                                            Office Unit
                                        </label>
                                        <div class="col-lg-4">    
                                            <select class='custom-select' id="sv_maintenance_filter_office_unit" name="sv_maintenance_filter_office_unit">
                                                <option value="-1">[All]</option>
                                                <option value="554">554</option>
                                                <option value="555">555</option>
                                                <option value="556">556</option>
                                                <option value="557">557</option>
                                                <option value="558">558</option>
                                            </select>
                                        </div>                                         
                                    </div>
                                    <div class="form-group row">
                                        <label for="filterfloor" class="col-lg-3">
                                            Floor
                                        </label>
                                        <div class="col-lg-4">    
                                            <select class='custom-select' id="sv_maintenance_filter_floor" name="sv_maintenance_filter_floor">
                                                <option value="-1">[All]</option>
                                                <option value="Ground Floor">Ground Floor</option>
                                                <option value="1">Level 1</option>
                                                <option value="2">Level 2</option>
                                                <option value="3">Level 3</option>
                                            </select>
                                        </div>                                         
                                    </div>
                                    <div class="form-group row">
                                        <label for="filtercategory" class="col-lg-3">
                                            Complaint Category
                                        </label>
                                        <div class="col-lg-4">    
                                            <select class='custom-select' id="sv_maintenance_filter_complaint_category" name="sv_maintenance_filter_complaint_category">
                                                <option value="">[All]</option>
                                                <option value="Lights">Lights</option>
                                                <option value="Aircond">Aircond</option>
                                                <option value="Washroom">Washroom</option>
                                                <option value="Copier Machine">Copier Machine</option>
                                                <option value="Furniture">Furniture</option>
                                                <option value="Others General">Others General</option>
                                                <option value="Cleanliness Floor">Cleanliness Floor</option>
                                                <option value="Other">Other</option>
                                            </select>
                                        </div>                                         
                                    </div>
                                    <div class="form-group row">
                                        <label for="sv_maintenance_filter_status" class="col-lg-3">
                                            Status
                                        </label>                           
                                        <div class="col-lg-4" >
                                            <select class="custom-select" id="sv_maintenance_filter_status" name="sv_maintenance_filter_status">
                                                <option value="-1">[All]</option>
                                                <option value="Pending">Pending</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_maintenance_filter_year" class="col-lg-3">
                                            Year
                                        </label>                           
                                        <div class="col-lg-4" >
                                            <input type="text" name="sv_maintenance_filter_year" id="sv_maintenance_filter_year" class="form-control datepicker-yyyy">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="sv_maintenance_filter_month" class="col-lg-3">
                                            Month
                                        </label>                           
                                        <div class="col-lg-4" >
                                            <input type="text" name="sv_maintenance_filter_month" id="sv_maintenance_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_maintenance" class="table table-bordered p-0 m-0" width="100%">
                                        <thead>
                                            <th class="sorting text-center">#</th>
                                            <th class="sorting text-center">Office unit / Floor</th>
                                            <!-- <th class="sorting text-center">Floor</th> -->
                                            <th class="sorting text-center">Complaint Category</th>
                                            <th class="sorting text-center">Problem</th>
                                            <th class="sorting text-center">File Name</th>
                                            <th class="sorting text-center">Request Date</th>
                                            <th class="sorting text-center">Fix Date</th>
                                            <th class="sorting text-center">Status</th>
                                            <th class="sorting text-center">Action</th>           
                                        </thead>

                                        <tbody id="list_maintenance_list">
                                            <?php if(!empty($rsMaintenanceList)) { ?> 
                                                <?php foreach($rsMaintenanceList as $key => $row) { //debug($row); ?>
                                                    <tr>
                                                        <td class="text-center"><?php echo $key+1; ?></td>
                                                        <td>Unit: <?php echo $row['office_unit']; ?><br>
                                                            Floor: <?php echo $row['floor']; ?>
                                                        </td>
                                                        <td><?php echo $row['complain_category']; ?></td>
                                                        <td><?php echo $row['problem']; ?></td>
                                                        <td><a download href="<?php echo base_url($row['file_location'].$row['photo_title']); ?>" ><?php echo $row['photo_title']; ?></a>
                                                        </td>
                                                        <td class="text-center"><?php echo date('d-m-Y',strtotime($row['createdTS'])); ?></td>
                                                        <td class="text-center">
                                                            <?php echo (!empty(strtotime($row['date_fixed'])))?date('d-m-Y',strtotime($row['date_fixed'])):''; ?>
                                                        </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-office_unit="<?php echo $row['office_unit']; ?>"
                                                                data-status="<?php echo $row['status_app']; ?>"
                                                                data-floor="<?php echo $row['floor']; ?>" 
                                                                data-complaintcategory="<?php echo $row['complain_category']; ?>" 
                                                                data-problem="<?php echo $row['problem']; ?>"
                                                                data-phototitle="<?php echo $row['photo_title']; ?>"
                                                                onclick="open_view_modal(this)"><i class="far fa-eye"></i></button>

                                                                <!-- <a href="<?php //echo base_url('hr/serviceform/maintenance_form/'.$row['ID']); ?>" target="_blank" class="btn btn-outline-dark" onclick="" data-trigger="hover" data-tooltip="tooltip" title="View Detail"><i class="far fa-eye"></i></a> -->


                                                                <?php if($_SESSION['all_modules_access'][0]['access_lvl'] == 'admin' || $_SESSION['user']['division_id'] == 4){ ?>
                                                                    <a href="<?php echo base_url('hr/serviceform/maintenance_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/maintenance_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 type="button" class="btn btn-outline-dark" href="<?php echo base_url('hr/serviceform_report/maintenance_print/').$row['ID']; ?>" target="_blank" data-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 } ?>
                                            <?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">Maintenance Request Detail</h5>&emsp;
                <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>Status</label>
                        <input type="text" class="form-control" name="modal_view_status" id="modal_view_status" disabled>
                    </div>
                </div>

                <div class="row">
                    <div class="col-4">
                        <label>Office Unit</label>
                        <input type="text" class="form-control" name="modal_view_office_unit" id="modal_view_office_unit" disabled>
                    </div>
                    <div class="col-4">
                        <label>Floor</label>
                        <input type="text" class="form-control" name="modal_view_floor" id="modal_view_floor" disabled>
                    </div>
                    <div class="col-4">
                        <label>Complaint Category</label>
                        <input type="text" class="form-control" name="modal_view_complaint" id="modal_view_complaint" disabled>
                    </div>
                </div>

                <div class="row">
                    <div class="col-6">
                        <label>Problem</label>
                        <input type="text" class="form-control" name="modal_view_problem" id="modal_view_problem" disabled>
                    </div>
                    <div class="col-6">
                        <label>Upload Picture</label>
                        <input type="text" class="form-control" name="modal_view_file" id="modal_view_file" 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 officeunit          = $(elem).data('office_unit');
        let floor               = $(elem).data('floor');
        let complaintcategory   = $(elem).data('complaintcategory');
        let problem             = $(elem).data('problem');
        let phototitle       = $(elem).data('phototitle');


        /* view modal */
        $('#modal_view_name').val(name);
        $('#modal_view_dept').val(dept);
        $('#modal_view_date_req').val(datereq);
        $('#modal_view_office_unit').val(officeunit);
        $('#modal_view_floor').val(floor);
        $('#modal_view_complaint').val(complaintcategory);
        $('#modal_view_problem').val(problem);
        $('#modal_view_file').val(phototitle);
    }

    function deleteData(ID) {
        validateForm("#deleteButton", "Delete this maintenance list?", function() {
            $.ajax({
                url:'<?php echo base_url('hr/serviceform/deleteMaintenanceList') ?>',
                data: {
                    maintenanceID : 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/hotel_list'));
                    }
                }
            });
        });
    }

    $(document).ready(function(){

        $('#table_maintenance').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 = moment(hover_item.createdTS).format('DD-MM-YYYY');

                if((hover_item.date_fixed != null || hover_item.date_fixed != '' || hover_item.date_fixed != undefined) && hover_item.date_fixed != '0000-00-00'){
                    var end = moment(hover_item.date_fixed).format('DD-MM-YYYY');
                }else{
                    var end = 'No fixed date'
                }

                tooltip = '<div class="tooltipevent"> Requester : '+hover_item.userName+'['+hover_item.staff_id+']'+'<br/> Email : '+hover_item.email+'<br/> Complaint : '+hover_item.complain_category+'<br/> Request Date : '+start+'<br/> Fix Date : '+end+'<br/>Department : '+hover_item.dept_name+'/'+hover_item.branchName+'</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_maintenance_filter_dept'); ?>
        <?php $this->session->unset_userdata('sv_maintenance_filter_office_unit'); ?>
        <?php $this->session->unset_userdata('sv_maintenance_filter_floor'); ?>
        <?php $this->session->unset_userdata('sv_maintenance_filter_complaint_category'); ?>
        <?php $this->session->unset_userdata('sv_maintenance_filter_year'); ?>
        <?php $this->session->unset_userdata('sv_maintenance_filter_month'); ?>
        <?php $this->session->unset_userdata('sv_maintenance_filter_status'); ?>
        <?php $this->session->unset_userdata('sv__maintenance'); ?>
    });

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

        frmData.append('sv_maintenance_filter_dept',$('#sv_maintenance_filter_dept').val());
        frmData.append('sv_maintenance_filter_office_unit',$('#sv_maintenance_filter_office_unit').val());
        frmData.append('sv_maintenance_filter_floor',$('#sv_maintenance_filter_floor').val());
        frmData.append('sv_maintenance_filter_complaint_category',$('#sv_maintenance_filter_complaint_category').val());
        frmData.append('sv_maintenance_filter_status',$('#sv_maintenance_filter_status').val());
        frmData.append('sv_maintenance_filter_year',$('#sv_maintenance_filter_year').val());
        frmData.append('sv_maintenance_filter_month',$('#sv_maintenance_filter_month').val());
        frmData.append('user_id',$('#user_id').val());

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

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

                let maintenance = data.table;

                if(maintenance != null){
                    $.each(maintenance,function(key,content)
                    {
                        var i = key + 1;

                        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-office_unit="'+content.office_unit+'" data-floor="'+content.floor+'" data-complaintcategory="'+content.complain_category+'" data-problem="'+content.problem+'" data-phototitle="'+content.photo_title+'" 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/maintenance_print/'+content.ID+'" data-trigger="hover" data-tooltip="tooltip" title="Print Detail"><i class="fa fa-print"></i></a>';

                        if(content.photo_title != null && content.photo_title != '' && content.photo_title != undefined){

                            var download_file = '<a download href="<?php echo base_url();?>hr/serviceform_report/maintenance_print/'+content.file_location+content.photo_title+'">'+content.photo_title+'</a>';
                        }else{
                            var download_file = '';
                        }

                        if((content.date_fixed != null || content.date_fixed != '' || content.date_fixed != undefined) && content.date_fixed != '0000-00-00'){
                            var fixed_date = moment(content.date_fixed).format('DD-MM-YYYY');
                        }else{
                            var fixed_date = '';
                        }

                         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/maintenance_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/maintenance_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_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;
                        }

                        table.row.add({
                            0   : '<div class="text-center">'+i+'</div>',
                            1   : 'Unit: '+content.office_unit+'<br>Floor: '+content.floor,
                            2   : content.complain_category,
                            3   : content.problem,
                            4   : download_file,
                            5   : '<div class="text-center">'+moment(content.createdTS).format('DD-MM-YYYY')+'</div>',
                            6   : '<div class="text-center">'+fixed_date+'</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();
                        console.log(data);

                    });                        
                }
            },
            error:function(){
                iziToast.warning({
                    position: 'bottomRight',
                    message: '500 Internal Server Error.'
                });
            }
        });
    }
</script>