<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_checkupinfo/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_checkupinfo/filter_dylayed" class="button sub inlineBlock rnd3 lightTextShadow">
            <span>المعاينات المعلقة</span>
        </a>
        <a href="<?= base_url() ?>patient/admin_checkupinfo/export_checkupinfo_reprt" class="button sub inlineBlock rnd3 lightTextShadow">
            <span>طباعة الكل</span>
        </a>
        <!-- Notification boxes -->
        <?php echo $this->template->flash_msg(); ?>
        <?php if ($checkupinfo == 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_checkupinfo/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>
                            <th>تاريخ الانشاء</th>
    <!--                            <th>ترتيب</th>-->
                            <th>خيارات</th>

                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $counter = $row + 1;
                        foreach ($checkupinfo as $n) :
                            ?>
                            <tr <?php
                            if ($counter % 2 == 1) {
                                echo "class='odd'";
                            }
                            ?> >
                                <td><input type="checkbox" name="check_nf[]" value="<?= $n['chi_id'] ?>" id="group" /></td>
                                <td class="align-center"><?php echo $counter; ?></td>
                                <td><?= date("Y-m-d", $n['chi_date']) ?></td>
                                <td><?php if($n['chi_nextdate'] !== "0"){
                                    echo date("Y-m-d", $n['chi_nextdate']);

                                }  else {
                                    echo "";
                                }
                                    ?></td>
                                <td><?= $n['chi_pi_id'] ?></td>
                                <td><?= $n['pi_name']." ".$n['pi_father']." ".$n['pi_family'] ?></td>
                                <td><?= $n['chi_cost'] ?></td>
                                <td><?= $row['type_name'] ?></td>
                                <td><?= $n['branch_name'] ?></td>
                                <td><?= $n['chi_steps'] ?></td>
                                <td><?= date('Y-m-d', $n['chi_created']) ?></td>


                                <td class="align-center">
                                    <a href="<?= base_url() ?>patient/admin_files/overview/<?= $n['chi_id'] ?>" ><img src="<?= base_url() ?>global/modules/admin/images/add_images.png" title="رفع المستندات" alt="up"/></a>&nbsp;&nbsp; | &nbsp;&nbsp;
                                    <a href="<?= base_url() ?>patient/admin_checkupinfo/edit/<?= $n['chi_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_checkupinfo/export_onecheckupinfo_reprt/<?= $n['chi_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>
                                </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; ?>

                </div>
            </form>
        <?php endif; ?>
    </div>
</div><!-- Data Grid End -->