private function getDataJSON($fromDate, $toDate, $folSeq, $timeInterval, $channelNoArr, $periodType, $exemptions, $stationType) { if (strpos($timeInterval, 'hours') !== false) { $timeInterval = "1hour"; } $CCDS = ChannelConfigurationDataStore::getInstance(); $ChannelsInfo = $CCDS->FindByFolderAndChannelNos($folSeq, $channelNoArr); $chArr = new ArrayObject(); $chNumbersArr = array(); foreach ($ChannelsInfo as $channel) { $channelUnit = $channel->getChannelUnit(); $channelName = $channel->getChannelName(); if (ConvertorUtils::getPrescribedUnit($channelName) != null) { $channelUnit = ConvertorUtils::getPrescribedUnit($channelName); } $channelUnit = mb_check_encoding($channelUnit, 'UTF-8') ? $channelUnit : utf8_encode($channelUnit); $chArr[$channelName] = $channelUnit; array_push($chNumbersArr, $channel->getChannelNumber()); } $jsonData['channels'] = $chArr; $WQDS = WQDDataDataStore::getInstance(); $WQDStackDS = WQDStackDataStore::getInstance(); $allDatesData = array(); $dataArray = null; //make special stack call here to the different datastore with same api structure $dataArray = null; if ($stationType == "stack" || $stationType == "effluent") { $dataArray = $WQDStackDS->getChannels($fromDate, $toDate, $folSeq, $channelNoArr, $timeInterval); } else { $dataArray = $WQDS->getChannels($fromDate, $toDate, $folSeq, $channelNoArr, $timeInterval); } foreach ($dataArray as $data) { $channelData = array(); $dated = $data['wqdfiledatadated']; $chValues = array(); $chStatuses = array(); $cnt = (count($data) - 2) / 4; // divided by 2 becos array produces both channelname and int values for ($i = 0; $i < $cnt; $i++) { $vl = (double) $data["ch" . $channelNoArr[$i] . "value"]; if ($vl < 0 || $vl == NULL) { $vl = "n.o"; } $isDateExempted = false; foreach ($exemptions as $exem) { $exemption = new Exemption(); $exemption = $exem; $isDateExempted = DateUtils::isDateInBetween($exemption->getFromDateRange(), $exemption->getToDateRange(), $dated); if ($isDateExempted) { $chNo = $channelNoArr[$i]; $exemptedChannelsNos = $exemption->getChannelNumbers(); if (in_array($chNo, $exemptedChannelsNos)) { $vl = StringUtils::$exemptedString; } } } array_push($chValues, $vl); array_push($chStatuses, (double) $data["ch" . $channelNoArr[$i] . "status"]); } //$channelData['values'] = $chValues; $allDatesData[strtotime($dated)]['channelValue'] = $chValues; $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses; //array_push($allDatesData,$channelData); } $jsonData['data'] = $allDatesData; return $jsonData; }