<style>
    #mira-application-update{
        border: 2px solid #dddddd;
    }
    #mira-application-update > thead > tr > th,
    #mira-application-update > tbody > tr > th,
    #mira-application-update > tfoot > tr > th,
    #mira-application-update > thead > tr > td,
    #mira-application-update > tbody > tr > td,
    #mira-application-update > tfoot > tr > td {
        border: 2px solid #dddddd;

    }
    #mira-application-update{
        width: 100%;
        overflow-x: scroll;
    }


</style>
<div class="panel"> 
    <div class="panel-body">
        <h2 class="text-center">Pregnant Women List of Weekly Questionnaire by ANM</h2>  
        <hr class="colorgraph">
        <table id="mira-application-update" class="table table-bordred table-striped table-hover">
            <thead>
                <tr style="background-color:  #f4efe1;height: 50px">
                    <th class="text-center">#</th>
                    <th class="text-center">House&nbsp;No.</th>
                    <th class="text-center">Women&nbsp;Name</th>
                    <th class="text-center">Pregnancy&nbsp;Date</th>
                    <th class="text-center">Running&nbsp;Week</th>
                    <th class="text-center">Attempt&nbsp;By</th>
                    <th class="text-center">Qus.1</th>
                    <th class="text-center">Qus.2</th>
                    <th class="text-center">Qus.3</th>
                    <th class="text-center">Qus.4</th>
                    <th class="text-center">Qus.5</th>
                    <th class="text-center" colspan="3">Anm Action</th>


                </tr>
            </thead>
            <tbody>

                <?php
                if (isset($womenList) and $womenList) {
                    for ($i = 0; $i < count($womenList); $i++) {
                        ?>
                        <tr id="<?= 'tr' . $womenList[$i]['pregnant_id'] ?>">
                            <td class="text-center"><?= ($i + 1) ?></td>
                            <td class="text-center"><?= $womenList[$i]['house_number'] ?></td>
                            <td class="text-center"><?= str_replace(' ', '&nbsp;', $womenList[$i]['name']) ?></td>
                            <td class="text-center"><?= date('d-m-Y', strtotime($womenList[$i]['pregnant_date'])) ?></td>
                            <td class="text-center"><?= $womenList[$i]['current_week'] ?></td>
                            <?php if ($womenList[$i]['week_qus_ans_list']['attempt'] == 0) { ?>
                                <td class="text-center"><span class="label label-warning">Pending..</span></td>
                            <?php } elseif ($womenList[$i]['week_qus_ans_list']['attempt'] == 1) { ?>
                                <td class="text-center"><span class="label label-success">Asha</span></td>
                            <?php } else { ?>
                                <td class="text-center"><span class="label label-success">ANM</span></td>
                            <?php }
                            ?>
                            <?php
                            if (isset($womenList[$i]['week_qus_ans_list']) and $womenList[$i]['week_qus_ans_list']) {
                                for ($j = 0; $j < count($womenList[$i]['week_qus_ans_list']['qus_ans_list']); $j++) {
                                    $q_id = $womenList[$i]['week_qus_ans_list']['qus_ans_list'][$j]['question_id'];
                                    $ans = $womenList[$i]['week_qus_ans_list']['qus_ans_list'][$j]['answer'];
                                    if ($q_id == 1) {


                                        if ($ans == '-') {
                                            ?>
                                            <td class="text-center"><span class="label label-info"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 1) { ?>
                                            <td class="text-center"><span class="label label-success"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 2) { ?>
                                            <td class="text-center"><span class="label label-danger"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 3) { ?>
                                            <td class="text-center"><span class="label"style="background-color: black"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 4) { ?>
                                            <td class="text-center"><span class="label"style="background-color: blue"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 5) { ?>
                                            <td class="text-center"><span class="label"style="background-color: orange"><?= $ans ?></span></td>
                                            <?php
                                        }
                                    } elseif ($q_id == 2) {

                                        if ($ans == '-') {
                                            ?>
                                            <td class="text-center"><span class="label label-info"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 1) { ?>
                                            <td class="text-center"><span class="label label-success"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 2) { ?>
                                            <td class="text-center"><span class="label label-danger"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 3) { ?>
                                            <td class="text-center"><span class="label"style="background-color: black"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 4) { ?>
                                            <td class="text-center"><span class="label"style="background-color: blue"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 5) { ?>
                                            <td class="text-center"><span class="label"style="background-color: orange"><?= $ans ?></span></td>
                                            <?php
                                        }
                                    } elseif ($q_id == 3) {

                                        if ($ans == '-') {
                                            ?>
                                            <td class="text-center"><span class="label label-info"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 1) { ?>
                                            <td class="text-center"><span class="label label-success"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 2) { ?>
                                            <td class="text-center"><span class="label label-danger"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 3) { ?>
                                            <td class="text-center"><span class="label"style="background-color: black"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 4) { ?>
                                            <td class="text-center"><span class="label"style="background-color: blue"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 5) { ?>
                                            <td class="text-center"><span class="label"style="background-color: orange"><?= $ans ?></span></td>
                                            <?php
                                        }
                                    } elseif ($q_id == 4) {

                                        if ($ans == '-') {
                                            ?>
                                            <td class="text-center"><span class="label label-info"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 1) { ?>
                                            <td class="text-center"><span class="label label-success"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 2) { ?>
                                            <td class="text-center"><span class="label label-danger"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 3) { ?>
                                            <td class="text-center"><span class="label"style="background-color: black"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 4) { ?>
                                            <td class="text-center"><span class="label"style="background-color: blue"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 5) { ?>
                                            <td class="text-center"><span class="label"style="background-color: orange"><?= $ans ?></span></td>
                                            <?php
                                        }
                                    } elseif ($q_id == 5) {

                                        if ($ans == '-') {
                                            ?>
                                            <td class="text-center"><span class="label label-info"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 1) { ?>
                                            <td class="text-center"><span class="label label-success"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 2) { ?>
                                            <td class="text-center"><span class="label label-danger"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 3) { ?>
                                            <td class="text-center"><span class="label"style="background-color: black"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 4) { ?>
                                            <td class="text-center"><span class="label"style="background-color: blue"><?= $ans ?></span></td>
                                        <?php } elseif ($ans == 5) { ?>
                                            <td class="text-center"><span class="label"style="background-color: orange"><?= $ans ?></span></td>
                                            <?php
                                        }
                                    }
                                }

                                if ($womenList[$i]['week_qus_ans_list']['attempt'] == 0) {
                                    ?>

                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to mira Normal"><button class="btn btn-info btn-xs" data-title="transferCaseMira" data-toggle="modal" data-target="#transferCaseAsha" disabled=""><strong>To&nbsp;Asha</strong><span class="glyphicon glyphicon-send"></span></button></p></td>
                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to mira Normal"><button class="btn btn-warning btn-xs" data-title="transferCaseMira" data-toggle="modal" data-target="#transferCaseSubCenter" disabled=""><strong>To&nbsp;SubCenter</strong><span class="glyphicon glyphicon-send"></span></button></p></td>
                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to doctor Danger"><button class="btn btn-danger btn-xs" data-title="transferCaseDoctor" data-toggle="modal" data-target="#transferCaseDoctor" disabled=""><strong>To&nbsp;Doctor</strong><span class="glyphicon glyphicon-send"></span></button></p></td>


                                <?php } elseif ($womenList[$i]['week_qus_ans_list']['attempt'] == 1) { ?>

                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to mira Normal"><button class="btn btn-info btn-xs transfer" data-title="transferCaseMira" data-toggle="modal" data-target="#transferCaseAsha" value="<?= $womenList[$i]['pregnant_id'] . ':' . $womenList[$i]['current_week'] . ':5' ?>"><strong>To&nbsp;Asha</strong><span class="glyphicon glyphicon-send"></span></button></p></td>
                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to mira Normal"><button class="btn btn-warning btn-xs transfer" data-title="transferCaseMira" data-toggle="modal" data-target="#transferCaseSubCenter" value="<?= $womenList[$i]['pregnant_id'] . ':' . $womenList[$i]['current_week'] . ':4' ?>"><strong>To&nbsp;SubCenter</strong><span class="glyphicon glyphicon-send"></span></button></p></td>
                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to doctor Danger"><button class="btn btn-danger btn-xs transfer" data-title="transferCaseDoctor" data-toggle="modal" data-target="#transferCaseDoctor" value="<?= $womenList[$i]['pregnant_id'] . ':' . $womenList[$i]['current_week'] . ':3' ?>" ><strong>To&nbsp;Doctor</strong><span class="glyphicon glyphicon-send"></span></button></p></td>


                                <?php } elseif ($womenList[$i]['week_qus_ans_list']['attempt'] == 2) { ?>

                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to mira Normal"><button disabled="" class="btn btn-info btn-xs" data-title="transferCaseMira" data-toggle="modal" data-target="#transferCaseAsha"><strong>To&nbsp;Asha</strong><span class="glyphicon glyphicon-send"></span></button></p></td>
                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to mira Normal"><button disabled="" class="btn btn-warning btn-xs" data-title="transferCaseMira" data-toggle="modal" data-target="#transferCaseSubCenter" ><strong>To&nbsp;SubCenter</strong><span class="glyphicon glyphicon-send"></span></button></p></td>
                                    <td class="text-center"><p data-placement="top" data-toggle="tooltip" title="Transfer to doctor Danger"><button disabled="" class="btn btn-danger btn-xs" data-title="transferCaseDoctor" data-toggle="modal" data-target="#transferCaseDoctor" ><strong>To&nbsp;Doctor</strong><span class="glyphicon glyphicon-send"></span></button></p></td>


                                    <?php
                                }
                            }
                            ?>
                        </tr>
                        <?php
                    }
                }
                ?>



            </tbody>
        </table>



        <!--        <div class="col-lg-8 col-lg-offset-2">
                    <p class=""><strong>Qus1:</strong>&nbsp;Do you feel weak, breathless & get tired easily?</p>
                    <p class=""><strong>Qus2:</strong>&nbsp;Are you suffering from fever, severe headache, blurring of vision or swelling all over the body?</p>
                    <p class=""><strong>Qus3:</strong>&nbsp;Are you suffering from continuous vaginal bleeding?</p>
                    <p class=""><strong>Qus4:</strong>&nbsp;Are you suffering from convulsions as well as loss of consciousness?</p>
                    <p class=""><strong>Qus5:</strong>&nbsp;Are suffering from severe abdominal pain for more than 12 hours?</p>
                </div>-->
    </div>
    <div class="panel-footer">
        <div class="row">

            <div class="col-lg-6">
                <ul class="pagination pagination-large">
                    <?php
                    if (isset($totalPage) and $totalPage and $totalPage > 1) {
                        for ($i = 0; $i < $totalPage; $i++) {
                            if($i==0){
                                if($activePage==1){?>
                                    <li class="disabled"><span>«</span></li>
                               <?php }  else {?>
                                    <li class="page" value="<?= ($activePage-1)?>"><a href="<?= base_url('immunization_pregnant/'.($activePage-1))?>"><span>«</span></a></li>
                              <?php  }
                            }
                            
                            
                            if (($i+1) == $activePage) {
                                ?>
                                
                                <li class="active page"><span><?= ($i + 1) ?></span></li>  
                            <?php } else { ?>
                                <li class="page"><a href="<?= base_url('immunization_pregnant/'.($i+1))?>"><span><?= ($i + 1) ?></span></a></li>
                                <?php
                            }
                            
                            
                            if(($i+1)==$totalPage){
                                if($totalPage==$activePage){?>
                                    <li class="disabled page"><a><span>Next</span></a></li>
                                <?php }  else {?>
                                    <li class="page"><a href="<?= base_url('immunization_pregnant/'.($activePage+1))?>"><span>Next</span></a></li>
                             <?php   }
                            }
                        }
                       }
                    ?>
                </ul>

            </div>
            <div class="col-lg-6">
                <p class="text-center" style="margin-top: 30px">
                    <span class="label label-info">Not Attempt</span>
                    <span class="label label-success ">1:Success</span>
                    <span class="label label-danger ">2:Danger</span>
                    <span class="label" style="background-color: orange">5:Refer To Asha</span>
                    <span class="label" style="background-color: black">3:Refer To PHC(Doctor)</span>
                    <span class="label" style="background-color: blue">4:Refer to SubCenter</span>
                </p>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        /**
         * 
         * 
         * 
         */
        $('.page').click(function (){
            
        });
        /**
         * 
         * 
         * 
         * 
         */
        $('.transfer').click(function () {

            var pregnant_id_current_week_referto = $(this).val().split(':');
            alert(pregnant_id_current_week_referto[0]);
            alert(pregnant_id_current_week_referto[1]);
            alert(pregnant_id_current_week_referto[2]);
            $.ajax({
                url: '<?= base_url('refer_by_anm') ?>',
                data: {
                    pregnant_id: pregnant_id_current_week_referto[0],
                    current_week: pregnant_id_current_week_referto[1],
                    refer_to: pregnant_id_current_week_referto[2]
                },
                type: "POST",
                success: function (json) {
                    var current_status_app = $.parseJSON(json);
                    if (current_status_app['status']) {
                        $('#tr' + pregnant_id_current_week_referto[0]).remove();
                    }
                },
                error: function (xhr, status, errorThrown) {

                },
                complete: function (xhr, status) {

                }
            });

        });
    });
</script>


