protected function storeReportData($reportType, $eventID = '', $campusID = '', $file_names = '') { $fileDir = SITE_PATH_REPORTS; // $filePrefix = ''; $fileName = ''; $fileNames = explode(',', $file_names); $dataGetter = new RegSummaryTools(); // echo "FileData = ".$fileData; // spreadsheet.php?file=contactdata.xls switch ($reportType) { case modulecim_reg::DOWNLOAD_EVENT_DATA: $fileName = $fileNames[0]; //modulecim_reg::EVENT_DATA_FILE_NAME; // $filePrefix = modulecim_reg::EVENT_DATA_FILE_NAME; // $filePath = tempnam($fileDir, $filePrefix); $fileData = $dataGetter->getCSVByCampus($eventID, $campusID); break; case modulecim_reg::DOWNLOAD_SCHOLARSHIP_DATA: $fileName = $fileNames[1]; //modulecim_reg::EVENT_SCHOLARSHIP_FILE_NAME; // $filePrefix = modulecim_reg::EVENT_SCHOLARSHIP_FILE_NAME; // $filePath = tempnam($fileDir, $filePrefix); $fileData = $dataGetter->getCSVScholarshipByCampus($eventID, $campusID); break; default: break; } // BEGIN: CODE MODIFIED FROM 'fwrite()' IN PHP.NET DOCUMENTATION >>> TODO?: write each record as it is read // Let's make sure the file exists and is writable first. //if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!($handle = fopen($fileDir . $fileName, 'w'))) { //$filePath, 'w')) { // echo "Cannot open file ({$fileDir}.{$fileName})"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $fileData) === FALSE) { echo "Cannot write to file ({$fileDir}.{$fileName})"; exit; } //echo "Success, wrote ($fileData) to file ($fileName)"; fclose($handle); //} else { // echo "The file $filename is not writable"; //} return $fileName; //$filePath; // }