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

$condX = $_REQUEST['condX'];
$conX = $_REQUEST['conX'];
$tblX = $_REQUEST['tblX'];
$trendStatus = $_REQUEST['trendStatus'];
$trendcondX = $_REQUEST['trendcondX'];

$spcX = "1=1";
$spcX2 = "1=1";

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

if($trendStatus=='false')
{
    $trendsValue = [];
    $recordCounter1 = new RecordCounter1($conn,$condX,$tblX,$spcX,$spcX2,$trendStatus,$trendsValue);
    $recordCounter2 = new RecordCounter2($conn,$condX,$tblX,$spcX,$spcX2,$trendStatus,$trendsValue);
    $recordCounter3 = new RecordCounter3($conn,$condX,$tblX,$spcX,$spcX2,$trendStatus,$trendsValue);

    $recordCounter1_1 = new RecordCounter1_1(
        $conn,
        $trendcondX,
        $tblX,
        $spcX,
        $spcX2,
        $trendStatus,
        $trendsValue
    );

    $recordCounter2_1 = new RecordCounter2_1(
        $conn,
        $trendcondX,
        $tblX,
        $spcX,
        $spcX2,
        $trendStatus,
        $trendsValue
    );

    $data['CH_F1'] = $recordCounter1->countRecords1('CH_F1', range(1,2));
    $data['CH_F1x1'] = $recordCounter1->countRecords1('CH_F1x1', range(1,3));
    $data['CH_F2'] = $recordCounter2->countRecords2('CH_F2', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,98));

    $data['CH_F3'] = $recordCounter2_1->countRecords2_1('CH_F3',[1,2,3,4,5,6,7,8,9]);
    $data['CH_F4'] = $recordCounter1_1->countRecords1_1('CH_F4', range(1,3));
    $data['CH_F5'] = $recordCounter2_1->countRecords2_1('CH_F5', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15));
    $data['CH_F6'] = $recordCounter1_1->countRecords1_1('CH_F6', array(1,2,99));
    $data['CH_F7'] = $recordCounter1_1->countRecords1_1('CH_F7', array(1,2,3,4,5,6,7,8,9,99));
    $data['CH_F8'] = $recordCounter1_1->countRecords1_1('CH_F8', array(1,2,3,99));

    $data['CH_F_C8'] = $recordCounter1->countRecords1('CH_F_C8', array(1,2,3,4,5,99));
    $data['CH_F_C11'] = $recordCounter2->countRecords2('CH_F_C11', range(1,7));
    $data['CH_F_C12'] = $recordCounter1->countRecords1('CH_F_C12', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,98));
    $data['CH_F_C15'] = $recordCounter1->countRecords1('CH_F_C15', array(1,2,3));

    $data['CH_C16'] = $recordCounter3->countRecords3('CH_C16', range(1,9));
    $data['CH_C17'] = $recordCounter1->countRecords1('CH_C17', range(1,3));
    $data['CH_C18'] = $recordCounter1->countRecords1('CH_C18', array(1,2,3,4,98,99));
    $data['CH_C19'] = $recordCounter2->countRecords2('CH_C19', array(1,2,3,4,5,6,7,8,9,10,98,99));
    $data['CH_C20'] = $recordCounter1->countRecords1('CH_C20', array(1,2,3));

    $data['S13_1'] = $recordCounter1->countRecords1('S13_1', array(1,2,3,4,5,6,7));
}

else
{
    $trendsValue = [1,2,3,4,90,91];
    $recordCounter1 = new RecordCounter1($conn,$trendcondX,$tblX,$spcX,$spcX2,$trendStatus,$trendsValue);
    $recordCounter2 = new RecordCounter2($conn,$trendcondX,$tblX,$spcX,$spcX2,$trendStatus,$trendsValue);
    $recordCounter3 = new RecordCounter3($conn,$trendcondX,$tblX,$spcX,$spcX2,$trendStatus,$trendsValue);
    $recordCounter1_1 = new RecordCounter1_1(
        $conn,
        $trendcondX,
        $tblX,
        $spcX,
        $spcX2,
        $trendStatus,
        $trendsValue
    );
    $recordCounter2_1 = new RecordCounter2_1(
        $conn,
        $trendcondX,
        $tblX,
        $spcX,
        $spcX2,
        $trendStatus,
        $trendsValue
    );
    // $data['CH_F2'] = $recordCounter2->countRecords2('CH_F2', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,98));
    // $data['CH_F3'] = $recordCounter2_1->countRecords2_1('CH_F3',[1,2,3,4,5,6,7,8,9]);
    // $data['CH_F4'] = $recordCounter1->countRecords1('CH_F4', range(1,3));

    $data['CH_F1'] = $recordCounter1->countRecords1('CH_F1', range(1,2));
    $data['CH_F1x1'] = $recordCounter1->countRecords1('CH_F1x1', range(1,3));
    
    $data['CH_F2'] = $recordCounter2->countRecords2('CH_F2', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,98));

    $data['CH_F3'] = $recordCounter2_1->countRecords2_1('CH_F3',[1,2,3,4,5,6,7,8,9]);
    $data['CH_F4'] = $recordCounter1_1->countRecords1_1('CH_F4', range(1,3));
    $data['CH_F5'] = $recordCounter2_1->countRecords2_1('CH_F5', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15));
    $data['CH_F6'] = $recordCounter1_1->countRecords1_1('CH_F6', array(1,2,99));
    $data['CH_F7'] = $recordCounter1_1->countRecords1_1('CH_F7', array(1,2,3,4,5,6,7,8,9,99));
    $data['CH_F8'] = $recordCounter1_1->countRecords1_1('CH_F8', array(1,2,3,99));

    $data['CH_F_C8'] = $recordCounter1->countRecords1('CH_F_C8', array(1,2,3,4,5,99));
    $data['CH_F_C11'] = $recordCounter2->countRecords2('CH_F_C11', range(1,7));
    $data['CH_F_C12'] = $recordCounter1->countRecords1('CH_F_C12', array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,98));
    $data['CH_F_C15'] = $recordCounter1->countRecords1('CH_F_C15', array(1,2,3));

    $data['CH_C16'] = $recordCounter3->countRecords3('CH_C16', range(1,9));
    $data['CH_C17'] = $recordCounter1->countRecords1('CH_C17', range(1,3));
    $data['CH_C18'] = $recordCounter1->countRecords1('CH_C18', array(1,2,3,4,98,99));
    $data['CH_C19'] = $recordCounter2->countRecords2('CH_C19', array(1,2,3,4,5,6,7,8,9,10,98,99));
    $data['CH_C20'] = $recordCounter1->countRecords1('CH_C20', array(1,2,3));

    $data['S13_1'] = $recordCounter1->countRecords1('S13_1', array(1,2,3,4,5,6,7));

}


echo json_encode($data);

?>