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

$condX = $_REQUEST['condX'];
$conX = $_REQUEST['conX'];
$tblX = $_REQUEST['tblX'];
$spcX = "PD_C1 = 1";
$protiencondX = $_REQUEST['protiencondX'];
$trendStatus = $_REQUEST['trendStatus'];
$trendcondX = $_REQUEST['trendcondX'];

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


if($trendStatus=='false')
{
    
    $trendsValue = [];
    $recordCounter1 = new RecordCounter1($conn,$condX,$tblX,$spcX,$protiencondX,$trendStatus,$trendsValue);
    $recordCounter2 = new RecordCounter2($conn,$condX,$tblX,$spcX,$protiencondX,$trendStatus,$trendsValue);
    $recordCounter3 = new RecordCounter3($conn,$condX,$tblX,$spcX,$protiencondX,$trendStatus,$trendsValue);
    $recordCounter4 = new RecordCounter4($conn,$condX,$tblX,$spcX,$trendStatus,$trendsValue);
    
    $data['PD_C0'] = $recordCounter4->countRecords4('PD_C0', range(1,2));
    $data['PD_C1'] = $recordCounter1->countRecords1('PD_C1', range(1,3));
    $data['PD_C1a'] = $recordCounter1->countRecords1('PD_C1a', range(1,2));
    $data['PD_C2'] = $recordCounter1->countRecords1('PD_C2', array(1,2,3,98,99));
    $data['PD_C3'] = $recordCounter1->countRecords1('PD_C3', array(1,2,3,4,5,6,7,8,98));
    $data['PD_C5'] = $recordCounter1->countRecords1('PD_C5', array(1,2,3,4,98));
    $data['PD_C6'] = $recordCounter1->countRecords1('PD_C6', array(1,2,3,4,5,99));
    $data['PD_C7'] = $recordCounter1->countRecords1('PD_C7', range(1,2));
    $data['PD_C8'] = $recordCounter1->countRecords1('PD_C8', array(1,2,3,4,5,99));
    $data['PD_C9'] = $recordCounter1->countRecords1('PD_C9', array(1,2,3,4,5,6,7,59));
    $data['PD_C10'] = $recordCounter1->countRecords1('PD_C10', array(1,2,3,4,98));
    
    $data['PD_C11'] = $recordCounter2->countRecords2('PD_C11', range(1,7));
    $data['PD_C12'] = $recordCounter1->countRecords1('PD_C12', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,98));
    $data['PD_C15'] = $recordCounter1->countRecords1('PD_C15', array(1,2,3));
    $data['PD_C16'] = $recordCounter3->countRecords3('PD_C16', range(1,9));
    $data['PD_C17'] = $recordCounter1->countRecords1('PD_C17', range(1,3));
    $data['PD_C18'] = $recordCounter1->countRecords1('PD_C18', array(1,2,3,4,98,99));
    $data['PD_C19'] = $recordCounter2->countRecords2('PD_C19', array(1,2,3,4,5,6,7,8,9,10,98,99));
    $data['PD_C20'] = $recordCounter1->countRecords1('PD_C20', array(1,2,3));
    
    $data['S13_8'] = $recordCounter1->countRecords1('S13_8', array(1,2,3,4,5,6,7));
}
else{
    $trendsValue = [1,2,3,4,90,91];
    $recordCounter1 = new RecordCounter1($conn,$condX,$tblX,$spcX,$protiencondX,$trendStatus,$trendsValue);
    $recordCounter2 = new RecordCounter2($conn,$condX,$tblX,$spcX,$protiencondX,$trendStatus,$trendsValue);
    $recordCounter3 = new RecordCounter3($conn,$condX,$tblX,$spcX,$protiencondX,$trendStatus,$trendsValue);
    $recordCounter4 = new RecordCounter4($conn,$condX,$tblX,$spcX,$trendStatus,$trendsValue);
    
    $data['PD_C0'] = $recordCounter4->countRecords4('PD_C0', range(1,2));
    $data['PD_C1'] = $recordCounter1->countRecords1('PD_C1', range(1,3));
    $data['PD_C1a'] = $recordCounter1->countRecords1('PD_C1a', range(1,2));
    $data['PD_C2'] = $recordCounter1->countRecords1('PD_C2', array(1,2,3,98,99));
    $data['PD_C3'] = $recordCounter1->countRecords1('PD_C3', array(1,2,3,4,5,6,7,8,98));
    $data['PD_C5'] = $recordCounter1->countRecords1('PD_C5', array(1,2,3,4,98));
    $data['PD_C6'] = $recordCounter1->countRecords1('PD_C6', array(1,2,3,4,5,99));
    $data['PD_C7'] = $recordCounter1->countRecords1('PD_C7', range(1,2));
    $data['PD_C8'] = $recordCounter1->countRecords1('PD_C8', array(1,2,3,4,5,99));
    $data['PD_C9'] = $recordCounter1->countRecords1('PD_C9', array(1,2,3,4,5,6,7,59));
    $data['PD_C10'] = $recordCounter1->countRecords1('PD_C10', array(1,2,3,4,98));
    
    $data['PD_C11'] = $recordCounter2->countRecords2('PD_C11', range(1,7));
    $data['PD_C12'] = $recordCounter1->countRecords1('PD_C12', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,98));
    $data['PD_C15'] = $recordCounter1->countRecords1('PD_C15', array(1,2,3));
    $data['PD_C16'] = $recordCounter3->countRecords3('PD_C16', range(1,9));
    $data['PD_C17'] = $recordCounter1->countRecords1('PD_C17', range(1,3));
    $data['PD_C18'] = $recordCounter1->countRecords1('PD_C18', array(1,2,3,4,98,99));
    $data['PD_C19'] = $recordCounter2->countRecords2('PD_C19', array(1,2,3,4,5,6,7,8,9,10,98,99));
    $data['PD_C20'] = $recordCounter1->countRecords1('PD_C20', array(1,2,3));
    
    $data['S13_8'] = $recordCounter1->countRecords1('S13_8', array(1,2,3,4,5,6,7));
    
}

echo json_encode($data);

?>