<script>
    jQuery(document).ready(function(){                                              
        jQuery("#operation").change(function () {                                        
                                                    
            var len = jQuery("#group:checked").length;
            if (len < 1) {
                alert("لم تقم باختيار أى عنصر");
                jQuery(".defaultOpt").attr("selected", "selected");
                return false;
            } else {
                if (jQuery("option.delete").is(":selected")) {
                    var answer = confirm('هل أنت متأكد من حذف هذه العناصر؟');
                    if (answer == false) {
                        jQuery(".defaultOpt").attr("selected", "selected");                        
                        return false;
                    }                    
                }
                jQuery("#form").submit();
            }                                            
        });     
    });     
</script>
<!-- Data Grid Start -->
<div class="block">
    <div class="title lightTextShadow"><?php echo $this->lang->line('users_list'); ?></div>    
    <div class="content">
        <?php $this->load->view('authorization/search_user', array('action' => 'authorization/admin_users/overview')); ?>

        <a href="<?= base_url() ?>authorization/admin_users/create" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('add_members'); ?><img src="<?= base_url() ?>global/modules/admin/images/plus-small.gif" width="12" height="9" alt="New new" /></span>
        </a>
        <a href="<?= base_url() ?>authorization/admin_groups" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('button_groups'); ?></span>
        </a>
        <a href="<?= base_url() ?>authorization/admin_users" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('button_users'); ?></span>
        </a>
        <!-- Notification boxes -->
        <?php echo $this->template->flash_msg(); ?>
        <?php if ($users == FALSE) : ?>
            <br/>            
            <p class="block boxStyle notice attention"><a href="javascript:void(0)" class="close"></a><b>تنبيه!</b>لا توجد بيانات مضافة<p>
            <?php else : ?>
            <form method="post" action="<?= base_url() ?>authorization/admin_users/operation/" id="form">                
                <table class="dataGrid tableSorter boxStyle" cellspacing="0" cellpadding="0" border="0">
                    <thead>
                        <tr>
                            <th><input type="checkbox" name="check_nf2" id="selectall"/></th>
                            <th>مسلسل</th>
                            <th ><?php echo lang('visitor_name'); ?></th>

                            <th ><?php echo lang('visitor_country'); ?></th>

                            <th ><?php echo lang('created'); ?></th>

                            <th ><?php echo lang('group'); ?></th>

                            <th ><?php echo lang('operation'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $counter = 1;
                        foreach ($users as $v) :
                            ?>
                            <tr <?php
                    if ($counter % 2 == 1) {
                        echo "class='odd'";
                    }
                            ?>>
                                <td><input type="checkbox" name="check_nf[]" value="<?= $v['user_id'] ?>" id="group" /></td>
                                <td class="align-center"><?php echo $counter; ?></td>

                                <td><?= $v['user_username']; ?></td>

                                <td><?php echo $v['user_country']; ?></td>

                                <td><?php echo $v['user_created_date'] ?></td>

                                <td><?php echo $v['gn'] ?></td>

                                <td class="align-center">                                        
                                    <a href="<?= base_url() ?>authorization/admin_users/remove/<?= $v['user_id']; ?>" onclick="return confirm('هل تريد حذف هذا العنصر؟');"><img src="<?= base_url() ?>global/modules/admin/images/del.gif" width="16" height="16" title="<?php echo lang('delete'); ?>" alt="<?php echo lang('delete'); ?>"  /></a>
                                    &nbsp;&nbsp; | &nbsp;&nbsp;
                                    <a href="<?= base_url() ?>authorization/admin_users/edit/<?= $v['user_id']; ?>" ><img src="<?= base_url() ?>global/modules/admin/images/pencil.gif" width="16" height="16" title="<?php echo lang('edit'); ?>" alt="<?php echo lang('edit'); ?>"  /></a>

                                </td>
                            </tr>
                            <?php
                            $counter++;
                        endforeach;
                        ?>
                    </tbody>
                </table>
                <div class="pager">
                    <?php if ($this->input->post("userdata") == "") { ?>
                        <div class="resultsCount"><b><?php echo $row + 1 ?></b> - <b><?php echo $row + 10 ?></b> / <em><?php echo $total_rows; ?></em></div>
                        <?php echo $links; ?>
                    <?php } ?>
                    <fieldset class="formList inlineBlock">
                        <p align="center"><?php echo $this->lang->line('choose_operation'); ?>:
                            <select class="select rnd5" id="operation" name="operation" onchange="" >
                                <option class="defaultOpt" value=""  >--<?php echo $this->lang->line('choose'); ?>--</option>                                
                                <option class="oButton delete" value="delete" ><?php echo $this->lang->line('delete'); ?></option>
                            </select>
                        </p>
                    </fieldset>                    
                </div>
            </form>
        <?php endif; ?>
    </div>
</div><!-- Data Grid End -->