<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">
        <a href="<?= base_url() ?>users/admin_users/create" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('button_new_user'); ?><img
                    src="<?= base_url() ?>global/modules/admin/images/plus-small.gif" width="12" height="9"
                    alt="New new"/></span>
        </a>
        <a href="<?= base_url() ?>users/admin_users/export_users_reprt"
           class="button sub inlineBlock rnd3 lightTextShadow">
            <span>طباعة الكل</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() ?>users/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>اسم الموظف</th>
                        <th>البريد الالكتروني</th>
                        <th>الفرع التابع له</th>
                        <th>رقم الهاتف</th>
                        <th>ملاحظات</th>
                        <th>تاريخ الانشاء</th>
                        <th>ترتيب</th>
                        <th>خيارات</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php
                    $counter = 1;
                    foreach ($users as $n) :
                        ?>
                        <tr <?php
                        if ($counter % 2 == 1) {
                            echo "class='odd'";
                        }
                        ?> >
                            <td><input type="checkbox" name="check_nf[]" value="<?= $n['user_id'] ?>" id="group"/></td>
                            <td class="align-center"><?php echo $counter; ?></td>
                            <td class="align-center"><?= $n['user_full_name'] ?></td>
                            <td class="align-center"><?= $n['user_email'] ?></td>
                            <td class="align-center"><?= $n['branch_name'] ?></td>
                            <td class="align-center"><?= $n['user_phone'] ?></td>
                            <td class="align-center"><?= $n['user_notice'] ?></td>
                            <td><?= date('Y-m-d', $n['user_created']) ?></td>
                            <td class="align-center">
                                <a href="<?= base_url() ?>users/admin_users/sort/up/<?= $n['user_id'] ?>"><img
                                        src="<?= base_url() ?>global/modules/admin/images/up.png" title="أعلى"
                                        alt="up"/></a>
                                <a href="<?= base_url() ?>users/admin_users/sort/down/<?= $n['user_id'] ?>"><img
                                        src="<?= base_url() ?>global/modules/admin/images/down.png" title="أسفل"
                                        alt="down"/></a>
                            </td>
                            <td class="align-center">
                                <a href="<?= base_url() ?>users/admin_users/edit/<?= $n['user_id']; ?>"><img
                                        src="<?= base_url() ?>global/modules/admin/images/edit2.png" width="16"
                                        height="16" title="<?php echo $this->lang->line('edit'); ?>" alt="تعديل"/></a>&nbsp;&nbsp;
                                | &nbsp;&nbsp;
                                <a href="<?= base_url() ?>users/admin_users/export_oneuser_reprt/<?= $n['user_id']; ?>"><img
                                        src="<?= base_url() ?>global/modules/admin/images/pdf_document.png" width="16"
                                        height="16" title="<?php echo $this->lang->line('export'); ?>" alt="'استخراج"/></a>|
                                &nbsp;&nbsp;
                                <?php if ($n['user_id'] != 42) { ?>
                                <a href="<?= base_url() ?>users/admin_users/remove/<?= $n['user_id']; ?>"
                                   onclick="return confirm('هل تريد حذف هذا العنصر؟');"><img
                                        src="<?= base_url() ?>global/modules/admin/images/del.png" width="16"
                                        height="16" title="<?php echo $this->lang->line('delete'); ?>" alt="حذف"/></a>
                            </td>
                            <?php } ?>
                        </tr>
                        <?php
                        $counter++;
                    endforeach;
                    ?>

                    </tbody>
                </table>
                <div class="pager">
                    <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; ?>
                    <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 -->