<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 bodyitem">
    <div class="row no-padding">
        <fieldset>
            <table class="table table-bg-color table-responsive table-bordered">
                <tr>
                    <th class="text-center">Order Id</th>
                    <th class="text-center">Order Type</th>
                    <th class="text-center">Customer</th>
                    <th class="text-center">Locked By</th>
                    <th class="text-center">Unlock</th>
                    <?php if ($this->session->userdata('gkpos_usertype') == 1): ?>
                        <th class="text-center"><a  href="javascript:void(0)" style="width: 130px" class="btn btn-sm btn-danger" onclick="releaseAllLocks('gkpos_order_lookup', '<?php echo site_url('gkpos/report/release_all_locks') ?>', '<?php echo site_url('gkpos/settings/locked_orders') ?>')">Release All Locks</a></th>
                    <?php else: ?>
                        <th>&nbsp;</th>
                    <?php endif; ?>
                </tr>
                <?php if (!empty($lockedOrders)): ?>
                    <?php foreach ($lockedOrders as $lOrder): ?>
                        <?php $thisOrder = get_single_record('gkpos_order', array('id' => $lOrder->order_id)) ?>
                        <?php if (!empty($thisOrder)): ?>
                            <tr>
                                <td class="text-center"><?php echo $lOrder->order_id ?></td>
                                <td class="text-center"><?php echo $thisOrder->order_type ?></td>
                                <td class="text-center"><?php $thisOrder->order_type == 'table' ? print 'Table-' . $thisOrder->table_number : print $thisOrder->name ?></td>
                                <td class="text-center"><?php echo get_user_name($lOrder->occupied_by) ?></td>
                                <td class="text-center"><i class="fa fa-lock fa-2x" onclick="orderExit('<?php echo $lOrder->order_id ?>')"></i></td>
                            </tr>
                        <?php endif; ?>
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr><td colspan="3">No Locked Orders Found</td></tr>
                <?php endif; ?>
            </table>
        </fieldset>
    </div>
</div>
<script>
    $(document).ready(function () {
        manageWindowHeight();
    });
    function releaseAllLocks(table, url, targetUrl) {
        $.confirm({
            'title': 'Order Releasing Warning',
            'message': 'Are you sure what are you doing?  Releasing locks does not retrive other\'s previous unsaved cart data',
            'buttons': {
                'YES': {
                    'class': 'btn btn-danger btn-sm',
                    'action': function () {
                        $.ajax({
                            url: url,
                            data: {
                                table: table
                            },
                            type: "POST",
                            dataType: 'json',
                            success: function (output) {
                                if (output.success) {
                                    getSettingPage(targetUrl, '');
                                } else {
                                    alert(output.message);
                                }
                            }
                        });
                    }
                },
                'NO': {
                    'class': 'btn btn-success btn-sm',
                    'action': function () {}
                }
            }
        });
    }
</script>
