<?php include('casa/setup.casa.php');
$titulo = 'Categorias para Productos';
include('inc_head.php');
?>
<style>
th{
	color:white;
	text-align:center;
	text-transform:uppercase;}	
</style>
</head>
<body>
	<div class="wrapper">
	
	<?php include('inc_menu.php');?>
		<div class="main-panel">
			<div class="content">
				
			<div class="page-inner">
					
					<div class="row">						
						<div class="col-md-12">
							<div class="card">
								<div class="card-header">
									<div class="d-flex align-items-center">
										<h3 class="card-title"><?php echo $titulo;?></h3>																																									
									</div>
								</div>
								
								<div class="card-body">		
									<div class="row" style='width:97%' align='left'>
											<div class="col-sm-3">
												<a href="<?php echo PATH_HOME.'categorias-ins1/nuevo';?>" class="btn bg-dark" style='color:white'>
												<i class="fas fa-image"></i> &nbsp; Crear Categoría</a>
													<hr>
											</div> 																											
										</div>											
										<div class="table-responsive">
                                    <table id="registros" class="table table-striped table-bordered">
                                        <thead>
                                            <tr class="bg-dark">
												<th>N&ordm;</th>
												<th>codigo</th>	
												<th>Categorias</th>																																									
												<th>acciones</th>
                                            </tr>
                                        </thead>
                                        <tbody>    
                                        <?php 
                                        $db=new DB();
										
										$sql = "SELECT * FROM ventas_categorias
										WHERE categ_visible = '1'		
										ORDER BY categ_id ASC;";
                                        $db->dbSQL($sql);
                                        $html='';
										$i=0;
                                        while($db->next()){
										$i++;													 

											$categ_codigo = $db->dbField('categ_codigo');
											$categ_nombre = caresp($db->dbField('categ_nombre'));
										
										
                                            $html.='<tr>'; 
											$html.='<td align=center>'.$i.'</td>';	
											$html.='<td>'.$categ_codigo.'</td>';	
											$html.='<td>'.$categ_nombre.'</td>';		

											$html.='<td align=center>
												  <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
													  <span class="btn-label"><i class="fa fa-cog"></i></span>
												  </button><div class="dropdown-menu">
												  <a class="dropdown-item" href="'.PATH_HOME.'categorias-upd1/'.$categ_codigo.'"><i class="fas fa-edit"></i> Modificar</a>
												  <div role="separator" class="dropdown-divider"></div>
												  <a class="dropdown-item" href="'.PATH_HOME.'categorias-del1/'.$categ_codigo.'"><i class="fas fa-edit"></i> Borrar</a>
												  </div></td>';                                         
                                            
                                            $html.='</tr>';
                                            
                                        }
                                        echo $html;                                        
                                        ?>                                                                                    
                                        </tbody>                                        
                                    </table>
                                </div>
								</div>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<?php include('inc_pie.php');?>
		</div>
		
		
	</div>
</body>
</html>
<script>
$(document).ready(function() {			
	$('#registros').DataTable({
		"pageLength": 25,
	});
});	
</script>