<?php
  if( $_POST['action'] == 'New' ){
    $Position   = '../../';
    require_once($Position.'config/config.php');
    require_once($Position.'config/conexion.php');
    require_once($Position.'funciones/funciones.php');
    $Action = 'New';
    $cont   = $_POST[cont];
    $SegCat = $_POST[seg];
  }else{
    $Action = 'Edit';
    $SegCat = $SegCat;
    $cont   = $SigCont;
  }
?>

<!-- Sesion -->
<div class="Categoria">
  <div class="card">
    <div
      class="card-body"
      style="
        position:relative;
        border-left: 3px solid #be1724;
      "
    >

      <!-- Btn Eliminar Sesión -->
      <button
        type="button"
        class="btn btn-sm btn-danger DelCategoria"
        style="
          position: absolute;
          top: 0px;
          right: 0px;
        "
      >
        <i class="fa fa-times"></i>
      </button>
      <!-- End Btn Eliminar Sesión -->


      <div class="row">

        <input type="hidden" name="Cats[]" value="<?php echo $SegCat; ?>" />
        <input type="hidden" name="Cat[<?php echo $SegCat; ?>][Action]" value="<?php echo $Action; ?>" />
        <input type="hidden" name="Cat[<?php echo $SegCat; ?>][Id]" value="<?php echo $Categoria[Id]; ?>" />

        <!-- Categoria -->
        <div class="form-group col-sm-12">
          <label>Categoría</label>
          <div>
            <select
              name="Cat[<?php echo $SegCat; ?>][Cat]"
              class="form-control chosen-select"
            >
              <option></option>
              <?php
                //Tipos de Crusos
                $Query = "
                  SELECT
                    cat.Id, cat.Nombre
                  FROM CMS_CrusosCategorias cat
                  WHERE
                    cat.Id != '0'
                  ORDER BY cat.Nombre ASC
                ";
                $Cats = $mysqli->query($Query);
                mysqli_data_seek($Cats, 0);
                while($Cat = mysqli_fetch_array($Cats)) {
              ?>
                <option
                  value="<?php echo $Cat['Id']; ?>"
                  <?php
                    if( $Categoria['Fk_Categoria'] == $Cat['Id'] ){
                      echo "selected";
                    }
                  ?>
                >
                  <?php echo $Cat['Nombre']; ?>
                </option>
              <?php } ?>
            </select>
          </div>
        </div>
        <!-- End Categoria -->

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

</div>
<!-- End Sesion -->
