<?php
require_once('config.php');
require_once('inc/header.php');
$manu_item_table_name = 'MainMenu';
$manu_lang = 'bn';
?>
<main id="main" class="main">
  <div class="row">
    <div class="col-6 align-items-center">
      <div class="pagetitle mb-2">
        <h1><?php echo $page_title ?></h1>
      </div>
    </div>
  </div>
  <section class="section mt-3">
    <div class="row">
        <div class="col-lg-5">
          <?php require_once('inc/menu-inc-dynamic-link.php'); ?>
        </div>
        <div class="col-lg-7">
          <div class="bg-white p-3 rounded-3">
            <div class="row">
              <div class="col-8">
                <h5>Arange Menu</h5>
              </div>
              <div class="col-4 text-end">
                <div id="loaderImageIcon">
                  <img src="assets/img/loading.gif" style=" height: 23px;">
                </div>
              </div>
            </div>
            <div class="cf nestable-lists">
               <div class="dd" id="nestable">
                 <ol class="dd-list">
                 <?php
                    $arrayof_menu = json_decode(getSingleValue('tt_info', 'InfoName', $manu_item_table_name, 'InfoValue'), true);
                    foreach ($arrayof_menu as  $the_menu) {
                      ?>
                         <li class="dd-item dd3-item" data-id="<?php echo $the_menu['id'] ?>" data-url="<?php echo $the_menu['url'] ?>" data-name="<?php echo $the_menu['name'] ?>" data-target="<?php echo $the_menu['target'] ?>">
                           <div class="dd-handle dd3-handle"></div>
                           <div class="dd3-content">
                             <span class="menu-name-item"><?php echo $the_menu['name'] ?></span>
                             <span class="action-btn">Edit</span>
                             <div class="item-editor" style="display: none;">
                               <input class="name-input form-control form-control-sm mt-2" type="text" value="<?php echo $the_menu['name'] ?>" placeholder="Link Name">
                               <input class="link-input form-control form-control-sm mt-1" type="text" value="<?php echo $the_menu['url'] ?>" placeholder="Link URL">
                               <select class="open-with-select form-control form-control-sm mt-1">
                                  <?php if ($the_menu['target'] == '_blank') {
                                    ?>
                                    <option value="_blank" selected>Open in New Tab</option>
                                    <option value="_self">Open in Same Tab</option>
                                    <?php
                                  }else {
                                    ?>
                                    <option value="_blank" >Open in New Tab</option>
                                    <option value="_self" selected>Open in Same Tab</option>
                                    <?php
                                  } ?>
                               </select>
                               <div class="mt-2">
                                 <span class="update-menu-item text-success ">Update</span> | <span class="delete-button text-danger">Delete</span>
                               </div>
                             </div>
                           </div>
                           <?php
                             if (isset($the_menu['children'])) {
                                 echo '<ol class="dd-list">';
                                 foreach ($the_menu['children'] as  $the_menu) {
                                     ?>
                                     <li class="dd-item dd3-item" data-id="<?php echo $the_menu['id'] ?>" data-url="<?php echo $the_menu['url'] ?>" data-name="<?php echo $the_menu['name'] ?>" data-target="<?php echo $the_menu['target'] ?>">
                                       <div class="dd-handle dd3-handle"></div>
                                       <div class="dd3-content">
                                         <span class="menu-name-item"><?php echo $the_menu['name'] ?></span>
                                         <span class="action-btn">Edit</span>
                                         <div class="item-editor" style="display: none;">
                                           <input class="name-input form-control form-control-sm mt-2" type="text" value="<?php echo $the_menu['name'] ?>" placeholder="Link Name">
                                           <input class="link-input form-control form-control-sm mt-1" type="text" value="<?php echo $the_menu['url'] ?>" placeholder="Link URL">
                                           <select class="open-with-select form-control form-control-sm mt-1">
                                              <?php if ($the_menu['target'] == '_blank') {
                                                ?>
                                                <option value="_blank" selected>Open in New Tab</option>
                                                <option value="_self">Open in Same Tab</option>
                                                <?php
                                              }else {
                                                ?>
                                                <option value="_blank" >Open in New Tab</option>
                                                <option value="_self" selected>Open in Same Tab</option>
                                                <?php
                                              } ?>
                                           </select>
                                           <div class="mt-2">
                                             <span class="update-menu-item text-success ">Update</span> | <span class="delete-button text-danger">Delete</span>
                                           </div>
                                         </div>
                                       </div>
                                       <?php
                                         if (isset($the_menu['children'])) {
                                             echo '<ol class="dd-list">';
                                             foreach ($the_menu['children'] as  $the_menu) {
                                                 ?>
                                                 <li class="dd-item dd3-item" data-id="<?php echo $the_menu['id'] ?>" data-url="<?php echo $the_menu['url'] ?>" data-name="<?php echo $the_menu['name'] ?>" data-target="<?php echo $the_menu['target'] ?>">
                                                   <div class="dd-handle dd3-handle"></div>
                                                   <div class="dd3-content">
                                                     <span class="menu-name-item"><?php echo $the_menu['name'] ?></span>
                                                     <span class="action-btn">Edit</span>
                                                     <div class="item-editor" style="display: none;">
                                                       <input class="name-input form-control form-control-sm mt-2" type="text" value="<?php echo $the_menu['name'] ?>" placeholder="Link Name">
                                                       <input class="link-input form-control form-control-sm mt-1" type="text" value="<?php echo $the_menu['url'] ?>" placeholder="Link URL">
                                                       <select class="open-with-select form-control form-control-sm mt-1">
                                                          <?php if ($the_menu['target'] == '_blank') {
                                                            ?>
                                                            <option value="_blank" selected>Open in New Tab</option>
                                                            <option value="_self">Open in Same Tab</option>
                                                            <?php
                                                          }else {
                                                            ?>
                                                            <option value="_blank" >Open in New Tab</option>
                                                            <option value="_self" selected>Open in Same Tab</option>
                                                            <?php
                                                          } ?>
                                                       </select>
                                                       <div class="mt-2">
                                                         <span class="update-menu-item text-success ">Update</span> | <span class="delete-button text-danger">Delete</span>
                                                       </div>
                                                     </div>
                                                   </div>
                                                   <?php
                                                     if (isset($the_menu['children'])) {
                                                         echo '<ol class="dd-list">';
                                                         foreach ($the_menu['children'] as  $the_menu) {
                                                             ?>
                                                             <li class="dd-item dd3-item" data-id="<?php echo $the_menu['id'] ?>" data-url="<?php echo $the_menu['url'] ?>" data-name="<?php echo $the_menu['name'] ?>" data-target="<?php echo $the_menu['target'] ?>">
                                                               <div class="dd-handle dd3-handle"></div>
                                                               <div class="dd3-content">
                                                                 <span class="menu-name-item"><?php echo $the_menu['name'] ?></span>
                                                                 <span class="action-btn">Edit</span>
                                                                 <div class="item-editor" style="display: none;">
                                                                   <input class="name-input form-control form-control-sm mt-2" type="text" value="<?php echo $the_menu['name'] ?>" placeholder="Link Name">
                                                                   <input class="link-input form-control form-control-sm mt-1" type="text" value="<?php echo $the_menu['url'] ?>" placeholder="Link URL">
                                                                   <select class="open-with-select form-control form-control-sm mt-1">
                                                                      <?php if ($the_menu['target'] == '_blank') {
                                                                        ?>
                                                                        <option value="_blank" selected>Open in New Tab</option>
                                                                        <option value="_self">Open in Same Tab</option>
                                                                        <?php
                                                                      }else {
                                                                        ?>
                                                                        <option value="_blank" >Open in New Tab</option>
                                                                        <option value="_self" selected>Open in Same Tab</option>
                                                                        <?php
                                                                      } ?>
                                                                   </select>
                                                                   <div class="mt-2">
                                                                     <span class="update-menu-item text-success ">Update</span> | <span class="delete-button text-danger">Delete</span>
                                                                   </div>
                                                                 </div>
                                                               </div>
                                                               <?php
                                                                 if (isset($the_menu['children'])) {
                                                                     echo '<ol class="dd-list">';
                                                                     foreach ($the_menu['children'] as  $the_menu) {
                                                                         ?>
                                                                         <li class="dd-item dd3-item" data-id="<?php echo $the_menu['id'] ?>" data-url="<?php echo $the_menu['url'] ?>" data-name="<?php echo $the_menu['name'] ?>" data-target="<?php echo $the_menu['target'] ?>">
                                                                           <div class="dd-handle dd3-handle"></div>
                                                                           <div class="dd3-content">
                                                                             <span class="menu-name-item"><?php echo $the_menu['name'] ?></span>
                                                                             <span class="action-btn">Edit</span>
                                                                             <div class="item-editor" style="display: none;">
                                                                               <input class="name-input form-control form-control-sm mt-2" type="text" value="<?php echo $the_menu['name'] ?>" placeholder="Link Name">
                                                                               <input class="link-input form-control form-control-sm mt-1" type="text" value="<?php echo $the_menu['url'] ?>" placeholder="Link URL">
                                                                               <select class="open-with-select form-control form-control-sm mt-1">
                                                                                  <?php if ($the_menu['target'] == '_blank') {
                                                                                    ?>
                                                                                    <option value="_blank" selected>Open in New Tab</option>
                                                                                    <option value="_self">Open in Same Tab</option>
                                                                                    <?php
                                                                                  }else {
                                                                                    ?>
                                                                                    <option value="_blank" >Open in New Tab</option>
                                                                                    <option value="_self" selected>Open in Same Tab</option>
                                                                                    <?php
                                                                                  } ?>
                                                                               </select>
                                                                               <div class="mt-2">
                                                                                 <span class="update-menu-item text-success ">Update</span> | <span class="delete-button text-danger">Delete</span>
                                                                               </div>
                                                                             </div>
                                                                           </div>
                                                                         </li>
                                                                         <?php
                                                                     }
                                                                     echo '</ol>';
                                                                 }
                                                               ?>
                                                             </li>
                                                             <?php
                                                         }
                                                         echo '</ol>';
                                                     }
                                                   ?>
                                                 </li>
                                                 <?php
                                             }
                                             echo '</ol>';
                                         }
                                       ?>
                                     </li>
                                     <?php
                                 }
                                 echo '</ol>';
                             }
                           ?>
                         </li>
                      <?php
                    }
                 ?>
                 </ol>
              </div>
            </div>
          </div>
        </div>
        <textarea  class="d-none" name="output_category" data-menuname="<?php echo $manu_item_table_name ?>" id="nestable-output" rows="8" cols="20" style="height: 364px;"></textarea>
    </div>
  </section>
</main>
<?php require_once('inc/footer.php'); ?>
