<?php
require('classes/fpdf.php');
require('classes/html.class.php');

function http_get_curl($url, $get_variables_array, $get_values_array)
{
    $get_variables_array[] = 'username';
    $get_variables_array[] = 'password';
    $get_values_array[] = 'MUX01';
    $get_values_array[] = 'MUX01!@';
    $index = 0;
    $get_vars = "?";
    foreach ($get_variables_array as $variables) {
        $get_vars = $get_vars . $variables . "=" . $get_values_array[$index] . "&";
        $index++;
    }

    $url = $url . $get_vars;
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

    $resp = curl_exec($curl);
    curl_close($curl);

    return $resp;
}


$pdf = new FPDF();
$pdf->AliasNbPages();
$pdf->AddPage('p');
$pdf->SetFont('Arial', 'B', 20);

$pdf->Cell(10);
$pdf->Cell(90, 15, "TANK LOG", "", 1, 'L');


$responce = http_get_curl("api.elegantwork.co.za/fuel/inter_site_com.php", ['tank_id', 'get_tank_log'], [$_GET['tank_id'], '']);

// echo $responce;
$pdf->SetFont('Arial', 'B', 9);


$row = explode("|", $responce);
foreach ($row as $data) {
    $log_info = explode(',', $data);
    $pdf->Cell(10);

    $pdf->Cell(40, 6, $log_info[0], "", 0, 'L');
    $pdf->Cell(10, 6, $log_info[1], "", 0, 'l');
    $pdf->Cell(50, 6, $log_info[2], "", 1, 'l');
}



$pdf->Output("I");
