<?php
$mysqli = new mysqli("localhost", "dmcentra_dmsc", "uGlG?gXfMhA1", "dmcentra_sc");
?>   
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <title>Dashboard Template · Bootstrap</title>


    <!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">


    <style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }

body {
  font-size: .875rem;
}

.feather {
  width: 16px;
  height: 16px;
  vertical-align: text-bottom;
}

/*
 * Sidebar
 */

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100; /* Behind the navbar */
  padding: 48px 0 0; /* Height of navbar */
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}

.sidebar-sticky {
  position: relative;
  top: 0;
  height: calc(100vh - 48px);
  padding-top: .5rem;
  overflow-x: hidden;
  overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
}

@supports ((position: -webkit-sticky) or (position: sticky)) {
  .sidebar-sticky {
    position: -webkit-sticky;
    position: sticky;
  }
}

.sidebar .nav-link {
  font-weight: 500;
  color: #333;
}

.sidebar .nav-link .feather {
  margin-right: 4px;
  color: #999;
}

.sidebar .nav-link.active {
  color: #007bff;
}

.sidebar .nav-link:hover .feather,
.sidebar .nav-link.active .feather {
  color: inherit;
}

.sidebar-heading {
  font-size: .75rem;
  text-transform: uppercase;
}

/*
 * Content
 */

[role="main"] {
  padding-top: 133px; /* Space for fixed navbar */
}

@media (min-width: 768px) {
  [role="main"] {
    padding-top: 48px; /* Space for fixed navbar */
  }
}

/*
 * Navbar
 */

.navbar-brand {
  padding-top: .75rem;
  padding-bottom: .75rem;
  font-size: 1rem;
  background-color: rgba(0, 0, 0, .25);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}

.navbar .form-control {
  padding: .75rem 1rem;
  border-width: 0;
  border-radius: 0;
}

.form-control-dark {
  color: #fff;
  background-color: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .1);
}

.form-control-dark:focus {
  border-color: transparent;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}      
    </style>
    <!-- Custom styles for this template -->
    <link href="dashboard.css" rel="stylesheet">
  </head>
  <body>
    <nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0 shadow">
  <a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Digital Media</a>
  <!--input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search"-->
  <ul class="navbar-nav px-3">
    <li class="nav-item text-nowrap">
      <!--a class="nav-link" href="#">Sign out</a-->
    </li>
  </ul>
</nav>

<div class="container-fluid">
  <div class="row">
    <nav class="col-md-2 d-none d-md-block bg-light sidebar">
      <div class="sidebar-sticky">
        <ul class="nav flex-column">
          <li class="nav-item">
            <a class="nav-link active" href="#">
              <span data-feather="home"></span>
              Categorias <span class="sr-only">(current)</span>
            </a>
          </li>
<?php 
$result = $mysqli->query("SELECT id,nombre FROM categorias_ingram WHERE parent_id = 0");
while ($row = $result->fetch_assoc()) {
if (isset($_GET["id"]) && $_GET["id"] == $row["id"]) {
  $result_sub = $mysqli->query("SELECT id,nombre FROM categorias_ingram WHERE parent_id = ".$row["id"]);
}
?>          
          <li class="nav-item">
            <a class="nav-link <?php echo (isset($_GET["id"]) && $_GET["id"] == $row["id"])?"active":""; ?>" href="index.php?id=<?php echo $row["id"]; ?>">
              
              <?php echo utf8_encode($row["nombre"]); ?>
            </a>
            <?php 
            if ($result_sub->num_rows>0) {
            ?>
            <ul class="nav flex-column">
              <?php 
                while ($row2 = $result_sub->fetch_assoc()) {
                  
              ?>
                <li class="nav-item">
                  <a class="nav-link <?php echo (isset($_GET["parent_id"]) && $_GET["parent_id"] == $row2["id"])?"active":""; ?>" href="index.php?id=<?php echo $row["id"]."&parent_id=".$row2["id"]; ?>">&nbsp;&nbsp;&nbsp;<?php echo utf8_encode($row2["nombre"]); ?></a>
                </li>
              <?php } ?>
            </ul>
            <?php } ?>
          </li>
<?php } ?>
          
        </ul>

        
      </div>
    </nav>

    <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
      <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">Productos</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
          <p>*** Seleccionar Marca</p>
        </div>
      </div>

      

      <h2><?php echo $subcategoria; ?></h2>
      <div class="table-responsive">
        <?php if (isset($_GET["parent_id"])): ?>
          
        
        <table class="table table-striped table-sm">
          <thead>
            <tr>
              <th>No.</th>
              <th>SKU</th>
              <th>Manufacturer Part</th>
              <th>Descripcion</th>
              <th>Price</th>
              <th>Stock</th>
            </tr>
          </thead>
          <tbody>
            <?php 
            $result_pro = $mysqli->query("SELECT SKU, MFRPartNumber, ProductDescription1, precio, segmentado,disponibilidad FROM pricefile WHERE id_fabricante = ".$_GET["id"]." AND isactive = 1");
            $i = 1;
            while ($row = $result_pro->fetch_assoc()) {
            ?>
            <tr>
              <td><?php echo $i; ?></td>
              <td><?php echo $row["SKU"]; ?></td>
              <td><?php echo $row["MFRPartNumber"]; ?></td>
              <td><?php echo utf8_encode($row["ProductDescription1"]); ?></td>
              <td><?php echo $row["precio"]; ?></td>
              <td><?php echo $row["disponibilidad"]; ?></td>
              <td><?php echo $row["segmentado"]; ?></td>
            </tr>
            <?php $i++;} ?>
          </tbody>
        </table>
        <?php endif ?>
      </div>
    </main>
  </div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
      <script>window.jQuery || document.write('<script src="/docs/4.3/assets/js/vendor/jquery-slim.min.js"><\/script>')</script><script src="/docs/4.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/feather-icons/4.9.0/feather.min.js"></script>
</html>
