<style>
    #mmira-pregnant-list-view{
        border: 2px solid #dddddd;
    }
    #mira-pregnant-list-view > thead > tr > th,
    #mira-pregnant-list-view > tbody > tr > th,
    #mira-pregnant-list-view > tfoot > tr > th,
    #mira-pregnant-list-view > thead > tr > td,
    #mira-pregnant-list-view > tbody > tr > td,
    #mira-pregnant-list-view > tfoot > tr > td {
        border: 2px solid #dddddd;
    }
    #mira-pregnant-list-view{
        width: 100%;
        overflow-x: scroll;
    }
    
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
  display: none; /* Initially hidden */
  z-index: 9999; /* Ensure it stays on top */
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 18px;
}

/* Loader style */
#loader {
  font-size: 40px;
  text-align: center;
}    

</style>
<?php

$level = $this->session->userdata('level');

?>

<div class="panel"> 
    <div class="row">
        <div class="col col-xs-6 text-left">
            <h3 class="text-info"><strong>Child&nbsp;Immunization</strong></h3>
        </div>
    </div>

    <div class="panel-body" style="margin-top: -16px">
        
                        <!-- Loader and Overlay -->
<div id="overlay" style="display: none;">
    <div id="loader" style="margin-top:280px!important;">Loading...</div>
</div>
        <table id="mira-pregnant-list-view" class="table table-bordred table-striped table-hover">
            <thead>
               <?php if($level==1){ ?>
                    <tr>
                        <th colspan="10">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i aria-hidden="true"></i><strong>Select Data View</strong></span>
                                            <select name="data_see_code" id="data_see_code" required class="form-control"> 
                                            <option value=0 selected="true" disabled=""> Select Asha</option>
                                            <option value=1 > Mira wise</option>
                                            <option value=2 > Child wise</option>
                                            </select>
                                             
                                           
                                        </div>                    
                                    </div> 
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i aria-hidden="true"></i><strong>Select ANM</strong></span>
                                            <select name="anm_region_code" id="anm_region_code" class="form-control">
                                                <option value="0" selected="true" disabled=""> Select ANM</option>
                                                <?php
                                                for ($i = 0; $i < count($anmList); $i++) {
                                                    if (isset($regionCode)) {
                                                        if ($anmselected == $anmList[$i]['region_code']) {
                                                            ?>
                                                            <option selected="true" value=<?= $anmList[$i]['region_code'] ?> ><strong><?= $anmList[$i]['user_name'] ?></strong></option>
                                                        <?php } else { ?>
                                                            <option value=<?= $anmList[$i]['region_code'] ?>><strong><?= $anmList[$i]['user_name'] ?></strong></option>
                                                            <?php
                                                        }
                                                    } else {
                                                        ?>
                                                        <option value=<?= $anmList[$i]['region_code'] ?>><strong><?= $anmList[$i]['user_name'] ?></strong></option>
                                                        <?php
                                                    }
                                                }
                                                ?>
                                            </select>
                                            <span class="input-group-addon"><i class="fa fa-level-down"aria-hidden="true"></i></span>
                                        </div>                    
                                    </div>   
                                </div>
                                
                                <div class="col-md-4" id="div_region_code" style="display:none;">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i aria-hidden="true"></i><strong>Select Asha</strong></span>
                                            <select name="region_code" id="region_code" class="form-control"> 
                                            <option value=0 selected="true" disabled=""> Select Asha</option>
                                            </select>
                                           
                                        </div>                    
                                    </div> 
                                </div>
                            </div>
                            <div class="row" id="start_end_date_row" style="display:none">
                                <div class="col-lg-4">   
                                    <div class="form-group">
                                        <div class="input-group date" id="st_date" data-date-fromat="dd-mm-yyyy" style="color: white">
                                            <span class="input-group-addon"><strong>Start Date</strong></span>
                                            <input class="form-control" type="text" name="st_date" id="st_date_input"   required placeholder="dd-mm-yyyy">
                                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        </div>                    
                                    </div>

                                </div>
                                <div class="col-lg-4">   
                                    <div class="form-group">
                                        <div class="input-group date" id="en_date" data-date-fromat="dd-mm-yyyy" style="color: white">
                                            <span class="input-group-addon"><strong>End Date</strong></span>
                                            <input class="form-control" type="text" name="en_date" id="en_date_input"  required placeholder="dd-mm-yyyy">
                                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        </div>                    
                                    </div>
                                </div>

                                <div class="col-lg-4">
                                    <input type="button" class="btn btn-primary" id="btnsearch" value="Submit">
                                </div>
                                </div>
                        </th>
                        <th colspan="5" style="border: none;">
                            <button type="button" id="dwnldBtn" style="margin-left: 230px; margin-bottom: 20px; display: none;" onclick="downloadTableAsExcel();">Download Sheet</button>
                        </th>
                    </tr>
                    <?php } ?>
                    
            <tr>
                <th class="text-center">#</th>
                <th class="text-center" >UPHC&nbsp;&nbsp;&nbsp;Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                 <th class="text-center" >Mohalla&nbsp;&nbsp;&nbsp;Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center" >House&nbsp;Number</th>
                <th class="text-center" >Address</th>
                <th class="text-center" id="chnage_title">Source&nbsp;Name</th>
                <th class="text-center" >Date&nbsp;Of&nbsp;Birth</th>
                <th class="text-center" >Age&nbsp;in&nbsp;Week</th>
                 <th class="text-center" >Mother&nbsp;&nbsp;Name</th>
                <th class="text-center" >Gender&nbsp;</th>
                <th class="text-center" >MCP&nbsp;</th>
                <th class="text-center" >Immunization&nbsp;&nbsp;Status</th>
                <th class="text-center" >Child&nbsp;Category&nbsp;Status</th>
                <th class="text-center" >Main&nbsp;Reason&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center" >Remarks&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center" >Registeration&nbsp;Date</th>
                <th class="text-center">HepatitisB&nbsp;&nbsp;</th>
                <th class="text-center">OPV0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">BCG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">OPV1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">Pentavalent1&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">Rotavirus1</th>
                <th class="text-center">IPV1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">PCV1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">OPV2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">Pentavalent2</th>
                <th class="text-center">Rotavirus2</th>
                <th class="text-center">OPV3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">Pentavalent3</th>
                <th class="text-center">Rotavirus3</th>
                <th class="text-center">IPV2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">PCV2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">Measles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">VitaminA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th class="text-center">PCVBooster</th>
                <th class="text-center">DPTBooster</th>
                <th class="text-center">OPVBooster</th>
                <th class="text-center">MeaslesBooster</th>
            </tr>
            </thead>
            <tbody>
                
               
            </tbody>
        </table>

    </div>

</div>


<!-- Include the SheetJS Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>

<script type="text/javascript">
    
    function downloadTableAsExcel() {
        var table = document.getElementById("mira-pregnant-list-view");
        var rows = table.querySelectorAll("tr");
        
        // Create an array to hold the table data
        var tableData = [];
        
        // Loop through the rows, starting from the second one (index 1)
        rows.forEach(function(row, index) {
            if (index === 0) return;  // Skip the first row (header row)

            var cols = row.querySelectorAll("td, th");
            var rowData = [];
            cols.forEach(function(col) {
                rowData.push(col.innerText);
            });
            tableData.push(rowData);
        });
        
        // Create a new workbook and add the table data to a worksheet
        var wb = XLSX.utils.book_new();
        var ws = XLSX.utils.aoa_to_sheet(tableData);
        
        // Append the worksheet to the workbook
        XLSX.utils.book_append_sheet(wb, ws, "Table Data");
        
        // Generate Excel file and trigger the download
        XLSX.writeFile(wb, "Child_Immunization.xlsx");
    }

    
    $(document).ready(function () {
        $('#datetimepicker2').datepicker({
            format: 'dd-mm-yyyy'
        });
       
        $('#region_code').change(function (e) {
             e.preventDefault();
             $('#overlay').show();
            var region_code = parseInt($('#region_code').val());
            $('#pregnant_list_update_spinner').css('display', 'block');
            $('#mira-pregnant-list-view tbody tr').remove();
           
            $.ajax({
                url: '<?= base_url('get_child_vaccination') ?>',
                data: {
                    region_code: region_code
                },
                type: "POST",
                success: function (data, textStatus, jqXHR) {
                     $('#overlay').hide();
                    $('#pregnant_list_update_spinner').css('display', 'none');
                    var vaccine_data = JSON.parse(data);     
                    console.log(vaccine_data['vaccineData']);
                    if (vaccine_data['vaccineData']) {
                        document.getElementById("dwnldBtn").style.display = "block";
                        // Iterate through the data array
                        for (var i = 0; i < vaccine_data['vaccineData'].length; i++) {
                            var child = vaccine_data['vaccineData'][i];
                            if (child['main_reason'] === "अन्य: ____________") {
                              child['main_reason'] = "अन्य";
                              }
                            $("#mira-pregnant-list-view tbody").append('<tr></tr>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['c_id'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['health_center_name'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['mohalla_name'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['house_number'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['address'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['child_name'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['dob'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['age_in_weeks'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['mother_name'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['gender_name'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['mcpcard_status'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['child_category_name'] + '</td>');  
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['immunization_status'] + '</td>'); 
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['main_reason'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['other_reason'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['mobile_date'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['HepatitisB'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['OPV0'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['BCG'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['OPV1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['Pentavalent1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['Rotavirus1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['IPV1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['PCV1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['OPV2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['Pentavalent2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['Rotavirus2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['OPV3'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['Pentavalent3'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['Rotavirus3'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['IPV2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['PCV2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['Measles'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['VitaminA'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['PCVBooster'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['DPTBooster'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['OPVBooster'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + child['MeaslesBooster'] + '</td>');
                        }
                    }
                    else{
                        document.getElementById("dwnldBtn").style.display = "none";
                    }
                }
            });
        });
        
        $('#anm_region_code').change(function (e) {
             e.preventDefault();
       var see_code_value = parseInt($('#data_see_code').val());
        var anmcode='0'
        if(see_code_value==1)
        {    
           var region_code = parseInt($('#anm_region_code').val());
         anmcode=region_code;
         let stdate=$('#st_date_input').val();
         let endate=$('#en_date_input').val();
        // let searchby=parseInt($('#searchbydate').val());
         if(stdate !== '' && endate !== '' && anmcode !== '0')
            {   $('#overlay').show(); 
                GetDataByAnmId(anmcode, stdate,endate,3)
            }
            
          
            else
            {    $('#overlay').show(); 
                GetDataByAnmId(region_code, null,null,null)
            }
        }
        else if(see_code_value==2){
            var region_code = parseInt($('#anm_region_code').val());
    //$('#region_code').children('option:not(:first)').remove(); // Clear existing options except the first
      $('#region_code').empty(); 
    // Show the dropdown
    $('#region_code').css('display', 'block');

    // Clear date inputs and reset any related displays
    $('#st_date_input').val('');
    $('#en_date_input').val('');
    $("#trd").text(0);
    $("#frd").text('0');

    $.ajax({
        url: '<?= base_url('getAshalistByANMId') ?>',
        data: {
            region_code: region_code
        },
        type: "POST",
        success: function (json) {
            var states = $.parseJSON(json);

            // Add "Select Asha" option first
            $('#region_code').append($("<option></option>").val(0).html("Select Asha").attr("disabled", true).attr("selected", true));

            // Populate the dropdown with other Asha options
            for (var i = 0; i < states['miraList'].length; i++) {
                $("#region_code").append($("<option></option>").val(states['miraList'][i]['region_code']).html(states['miraList'][i]['user_name']));
            }

            $('#asha_list_update_spinner').css('display', 'none');
        },
        error: function (xhr, status, errorThrown) {
            $('#asha_list_update_spinner').css('display', 'none');
        },
        complete: function (xhr, status) {
            $('#asha_list_update_spinner').css('display', 'none');
        }
    });
        }
        
      
          });

       $('#data_see_code').change(function(){
            $('#mira-pregnant-list-view tbody').empty();
          var see_code_value = parseInt($('#data_see_code').val());
          if(see_code_value==1)
          {
           $('#div_region_code').css('display', 'none'); 
           $('#chnage_title').html('Mira&nbsp;Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
           $('#start_end_date_row').css('display', 'block');
           $('#mira-pregnant-list-view tbody tr').remove();
          }
          else if(see_code_value==2){
           $('#div_region_code').css('display', 'block'); 
           $('#start_end_date_row').css('display', 'none');
            $('#mira-pregnant-list-view tbody tr').remove();
           $('#chnage_title').html('Child&nbsp;Name&nbsp;&nbsp; ');
          }
        })

        $('#btnsearch').click(function(e){
            e.preventDefault();
            let stdate=$('#st_date_input').val();
            let endate=$('#en_date_input').val();
            let rcode=parseInt($('#region_code').val());
            let searchby=3;//parseInt($('#searchbydate').val());
            let searchbyanm =parseInt($('#anm_region_code').val());
                     console.log(stdate);
                     console.log(endate);
                     console.log(searchby);
                     console.log(anmcode);
            if(searchby !== '0' && stdate !== '' && endate !== '' && anmcode !== '0')
            {
                $('#overlay').show(); 
                console.log('Hi I am in this code');
                GetDataByAnmId(anmcode, stdate,endate,searchby)
            }
            else
            {
                alert("Plese Select and fill all fields");
            }
        });

        $('#st_date').datepicker({ autoclose: true, format: 'dd-mm-yyyy' });
        $('#en_date').datepicker({ autoclose: true, format: 'dd-mm-yyyy' });
        
    });

    

   function GetDataByAnmId(region_code,st_date,en_date,searchby){
          
            anmcode=region_code;
            $('#mira-pregnant-list-view tbody').empty();
           // $('#mira-pregnant-list-view tbody tr').remove();
            $.ajax({
                url: '<?= base_url('getAshaHouseHoldDataByANMId') ?>',
                data: {
                    region_code: region_code,
                    st_date_input:st_date,
                    en_date_input:en_date,
                    searchbydate:searchby
                },
                type: "POST",
                success: function (json) {
                     $('#overlay').hide();
                    var states = $.parseJSON(json);
                    console.log(states['miraList']);
                    document.getElementById("dwnldBtn").style.display = "block";
                    for (var i = 0; i < states['miraList'].length; i++) {
                        
                          var userName = states['miraList'][i]['user_name'];

                  // Use regular expression to split the string and apply styles
               var formattedUserName = userName.replace(/^([^\(]+)\(([^)]+)\)$/, function(match, p1, p2) {
                    // p1 is the part before the parentheses (Mira-01)
                    // p2 is the part inside the parentheses (Parveen)

                   return '<span style="font-weight: bold;">' + p1 + '</span>' + 
                          '<span style="font-size: 9px;">(' + p2 + ')</span>';
                    });
                        
                           $("#mira-pregnant-list-view tbody").append('<tr></tr>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + (parseInt(i) + 1) + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-left">' + formattedUserName + '</td>');
                            
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_heptb'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_opv'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_bcg'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_opv_1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_pentavalent_1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_rotavirus_1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_ipv_1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_pcv_1'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_opv_2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_pentavalent_2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_rotavirus_2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_opv_3'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_pentavalent_3'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_rotavirus_3'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_ipv_2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_pcv_2'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_measles'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_vitaminA'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_pcv_booster'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_dpt_booster'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_opv_booster'] + '</td>');
                            $('#mira-pregnant-list-view tbody tr:last').append('<td class="text-center">' + states['miraList'][i]['total_measles_booster'] + '</td>');
                            
                            
                    }
                    $('#asha_list_update_spinner').css('display', 'none');
                },
                error: function (xhr, status, errorThrown) {
                    $('#overlay').hide();
                    $('#asha_list_update_spinner').css('display', 'none');
                },
                complete: function (xhr, status) {
                    $('#asha_list_update_spinner').css('display', 'none');
                }
            });
     }
     
    function getDateFormat(date) {
        var split_date_array1 = date.split('-');
        var split_date_array2 = split_date_array1[2].split(' ');
        return (split_date_array2[0] + '-' + split_date_array1[1] + '-' + split_date_array1[0]);
    }
    
</script>
