<?php

    /* Grab the report ID if it exists */
    if(isset($_GET['reportID']))
    {
        $rID = $_GET['reportID'];


    }

    /* Figure out what kind of report it is */
    if($rID == "topTenQuotaUsers"){
        $dataReportFile = 'part-r-00000.txt';
    }
    if($rID == "topTenChurnUsers"){
        $dataReportFile = 'topTenChurnUsers.txt';
    }
    if($rID == "growthTrends"){
        $dataReportFile = 'growthTrends.txt';
    }
    
    $dataReportFileString = file_get_contents($dataReportFile);
    $dataReportFileString = preg_replace('/[ ]{2,}|[\t]/', ' ', trim($dataReportFileString)); //normalizes the text file delimiters
    echo "<pre>".$dataReportFileString."</pre>";
//    $dataReportFileRows = explode("\n", $dataReportFileString);

//    $tableHead = [];
//    $tableCategory = [];
//    $tableData = [];


    /* Iterate through the array of rows and place them in the appropriate arrays for sorting */
//    foreach ($dataReportFileRows as $i => $currRow){
//        $elements = explode(" ", $currRow);  
//
//        $tableHead[$i] = $elements[0];
//        $tableCategory[$i] = $elements[1];
//        $tableData[$i] = (floatval($elements[5]) / floatval($elements[4]));
//    }

    /* Initialize the HTML Table string */
//    $htmlTable = "<table id=\"datatable\">";

    /* Create the HTML Table */


    /* Close the HTML Table tag */
//    $htmlTable = $htmlTable."</table>";


/* -------------------------------------------------------------- */
/* The <pre> tags makes the output formatted as it is in the file */
/* Paste Data Report as-is */


// $datareportfile = 'part-r-0000011.txt';
// $datareportfileString = file_get_contents($datareportfile);
// $datareportfileStringReplaced = preg_replace('/[ ]{2,}|[\t]/', ' ', trim($datareportfileString));


?>