public function getMultiStationReport($GET) { $infoType = $GET['infoTypeRadio']; $exportType = $GET['exportTypeRadio']; $valueType = $GET['valueTypeRadio']; $folSeq = $GET['stationsSelect']; $fromDateStr = $GET['fromDate']; $toDateStr = $GET['toDate']; $timeBase = $GET['timeBase']; $timeBaseQuick = $GET['timeBaseQuick']; $quickReportType = $GET['quickReportType']; if ($quickReportType != "null") { $timeBase = $timeBaseQuick; } if ($valueType != "normal") { $timeBase = "5min"; } $isValidated = $GET['isValidated']; $isAverage = $GET['isAverage']; $folSeqArray = array(); //holds all folderseqs $folChannelsArray = array(); //holds selected channels by foldSeq as key foreach ($GET as $key => $value) { if (strpos($key, "channelNos_") !== false) { $folSeq = (double) substr($key, 11); array_push($folSeqArray, $folSeq); $folChannelsArray[$folSeq] = $value; } } //a few validation checks if (count($folChannelsArray) == 0) { return null; } if ($quickReportType == "null" && (false === strtotime($fromDateStr) || false === strtotime($toDateStr))) { return null; } //get folderNames from DB $FDS = FolderDataStore::getInstance(); $foldersObjArray = $FDS->FindBySeqs($folSeqArray); //calculating from to dates from provided $_GET $fromToDates = DateUtils::getDatesArrayForStationReports($quickReportType, $fromDateStr, $toDateStr); //calculating Date Slices now from DateUtils $fromDate = new DateTime($fromToDates['fromDate']); $toDate = new DateTime($fromToDates['toDate']); $folChannelsNamesArray = array(); //holds selected channels by foldSeq as key $allChannelsArray = array(); $channelUnitArray = array(); foreach ($folChannelsArray as $folSeq => $folChannelChannelsArr) { $folName = $foldersObjArray[$folSeq]->getFolderName(); $CCDS = ChannelConfigurationDataStore::getInstance(); $ChannelsInfo = $CCDS->FindByFolderAndChannelNos($folSeq, $folChannelChannelsArr); $channelNamesArr = array(); foreach ($ChannelsInfo as $chInfo) { if ($valueType != "normal") { if (!self::isZeroSpanChannel($chInfo->getChannelName())) { $chNo = $chInfo->getChannelNumber(); $chArr = $folChannelsArray[$folSeq]; if (($key = array_search($chNo, $chArr)) !== false) { unset($folChannelsArray[$folSeq][$key]); $folChannelsArray[$folSeq] = array_values($folChannelsArray[$folSeq]); } continue; } } $chUnit = $chInfo->getChannelUnit(); if (ConvertorUtils::getPrescribedUnit($chInfo->getChannelName()) != null) { $chUnit = ConvertorUtils::getPrescribedUnit($chInfo->getChannelName()); } $chUnit = mb_check_encoding($chUnit, 'UTF-8') ? $chUnit : utf8_encode($chUnit); $chStation = $chInfo->getChannelStation(); if (!empty($chStation)) { $chStation = " - " . $chStation; } $chStr = $folName . '<br>' . $chInfo->getChannelName() . $chStation . '<br>' . $chUnit; array_push($allChannelsArray, $chStr); array_push($channelUnitArray, $chUnit); array_push($channelNamesArr, $chInfo->getChannelName()); } $folChannelsNamesArray[$folSeq] = $channelNamesArr; } //Created an array with folSeq and seelcted channels for it $folChannelDataArray = array(); foreach ($folSeqArray as $folSeq) { $channelNoArray = $folChannelsArray[$folSeq]; $EDS = ExemptionDataStore::getInstance(); $exemptions = $EDS->FindExemptionsByFolderDatesChannels($folSeq, $fromToDates['fromDate'], $fromToDates['toDate'], implode(', ', $channelNoArray)); //Stack or AQMS $stationType = $foldersObjArray[$folSeq]->getStationType(); $dataJson = self::getDataJSON($fromToDates['fromDate'], $fromToDates['toDate'], $folSeq, "5min", $channelNoArray, $periodType, $exemptions, $stationType); //$avgData = self::getAverageData($fromToDates['fromDate'],$fromToDates['toDate'],$folSeq,$channelNoArray); $folChannelDataArray[$folSeq] = $dataJson['data']; } //Created an array with folSeq -> date->chanelvalues $CMD = CommentsDataStore::getInstance(); $commentsObjs = $CMD->FindCommentsMasterByFolChannel($folSeqArray[0], $folChannelsArray[$folSeqArray[0]]); $dataSlices = null; //if its stack type we are supporting single station/folder data only $stationType = $foldersObjArray[$folSeqArray[0]]->getStationType(); if ($stationType == 'stack' || $stationType == 'effluent') { //if($isAverage == "on"){ //$dateSlices = DateUtils::getDateSlicesByInterval($fromDate,$toDate,$timeBase); //}else{ if ($timeBase == "instant") { $dateSlices = DateUtils::getDateSlicesForData($folChannelDataArray[$folSeqArray[0]], $isAverage, $timeBase); } else { $dateSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, $timeBase); } //} } else { $dateSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, $timeBase); } //$dateSlices = $dateSlicesValid; $dataFinal = self::getFinalDataByValueType($timeBase, $dateSlices, $folSeqArray, $folChannelDataArray, $folChannelsNamesArray, $valueType, $isAverage, $stationType); if ($isValidated == "on") { $dateSlicesValidByChannelNumber = DateUtils::getDateSlicesByComments($commentsObjs, $timeBase, $folChannelsArray[$folSeqArray[0]]); $dataFinal = self::getValidatedDataOnly($dataFinal, $dateSlicesValidByChannelNumber); } if ($valueType != "normal") { $dataFinal = self::getZeroSpanValues($dataFinal); } $channelDataJSON = array(); $channelDataJSON['channels'] = $allChannelsArray; //all channels with key as chno and val as chname $channelDataJSON['data'] = $dataFinal; //dateFinal is date as key and array of channel values as value $finalDataJSON = self::processDataJsonForGridGraph($channelDataJSON, $infoType); $finalDataJSON["units"] = $channelUnitArray; if ($infoType == "export") { ExportUtils::exportMultiStationGridReport($finalDataJSON, $exportType); return null; } else { if (count($channelDataJSON['channels']) == 1) { $chName = $channelNamesArr[0]; $presLimit = PrescribedLimitsUtils::getPrescribedLimit($chName); if ($presLimit != null) { $finalDataJSON['presLimit'] = $presLimit; } } return self::getAvgMinMaxValues($finalDataJSON); } }