<script>
    $(document).ready(function() {
        $('select').select2();
        $.each($(".select2-container"), function (i, n) {
            $(n).next().show().fadeTo(0, 0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
            $(n).prepend($(n).next());
            $(n).delay(500).queue(function () {
                $(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
                $(this).dequeue();
            });
        });
        var oTable = $("#test").dataTable({
            "iDisplayLength": 10,
            "aLengthMenu": [5, 10, 25, 50, 100],
            "sPaginationType": "full_numbers", "aoColumns": [{
                    "bSortable": false},
                null,
                null,
                null,
                null,
                null, {
                    "bSortable": false}]});
        oTable.fnSort([[1, 'asc']]);
        $("table.editable").on("click", ".edit", function() {
            rRow = $(this).parents("tr");
            ID = $('td:first', $(this).parents('tr')).text();
            $("#row_edit").dialog("open");
        });
        $("#row_edit").dialog({
            autoOpen: false,
            resizable: false,
            modal: true,
            buttons: {
                "Continue...": function() {
                    window.location.href = "<?php echo base_url(); ?>zakatsetup/Center/" + ID;
                    $(this).dialog("close");
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
        $("table.editable").on("click", ".remove", function() {
            rRow = $(this).parents("tr");
            fldid = $('td:first', $(this).parents('tr')).text();
            $("#row_delete").dialog("open");
        });
        function remove_row(row) {
            $.ajax({
                type: "POST",
                url: "<?php echo base_url() ?>zakatreport/centerDelete",
                data: "fldid=" + fldid,
                success: function() {
                  //  row.remove();
                  //  alert('Row has been deleted...');
                  window.location.href = "<?php echo base_url(); ?>zakatSetup/zakatcentersetup";
                  windo
                  
                },
                failed: function() {
                    alert('Action failed...');
                },
            });       // Here your ajax action after delete confirmed
        }
        $("#row_delete").dialog({
            autoOpen: false,
            resizable: false,
            modal: true,
            buttons: {
                "Delete": function() {
                    remove_row(rRow);
                    $(this).dialog("close");
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
    });
</script>
<div id="content">                        
    <div class="wrap">

        <div class="head">
            <div class="info">
                <!--<h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
                    <?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>-->
                <ul class="breadcrumb">
                    <li><a href="<?php echo base_url() ?>home"><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                    <li><a href="zakat/home"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                    <li class="active"><?php echo $this->lang->line('title') ?></li>
                </ul>
            </div>

            <div class="search">
                <form action="<?php echo base_url() ?>admin/search" method="post">
                    <input name="search_text" type="text" placeholder="search..."/>                                
                    <button type="submit"><span class="i-magnifier"></span></button>
                </form>
            </div>                        
        </div>  <!-- Head -->
        <div class="content">
            <div class="row-fluid">
                <div class="span12">
                    <div class="block">
                        <div class="head">
                            <h2><?php echo $this->lang->line('titlelist') ?></h2>
                            <div class="side fr">
                                <a href="<?php echo base_url() ?>zakatSetup/center" class="btn-icon btn-warning-form" title="Add New"><span class="i-plus-2"></span></a>
                                <a href="<?php echo base_url(); ?>zakatreport/centerList_print" class="btn-icon btn-success-form" name="updatePosting" onclick="" target="_blank"><?php echo $this->lang->line('print') ?></a>
                            </div>                                        
                        </div><!-- head -->
                        <div class="content np table-sorting">
                            <table cellpadding="0" cellspacing="0" width="100%" id="test" class="editable">
                                <thead>
                                    <tr>
                                        <th style="display:none"></th>
                                        <th class="tac">#</th>
                                        <th><?php echo $this->lang->line('shortName') ?></th>
                                        <th><?php echo $this->lang->line('name') ?></th>
                                        <th><?php echo $this->lang->line('telephone') ?></th>
                                        <th><?php echo $this->lang->line('website') ?></th>
                                        <th class="tac"><?php echo $this->lang->line('action') ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $bil = 0;
                                    if ($datatbls) {
                                        foreach ($datatbls as $datatbl):
                                            $bil++
                                            ?>
                                            <tr>
                                                <td style="display:none" ><?php echo $datatbl->ID; ?></td>
                                                <td class="tac"><?php echo $bil; ?></td>
                                                <td class="edit"><a title="<?php echo $this->lang->line('details'); ?>" class="btn-link"><?php echo $datatbl->shortName ?></a></td>
                                                <td><?php echo $datatbl->name ?></td>
                                                <td><?php echo $datatbl->noTel ?></td>
                                                <td><a href="<?php echo $datatbl->website; ?>"><?php echo $datatbl->website; ?></a></td>
                                                <td class="tac"><?php
                                                    $js = 'class="btn-icon btn-mini btn-danger-form remove" title="' . $this->lang->line('delete') . '"';
                                                    echo form_button('remove', '<span class="i-trashcan">', $js);
                                                    ?></td>
                                            </tr>
    <?php endforeach;
} ?>
                                </tbody>
                            </table>
                        </div><!-- content -->
                    </div><!-- block -->
                </div>  <!-- span12 -->
            </div>  <!-- row-fluid -->
        </div>  <!-- content -->
    </div>  <!-- wrap -->
</div>  <!-- content -->
<div class="dialog" id="row_edit" style="display: none;" title="<?php echo $this->lang->line('edit'); ?> ?">
    <p><?php echo $this->lang->line('message1'); ?></p>
</div>  
<div class="dialog" id="row_delete" style="display: none;" title="<?php echo $this->lang->line('delete'); ?> ?">
    <p><?php echo $this->lang->line('message3'); ?></p>
</div>  
