<?php
  $Position   = '../';
  require_once($Position.'config/config.php');
  require_once($Position.'config/conexion.php');
  require_once($Position.'config/user.php');
  require_once($Position.'funciones/acces.php');
  require_once($Position.'funciones/logout.php');
  require_once($Position.'funciones/funciones.php');

  if( $_POST[Id] ){

    //Menu
    $Query = "
      SELECT
        men.Id, men.Nombre
      FROM Menus men
      WHERE men.Id = '$_POST[Id]'
  	";
  	$Menult = mysqli_query($mysqli, $Query );
  	$Men = mysqli_fetch_assoc($Menult);

  }

?>

<style>
  .OrdenarBoxes { list-style-type: none; margin: 0; padding: 0; width: 100%; }
  .OrdenarBoxes li { float: left; }
  .sortable-placeholder{
    height: 37px !important;
    width: 100%;
    border: 1px dotted #333333 !important;
    background: #dbdbdb !important;
  }
  .BoxesSort li{
    background: #ffffff;
    border: 1px solid rgba(120, 130, 140, 0.13);
    padding: 8px 16px;
    margin: 4px 0px;
    height: auto;
    width: 100%;
    cursor:move;
    position: relative;
  }
</style>

<form
  method="post"
  enctype="multipart/form-data"
  id="Form-Categorias"
>

  <!-- Variables -->
  <input type="hidden" name="Save" value="Ok" />
  <?php if($Men[Id]){ ?>
    <input type="hidden" name="IdMenu" value="<?php echo $Men[Id]; ?>" />
  <?php } ?>
  <!-- End Variables -->

  <div class="row">

    <!-- Categorias -->
    <div class="col-sm-12">
      <div class="card">
        <div class="card-body">
          <div class="row">

            <!-- Titulo -->
            <div class="col-sm-12">
              <h4>Categorías</h4>
              <hr>
            </div>
            <!-- End Titulo -->

            <div class="col-lg-12 col-md-12 Pag">
              <div class="card">
                <div class="card-body">

                  <div class="row">

                    <div class="col-sm-12">
                      <ul class="OrdenarBoxes BoxesSort">
                        <?php
                          //Categorias
                          $Query = "
                            SELECT
                              cat.Id, cat.Nombre
                            FROM MenusCategorias cat
                            WHERE cat.Id != '0'
                              AND cat.Fk_Menu = '$Men[Id]'
                              AND cat.Fk_Cuenta = '$Cuenta[Id]'
                            ORDER BY cat.Sort ASC
                          ";
                          $ItemsIn = $mysqli->query($Query);
                          mysqli_data_seek($ItemsIn, 0);
                          while($ItemIn = mysqli_fetch_array($ItemsIn)) {
                            $Action = 'Edit';
                            require($Position.'funciones-modulos/menu-categorias-item.php');
                          }
                        ?>
                      </ul>
                    </div>

                    <div class="col-sm-12"><hr></div>

                    <div class="col-sm-12">
                      <div class="">
                        <button
                          type="button" class="btn btn-success btn-block BtnAddItem"
                          data-menu="<?php echo $Men[Id]; ?>"
                        >
                          Agregar Categoría
                        </button>
                      </div>
                    </div>

                  </div>

                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
    <!-- End Categorias -->

  </div>

</form>
