<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
</head>

<body>
	
	<?php
 	date_default_timezone_set("America/Mexico_City");
	session_start();
	include("conexion.php");
	
	
			
			$sql = "select ";
            $sql .= "id_transaccion, ";
            $sql .= "id_tipo, ";
            $sql .= "date_format(fecha,'%Y-%m-%d %H:%i:%s') as fecha, ";
            $sql .= "id_cliente, ";
            $sql .= "id_vehiculo, ";
            $sql .= "ifnull(monto,0) as monto, ";
            $sql .= "ifnull(saldo,0) as saldo, ";
            $sql .= "id_turno, ";
            $sql .= "descripcion, ";
            $sql .= "placa, ";
            $sql .= "id_tag, ";
            $sql .= "ifnull(odometro,0) as odometro, ";
            $sql .= "ifnull(odometro_diferencia,0) as odometro_diferencia, ";
            $sql .= "clase, ";
            $sql .= "factura ";
            $sql .= "from ";
            $sql .= "transacciones ";
            $sql .= "where ";
            $sql .= "id_transaccion=" . $_GET['page'];
		
		mysqli_query($iden,'SET NAMES utf8');
			$resultado = $iden->query($sql); 	
			if(mysqli_num_rows($resultado)==0){

	echo '<b>No hay sugerencias</b>';

	}else{
				if(!$resultado) 
		die("Error: no se pudo realizar la consulta");
		$fila = $resultado->fetch_assoc();
		echo "<br>";
		echo "<br>";
		echo "<br>";
		echo "<table id='tabla_vehiculos2' style='color:black;background-color:transparent;' align='center' >";
		echo "<tbody>";
			echo "<tr  style='height:30px;'>";
		echo "<td width='150px'>Id Transacción</td>";
		echo "<td width='250px'><input type='text' name='texto' style='text-align: right' value=".$fila['id_transaccion']."disabled></td>";
		echo "<td>Id Tipo</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[id_tipo]' disabled></td>";
		echo "<td>Fecha</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[fecha]' disabled></td>";
		echo "</tr>";
		echo "<tr style='height:30px;'>";
		echo "<td>Id Cliente</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[id_cliente]' disabled></td>";
		echo "<td  width='250px'>Id Turno</td>";
		echo "<td width='250px'><input type='text' name='texto' style='text-align: right' value='$fila[id_turno]' disabled></td>";
		echo "<td  width='150px'>Factura</td>";
		echo "<td  width='250px'><input type='text' name='texto' style='text-align: right' value='$fila[factura]' disabled></td>";
		echo "</tr>";
		echo "<tr style='height:30px;'>";
		echo "<td>Id Vehiculo</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[id_vehiculo]' disabled></td>";
		echo "<td>Posición</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value=' ' disabled></td>";
		echo "<td>Descripcion</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[descripcion]' disabled></td>";
		echo "</tr>";
		echo "<tr style='height:30px;'>";
		echo "<td>Monto</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='".number_format($fila['monto'],2,'.',',')."' disabled></td>";
		echo "<td>Saldo</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='".number_format($fila['saldo'],2,'.',',')."' disabled></td>";
		echo "<td>Clase</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[clase]' disabled></td>";
		echo "</tr>";
		echo "<tr style='height:30px;'>";
		echo "<td>Placa</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[placa]' disabled></td>";
		echo "<td>Id Tag</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[id_tag]' disabled></td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "</tr>";
		echo "<tr style='height:30px;'>";
		echo "<td>Odómetro</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[odometro]' disabled></td>";
		echo "<td width='150px'>Odómetro Diferencia</td>";
		echo "<td><input type='text' name='texto' style='text-align: right' value='$fila[odometro_diferencia]' disabled></td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "</tr>";
			echo "</tbody>";
		echo "</table>";
			}
	
			$sql = "select ";
            $sql .= "date_format(v.fecha_venta,'%Y-%m-%d %H:%i:%s') as fecha_venta, ";
            $sql .= "v.id_venta, ";
            $sql .= "v.id_producto,  ";
            $sql .= "p.nombre, ";
            $sql .= "v.id_bomba, ";
            $sql .= "ifnull(v.volumen,0) as volumen,  ";
            $sql .= "ifnull(v.monto,0) as monto ";
            $sql .= "from gaslight.ventas v, gaslight.productos p ";
            $sql .= "where  ";
            $sql .= "v.id_producto = p.id_producto ";
            $sql .= "and id_venta in  ";
            $sql .= "(select id_venta  ";
            $sql .= "from gaslight.transacciones_detalle  ";
            $sql .= "where id_transaccion =" .  $_GET['page'] . ") ";

			mysqli_query($iden,'SET NAMES utf8');

			$resultado = $iden->query($sql); 

			if(!$resultado)
			{
					echo mysqli_error($iden);
					return;

			}

			$registros = mysqli_num_rows($resultado);

			if($registros == 0){
	echo "<div align='center'>";
	echo '<b>No hay sugerencias</b>';
	echo "</div>";
	}else{
				if(!$resultado) 
		die("Error: no se pudo realizar la consulta");
		$fila2 = $resultado->fetch_assoc();
		echo "<br>";
		echo "<br>";
		echo "<br>";
		echo "<table id='tabla_vehiculos2' style='color:black;background-color:transparent;' align='center' >";
		echo "<tbody>";
		echo "<tr  style='height:30px;'>";
		echo "<td width='40px'> </td>";
		echo "<td>Detalle Venta</td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "<td></td>";
		echo "</tr>";
		echo "</tr>";
		echo "</tbody>";
		echo "</table>";
		echo "<table id='tabla_vehiculos2' style='color:black;background-color:transparent;' align='center' border='1' >";
		echo "<tbody>";
		echo "<tr  style='height:30px;'>";
		echo "<td width='180' align='left'>Fecha Registro</td>";
		echo "<td width='180' align='left'>Venta</td>";
		echo "<td width='180' align='left'>Producto</td>";
		echo "<td width='180' align='left'>Nombre</td>";
		echo "<td width='180' align='left'>Bomba</td>";
		echo "<td width='180' align='left'>Volumen</td>";
		echo "<td width='180' align='left'>Monto</td>";
		echo "</tr>";
		echo "<tr  style='height:30px;'>";
		echo "<td align='center'>$fila2[fecha_venta]</td>";
		echo "<td align='center'>$fila2[id_venta]</td>";
		echo "<td align='center'>$fila2[id_producto]</td>";
		echo "<td align='center'>$fila2[nombre]</td>";
		echo "<td align='center'>$fila2[id_bomba]</td>";
		echo "<td align='right'>".number_format($fila2['volumen'],2,'.',',')."</td>";
		echo "<td align='right'>".number_format($fila2['monto'],2,'.',',')."</td>";
		echo "</tr>";
		echo "</tbody>";
		echo "</table>";
			}
	?>
</body>
</html>