<?php require_once('topo.php');?>
<?php require_once('lateral.php');?>
      <!-- Right side column. Contains the navbar and content of the page -->
      <div class="content-wrapper" style="<?php if($_GET['Box'] != ""){ echo "margin-left: 0px;"; }?>">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Subcategorias
            <small>listagem de subcategorias cadastrados</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="index.php?Box=<?php echo $_GET['Box'];?>"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="listar_subcategorias.php?Box=<?php echo $_GET['Box'];?>">Subcategorias</a></li>
            <li class="active">Listagem</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12"><!-- /.box -->

              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Listagem de subcategorias</h3>
                  <button type="button" class="btn btn-primary" style=" float:right;" onclick="location.href='manutencao_subcategorias.php?Box=<?php echo $_GET['Box'];?>';">Nova Subcategoria</button>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th style="cursor:pointer">Código</th>
                        <th style="cursor:pointer">Categoria</th> 
                        <th style="cursor:pointer">Titulo</th>                     
                      </tr>
                    </thead>
                    <tbody>
                    <?php

						$Seleciona = Seleciona("subcategorias", "", "ORDER BY titulo ASC");	
					while($linha = mysql_fetch_array($Seleciona)){
						
						$idcategoria_atual = $linha['idcategoria'];
							
						//SELECIONA CATEGORIA
						$seleciona_categoria = Seleciona("categorias", "WHERE idcategoria='$idcategoria_atual'", "");				
						while($linha_categoria=mysql_fetch_array($seleciona_categoria)){
						
						$NomeCategoria = $linha_categoria['titulo'];	
							
						}						
					?>
                      <tr style="cursor:pointer" onclick="location.href='manutencao_subcategorias.php?idsubcategoria=<?php echo $linha['idsubcategoria'];?>&Box=<?php echo $_GET['Box'];?>';">
                        <td><?php echo $linha['idsubcategoria'];?></td>
                         <td><?php echo $NomeCategoria;?></td>
                        <td><?php echo $linha['titulo'];?></td>                      
                      </tr>
                      <?php 
					  $NomeCategoria = "";
					  }?>
                    </tbody>
                    <tfoot>
                      <tr>
                        <th>Código</th>
                        <th style="cursor:pointer">Categoria</th>
                        <th>Titulo</th>
                      </tr>
                    </tfoot>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
<?php require_once('rodape.php');?>