<style type="text/css">


    .panel.panel-default.panel-body{
        margin-top: 20px;
    }


    .label-circle {


    }
    .table-background-odd{
        background-color: #f3e3e0;

    }
    .table-background-even{
        background-color: #f6f0ee  
    }
    .table-background-head{
        background-color: #e8eff4;  
    }




    .spinner{
        margin-top: 8px;
        margin-left: -5px;
        display: none;
    }
    .form_label{
        margin-top: 4px;
    }
    .td_success{
        background-color: green;
    }
    .td_danger{
        background-color: red;
    }
    .td_dots{
        background-color: blue;
    }
    .td_outside{
        background-color: #0099FF;
    }
    .td_remain{
        background-color: #5bc0de;
    }
    .permanent_patient_id{
        cursor: pointer;
    }

    .table-user-information tbody tr td{
        text-align: center;
        color: #269abc;

    }
    .table-user-information{
        margin-top: -12px;

    }


    .table-user-information > tbody > tr {
        border-top: 1px solid rgb(221, 221, 221);
    }

    .table-user-information > tbody > tr:first-child {
        border-top: 0;
    }


    .table-user-information > tbody > tr > td {
        border-top: 0;
    }



    #patient_dose_taken_phase1_table{
        border: 1px solid #857875;
    }
    #patient_dose_taken_phase1_table > thead > tr > th,
    #patient_dose_taken_phase1_table > tbody > tr > th,
    #patient_dose_taken_phase1_table > tfoot > tr > th,
    #patient_dose_taken_phase1_table > thead > tr > td,
    #patient_dose_taken_phase1_table > tbody > tr > td,
    #patient_dose_taken_phase1_table > tfoot > tr > td {
        border: 1px solid #857875;

    }
    #patient_dose_taken_phase1_table{
        width: 100%;

    }

    .field-coordinator-patient-dose .panel{

    }
    .verticalLine {
        border:solid #ecf2f2;
    }
    .text-setting{
        margin-top: 4px;
    }
</style>
<div class="panel"> 
    <?php $this->load->view('mira_work_details_button')?>
    <hr style="margin-bottom: 0;margin-top: 0">
    <hr style="margin-bottom: 12px;margin-top: 0">
    <div class="row">
        <div class="col-lg-3"><p class="text-center" data-placement="top" data-toggle="tooltip" title=""><span>Worker&nbsp;Name:&nbsp;<strong><?= $region_detail[0]['user_name'] ?></strong></span></p></div>
        <div class="col-lg-3"><p class="text-center" data-placement="top" data-toggle="tooltip" title=""><span>Region&nbsp;Name:&nbsp;<strong><?= $region_detail[0]['region_name'] ?></strong></span></p></div>
        <div class="col-lg-3"><p class="text-center" data-placement="top" data-toggle="tooltip" title=""><span>Joing&nbsp;Date&nbsp;<strong><?= date('d-m-Y H:i:s', strtotime($region_detail[0]['user_create_date'])) ?></strong></span></p></div>
    </div>

    <hr style="margin-bottom: 0;margin-top: 0">
    <hr style="margin-bottom: 0;margin-top: 0">

    <div class="panel-body" style="margin: 0;padding: 0">
        <table class="table tatable-bordered table-hover tableborder" id="patient_dose_taken_phase1_table" style="margin: 0;padding: 0">
            <thead>         
                <tr class="table-background-head">
                  
                    <th class="text-center fix" rowspan="2">H.&nbsp;No.</th> 
                    <th class="text-center" rowspan="2">Women&nbsp;Name</th>
                    <th class="text-center" rowspan="2">Start&nbsp;Date&nbsp;&nbsp;</th> 
                    <th class="text-center" rowspan="2">Week/Day</th>
                    <th class="text-center" colspan="5">Last&nbsp;Week</th>
                    <th class="text-center" colspan="6">Last&nbsp;Tracking</th>
                    <th class="text-center" colspan="5">Running&nbsp;Week</th>
                    <th class="text-center" colspan="6">Running&nbsp;Tracking</th>
                </tr>
                <tr class="table-background-head">
                    <th class="text-center">Q1</th>
                    <th class="text-center">Q2</th>
                    <th class="text-center">Q3</th>
                    <th class="text-center">Q4</th>
                    <th class="text-center">Q5</th>
                    <th class="text-center">Time</th>
                    <th class="text-center">S1</th>
                    <th class="text-center">S2</th>
                    <th class="text-center">S3</th>
                    <th class="text-center">S4</th>
                    <th class="text-center">S5</th>


                    <th class="text-center">Q1</th>
                    <th class="text-center">Q2</th>
                    <th class="text-center">Q3</th>
                    <th class="text-center">Q4</th>
                    <th class="text-center">Q5</th>

                    <th class="text-center">Time</th>
                    <th class="text-center">S1</th>
                    <th class="text-center">S2</th>
                    <th class="text-center">S3</th>
                    <th class="text-center">S4</th>
                    <th class="text-center">S5</th>


                </tr>


            </thead>
            <tbody>
                <?php
                if (isset($list) and $list) {
                    for ($i = 0; $i < count($list); $i++) {
                        ?>


                        <tr>
                            
                            <td class="text-center table-background-odd fix"><?= $list[$i]['house_number'] ?></td>
                            <td class="text-center table-background-odd"><?= str_replace(' ', '&nbsp;', $list[$i]['name']) ?></td>
                            <td class="text-center table-background-odd"><?= date('d-m-Y', strtotime($list[$i]['pregnant_date'])) ?></td>




                            <?php if ($list[$i]['current_week'] > 40) { ?>
                                <td class="text-center table-background-odd"><?= "40+" . "/" . ($list[$i]['day'] + 1) ?></td>
                            <?php } else { ?>
                                <td class="text-center table-background-odd"><?= $list[$i]['current_week'] . "/" . ($list[$i]['day'] + 1) ?></td>
                            <?php }
                            ?>
                            <?php
                            if (isset($list[$i]['last_ans'][0]) and $list[$i]['last_ans'][0]) {
                                foreach ($list[$i]['last_ans'][0]['ans'] as $key => $value) {
                                    if (!$list[$i]['last_ans'][0]['alert'] or ! $value['anm_answer']) {
                                        //Mira question answer update.
                                        if ($value['asha_answer'] == 1) {
                                            ?>

                                            <td class="text-center"><span class="label label-success label-circle"><?= $value['asha_answer'] ?></span></td>
                                        <?php } else { ?>
                                            <td class="text-center"><span class="label label-danger label-circle"><?= $value['asha_answer'] ?></span></td> 
                                            <?php
                                        }
                                    } else {
                                        //ANM Rrefre to doctor,phi etc.
                                        if ($value['anm_answer'] == 1) {
                                            ?>
                                            <td class="text-center"><span class="label label-success label-circle"><?= $value['asha_answer'] ?></span></td>
                                            <?php
                                        } elseif ($value['anm_answer'] == 3) {
                                            ?>
                                            <td class="text-center"><span class="label label-primary label-circle"><?= $value['anm_answer'] ?></span></td>
                                            <?php
                                        } elseif ($value['anm_answer'] == 4) {
                                            ?>
                                            <td class="text-center"><span class="label label-default label-circle"><?= $value['anm_answer'] ?></span></td> 
                                            <?php
                                        } elseif ($value['anm_answer'] == 5) {
                                            ?>
                                            <td class="text-center"><span class="label label-default label-circle"><?= $value['anm_answer'] ?></span></td> 
                                            <?php
                                        }
                                    }
                                }
                            } else {
                                ?>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                            <?php }
                            ?>
                            <?php if (isset($list[$i]['last_track']) and $list[$i]['last_track']) { ?>
                                <td class="text-center"><span class="label label-info"><?= $list[$i]['current_track']['time'] ?></span></td>
                                <?php
                                for ($j = 0; $j < count($list[$i]['last_track']['sub_module_data']); $j++) {
                                    if ($list[$i]['last_track']['sub_module_data'][$j]['status']) {
                                        ?>
                                        <td class="text-center"><span class="label label-success"><i class=" fa fa-check"></i></span></td>
                                    <?php } else { ?>
                                        <td class="text-center"><span class="label label-danger"><i class=" fa fa-times"></i></span></td>
                                        <?php
                                    }
                                }
                                ?> 
                            <?php } else { ?>
                                <td class="text-center"><span class="label label-info">--:--</span></td>
                                <?php for ($j = 0; $j < 5; $j++) { ?>
                                    <td class="text-center"><span class="label label-warning">-</span></td>
                                <?php }
                                ?>
                            <?php } ?>  









                            <?php
                            if ($list[$i]['ans'][0]) {
                                foreach ($list[$i]['ans'][0]['ans'] as $key => $value) {
                                    if (!$list[$i]['ans'][0]['alert'] or ! $value['anm_answer']) {
                                        //Mira question answer update.
                                        if ($value['asha_answer'] == 1) {
                                            ?>

                                            <td class="text-center"><span class="label label-success label-circle"><?= $value['asha_answer'] ?></span></td>
                                        <?php } else { ?>
                                            <td class="text-center"><span class="label label-danger label-circle"><?= $value['asha_answer'] ?></span></td> 
                                            <?php
                                        }
                                    } else {
                                        //ANM Rrefre to doctor,phi etc.
                                        if ($value['anm_answer'] == 1) {
                                            ?>
                                            <td class="text-center"><span class="label label-success label-circle"><?= $value['asha_answer'] ?></span></td>
                                            <?php
                                        } elseif ($value['anm_answer'] == 3) {
                                            ?>
                                            <td class="text-center"><span class="label label-primary label-circle"><?= $value['anm_answer'] ?></span></td>
                                            <?php
                                        } elseif ($value['anm_answer'] == 4) {
                                            ?>
                                            <td class="text-center"><span class="label label-default label-circle"><?= $value['anm_answer'] ?></span></td> 
                                            <?php
                                        } elseif ($value['anm_answer'] == 5) {
                                            ?>
                                            <td class="text-center"><span class="label label-default label-circle"><?= $value['anm_answer'] ?></span></td> 
                                            <?php
                                        }
                                    }
                                }
                            } else {
                                ?>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                                <td class="text-center"><span class="label label-warning label-circle">0</span></td>
                            <?php }
                            ?>
                            <?php if (isset($list[$i]['current_track']) and $list[$i]['current_track']) { ?>
                                <td class="text-center"><span class="label label-info"><?= $list[$i]['current_track']['time'] ?></span></td>
                                <?php
                                for ($j = 0; $j < count($list[$i]['current_track']['sub_module_data']); $j++) {
                                    if ($list[$i]['current_track']['sub_module_data'][$j]['status']) {
                                        ?>
                                        <td class="text-center"><span class="label label-success"><i class=" fa fa-check"></i></span></td>
                                    <?php } else { ?>
                                        <td class="text-center"><span class="label label-danger"><i class=" fa fa-times"></i></span></td>
                                        <?php
                                    }
                                }
                                ?> 
                            <?php } else { ?>
                                <td class="text-center"><span class="label label-info">--:--</span></td>
                                <?php for ($j = 0; $j < 5; $j++) { ?>
                                    <td class="text-center"><span class="label label-warning">-</span></td>
                                <?php }
                                ?>
                            <?php } ?>  
                        </tr>
                        <?php
                    }
                }
                ?>


            </tbody>
        </table>
        <div class="panel-footer" style="margin: 0">
            <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('mira-work-detail-current/' . ($activePage - 1) . '/' . $region_detail[0]['region_code']) ?>"><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('mira-work-detail-current/' . ($i + 1) . '/' . $region_detail[0]['region_code']) ?>"><span><?= ($i + 1) ?></span></a></li>
                                    <?php
                                }


                                if (($i + 1) == $totalPage) {
                                    if ($totalPage == $activePage) {
                                        ?>
                                        <li class="disabled page"><span>Next</span></li>
                                    <?php } else { ?>
                                        <li class="page"><a href="<?= base_url('mira-work-detail-current/' . ($activePage + 1) . '/' . $region_detail[0]['region_code']) ?>"><span>Next</span></a></li>
                                        <?php
                                    }
                                }
                            }
                        }
                        ?>
                    </ul>
                </div>
                <div class="col-lg-6">
                    <p class="text-center">
                        <span class="label label-warning ">0-> Not Attempt By Asha</span>
                        <span class="label label-success ">1,2->Attempt By Asha</span>
                        <span class="label label-primary ">3,4,5->Action By ANM</span>

                    </p>
                </div>
            </div>

        </div>
    </div>
</div>