<!-- Sidebar  -->
<style>
            .custicon{
                color: #989898;

            }
            .custcolumn .customicon{
                color: #989898;
            }
            .custcolumn:hover .customicon{
                color: #7d4495;
            }
            .custcolumn  span{
                color: #989898;
            }
            .custcolumn:hover  span{
                color: #7d4495;
            }
            .custcolumn {
                margin-bottom: 1px;
            }
            .custombutton{
                color: #ffffff;
                background-color: #7d4495;
            }
            .custombutton:hover{
                background-color: #914cae;
            }
        </style>
        <nav id="sidebar" style="background-color: #e5e5e5;">
            <!-- <div class="sidebar-header">
                <h3>Bootstrap Sidebar</h3>
            </div> -->

            <ul class="list-unstyled components" style="color:#ffffff;border-bottom: 0px solid #ffffff;">
               
                <p style="color: #989898;line-height:30px;background-color: #ffffff;margin-bottom:1px;"> <i class="fas fa-cog mr-2" style="color: #989898;"></i>你好! admin
                <?php  
                // echo "user_id";
                // echo $userid;
                // echo $sample1;
                // echo $heading;
                 ?>    
                </p>
                
                <!-- //new menu list -->
                 <!-- new table -->
                            <table class="table table-bordered table-sm   ">
                          <?php


                          foreach($record as $row)
                          {


                          $i=1;
                          
                          
                          foreach($directoryList as $row1)
                          {
                          ?>
                          <!-- level1 -->
                             <tbody>
                              <tr class="  tablerowoddbg "  style="">
                          <td class="levleonetext " > <input type="checkbox" class="<?php echo $row->id;?>-<?php echo $row1->id;?>" id="admincheck" name="admincheck" value="<?php echo  $row1->id; ?>"  onclick="checkalllevel(this)"
                            <?php

                                      //check previous right and this level right
                                      if(
                                        (in_array($row->id, $frontuser[$row->id]['level0'])==true && in_array($row1->id, $frontuser[$row->id]['level1NoRight'])==false)

                                        ||

                                        (in_array($row1->id, $frontuser[$row->id]['level1'])==true && in_array($row1->id, $frontuser[$row->id]['level1NoRight'])==false)

                                    ){
                                        echo "checked";
                                      }
                                    ?>

                            ></td>
                           <td class="directorytext clickable" data-toggle="collapse" data-target="#person<?php echo $row->id;?>-1level<?php echo $i;?>" aria-expanded="false" aria-controls="person<?php echo $row->id;?>-1level<?php echo $i;?>"><span><?php echo $row1->name;?></span></td>
                              </tr>
                            </tbody>
                            <!-- level2 -->
                               <tbody id="person<?php echo $row->id;?>-1level<?php echo $i;?>" class="collapse" style="background-color: #ffeeba;">
                    <tr class="tablerowoddbg " >
                                <td class="levleonetext"></td>
                                <td class="directorytext">
                                  <!-- level2 insize -->
                                  <table class="table table-bordered table-sm   ">

                                    <?php
                            $countLevel1=1;
                            
                            foreach($level1[$i] as $row2)
                            {

                            ?>
                             <tbody>
                              <tr class="  tablerowoddbg " style="">
                                <td class="levleonetext"> <input type="checkbox" class="<?php echo $row->id;?>-<?php echo $row1->id;?>-<?php echo $row2->id;?>" id="admincheck" name="admincheck" value="<?php echo  $row2->id; ?>" onclick="checkalllevel(this)"
                                   <?php

                                      //check previous right and this level right
                                      if(
                                        (in_array($row1->id, $frontuser[$row->id]['level1'])==true && in_array($row2->id, $frontuser[$row->id]['level2NoRight'])==false)

                                        ||

                                        (in_array($row2->id, $frontuser[$row->id]['level2'])==true && in_array($row2->id, $frontuser[$row->id]['level2NoRight'])==false)

                                    ){
                                        echo "checked";
                                      }
                                    ?>
                                  ></td>
                                    <td class="directorytext"  data-toggle="collapse" data-target="#person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>" aria-expanded="false" aria-controls="#person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>"><span><?php echo $row2->name;?></span></td>
                              </tr>
                            </tbody>
                            <!-- level3   -->
                              <tbody id="person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>" class="collapse" style="background-color: #ffeeba;">
                    <tr class="tablerowoddbg " >
                                <td class="levleonetext"></td>
                                <td class="directorytext">
                                <!-- //level3 inside -->
                                     <table class="table table-bordered table-sm   "> 
                                         <?php
                            $countLevel2=1;
                            
                            foreach($level2[$i][$countLevel1] as $row3)
                            {

                            ?>
                              <tbody>
                              <tr class="  tablerowoddbg " style="">
                                <td class="levleonetext"> <input type="checkbox" class="<?php echo $row->id;?>-<?php echo $row1->id;?>-<?php echo $row2->id;?>-<?php echo $row3->id;?>" id="admincheck" name="admincheck" value="<?php echo  $row3->id; ?>"  onclick="checkalllevel(this)"
                                    <?php

                                      //check previous right and this level right
                                      if(
                                        (in_array($row2->id, $frontuser[$row->id]['level2'])==true && in_array($row3->id, $frontuser[$row->id]['level3NoRight'])==false)

                                        ||

                                        (in_array($row3->id, $frontuser[$row->id]['level3'])==true && in_array($row3->id, $frontuser[$row->id]['level3NoRight'])==false)

                                    ){
                                        echo "checked";
                                      }
                                    ?>
                                  ></td>
                                    <td class="directorytext"  data-toggle="collapse" data-target="#person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>-3level<?php echo $countLevel2;?>" aria-expanded="false" aria-controls="#person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>-3level<?php echo $countLevel2;?>"><span><?php echo $row3->name;?></span></td>
                              </tr>
                            </tbody>
                            <!-- level4 -->   
                               <tbody id="person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>-3level<?php echo $countLevel2;?>" class="collapse" style="background-color: #ffeeba;">
                    <tr class="tablerowoddbg " >
                                <td class="levleonetext"></td>
                                <td class="directorytext">
                                  <!-- level4 inside -->
                                     <table class="table table-bordered table-sm   "> 
                                            <?php
                                      $countLevel3=1;
                              
                              foreach($level3[$i][$countLevel1][$countLevel2] as $row4)
                              {

                              ?>
                                <tbody>
                                <tr class="  tablerowoddbg " style="">
                                  <td class="levleonetext"> <input type="checkbox" class="<?php echo $row->id;?>-<?php echo $row1->id;?>-<?php echo $row2->id;?>-<?php echo $row3->id;?>-<?php echo $row4->id;?>" id="admincheck" name="admincheck" value="<?php echo  $row4->id; ?>" onclick="checkalllevel(this)"
                                    <?php

                                      //check previous right and this level right
                                      if(
                                        (in_array($row3->id, $frontuser[$row->id]['level3'])==true && in_array($row4->id, $frontuser[$row->id]['level4NoRight'])==false)

                                        ||

                                        (in_array($row4->id, $frontuser[$row->id]['level4'])==true && in_array($row4->id, $frontuser[$row->id]['level4NoRight'])==false)

                                    ){
                                        echo "checked";
                                      }
                                    ?>
                                    ></td>
                                    <?php
                                      // foreach ($frontuser[$row->id]['level4'] as $key => $value) {
                                      //    echo $value;
                                      //  } 
                                     ?>
                                      <td class="directorytext"  data-toggle="collapse" data-target="#person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>-3level<?php echo $countLevel2;?>-4level<?php echo $countLevel3;?>" aria-expanded="false" aria-controls="#person<?php echo $row->id;?>-1level<?php echo $i;?>-2level<?php echo $countLevel1;?>-3level<?php echo $countLevel2;?>-4level<?php echo $countLevel3;?>"><span><?php echo $row4->name;?></span></td>
                                </tr>
                              </tbody>
                               <!-- end level4 -->
                            <?php  
                                // echo $row->name;
                                $countLevel3=$countLevel3+1;
                            
                            }//foreach($level2[$i] as $row3)
                        ?>  
                                    </table>
                                  <!-- end level4 inside -->
                                </td>
                              </tr>
                            </tbody>
                            <!-- end level4 -->
                            <?php  
                                // echo $row->name;
                                $countLevel2=$countLevel2+1;
                            
                            }//foreach($level2[$i] as $row3)
                        ?>  
                                     </table> 
                                <!-- //end level3 inside -->
                                </td>
                              </tr>
                            </tbody>
                            <!-- end level3 -->
                          <?php //echo $row2->name;?>
                          <!-- <br> -->

                           <?php  
                                // echo $row->name;
                                $countLevel1=$countLevel1+1;
                            
                            }
                        ?>  
                      </table>
                                  <!-- end level2 insize -->
                                </td>
                              </tr>
                            </tbody>

                            <!-- end level 2 -->
                          <!-- end level1 -->
                           <?php
                           $i++;
                            }//foreach($directoryList as $row2)
                            }//foreach($record as $row)
                          ?>
                          <!-- end new table -->
                            </table>
                      

                <!-- end new menu list -->


                
                <li style="background-color: #ffffff;" class="custcolumn">
                    <a href="/at-cms/adminmain"><i class="fas fa-user mr-2 customicon"></i><span >管理員用戶</span></a>
                </li>
                <!-- <li class="active">
                    <a href="#homeSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><p><i class="fas fa-user mr-2"></i>管理員用戶</p></a>
                    <ul class="collapse list-unstyled" id="homeSubmenu">
                        <li>
                            <a href="#">Home 1</a>
                        </li>
                        <li>
                            <a href="#">Home 2</a>
                        </li>
                        <li>
                            <a href="#">Home 3</a>
                        </li>
                    </ul>
                </li> -->
                
                <li style="background-color: #ffffff;" class="custcolumn">
                    <a href="/at-cms/frontadmin"><i class="fas fa-university mr-2 customicon"></i><span >機構用戶</span></a>
                </li>
                <li style="background-color: #ffffff;" class="custcolumn">
                    <a href="/at-cms/folderadmin"><i class="fas fa-folder mr-2 customicon"></i><span >分類管理</span></a>
                </li>
                <!-- <li style="background-color: #ffffff;" class="custcolumn">
                    <a href="#pageSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><i class="fas fa-folder mr-2 customicon"></i><span >分類管理</span></a>
                    <ul class="collapse list-unstyled" id="pageSubmenu">
                        <li>
                            <a href="#">Page 1</a>
                        </li>
                        <li>
                            <a href="#">Page 2</a>
                        </li>
                        <li>
                            <a href="#">Page 3</a>
                        </li>
                    </ul>
                </li> -->
                <li style="background-color: #ffffff;" class="custcolumn">
                    <a href="/at-cms/fileadmin"><i class="far fa-calendar-minus mr-2 customicon" ></i><span >筆記管理</span></a>
                </li>
                <li style="background-color: #ffffff;"  class="custcolumn">
                    <a href="/at-cms/rightadmin"><i class="fas fa-lock mr-2 customicon"></i><span >用戶權限</span></a>
                </li>
                <li style="background-color: #ffffff;"  class="custcolumn">
                    <a href="#"><i class="far fa-clock mr-2 customicon"></i><span >用戶記錄</span></a>
                </li>
                <li style="background-color: #ffffff;"  class="custcolumn">
                    <a href="http://notesvision.at-webs.hk/at-cms/login/logout"><i class="fas fa-power-off mr-2 customicon"></i><span >安全登出</span></a>
                </li>
                <li style="background-color: #ffffff;height:40vh;"  >
                   
                </li>
            </ul>

            <!-- <ul class="list-unstyled CTAs">
                <li>
                    <a href="https://bootstrapious.com/tutorial/files/sidebar.zip" class="download">Download source</a>
                </li>
                <li>
                    <a href="https://bootstrapious.com/p/bootstrap-sidebar" class="article">Back to article</a>
                </li>
            </ul> -->
        </nav>