<div class="content-top-1 box box-default">
    <div class="box-header">
        <div class="box-tools pull-right">
            <div class="row" style="margin-right: 10px">

                <?php
                if ($this->session->userdata('role') == "Admin" || $this->session->userdata('role') == "Tech") {
                ?> 
                <a href="javascript:void(0);" id="disable" class="btn btn-danger btn-sm"><i class="fa fa-ban"></i> Remove Redemption Point </a> &nbsp; &nbsp; &nbsp;
                <?php
                }
                ?>   
            </div>
        </div>
    </div>
    <br>
    <div class="box-body">
        <div class="row">
            <div class="col-md-12">
                <table id="usersTable" class="ui celled table stripe" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th>Redemption Partner</th>
                            <th>Client</th>
                            <th>Type</th> 
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
        <br>
        <label class="label label-info" id="wait"></label>

    </div>
</div>
 

<div style="position: absolute; left:-999999999999; top: -999999999; visibility: hidden">
    <?= form_open("/crossindustry/disable_partner", array('id' => 'dfrm')) ?> 
    <button type="submit" id="dsubmit"></button>
    </form> 
</div> 
<script type="text/javascript">
    var table;

    function loadTable() {
        table = $('#usersTable').DataTable({
            destroy: true,
            responsive: false,
            "ajax": {
                url: '/tables/crossindustrypartners',
                type: 'get'
            },
            select: {
                style: 'single',
                selector: 'td'
            },  
            fixedColumns: false,
            scrollY: "800px",
            scrollX: true,
            scrollCollapse: true,
            paging: true,
            lengthChange: true,
            "rowCallback": function(nRow, aData) { 
            }
        });

    }

    $(document).ready(function() {  
        $('#disable').click(function() {
            if (table.rows('.selected').data().length > 0) { 
                $('#dfrm input').remove();
                var len = table.rows('.selected').data().length;
                var items = table.rows('.selected').data();
                for (var i = 0; i < len; i++) {
                    var row = table.rows('.selected').data()[i]; 
                    $('#dfrm').append("<input type='hidden' name='code[]' value='" + row[3] + "'>");
                }
                $('#dfrm').append("<input type='hidden' name='client' value='" + row[4] + "'>");
                $('#dfrm').append("<input type='hidden' name='action' value='client'>");
                $('#dsubmit').click();
            } else
                alert("please select a partner");
        }); 

        loadTable()

    });
</script>