<div class="buttons" style="margin: 10px 0px;">
    <div onclick="getPage('<?php echo site_url('gkpos/manage_delivery') ?>', 'online order')" class="col-lg-3 col-md-3 col-sm-3 col-xs-12 btn btn-danger gradient" style="font-size: 90%;" >Unassigned Jobs</div>
    <div onclick="getPage('<?php echo site_url('gkpos/manage_delivery/assigned') ?>', 'online order')" class="col-lg-3 col-md-3 col-sm-3 col-xs-12 btn  btn-success gradient" style="font-size: 90%;">Assigned Jobs</div>
    <div onclick="getPage('<?php echo site_url('gkpos/driver_account/') ?>', 'online order')" class="col-lg-3 col-md-3 col-sm-3 col-xs-12 btn btn-info gradient" style="font-size: 90%;" >Drivers' Account</div>
    <div onclick="getPage('<?php echo site_url('gkpos/add_driver') ?>', 'online order')" class="col-lg-3 col-md-3 col-sm-3 col-xs-12 btn  btn-primary gradient" style="font-size: 90%;" >Add New Driver</div>
</div>
<div class="modal-content-order-detail">
    <div class="clearfix"></div>
    <div class="modal-body">
        <table class="table table-responsive table-bg-color-white">
            <tr>
                <th>Name</th>
                <th>Email</th>
                <th>Phone</th> 
                <th>Delete</th> 
            </tr>
            <?php if (!empty($drivers)): ?>
                <?php foreach ($drivers as $adriver): ?>
                    <tr>
                        <td><?php echo $adriver->name ?></td>
                        <td><?php echo $adriver->email ?></td>
                        <td><?php echo $adriver->phone ?></td> 
                        <td><span class="glyphicon glyphicon-trash" style="color: #FF0000" onclick="deletDriver('<?php echo site_url('gkpos/delete_driver/' . $adriver->id) ?>', 'online order')"></span></td> 
                    </tr>
                <?php endforeach; ?>
            <?php endif; ?>
        </table>
    </div>
</div>
<script type="text/javascript">
    function deletDriver(url) {
        $.confirm({
            'title': 'User Delete Warning',
            'message': 'Are you sure? You want to delete this user',
            'buttons': {
                'Yes': {
                    'class': 'btn btn-danger',
                    'action': function () {
                        $.ajax({
                            url: url,
                            type: 'Get',
                            dataType: 'json',
                            success: function (response) {
                                if (response.status === true) {
                                    getPage('<?php echo site_url('gkpos/list_driver') ?>', 'online order')
                                } else {
                                    ALERT_TITLE = "Error!";
                                    ALERT_BUTTON_TEXT = "Close";
                                    alert('Driver could not be deleted because he/she is assigned to job');
                                }
                            }
                        });
                    }
                },
                'No': {
                    'class': 'btn btn-success',
                    'action': function () {}
                }
            }
        });
    }

</script>
