<?php

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

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

$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_14', array(1,2,3,54,55));
    $data['S13_12Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('S13_14', array(1,2,3,54,55));

    // Sub-Categories
    $data['BC_C2Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('BC_C2', array(1,2,3,4,5,6,98));
    $data['BC_C2Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('BC_C2', array(1,2,3,4,5,6,98));

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

    // Packaging Size
    $data['BC_C7Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('BC_C7', array(1,2));
    $data['BC_C7Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('BC_C7', array(1,2));

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

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

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

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

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

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

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

    $data['BC_C16Quarter'] = $QuarterWiseCounterRecord3->QuarterWiseCounterRecords3('BC_C16', range(1,9));
    $data['BC_C16Country'] = $CounteryWiseCounterRecord3->CountryWiseCounterRecords3('BC_C16', range(1,9));

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

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

    // Purchase Channel
    $data['BC_C17_1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('BC_C17_1', array(1));
    $data['BC_C17_1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('BC_C17_1', array(1));

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

?>
