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

$condX = $_REQUEST['condX'];
$conX = $_REQUEST['conX'];
$tblX = $_REQUEST['tblX'];
$tabStatus = $_REQUEST['tabStatus'];


$Q29a_s = array(2);
$Q29a_ns = array(7);

$profileOverall = new ProfileOverall($conn,$tblX,$Q29a_s);
$profileOverall2 = new ProfileOverall($conn,$tblX,$Q29a_ns);
$recordCounter = new RecordCounter($conn,$condX,$tblX);

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

$data = array();

if($tabStatus=="false")
{
    $data['genderOverall_s'] = $profileOverall->profileOverallCount('HQ8',range(1, 2));
    $data['ageOverall_s'] = $profileOverall->profileOverallCount('HQ9',array(2,3,4,5));
    $data['airportOverall_s'] = $profileOverall->profileOverallCount('Q5',array(1,2,3,4,5,6,7));
    $data['incomeOverall_s'] = $profileOverall->profileOverallCount('Q11',array(1,2,3,4));
    $data['segmentOverall_s'] = $profileOverall->profileOverallCount('Q13a',array(1,2));
    $data['typesOverall_s'] = $profileOverall->profileOverallCount('Q13b',array(1,2));
    $data['dwellOverallD_s'] = $profileOverall->profileOverallCount('Q16a',array(1,2,3,4,5,6));
    $data['dwellOverallA_s'] = $profileOverall->profileOverallCount('Q16b',array(1,2,3,4,5,6));
    $data['frequencyOverallD_s'] = $profileOverall->profileOverallCount('Q17a',array(1,2,3,4,5));
    $data['frequencyOverallI_s'] = $profileOverall->profileOverallCount('Q17b',array(1,2,3,4,5));
    $data['travellingOverall_s'] = $profileOverall->profileOverallCount('Q18',array(1,2,3,4));
    $data['purposeOverall_s'] = $profileOverall->profileOverallCount('Q19',array(1,2,3,4,5));
    $data['terminalOverall_s'] = $profileOverall->profileOverallCount('Q5a',array(1,2,3));
    $data['travellerOverall_s'] = $profileOverall->profileOverallCount('Q14c',array(1,2));
    
    $data['genderOverall_ns'] = $profileOverall2->profileOverallCount('HQ8',range(1, 2));
    $data['ageOverall_ns'] = $profileOverall2->profileOverallCount('HQ9',array(2,3,4,5));
    $data['airportOverall_ns'] = $profileOverall2->profileOverallCount('Q5',array(1,2,3,4,5,6,7));
    $data['incomeOverall_ns'] = $profileOverall2->profileOverallCount('Q11',array(1,2,3,4));
    $data['segmentOverall_ns'] = $profileOverall2->profileOverallCount('Q13a',array(1,2));
    $data['typesOverall_ns'] = $profileOverall2->profileOverallCount('Q13b',array(1,2));
    $data['dwellOverallD_ns'] = $profileOverall2->profileOverallCount('Q16a',array(1,2,3,4,5,6));
    $data['dwellOverallA_ns'] = $profileOverall2->profileOverallCount('Q16b',array(1,2,3,4,5,6));
    $data['frequencyOverallD_ns'] = $profileOverall2->profileOverallCount('Q17a',array(1,2,3,4,5));
    $data['frequencyOverallI_ns'] = $profileOverall2->profileOverallCount('Q17b',array(1,2,3,4,5));
    $data['travellingOverall_ns'] = $profileOverall2->profileOverallCount('Q18',array(1,2,3,4));
    $data['purposeOverall_ns'] = $profileOverall2->profileOverallCount('Q19',array(1,2,3,4,5));
    $data['terminalOverall_ns'] = $profileOverall2->profileOverallCount('Q5a',array(1,2,3));
    $data['travellerOverall_ns'] = $profileOverall2->profileOverallCount('Q14c',array(1,2));
}

$data['Q101'] = $recordCounter->countRecords('A_Q101_', range(1, 9),$airport);
$data['Q102'] = $recordCounter->countRecords('A_Q102_', range(1, 9),$airport);
$data['Q103'] = $recordCounter->countRecords('A_Q103_', range(1, 15),$airport);
$data['Q106'] = $recordCounter->countRecords('A_Q106_', range(1, 9),$airport);
$data['Q109'] = $recordCounter->countRecords('A_Q109_', range(1, 6),$airport);

$data['Q201'] = $recordCounter->countRecords('A_Q201_', range(1, 9),$airport);
$data['Q202'] = $recordCounter->countRecords('A_Q202_', range(1, 15),$airport);
$data['Q206'] = $recordCounter->countRecords('A_Q206_', range(1, 9),$airport);
$data['Q209'] = $recordCounter->countRecords('A_Q209_', range(1, 6),$airport);

echo json_encode($data);

?>