?>
<div class="content-wrapper">
    <section class="content-header"><h1>Hojas de Costos</h1></section>
    <section class="content">
        <?php if($this->session->flashdata('success')): ?><div class="alert alert-success"><?php echo $this->session->flashdata('success'); ?></div><?php endif; ?>
        <?php if(tiene_permiso('costos_hoja_crear')): ?><a href="<?php echo base_url('index.php/produccion/costos/hojas/create'); ?>" class="btn btn-success"><i class="fa fa-plus"></i> Nueva Hoja</a><br><br><?php endif; ?>
        <div class="panel panel-primary">
            <div class="panel-heading"><strong>Productos y sus Hojas de Costos</strong></div>
            <div class="panel-body">
                <table id="tablaHojas" class="table table-bordered table-hover table-striped">
                    <thead><tr><th>Código</th><th>Producto</th><th>Hojas</th><th>Tiene Hoja</th><th style="width:100px;">Acciones</th></tr></thead>
                    <tbody>
                        <?php foreach($productos as $p): ?>
                        <tr>
                            <td><code><?php echo $p->codigo; ?></code></td>
                            <td><?php echo htmlspecialchars($p->nombre); ?></td>
                            <td><?php echo $p->total_hojas; ?></td>
                            <td><?php echo $p->total_hojas > 0 ? '<span class="label label-success">Sí</span>' : '<span class="label label-default">No</span>'; ?></td>
                            <td>
                                <?php if($p->hoja_principal_id): ?>
                                <a href="<?php echo base_url('index.php/produccion/costos/hojas/ver/'.$p->hoja_principal_id); ?>" class="btn btn-info btn-xs" title="Ver hoja"><i class="fa fa-eye"></i></a>
                                <?php endif; ?>
                                <?php if(tiene_permiso('costos_hoja_crear')): ?>
                                <a href="<?php echo base_url('index.php/produccion/costos/hojas/create/'.$p->id); ?>" class="btn btn-success btn-xs" title="Nueva variante"><i class="fa fa-plus"></i></a>
                                <?php endif; ?>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </section>
</div>
<script>window.addEventListener('load',function(){if(typeof $.fn.DataTable!=='undefined'){$('#tablaHojas').DataTable({language:{lengthMenu:"Mostrar _MENU_ registros",zeroRecords:"Sin resultados",info:"Del _START_ al _END_ de _TOTAL_",search:"Buscar:",paginate:{first:"Primero",last:"Último",next:"Siguiente",previous:"Anterior"}},pageLength:10});}});</script>

<?php