<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">قائمة اقسام المدن</div>

    <div class="content">
        <a href="<?= base_url() ?>patient/admin_city_category/create" class="button sub inlineBlock rnd3 lightTextShadow">
            <span>اضف مدينة<img src="<?= base_url() ?>global/modules/admin/images/plus-small.gif" width="12" height="9" alt="New new" /></span>
        </a>
        <a href="<?= base_url() ?>patient/admin_branch_category/overview" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('button_branch_category'); ?></span>
        </a>
        <a href="<?= base_url() ?>patient/admin_product_type_category/overview" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('button_product_type_category'); ?></span>
        </a>
        <a href="<?= base_url() ?>patient/admin_city_category/overview" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('button_city_category'); ?></span>
        </a> 
        <a href="<?= base_url() ?>patient/admin_patient/overview" class="button sub inlineBlock rnd3 lightTextShadow">
            <span><?php echo $this->lang->line('button_patient'); ?></span>
        </a>                  
        <!-- Notification boxes -->
        <?php echo $this->template->flash_msg(); ?>
        <?php if ($categories == 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() ?>patient/admin_city_category/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 ><?php echo $this->lang->line('created'); ?></th>
                            <?php
                            $lang_array = $this->config->item('supported_languages');
                            $l = count($lang_array);
                            if ($l > 1) {
                                ?>
                                <th ><?php echo $this->lang->line('lang'); ?></th>
                            <?php } ?>
                            <th ><?php echo $this->lang->line('order'); ?></th>
                            <th ><?php echo $this->lang->line('operation'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $counter = $row + 1;
                        ;
                        foreach ($categories as $cat) :
                            ?>
                            <tr <?php
                            if ($counter % 2 == 1) {
                                echo "class='odd'";
                            }
                            ?>>
                                <td><input type="checkbox" name="check_nf[]" value="<?= $cat['ct_id'] ?>" id="group" /></td>
                                <td class="align-center"><?php echo $counter; ?></td>
                                <td><a href="<?= base_url() ?>patient/admin_city_category/edit/<?= $cat['ct_id']; ?>"><?= $cat['ct_name'] ?></a></td>
                                <td><?= date('Y-m-d', $cat['ct_created']) ?></td>
                                <td class="align-center">
                                    <a href="<?= base_url() ?>patient/admin_city_category/sort/up/<?= $cat['ct_id'] ?>"  ><img src="<?= base_url() ?>global/modules/admin/images/up.png" title="أعلى" alt="up"/></a>
                                    <a href="<?= base_url() ?>patient/admin_city_category/sort/down/<?= $cat['ct_id'] ?>" ><img src="<?= base_url() ?>global/modules/admin/images/down.png" title="أسفل" alt="down"/></a>
                                </td>
                                <td class="align-center">                            
                                    <?php if ($cat['ct_hide'] == 1) : ?>
                                        <a href="<?= base_url() ?>patient/admin_city_category/deactivate/<?= $cat['ct_id']; ?>"><img src="<?= base_url() ?>global/modules/admin/images/tick-circle.gif" width="16" height="16"  title="<?php echo $this->lang->line('act'); ?>" alt="خيارات النشر" /></a>&nbsp;&nbsp; | &nbsp;&nbsp;
                                    <?php else : ?>
                                        <a href="<?= base_url() ?>patient/admin_city_category/activate/<?= $cat['ct_id']; ?>"><img src="<?= base_url() ?>global/modules/admin/images/minus-circle.gif" width="16" height="16" title="<?php echo $this->lang->line('inact'); ?>" alt="خيارات النشر النشر" /></a>&nbsp;&nbsp; | &nbsp;&nbsp;
        <?php endif; ?>
                                    <a href="<?= base_url() ?>patient/admin_city_category/edit/<?= $cat['ct_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() ?>patient/admin_city_category/remove/<?= $cat['ct_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>
                            </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" value="active"   ><?php echo $this->lang->line('active'); ?></option>
                                <option class="oButton" value="inactive" ><?php echo $this->lang->line('disactive'); ?></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 -->