<?php
//ini_set('display_errors',1);
session_start();
require_once ("../../config/Cado.php");
require_once ("cCliente.php");
$oCliente = new cCliente();
$dts1=$oCliente->filtrar($_POST['cli_id']);
$num_rows= mysqli_num_rows($dts1);
?>


<section class="content" >
	<div class="container-fluid">
	<div class="row">
	    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" >
		    <div class="card">
			
				<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:5px;">
	
	<div class="table-responsive">
				
            <table id="tabla_cliente" class="table table-bordered table-striped ">
                <thead>
                    <tr>
						<th>&nbsp;</th>
						<th>CLIENTE</th>
                        <th>TIP. DOC.</th>
                        <th>DOCUMENTO</th>
                        <th>DIRECCION</th>
                       <!-- <th>CONTACTO</th> -->
                        <th>TELEFONO</th>
                        <th>EMAIL</th>
                        <th>ID</th>
                       
                    </tr>
                </thead>
                <?php
                if($num_rows>0){
                ?>
                <tbody>
                    <?php
                        while($dt1 = mysqli_fetch_array($dts1)){
							
						$dtsclidir = $oCliente->filtrardirecciones($dt1['tb_cliente_id'],'1');
						$dtdir = mysqli_fetch_array($dtsclidir);
						$dir = $dtdir['tb_clientedireccion_nom'];
						
							?>
                            <tr>
								<td nowrap >  
								<?php if ($_SESSION['usuariogrupo_id']=='6'){
								?>
					
								<button class="btn btn-sm btn-primary" 
								onClick="cliente_form('editar','<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-edit"></i></button>
								<button class="btn btn-sm btn-warning" 
								onClick="direccion_cliente('<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-home"></i></button>
								<button class="btn btn-sm btn-success" 
								onClick="vehiculo_cliente('<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-tasks"></i></button>
								<button class="btn btn-sm btn-info" 
								onClick="correo_cliente('<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-envelope"></i></button>
								
	
								<?php
								}else{
								?>
							
								
								<button class="btn btn-sm btn-primary" 
								onClick="cliente_form('editar','<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-edit"></i></button>
								<button class="btn btn-sm btn-warning" 
								onClick="direccion_cliente('<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-home"></i></button>
								<button class="btn btn-sm btn-success" 
								onClick="vehiculo_cliente('<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-tasks"></i></button>
							<!--	<button class="btn btn-sm btn-info" 
								onClick="correo_cliente('<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-envelope"></i></button>
								-->
								<button class="btn btn-sm btn-danger" 
								onClick="eliminar_cliente('<?php echo $dt1['tb_cliente_id']?>')" ><i class="fas fa-trash"></i></button>
	
	
	
								<?php }?>
								</td>
								
                                <td nowrap ><?php echo $dt1['tb_cliente_nom']?></td>
                                <td >
                                    <?php  
                                    if($dt1['tb_cliente_tip']==1){
                                        echo "DNI";
                                    }else if ($dt1['tb_cliente_tip']==2) {
                                        echo "RUC";
                                    }
                                    ?>
                                </td>                            
                                <td><?php echo $dt1['tb_cliente_doc']?></td>
                                <td nowrap ><?php echo $dir; ?></td>                 
                                <td><?php echo $dt1['tb_cliente_tel']?></td>
                                <td><?php echo $dt1['tb_cliente_ema']?></td>
                                <td><?php echo $dt1['tb_cliente_id']?></td>
                            </tr>
                    <?php
                    }
                    mysqli_free_result($dts1);
                    ?>
                    </tbody>
                <?php }?>
            </table>
          
		  </div>
        </div>
        </div>
        </div>
    </div>
  </div>
</section>
 <script type="text/javascript">
  $(function() {  
  
	
	 $('#tabla_cliente').DataTable({
 
        "language": {
                "lengthMenu": "Mostrar _MENU_ registros",
                "zeroRecords": "No se encontraron resultados",
                "info": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
                "infoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
                "infoFiltered": "(filtrado de un total de _MAX_ registros)",
                "sSearch": "Buscar:",
                "oPaginate": {
                    "sFirst": "Primero",
                    "sLast":"Último",
                    "sNext":"Siguiente",
                    "sPrevious": "Anterior"
			     },
			     "sProcessing":"Procesando...",
            }
    });  
	
	
	 $('.table-responsive').doubleScroll();
	
	
  }); 
</script> 