<?php

include "../config.php";
include "classes.php";

$data = array();
$rangeXX = array(7);

$conX = $_REQUEST['conX'];
$condX = $_REQUEST['condX'];
$tblX = $_REQUEST['tblX'];
$spcX = "1=1";

if ($conX == 1) {
    $condX = "1=1";
}

$stats = new ConsumptionStats($conn, $quarter, $condX);
$stats2 = new CountryConsumptionStats($conn, $country4X, $condX);

$QuarterWiseCounterRecord = new QuarterWiseCounter($conn,$condX,$tblX,$spcX,$quarter);
$CounteryWiseCounterRecord = new CountryWiseCounter($conn,$condX,$tblX,$spcX,$country4X);
$CounteryWiseCounterRecordX = new CountryWiseCounterX($conn,$condX,$tblX,$spcX,$country4X);

$QuarterWiseCounterRecord2 = new QuarterWiseCounter2($conn,$condX,$tblX,$spcX,$quarter);
$CounteryWiseCounterRecord2 = new CountryWiseCounter2($conn,$condX,$tblX,$spcX,$country4X);

$QuarterWiseCounterRecord3 = new QuarterWiseCounter3($conn,$condX,$tblX,$spcX,$quarter);
$CounteryWiseCounterRecord3 = new CountryWiseCounter3($conn,$condX,$tblX,$spcX,$country4X);

// Common Question

    // Consumption Funnel
    $data['ConsumptionQuarter'] = $stats->calculate("S11_", $rangeXX);
    $data['ConsumptionCountry'] = $stats2->calculate2("S11_", $rangeXX);

    // Frequency of Consumption
    $data['S13_12Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('S13_7', array(1,2,3,54,55));
    $data['S13_12Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('S13_7', array(1,2,3,54,55));

    // Sub-Categories
    $data['SD_C1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C1', array(1,2,98));
    $data['SD_C1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C1', array(1,2,98));

    // Packaging Type
    $data['SD_C6Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C6', array(1,2,3,4));
    $data['SD_C6Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C6', array(1,2,3,4));

    // Packaging Size
    $data['SD_C7Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C7', array(1,2));
    $data['SD_C7Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C7', array(1,2));

    // Time of Consumption
    $data['SD_C8Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C8', array(1,2,3,4,5));
    $data['SD_C8Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C8', array(1,2,3,4,5));

    // Place of Consumption
    $data['SD_C9Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C9', array(1,2,3,4,5,6,7));
    $data['SD_C9Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C9', array(1,2,3,4,5,6,7));

    // Accompanied with…
    $data['SD_C10Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C10', array(1,2,4,5,98));
    $data['SD_C10Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C10', array(1,2,4,5,98));

    // Consumed Alone vs. with others
    $data['SD_C11Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('SD_C11', range(1,7));
    $data['SD_C11Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('SD_C11', range(1,7));

    // Reason for Consumption
    $data['SD_C12Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C12', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15));
    $data['SD_C12Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C12', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15));

    // Change in personal Consumption
    $data['SD_C15Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C15', array(1,2,3));
    $data['SD_C15Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C15', array(1,2,3));

    // Change in Household Consumption
    $data['SD_C20Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C20', array(1,2,3));
    $data['SD_C20Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C20', array(1,2,3));

    $data['SD_C16Quarter'] = $QuarterWiseCounterRecord3->QuarterWiseCounterRecords3('SD_C16', range(1,9));
    $data['SD_C16Country'] = $CounteryWiseCounterRecord3->CountryWiseCounterRecords3('SD_C16', range(1,9));

    // Purchase in Household Role in purchasing
    $data['SD_C17Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C17', range(1,3));
    $data['SD_C17Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C17', range(1,3));

    // Who Purchases
    $data['SD_C18Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C18', array(1,2,3,4));
    $data['SD_C18Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C18', array(1,2,3,4));

    // Purchase Channel
    $data['SD_C17_1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('SD_C17_1', array(1));
    $data['SD_C17_1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('SD_C17_1', array(1));

    $data['SD_C19Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('SD_C19', array(5,6,1,3,10,9,7,4,8,2));
    $data['SD_C19Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('SD_C19', array(5,6,1,3,10,9,7,4,8,2));

    // Age
    $data['HAGE'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('HAGE', array(2,3,4,5,6));

    // Education
    $data['P4'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('P4', array(2,3,4,5,6));

    // Dietry Restriction
    $data['S10'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('S10', array(1,2,3));

    // Occupation
    $data['P5'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('P5', array(1,2,3,33,6,7,32));

    // Income
    $data['S7'] = $CounteryWiseCounterRecordX->CountryWiseCounterRecordsX('S7', array(91,92,93,94,95,96));

    // Relationship
    $data['P1'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('P1', array(1,2,3,4,5));

    // People living in household

// Particular Question


echo json_encode($data);

?>
