public static function getInstance() { if (!self::$CCDataStore) { self::$CCDataStore = new ChannelConfigurationDataStore(); return self::$CCDataStore; } return self::$CCDataStore; }
private function getDataJSON($fromDate, $toDate, $folSeq, $timeInterval, $channelNoArr, $periodType) { $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(); $allDatesData = array(); if ($periodType == "recent") { $latestInfo = $WQDS->getChannelsLatestInfo($folSeq); $channelData = array(); $channelData['dated'] = $latestInfo['formatedDated']; $chValues = array(); foreach ($chNumbersArr as $chNumber) { array_push($chValues, (double) $latestInfo['channelsInfo']['ch' . $chNumber . 'value']); } $channelData['values'] = $chValues; array_push($allDatesData, $channelData); } else { $channelsArray = $WQDS->getChannels($fromDate, $toDate, $folSeq, $channelNoArr, $timeInterval); foreach ($channelsArray as $channels) { $channelData = array(); $channelData['dated'] = $channels['wqdfiledatadated']; $chValues = array(); $cnt = count($channels) / 2; // divided by 2 becos array produces both channelname and int values for ($i = 1; $i < $cnt; $i++) { array_push($chValues, (double) $channels[$i]); } $channelData['values'] = $chValues; array_push($allDatesData, $channelData); } } $allDatesData = self::getPLConvertedValueByChannel($allDatesData, $chArr); $jsonData['data'] = $allDatesData; return $jsonData; }
private function addChannels($channels, $units, $folderSeq) { $i = 0; $chNoArr = array(); $CCDS = ChannelConfigurationDataStore::getInstance(); foreach ($channels as $ch) { $chConf = new ChannelConfiguration(); $chConf->setChannelName($ch); $number = $i + 1; $chConf->setChannelNumber($number); $chConf->setFolderSeq($folderSeq); $chConf->setChannelStatusFlag(1); $chConf->setChannelUnit($units[$i]); $CCDS->Save($chConf); $chNoArr[$ch] = $number; $i++; } return $chNoArr; }
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; }
<?php require_once $ConstantsArray['dbServerUrl'] . "DataStoreMgr/WQDDataDataStore.php"; require_once $ConstantsArray['dbServerUrl'] . "DataStoreMgr/ChannelConfigurationDataStore.php"; require_once $ConstantsArray['dbServerUrl'] . "DataStoreMgr/FolderDataStore.php"; require_once $ConstantsArray['dbServerUrl'] . "Utils/PrescribedLimitsUtils.php"; require_once $ConstantsArray['dbServerUrl'] . "Utils/ConvertorUtils.php"; require_once $ConstantsArray['dbServerUrl'] . "Utils/StringUtils.php"; $folSeqs = $_GET["folSeq"]; $folSeqArray = explode(",", $folSeqs); $fromDate = new DateTime($_GET["fromDate"]); $toDate = new DateTime($_GET["toDate"]); $toDate->setTime(23, 59, 59); $chSeq = $_GET["chSeq"]; $CCDS = ChannelConfigurationDataStore::getInstance(); $channel = $CCDS->FindBySeq($chSeq); $channelNumber = $channel->getChannelNumber(); $channelName = $channel->getChannelName(); $channelUnit = $channel->getChannelUnit(); $fromDate = $fromDate->format("Y/m/d H:i:s"); $toDate = $toDate->format("Y/m/d H:i:s"); $WQDS = WQDDataDataStore::getInstance(); $dailyAverageArray = null; foreach ($folSeqArray as $folSeq) { $arr = $WQDS->getDailyAverageValues($fromDate, $toDate, $folSeq, $channelNumber); $folder = FolderDataStore::getInstance()->FindBySeq($folSeq); $dailyAverageArray[$folder->getFolderName()] = $arr; } //get values for the whole day average //$channelConfig = ChannelConfigurationDataStore::getInstance()->FindByFolderAndChannelNo($folSeqArray[0],$channelNumber); $limit = PrescribedLimitsUtils::getPrescribedLimit($channelName);
private function processChannelNumbersToParameters($dataArray, $isConvertUnits) { //method will set channelnames and units $CCDS = ChannelConfigurationDataStore::getInstance(); $processedData = new ArrayObject(); foreach ($dataArray as $data) { $processedDataItem = new ArrayObject(); $processedDataItem['folderSeq'] = $data['folderSeq']; $processedDataItem['folderName'] = $data['folderName']; $processedDataItem['dated'] = $data['dated']; $channelNameWiseData = new ArrayObject(); $channelsInfo = $CCDS->FindByFolder($data['folderSeq']); $channelsNumberWiseData = $data['channelsInfo']; foreach ($channelsInfo as $channel) { $chNo = $channel->getChannelNumber(); $chName = $channel->getChannelName(); $chUnit = $channel->getChannelUnit(); if ($isConvertUnits == 1) { $chNoData = $channelsNumberWiseData['ch' . $chNo . 'value']; $presValue = ConvertorUtils::getPrescribedValue($chName, $chNoData); $chConvertedUnitVal = ConvertorUtils::getPrescribedUnit($chName); if ($chConvertedUnitVal == null) { $chConvertedUnitVal = $chUnit; } $presUnit = ConvertorUtils::getUTF8Encoded($chConvertedUnitVal); if ($presValue == null) { $channelNameWiseData[$chName] = 'no data'; } else { $channelNameWiseData[$chName] = $presValue . ' ' . $presUnit; } } else { $unitVal = $unitName[$chName]; $channelNameWiseData["ch" . $chNo . "unit"] = ConvertorUtils::getUTF8Encoded($unitVal); } } $processedDataItem['data'] = $channelNameWiseData; $processedData[] = $processedDataItem; } return $processedData; }
public function generateFile() { echo "MANIKGARH Generator starts...\n"; $CCDS = ChannelConfigurationDataStore::getInstance(); $FDS = FolderDataStore::getInstance(); $WQDS = WQDDataDataStore::getInstance(); $folders = $FDS->FindByLocationSeqs("11"); echo "<br>--------TotalFolders:" . count($folders); foreach ($folders as $folder) { $folSeq = $folder->getSeq(); //$latestDataRows = $WQDS->getChannelsLatestInfo($folSeq); echo "FolderSeq:" . $folSeq . " FolderName:" . $folder->getFolderName() . "<br>\n"; echo "<br>\n ToDateFromLatestData " . $latestDataRows['dated']; $channelConfigs = $CCDS->FindByFolder($folSeq); $toDateStr = date('Y/m/d H:00:00'); $fromDateStr = date('Y/m/d H:00:00', strtotime('-1 hour')); //$toDateStr = "2014/02/15 18:00:00"; // $fromDateStr = "2014/02/15 17:00:00"; $toDate = new DateTime($toDateStr); $fromDate = new DateTime($fromDateStr); echo "<br>From:" . $fromDateStr . "<br>\n"; echo "To:" . $toDateStr . "<br>\n"; $dataArray = $WQDS->getAllDataByFol($fromDateStr, $toDateStr, $folSeq); $channelNoArr = self::getChannelNumberNameArray(self::$channelsList, $channelConfigs); $addDatesData = array(); foreach ($dataArray as $data) { $channelData = array(); $dated = $data['wqdfiledatadated']; $chValues = array(); $chStatuses = array(); foreach ($channelNoArr as $key => $value) { $vl = (double) $data["ch" . $key . "value"]; if ($vl < 0) { $vl = "n.o"; } array_push($chValues, $vl); array_push($chStatuses, (double) $data["ch" . $key . "status"]); } $allDatesData[strtotime($dated)]['channelValue'] = $chValues; $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses; } $channelArr = array(); foreach ($channelNoArr as $chName) { array_push($channelArr, $chName); } $dataSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, "15min"); $dataRows = $WQDS->getAverageDataByDataArrayDataSlices("15min", $allDatesData, $dataSlices, $channelArr, "normal", array()); $repStr = ""; if (count($dataRows) > 1) { $repStr = ""; foreach ($dataRows as $dateStr => $row) { $chNameValueArr = array(); foreach ($row as $rowId => $rowVal) { $chNameValueArr[$channelArr[$rowId]] = $rowVal; } $dated = new DateTime($dateStr); $repStr .= $dated->format("Y-m-d H:i:s"); $channelsList = self::$channelsList; foreach ($channelsList as $chName) { if ($chNameValueArr[$chName] != null) { $repStr .= "," . $chNameValueArr[$chName]; } else { $repStr .= ",NA"; } } $repStr .= "\r\n"; } echo $repStr; $currDate = new DateTime(); $fileName = "MHCHDMANIKGARHC011_" . $dated->format("YmdHis") . ".csv"; $repFileName = "/home/envirote/public_html/Generated/Manikgarh/" . $folSeq . "/" . $fileName; //$repFileName = $fileName; if (!file_exists(dirname($repFileName))) { mkdir(dirname($repFileName), 0777, true); } $fh = fopen($repFileName, 'w') or die("can't open file"); fwrite($fh, $repStr); fclose($fh); } unset($channelArr); unset($latestDataRows); unset($channelConfigs); unset($channelNoArr); unset($dataSlices); unset($dataRows); unset($chNameValueArr); unset($allDatesData); unset($channelsList); } //for loop ends }
function ConfigurationParsing($value, $folder) { echo "\n\n Starting with Configuration file: " . $value; $configs = ParserConfig::parseConfig($value, $folder->getSeq()); $CCDS = ChannelConfigurationDataStore::getInstance(); $CCDS->Delete($folder->getSeq()); foreach ($configs as $config) { $channelConfig = new ChannelConfiguration(); $channelConfig->setFolderSeq($folder->getSeq()); $channelConfig->setChannelNumber(trim($config[0])); $channelConfig->setChannelStatusFlag(trim($config[1])); $channelConfig->setChannelName(trim($config[2])); $channelConfig->setChannelUnit(trim($config[3])); $CCDS->Save($channelConfig); } echo "\n Unlinking configuration file" . $value; unlink($value); }
public function getWindRoseReport($GET) { $infoType = $GET['infoTypeRadio']; $periodType = $GET['periodTypeRadio']; $fromDateStr = $GET['fromDate']; $toDateStr = $GET['toDate']; $timeBase = $GET['timeBase']; $timeBaseQuick = $GET['timeBaseQuick']; $quickReportType = $GET['quickReportType']; if ($quickReportType != "null") { $timeBase = $timeBaseQuick; } $timeBaseFromGet = $timeBase; $folSeqArray = array(); //holds all folderseqs foreach ($GET as $key => $value) { if (strpos($key, "channelNos_") !== false) { $folSeq = (double) substr($key, 11); array_push($folSeqArray, $folSeq); } } if (count($folSeqArray) == 0) { return null; } $folSeq = $folSeqArray[0]; //calculating from to dates from provided $_GET $fromToDates = DateUtils::getDatesArrayForStationReports($quickReportType, $fromDateStr, $toDateStr); // $dateSlices = DateUtils::getDateSlicesByInterval($fromDate,$toDate,$timeBase); $WSChannelNo = 0; $WDChannelNo = 0; $CCDS = ChannelConfigurationDataStore::getInstance(); $ChannelsInfo = $CCDS->FindByFolder($folSeq); foreach ($ChannelsInfo as $channel) { if ($channel->getChannelName() == "Wind Speed") { $WSChannelNo = $channel->getChannelNumber(); } else { if ($channel->getChannelName() == "Wind Direction") { $WDChannelNo = $channel->getChannelNumber(); } } } $fromDate = new DateTime($fromToDates['fromDate']); $toDate = new DateTime($fromToDates['toDate']); $toDate->setTime(23, 59, 59); $fromDate = $fromDate->format("Y/m/d H:i:s"); $toDate = $toDate->format("Y/m/d H:i:s"); $WQDS = WQDDataDataStore::getInstance(); if (strpos($timeBase, 'hours') !== false) { $timeBase = "1hour"; } $WSArrayDB = $WQDS->getChannel($fromDate, $toDate, $folSeq, $WSChannelNo, $timeBase); $WDArrayDB = $WQDS->getChannel($fromDate, $toDate, $folSeq, $WDChannelNo, $timeBase); if ($WSArrayDB == null || $WDArrayDB == null) { return null; } $WS = array(); $WD = array(); $i = 0; $WSDateInterval = $WSArrayDB[0][0]; foreach ($WSArrayDB as $ws) { if (strtotime($ws[0]) == strtotime($WSDateInterval)) { $WS[$i++] = floatval($ws[1]); $WSDateInterval = DateUtils::getIncrementedDateStr($WSDateInterval, $timeBaseFromGet); } } $i = 0; $WDDateInterval = $WDArrayDB[0][0]; foreach ($WDArrayDB as $wd) { if (strtotime($wd[0]) == strtotime($WDDateInterval)) { $WD[$i++] = floatval($wd[1]); $WDDateInterval = DateUtils::getIncrementedDateStr($WDDateInterval, $timeBaseFromGet); } } $direction_array["N"][] = null; $direction_array["NNE"][] = null; $direction_array["NE"][] = null; $direction_array["ENE"][] = null; $direction_array["E"][] = null; $direction_array["ESE"][] = null; $direction_array["SE"][] = null; $direction_array["SSE"][] = null; $direction_array["S"][] = null; $direction_array["SSW"][] = null; $direction_array["SW"][] = null; $direction_array["WSW"][] = null; $direction_array["W"][] = null; $direction_array["WNW"][] = null; $direction_array["NW"][] = null; $direction_array["NNW"][] = null; for ($ii = 0; $ii < count($WD); $ii++) { switch ($WD[$ii]) { case $WD[$ii] >= 348.75 or $WD[$ii] < 11.25: $direction_array["N"][] = $WS[$ii]; break; case $WD[$ii] >= 11.25 and $WD[$ii] < 33.75: $direction_array["NNE"][] = $WS[$ii]; break; case $WD[$ii] >= 33.75 and $WD[$ii] < 56.25: $direction_array["NE"][] = $WS[$ii]; break; case $WD[$ii] >= 56.25 and $WD[$ii] < 78.75: $direction_array["ENE"][] = $WS[$ii]; break; case $WD[$ii] >= 78.75 and $WD[$ii] < 101.25: $direction_array["E"][] = $WS[$ii]; break; case $WD[$ii] >= 101.25 and $WD[$ii] < 123.75: $direction_array["ESE"][] = $WS[$ii]; break; case $WD[$ii] >= 123.75 and $WD[$ii] < 146.25: $direction_array["SE"][] = $WS[$ii]; break; case $WD[$ii] >= 146.25 and $WD[$ii] < 168.75: $direction_array["SSE"][] = $WS[$ii]; break; case $WD[$ii] >= 168.75 and $WD[$ii] < 191.25: $direction_array["S"][] = $WS[$ii]; break; case $WD[$ii] >= 191.25 and $WD[$ii] < 213.75: $direction_array["SSW"][] = $WS[$ii]; break; case $WD[$ii] >= 213.75 and $WD[$ii] < 236.25: $direction_array["SW"][] = $WS[$ii]; break; case $WD[$ii] >= 236.25 and $WD[$ii] < 258.75: $direction_array["WSW"][] = $WS[$ii]; break; case $WD[$ii] >= 258.75 and $WD[$ii] < 281.25: $direction_array["W"][] = $WS[$ii]; break; case $WD[$ii] >= 281.25 and $WD[$ii] < 303.75: $direction_array["WNW"][] = $WS[$ii]; break; case $WD[$ii] >= 303.75 and $WD[$ii] < 326.25: $direction_array["NW"][] = $WS[$ii]; break; case $WD[$ii] >= 326.25 and $WD[$ii] < 348.75: $direction_array["NNW"][] = $WS[$ii]; break; } } $direction_keys = array_keys($direction_array); $max_wind = round(max($WS), 0); $num_data = count($WS); $wind_range_max = $max_wind < 20 ? 25 : $max_wind; $data_range_array = array(1, 5, 10, 15, 20, $wind_range_max); foreach ($direction_keys as $direction) { for ($ii = 0; $ii <= 5; $ii++) { $count_data[$ii] = 0; } $raw_data = $direction_array[$direction]; foreach ($raw_data as $temp_speed) { if ($temp_speed >= 0 and $temp_speed < $data_range_array[0]) { $count_data[0]++; } elseif ($temp_speed >= $data_range_array[0] and $temp_speed < $data_range_array[1]) { $count_data[1]++; } elseif ($temp_speed >= $data_range_array[1] and $temp_speed < $data_range_array[2]) { $count_data[2]++; } elseif ($temp_speed >= $data_range_array[2] and $temp_speed < $data_range_array[3]) { $count_data[3]++; } elseif ($temp_speed >= $data_range_array[3] and $temp_speed < $data_range_array[4]) { $count_data[4]++; } elseif ($temp_speed >= $data_range_array[4]) { $count_data[5]++; } } for ($ii = 0; $ii <= 5; $ii++) { $plot_data[$direction][$ii] = 0; } for ($ii = 0; $ii <= 5; $ii++) { $plot_data[$direction][$ii] = round($count_data[$ii] / $num_data * 100, 2); } } return $plot_data; }
public function generateFile() { echo "APPCB Generator starts...\n"; $CCDS = ChannelConfigurationDataStore::getInstance(); $FDS = FolderDataStore::getInstance(); $WQDS = WQDDataDataStore::getInstance(); $folders = $FDS->FindByLocationSeqs("7,10"); echo "<br>--------TotalFolders:" . count($folders); foreach ($folders as $folder) { $stationName = $folder->getFolderName(); $stationNumber = substr($stationName, 7); $districtCode = "kham"; $industryCode = "ITCPBCM"; //if($folder->getSeq() == 20){ if ($folder->getLocationSeq() == 10) { $stationNumber = 1; if ($folder->getSeq() == 26) { $stationNumber = 2; } else { if ($folder->getSeq() == 27) { $stationNumber = 3; } else { if ($folder->getSeq() == 28) { $stationNumber = 4; } else { if ($folder->getSeq() == 29) { $stationNumber = 5; } } } } $districtCode = "hyde"; $industryCode = "APPCB"; } $folSeq = $folder->getSeq(); $latestDataRows = $WQDS->getChannelsLatestInfo($folSeq); echo "FolderSeq:" . $folSeq . " FolderName:" . $folder->getFolderName() . "<br>\n"; //echo ("<br>\nTotal Rows found:". count($latestDataRows)); echo "<br>\n ToDateFromLatestData " . $latestDataRows['dated']; if (count($latestDataRows) > 0) { $channelConfigs = $CCDS->FindByFolder($folSeq); $toDateStr = $latestDataRows['dated']; $toDate = new DateTime($toDateStr); $fromDate = new DateTime($toDateStr); $fromDate->setTime(0, 0, 0); $fromDateStr = DateUtils::getSQLDateFromDateObj($fromDate); echo "<br>From:" . $fromDateStr . "<br>\n"; echo "To:" . $toDateStr . "<br>\n"; $dataArray = $WQDS->getAllDataByFol($fromDateStr, $toDateStr, $folSeq); $channelNoArr = self::getChannelNumberNameArray(self::$channelsList, $channelConfigs); $addDatesData = array(); foreach ($dataArray as $data) { $channelData = array(); $dated = $data['wqdfiledatadated']; $chValues = array(); $chStatuses = array(); foreach ($channelNoArr as $key => $value) { $vl = (double) $data["ch" . $key . "value"]; if ($vl < 0) { $vl = "n.o"; } array_push($chValues, $vl); array_push($chStatuses, (double) $data["ch" . $key . "status"]); } $allDatesData[strtotime($dated)]['channelValue'] = $chValues; $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses; } $channelArr = array(); foreach ($channelNoArr as $chName) { array_push($channelArr, $chName); } $dataSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, "1hour"); $dataRows = $WQDS->getAverageDataByDataArrayDataSlices("1hour", $allDatesData, $dataSlices, $channelArr, "normal", array()); } else { echo " \n<br>Null FromDate"; } if (count($dataRows) > 1) { $repStr = ""; foreach ($dataRows as $dateStr => $row) { $chNameValueArr = array(); foreach ($row as $rowId => $rowVal) { $chNameValueArr[$channelArr[$rowId]] = $rowVal; } $repStr .= $districtCode; $repStr .= "," . $industryCode; $repStr .= "," . $stationNumber . ","; $dated = new DateTime($dateStr); $repStr .= $dated->format("m/d/Y h:i:s A"); $channelsList = self::$channelsList; foreach ($channelsList as $chName) { if ($chNameValueArr[$chName] != null) { $repStr .= "," . $chNameValueArr[$chName]; } else { $repStr .= ",NA"; } } $repStr .= "\r\n"; } echo $repStr; //$fileName = "khmmitcl".$folder->getFolderName(). date("Ymd") .".txt"; //$fileName = "air". date("Ymd") .".txt"; $fileName = "air" . $fromDate->format("Ymd") . ".txt"; $repFileName = "/home/envirote/public_html/Generated/APPCB/" . $folSeq . "/" . $fileName; //$repFileName ="d:". $folSeq ."/" . $fileName; if (!file_exists(dirname($repFileName))) { mkdir(dirname($repFileName), 0777, true); } $fh = fopen($repFileName, 'w') or die("can't open file"); fwrite($fh, $repStr); fclose($fh); } unset($channelArr); unset($latestDataRows); unset($channelConfigs); unset($channelNoArr); unset($dataSlices); unset($dataRows); unset($chNameValueArr); unset($allDatesData); unset($channelsList); } //for loop ends }