<section class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1>
                </h1>
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="<?php echo base_url();?>">Dashboard</a></li>
                    <li class="breadcrumb-item"><?php echo $parent;?></li>
                    <li class="breadcrumb-item active"><?php echo $title;?></li>
                </ol>
            </div>
        </div>
    </div>
</section>
<!-- Main content -->
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="card card-default">
                    <div class="card-header">
                        <h3 class="card-title"><?php echo $title;?></h3>
                    </div>
                    <div class="card-body">
                        <?php if($this->session->flashdata('message')){?>
                        <div id="alert" class="alert alert-success alert-dismissable">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                            <i class="icon fa fa-check"></i> Alert!
                            <?php echo $this->session->flashdata('message');?>
                        </div>
                        <?php }?>
                        <script> 
                            setTimeout(function() {
                                $('#alert').hide('fast');
                            }, 3000);
                        </script>
                        <table class="table table-bordered">
                            <thead>
                                <tr class="bg-gray color-palette">
                                    <th>No</th>
                                    <th>Gr 1</th>
                                    <th>Gr 2</th>
                                    <th>Gr 3</th>
                                    <th>Gr 4</th>
                                    <th>Gr 5</th>
                                    <th>Kode</th>
                                    <th>Nama</th>
                                    <th>Kode Satu Sehat</th>
                                    <th>ID Location Simgos</th>
                                    <th>Kode Parent</th>
                                    <th>Nama Parent</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                    $no=0;
                                    foreach($lrgr as $datlrgr){
                                        if($datlrgr->Group == "1"){$no++;
                                            echo("
                                                <tr class='bg-red'>
                                                    <th>".$no."</th>
                                                    <td>".$datlrgr->Group."</td>
                                                    <td colspan='4'></td>
                                                    <td>".$datlrgr->Kode."</td>
                                                    <td>".$datlrgr->Nama."</td>
                                                    <td>".$datlrgr->Kode_satusehat."</td>
                                                    <td>".$datlrgr->Id_location_simgos."</td>
                                                    <td></td>
                                                    <td></td>
                                                </tr>
                                            ");
                                            foreach($lrgr as $datlrgr2){
                                                $setgr2=""; $setbg2="";
                                                if($datlrgr2->Parent == $datlrgr->id){
                                                    if($datlrgr2->Group == "1"){
                                                        $setbg2  ="class='bg-red'";
                                                        $setgr2 = "<td></td>".$datlrgr2->Group."</td><td colspan='4'></td>";
                                                    }elseif($datlrgr2->Group == "2"){
                                                        $setbg2  ="class='bg-yellow'";
                                                        $setgr2 = "<td></td><td></td><td>".$datlrgr2->Group."</td><td colspan='3'></td>";
                                                    }elseif($datlrgr2->Group == "3"){
                                                        $setbg2  ="class='bg-blue'";
                                                        $setgr2 = "<td></td><td colspan='2'></td><td>".$datlrgr2->Group."</td><td colspan='2'></td>";
                                                    }elseif($datlrgr2->Group == "4"){
                                                        $setbg2  ="class='bg-green'";
                                                        $setgr2 = "<td></td><td colspan='3'></td><td>".$datlrgr2->Group."</td><td colspan='1'></td>";
                                                    }elseif($datlrgr2->Group == "5"){
                                                        $setbg2  ="class='bg-purple'";
                                                        $setgr2 = "<td></td><td colspan='4'></td><td>".$datlrgr2->Group."</td>";
                                                    }
                                                    echo("
                                                        <tr ".$setbg2." >
                                                            ".$setgr2."
                                                            <td>".$datlrgr2->Kode."</td>
                                                            <td>".$datlrgr2->Nama."</td>
                                                            <td>".$datlrgr2->Kode_satusehat."</td>
                                                            <td>".$datlrgr2->Id_location_simgos."</td>
                                                            <td>".$datlrgr->Kode."</td>
                                                            <td>".$datlrgr->Nama."</td>
                                                        </tr>
                                                    ");

                                                    foreach($lrgr as $datlrgr3){
                                                        $setgr3=""; $setbg3="";
                                                        if($datlrgr3->Parent == $datlrgr2->id){
                                                            if($datlrgr3->Group == "1"){
                                                                $setbg3  ="class='bg-red'";
                                                                $setgr3 = "<td></td>".$datlrgr3->Group."</td><td colspan='4'></td>";
                                                            }elseif($datlrgr3->Group == "2"){
                                                                $setbg3  ="class='bg-yellow'";
                                                                $setgr3 = "<td></td><td></td><td>".$datlrgr3->Group."</td><td colspan='3'></td>";
                                                            }elseif($datlrgr3->Group == "3"){
                                                                $setbg3  ="class='bg-blue'";
                                                                $setgr3 = "<td></td><td colspan='2'></td><td>".$datlrgr3->Group."</td><td colspan='2'></td>";
                                                            }elseif($datlrgr3->Group == "4"){
                                                                $setbg3  ="class='bg-green'";
                                                                $setgr3 = "<td></td><td colspan='3'></td><td>".$datlrgr3->Group."</td><td colspan='1'></td>";
                                                            }elseif($datlrgr3->Group == "5"){
                                                                $setbg3  ="class='bg-purple'";
                                                                $setgr3 = "<td></td><td colspan='4'></td><td>".$datlrgr3->Group."</td>";
                                                            }
                                                            echo("
                                                                <tr ".$setbg3.">
                                                                    ".$setgr3."
                                                                    <td>".$datlrgr3->Kode."</td>
                                                                    <td>".$datlrgr3->Nama."</td>
                                                                    <td>".$datlrgr3->Kode_satusehat."</td>
                                                                    <td>".$datlrgr3->Id_location_simgos."</td>
                                                                    <td>".$datlrgr2->Kode."</td>
                                                                    <td>".$datlrgr2->Nama."</td>
                                                                </tr>
                                                            ");

                                                            foreach($lrgr as $datlrgr4){
                                                                $setgr4=""; $setbg4="";
                                                                if($datlrgr4->Parent == $datlrgr3->id){
                                                                    if($datlrgr4->Group == "1"){
                                                                        $setbg4  ="class='bg-red'";
                                                                        $setgr4 = "<td></td>".$datlrgr4->Group."</td><td colspan='4'></td>";
                                                                    }elseif($datlrgr4->Group == "2"){
                                                                        $setbg4  ="class='bg-yellow'";
                                                                        $setgr4 = "<td></td><td></td><td>".$datlrgr4->Group."</td><td colspan='3'></td>";
                                                                    }elseif($datlrgr4->Group == "3"){
                                                                        $setbg4  ="class='bg-blue'";
                                                                        $setgr4 = "<td></td><td colspan='2'></td><td>".$datlrgr4->Group."</td><td colspan='2'></td>";
                                                                    }elseif($datlrgr4->Group == "4"){
                                                                        $setbg4  ="class='bg-green'";
                                                                        $setgr4 = "<td></td><td colspan='3'></td><td>".$datlrgr4->Group."</td><td colspan='1'></td>";
                                                                    }elseif($datlrgr4->Group == "5"){   
                                                                        $setbg4  ="class='bg-purple'";
                                                                        $setgr4 = "<td></td><td colspan='4'></td><td>".$datlrgr4->Group."</td>";
                                                                    }
                                                                    echo("
                                                                        <tr ".$setbg3.">
                                                                            ".$setgr4."
                                                                            <td>".$datlrgr4->Kode."</td>
                                                                            <td>".$datlrgr4->Nama."</td>
                                                                            <td>".$datlrgr4->Kode_satusehat."</td>
                                                                            <td>".$datlrgr4->Id_location_simgos."</td>
                                                                            <td>".$datlrgr3->Kode."</td>
                                                                            <td>".$datlrgr3->Nama."</td>
                                                                        </tr>
                                                                    ");

                                                                    foreach($lrgr as $datlrgr5){
                                                                        $setgr5=""; $setbg5="";
                                                                        if($datlrgr5->Parent == $datlrgr4->id){
                                                                            if($datlrgr5->Group == "1"){
                                                                                $setbg5  ="class='bg-red'";
                                                                                $setgr5 = "<td></td>".$datlrgr5->Group."</td><td colspan='4'></td>";
                                                                            }elseif($datlrgr5->Group == "2"){
                                                                                $setbg5  ="class='bg-yellow'";
                                                                                $setgr5 = "<td></td><td></td><td>".$datlrgr5->Group."</td><td colspan='3'></td>";
                                                                            }elseif($datlrgr5->Group == "3"){
                                                                                $setbg5  ="class='bg-blue'";
                                                                                $setgr5 = "<td></td><td colspan='2'></td><td>".$datlrgr5->Group."</td><td colspan='2'></td>";
                                                                            }elseif($datlrgr5->Group == "4"){
                                                                                $setbg5  ="class='bg-green'";
                                                                                $setgr5 = "<td></td><td colspan='3'></td><td>".$datlrgr5->Group."</td><td colspan='1'></td>";
                                                                            }elseif($datlrgr5->Group == "5"){
                                                                                $setbg5  ="class='bg-purple'";
                                                                                $setgr5 = "<td></td><td colspan='4'></td><td>".$datlrgr5->Group."</td>";
                                                                            }
                                                                            echo("
                                                                                <tr ".$setbg3.">
                                                                                    ".$setgr5."
                                                                                    <td>".$datlrgr5->Kode."</td>
                                                                                    <td>".$datlrgr5->Nama."</td>
                                                                                    <td>".$datlrgr5->Kode_satusehat."</td>
                                                                                    <td>".$datlrgr5->Id_location_simgos."</td>
                                                                                    <td>".$datlrgr4->Kode."</td>
                                                                                    <td>".$datlrgr4->Nama."</td>
                                                                                </tr>
                                                                            ");
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
