  <!--start main wrapper-->
    <main class="main-wrapper">

        <div class="main-content">
            <button class="btn guestBtn d-flex gap-2 align-items-center" id="backBtn"><img
                    src="<?php echo base_url(); ?>assets/images/arowleft.svg" alt="" width="15px"> Back</button>
            <h3 class=" fmon fw-bolder  mt-2   "> <img src="<?php echo base_url(); ?>assets/images/megaIcons/CHECKIVON.svg" alt=""> Check lists
            </h3>

            <div class="row">
                <div class="col-md-7">

                    <!-- <div class="input-group border-15">
                        <span class="input-group-text  border-15"><img src="<?php echo base_url(); ?>assets/images/serIcon.png" alt=""
                                width="25px"></span>
                        <input type="text" name="" id="" class="form-control form-Search  border-15  py-2"
                            placeholder="search">
                    </div> -->

                </div>
                <div class="col-md-5 d-flex justify-content-end gap-2">

                    <a href="<?php echo base_url().'site/createcheck'; ?>" class="btn addBtn"><img src="<?php echo base_url(); ?>assets/images/megaIcons/aplu.png"
                            alt="">
                        Create Check List</a>

                    <div class="btn bg-white d-flex gap-5 align-items-center px-3 border-15" data-bs-toggle="offcanvas"
                        data-bs-target="#offcanvasRight" aria-controls="offcanvasRight">
                        Filter <img src="<?php echo base_url(); ?>assets/images/e.png " alt="" width="20px">
                    </div>
                    <div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight"
                        aria-labelledby="offcanvasRightLabel">
                        <div class="offcanvas-header">
                            <h5 class="offcanvas-title" id="offcanvasRightLabel">Filters</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="offcanvas"
                                aria-label="Close"></button>
                        </div>
                        <div class="offcanvas-body">

                            <form>



                                <!-- Date Sent -->
                                <div class="mb-3">
                                    <label for="dateSent" class="form-label">Started at</label>
                                    <input type="date" class="form-control" id="dateSent" name="dateSent">
                                </div>

                                <!-- Sent By -->
                                <div class="mb-3">
                                    <label for="sentBy" class="form-label">Status</label>
                                    <select class="form-select" name="satatus" id="status">
                                        <option value="" selected>Select Status</option>
                                        <option value="completed">Completed</option>
                                        <option value="Inprocess"> In process</option>
                                    </select>
                                </div>

                                <button class="btn addBtn w-100" onclick="applyFilters()">Apply Filters</button>

                            </form>
                        </div>

                    </div>

                </div>
                <div>
                    <div class="table-responsive mt-3 ">
                        <table class="table table-striped table-hover">
                            <thead>
                                <tr>

                                    <th scope="col">Title</th>

                                    <th scope="col">Frequency</th>
                                    <th scope="col">Status</th>
                                    <th scope="col">Started at</th>
                                    <th scope="col">Actions</th>

                                </tr>
                            </thead>
                            <div class="">
                                <tbody class="">
                                    <?php foreach($CheckLists as $mainkey=> $CheckList){ ?>
                                    <tr>

                                        <td>
                                            <p class="ft7 fmon m-0"><?php echo $CheckList['title']; ?></p>
                                        </td>

                                        <td>
                                            <div class="d-flex  align-items-center">
                                                <div class="b-badge-success px-3 py-1"><?php echo $CheckList['frequency']; ?></div>
                                            </div>


                                        </td>
                                        <td>
                                            <?php
                                            $percentage=0;
                                            $checked=0;
                                            $unchecked=0;

                                            foreach($CheckList['areaToCheck'] as $area=>$areaData){ 
                                               foreach($areaData['areaToCheck'] as $key=>$data){
                                               if($data==true){
                                                $checked++;
                                               }else{
                                                $unchecked++;
                                               }
                                               }
                                            //     echo "<pre>";
                                            //     print_r($areaData);
                                            //     echo "</pre>";
                                             }
                                             $total=$checked+$unchecked;
                                             $percentage=round(($checked/$total)*100);
                                            ?>
                                            <div class="">
                                                <div class="progress table-proggress" role="progressbar"
                                                    aria-label="Basic example" aria-valuenow="<?php echo $percentage; ?>" aria-valuemin="0"
                                                    aria-valuemax="100">
                                                        <div class="progress-bar" style="width: <?php echo $percentage; ?>%">
                                                            <span class="text-center w-100 d-block text-white"><?php echo $percentage; ?>%</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </td>


                                        <td>
                                            <p class="ft7 fmon m-0"><?php echo date('d M Y h:i A', $CheckList['startDate']); ?></p>

                                        </td>


                                        <td>
                                            <a href="<?php echo base_url().'site/checkview/'.$mainkey; ?>">
                                                <img src="<?php echo base_url(); ?>assets/images/eye3.png" alt="">
                                            </a>

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

                                    <!-- Add more rows as needed -->
                                </tbody>
                            </div>
                        </table>
                      
                    </div>
                </div>
            </div>
        </div>

    </main>
    <!--end main wrapper-->
