<?php  
	include "conexion.php";

	$id_transaccion = $_GET['id_transaccion'];

	$sql = "select ";
	$sql .= "id_venta ";
	$sql .= "from ";
	$sql .= "transacciones_detalle ";
	$sql .= "where ";
	$sql .= "id_transaccion=".$id_transaccion." ";
	$sql .= "and id_venta!=0 ";

	$resultado = $conexion->query($sql);

    if(!$resultado) 
    {
        echo response(2,"Error al consultar","");
        return;
    }
    $id_venta=0;
	
    while ($row=$resultado->fetch_assoc())
    {
        $id_venta=$row["id_venta"];
    }

    $resultado->free();


    if($id_venta==0)
    {
    	echo response(0,"OK","");
    	return;
    }

    $sql = "select ";
    $sql .= "t.forma_pago, ";
    $sql .= "c.tipo ";
    $sql .= "from ";
    $sql .= "transacciones t ";
    $sql .= "left join clientes c on (c.id_cliente=t.id_cliente) ";
    $sql .= "where ";
    $sql .= "t.id_transaccion=".$id_transaccion;

    $resultado = $conexion->query($sql);

    if(!$resultado) 
    {
        echo response(2,"Error al consultar","");
        return;
    }
    $forma_pago="";
    $tipo_cliente=0;
	
    while ($row=$resultado->fetch_assoc())
    {
        $forma_pago=$row["forma_pago"];
        $tipo_cliente=$row["tipo"];
    }

    $resultado->free();


    echo $forma_pago;
    echo $tipo_cliente;


    function response($estatus,$estatus_mensaje,$respuesta){
		header("HTTP/1.1".$estatus);

		$response["estatus"]=$estatus;
		$response["estatus_mensaje"]=$estatus_mensaje;
		$response["respuesta"]=$respuesta;
		
		$json_response = json_encode($response, JSON_UNESCAPED_UNICODE);

		echo $json_response;

	}

?>