<?php

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

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

$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_2Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('S13_2', array(1,2,3,54,55));
    $data['S13_2Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('S13_2', array(1,2,3,54,55));

    // Sub-Categories
    $data['Y_C2Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C2', array(1,2,3,4));
    $data['Y_C2Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C2', array(1,2,3,4));

    // Packaging Type
    $data['Y_C6Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C6', array(1,2,3,4,5,99));
    $data['Y_C6Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C6', array(1,2,3,4,5,99));

    // Packaging Size
    $data['Y_C7Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C7', array(1,2));
    $data['Y_C7Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C7', array(1,2));

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

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

    // Accompanied with…
    $data['Y_C10Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C10', array(1,2,3,4,98));
    $data['Y_C10Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C10', array(1,2,3,4,98));

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

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

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

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

    $data['Y_C16Quarter'] = $QuarterWiseCounterRecord3->QuarterWiseCounterRecords3('Y_C16', range(1,9));
    $data['Y_C16Country'] = $CounteryWiseCounterRecord3->CountryWiseCounterRecords3('Y_C16', range(1,9));

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

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

    // Purchase Channel
    $data['Y_C17_1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C17_1', array(1));
    $data['Y_C17_1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C17_1', array(1));

    $data['Y_C19Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('Y_C19', array(5,6,1,3,10,9,7,4,8,2));
    $data['Y_C19Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('Y_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));

    // How was it consumed
    $data['Y_C5Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C5', array(1,2,3,4,98));
    $data['Y_C5Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C5', array(1,2,3,4,98));

    // Greek or protein
    $data['Y_C4dQuarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C4d', array(1,2,99));
    $data['Y_C4dCountry'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C4d', array(1,2,99));

    // Flavour
    $data['Y_C3Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C3', array(1,2,3,4,98));
    $data['Y_C3Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C3', array(1,2,3,4,98));

    // dairy or Vegan
    $data['Y_C4aQuarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('Y_C4a', array(1,2,3,99));
    $data['Y_C4aCountry'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('Y_C4a', array(1,2,3,99));

    // Add ins
    $data['Y_C4eQuarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('Y_C4e', array(1,2,3,98,5));
    $data['Y_C4eCountry'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('Y_C4e', array(1,2,3,98,5));

// Particular Question


echo json_encode($data);




?>
