<?php

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

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

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

    // Sub-Categories
    $data['FD_C2Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('FD_C2', array(1,2,3,4,5,6));
    $data['FD_C2Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('FD_C2', array(1,2,3,4,5,6));

    // Packaging Type
    $data['FD_C6Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('FD_C6', array(1,2,3,4,5,98,99));
    $data['FD_C6Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('FD_C6', array(1,2,3,4,5,98,99));

    // Packaging Size
    $data['FD_C7Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('FD_C7', array(1,2));
    $data['FD_C7Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('FD_C7', array(1,2));

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

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

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

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

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

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

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

    $data['FD_C16Quarter'] = $QuarterWiseCounterRecord3->QuarterWiseCounterRecords3('FD_C16', range(1,9));
    $data['FD_C16Country'] = $CounteryWiseCounterRecord3->CountryWiseCounterRecords3('FD_C16', range(1,9));

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

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

    // Purchase Channel
    $data['FD_C17_1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('FD_C17_1', array(1));
    $data['FD_C17_1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('FD_C17_1', array(1));

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

    // flavour
    $data['FD_C3Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('FD_C3', array(1,2,3,4,5,6,98));
    $data['FD_C3Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('FD_C3', array(1,2,3,4,5,6,98));
    
    // dairy or vegan
    $data['FD_C4aQuarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('FD_C4a', array(1,2,3,99));
    $data['FD_C4aCountry'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('FD_C4a', array(1,2,3,99));

// Particular Question


echo json_encode($data);




?>
