<?php  
	session_start();
	include "conexion.php";
	include "mysql_Valida_permiso.php";

	if(!isset($_SESSION['id_usuario']))
	{
		header('location: index.php');
		return;
	}

	$saldo=0;
	$razon_social="";

	$sql="select ";
	$sql.="razon_social, ";
	$sql.="format(saldo,2) as saldo ";
	$sql.="from ";
	$sql.="clientes ";
	$sql.="where ";
	$sql.="id_cliente = " . $_SESSION['id_cliente'];	
	
	$resultado = $conexion->query($sql); 

	if(!$resultado) 
	{
		echo "Error: No se pudo realizar la consulta de los vehiculos.";
		return;
	}

	while($fila = $resultado->fetch_assoc()) 
	{
		$saldo=$fila['saldo'];
		$razon_social=$fila['razon_social'];
	}

	$agregar =  validaPermiso('Vehiculos','VehiculosAlta',$_SESSION['id_usuario']);
	/*$eliminar = validaPermiso('catalogo_vehiculos','catalogo_vehiculos_eliminar',$_SESSION['userid']);
	$consultar = validaPermiso('catalogo_vehiculos','catalogo_vehiculos_consultar',$_SESSION['userid']);					
	$buscar = validaPermiso('catalogo_vehiculos','catalogo_vehiculos_buscar',$_SESSION['userid']);					
	$editar = validaPermiso('catalogo_vehiculos','catalogo_vehiculos_editar',$_SESSION['userid']);
	$vehiculos_codigo = validaPermiso('catalogo_vehiculos','catalogo_vehiculos_codigo',$_SESSION['userid']);
	$deshabilitar = validaPermiso('catalogo_vehiculos','catalogo_vehiculos_habilitar',$_SESSION['userid']);
	$reporte =validaPermiso('catalogo_vehiculos','catalogo_vehiculos_reporte',$_SESSION['userid']);
	$reporte_detalle =validaPermiso('catalogo_vehiculos','catalogo_vehiculos_reporte_detalle',$_SESSION['userid']);

	if($consultar==0)
	{
		header('location: inicio.php');
		return;
	}*/
?>
<!DOCTYPE html>
<html lang="en" translate="no">
<head>
	<link rel="stylesheet" href="css/bootstrap.css">
	<link rel="stylesheet" href="css/sweetalert2.min.css">
	<link rel="stylesheet" href="css/datepicker.css">
	<link rel="shortcut icon" href="images/Logo.jpg" type="image/jpeg"/>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">
    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
    <meta name="google" content="notranslate" />
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta charset="utf8">
	<meta http-equiv="Expires" content="0">
 	<meta http-equiv="Last-Modified" content="0">
	<meta http-equiv="Cache-Control" content="no-cache, mustrevalidate">
	<meta http-equiv="Pragma" content="no-cache">
	<title>Vehículos</title>
</head>
<body onload="actualizar_vehiculos();">
	<?php include "menu.php"; ?>
	<div id= "contenidoPrincipal" class="col-lg-10 offset-lg-1 col-md-12">
		<div id="encabezado">
			<h1>Vehículos</h1>
		</div>
		<hr></hr>
		<div id="cuerpo">
			<div class="row form-group">
				<div class="col-lg-2 offset-lg-10">
					<?php
					if($agregar==1){
				  		echo '<button class="btn btn-success btn-block" onclick="operacion_vehiculo(2,0);">Nuevo</button>';
				    	 }
				     ?>
				</div> 
				<div class="col-lg-12">
					<label><strong>Cliente:</strong></label>
					<label><strong><?php echo $_SESSION['id_cliente'];  ?> </strong></label>
				</div>		
				<div class="col-lg-12">
					<label><strong>Razon Social:</strong></label>
					<label><strong><?php echo $razon_social;  ?></strong></label>
				</div>
				<div class="col-lg-12">
					<label><strong>Saldo:</strong></label>
					<label><strong>$<?php echo $saldo;  ?></strong></label>
				</div>
			</div>		
		</div>				
		
			
		<div class="row form-group">
			
			
			<div class="table-responsive" id ="tablaContenido">
				<table class="table table-hover table-sm table-striped" name="vehiculo_table" id="vehiculo_table">
					<thead>
						<th>Id</th>
						<th>Descripción</th>
						<th>Departamento</th>
						<th>N° Eco</th>
						<th>Placa</th>
						<th>Tarjeta</th>
						<th>Estado</th>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
		</div>
		<div id="pie">
		</div>
	</div>
	<div class="col-lg-10 offset-lg-1 col-md-12" id="contenedorOperacion">
		
	</div>
	<div class="col-lg-10 offset-lg-1 col-md-12" id="contenedorOperacion2">
		
	</div>


</body>

<script src="./js/funciones_vehiculos.js"></script>
<script src="./js/funciones_generales.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/bootstrap-datepicker.js"></script>
<script src="js/sweetalert2.min.js"></script>

</html>
