<?php

// FD_C3


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

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

$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);

    // Mandatory

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

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

    // Profile

        // 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));

    // Food Service

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

        // How Was The Cheese Consumed?
            $data['CH_F1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F1', array(1,2));
            $data['CH_F1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F1', array(1,2));

            $data['CH_F2Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('CH_F2',array(1,2,3,4,5,6,7,8,10));
            $data['CH_F2Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('CH_F2',array(1,2,3,4,5,6,7,8,10));

        // Format of Cheese Consumed
            $data['CH_F3Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('CH_F3',array(1,2,3,4,5,6,7,98,99));
            $data['CH_F3Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('CH_F3',array(1,2,3,4,5,6,7,98,99));

        // Natural vs. Processed Cheese
            $data['CH_F6Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F6', array(1,2,99));
            $data['CH_F6Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F6', array(1,2,99));

        // Variety of Cheese consumed
            $data['CH_F5Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('CH_F5',array(1,2,3,4,5,6,7,8,9,10,11,12,13,97,98));
            $data['CH_F5Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('CH_F5',array(1,2,3,4,5,6,7,8,9,10,11,12,13,97,98));

        // Dairy or Vegan
            $data['CH_F8Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F8', array(1,2,3,99));
            $data['CH_F8Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F8', array(1,2,3,99));

        // Country of origin
            $data['CH_F7Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F7', array(1,2,3,4,5,6,7,8,9,99));
            $data['CH_F7Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F7', array(1,2,3,4,5,6,7,8,9,99));

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

        // Place of Consumption
            $data['CH_F1x1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F1x1', range(1,3));
            $data['CH_F1x1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F1x1', range(1,3));
        
        // Consumed Alone vs. with others
            $data['CH_F_C11Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('CH_F_C11', range(1,7));
            $data['CH_F_C11Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('CH_F_C11', range(1,7));

        // Change in Consumption
            $data['CH_F_C15Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F_C15', array(1,2,3));
            $data['CH_F_C15Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F_C15', array(1,2,3));

            // dono ke liye use ho jayega
            $data['CH_C20Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_C20', array(1,2,3));
            $data['CH_C20Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_C20', array(1,2,3));

    // Retails

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

        // How Was The Cheese Consumed?
            $data['CH_R1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_R1', array(1,2));
            $data['CH_R1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_R1', array(1,2));

            $data['CH_R2Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('CH_R2',array(1,2,3,4,5,6,7,8,10));
            $data['CH_R2Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('CH_R2',array(1,2,3,4,5,6,7,8,10));

        // Format of Cheese Consumed
            $data['CH_R3Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('CH_R3',array(1,2,3,4,5,6,7,98,99));
            $data['CH_R3Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('CH_R3',array(1,2,3,4,5,6,7,98,99));

        // Natural vs. Processed Cheese
            $data['CH_R6Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_R6', array(1,2,99));
            $data['CH_R6Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_R6', array(1,2,99));

        // Variety of Cheese consumed
            $data['CH_R5Quarter'] = $QuarterWiseCounterRecord2->QuarterWiseCounterRecords2('CH_R5',array(1,2,3,4,5,6,7,8,9,10,11,12,13,97,98));
            $data['CH_R5Country'] = $CounteryWiseCounterRecord2->CountryWiseCounterRecords2('CH_R5',array(1,2,3,4,5,6,7,8,9,10,11,12,13,97,98));

        // Dairy or Vegan
            $data['CH_R8Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F8', array(1,2,3,99));
            $data['CH_R8Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F8', array(1,2,3,99));

        // Country of origin
            $data['CH_R7Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_F7', array(1,2,3,4,5,6,7,8,9,99));
            $data['CH_R7Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_F7', array(1,2,3,4,5,6,7,8,9,99));
        
        // Time of Consumption
            $data['CH_R_C8Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_R_C8', array(1,2,3,4,5));
            $data['CH_R_C8Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_R_C8', array(1,2,3,4,5));

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

        // Purchase Behaviour
            $data['CH_C17_1Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_C17_1', array(1));
            $data['CH_C17_1Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_C17_1', array(1));

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

        // Change in Consumption
            $data['CH_R_C15Quarter'] = $QuarterWiseCounterRecord->QuarterWiseCounterRecords('CH_R_C15', array(1,2,3));
            $data['CH_R_C15Country'] = $CounteryWiseCounterRecord->CountryWiseCounterRecords('CH_R_C15', array(1,2,3));
        
            $data['CH_C16Quarter'] = $QuarterWiseCounterRecord3->QuarterWiseCounterRecords3('CH_C16', range(1,9));
            $data['CH_C16Country'] = $CounteryWiseCounterRecord3->CountryWiseCounterRecords3('CH_C16', range(1,9));
        
        
echo json_encode($data);




?>
