private function generateReport($report, $data)
 {
     global $employeeCurrent;
     $fileFirst = "Report_" . str_replace(" ", "_", $report->name) . "-" . date("Y-m-d_H-i-s");
     $file = $fileFirst . ".csv";
     $fileName = CLIENT_BASE_PATH . 'data/' . $file;
     $fp = fopen($fileName, 'w');
     foreach ($data as $fields) {
         fputcsv($fp, $fields);
     }
     fclose($fp);
     $fileObj = new File();
     $fileObj->name = $fileFirst;
     $fileObj->filename = $file;
     $fileObj->file_group = "Report";
     $ok = $fileObj->Save();
     if (!$ok) {
         error_log($fileObj->ErrorMsg());
         return array("ERROR", "Error generating report");
     }
     return array("SUCCESS", $file);
 }
            $arr = explode("/", $final_img_location);
            return array('success' => 1, 'filename' => $arr[count($arr) - 1], 'error' => '');
        } else {
            return array('success' => 0, 'error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
        }
    }
}
//Generate File Name
$saveFileName = $_POST['file_name'];
if (empty($saveFileName) || $saveFileName == "_NEW_") {
    $saveFileName = microtime();
    $saveFileName = str_replace(".", "-", $saveFileName);
}
$file = new File();
$file->Load("name = ?", array($saveFileName));
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = explode(',', FILE_TYPES);
// max file size in bytes
$sizeLimit = MAX_FILE_SIZE_KB * 1024;
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload(CLIENT_BASE_PATH . 'data/', $saveFileName);
// to pass data through iframe you will need to encode all html tags
if ($result['success'] == 1) {
    $file->name = $saveFileName;
    $file->filename = $result['filename'];
    $file->employee = $_POST['user'] == "_NONE_" ? null : $_POST['user'];
    $file->file_group = $_POST['file_group'];
    $file->Save();
    $result['filename'] = CLIENT_BASE_URL . 'data/' . $result['filename'];
}
echo "<script>parent.closeUploadDialog(" . $result['success'] . ",'" . $result['error'] . "','" . $result['filename'] . "');</script>";
Example #3
0
 public function checkAddSmallProfileImage($profileImage)
 {
     $file = new File();
     $file->Load('name = ?', array($profileImage->name . "_small"));
     if (empty($file->id)) {
         LogManager::getInstance()->info("Small profile image " . $profileImage->name . "_small not found");
         $largeFileUrl = $this->getFileUrl($profileImage->name);
         $file->name = $profileImage->name . "_small";
         $signInMappingField = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
         $file->{$signInMappingField} = $profileImage->{$signInMappingField};
         $file->filename = $file->name . str_replace($profileImage->name, "", $profileImage->filename);
         $file->file_group = $profileImage->file_group;
         file_put_contents("/tmp/" . $file->filename . "_orig", file_get_contents($largeFileUrl));
         if (file_exists("/tmp/" . $file->filename . "_orig")) {
             //Resize image to 100
             $img = new abeautifulsite\SimpleImage("/tmp/" . $file->filename . "_orig");
             $img->fit_to_width(100);
             $img->save("/tmp/" . $file->filename);
             $uploadFilesToS3Key = SettingsManager::getInstance()->getSetting("Files: Amazon S3 Key for File Upload");
             $uploadFilesToS3Secret = SettingsManager::getInstance()->getSetting("Files: Amazone S3 Secret for File Upload");
             $s3Bucket = SettingsManager::getInstance()->getSetting("Files: S3 Bucket");
             $uploadname = CLIENT_NAME . "/" . $file->filename;
             $localFile = "/tmp/" . $file->filename;
             $s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
             $result = $s3FileSys->putObject($s3Bucket, $uploadname, $localFile, 'authenticated-read');
             unlink("/tmp/" . $file->filename);
             unlink("/tmp/" . $file->filename . "_orig");
             LogManager::getInstance()->info("Upload Result:" . print_r($result, true));
             if (!empty($result)) {
                 $ok = $file->Save();
             }
             return $file;
         }
         return null;
     }
     return $file;
 }
Example #4
0
 private function generateReport($report, $data)
 {
     $fileFirst = "Report_" . str_replace(" ", "_", $report->name) . "-" . date("Y-m-d_H-i-s");
     $file = $fileFirst . ".csv";
     $fileName = CLIENT_BASE_PATH . 'data/' . $file;
     $fp = fopen($fileName, 'w');
     foreach ($data as $fields) {
         fputcsv($fp, $fields);
     }
     fclose($fp);
     $uploadedToS3 = false;
     $uploadFilesToS3 = SettingsManager::getInstance()->getSetting("Files: Upload Files to S3");
     $uploadFilesToS3Key = SettingsManager::getInstance()->getSetting("Files: Amazon S3 Key for File Upload");
     $uploadFilesToS3Secret = SettingsManager::getInstance()->getSetting("Files: Amazone S3 Secret for File Upload");
     $s3Bucket = SettingsManager::getInstance()->getSetting("Files: S3 Bucket");
     $s3WebUrl = SettingsManager::getInstance()->getSetting("Files: S3 Web Url");
     if ($uploadFilesToS3 . '' == '1' && !empty($uploadFilesToS3Key) && !empty($uploadFilesToS3Secret) && !empty($s3Bucket) && !empty($s3WebUrl)) {
         $uploadname = CLIENT_NAME . "/" . $file;
         $s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
         $res = $s3FileSys->putObject($s3Bucket, $uploadname, $fileName, 'authenticated-read');
         if (empty($res)) {
             return array("ERROR", $file);
         }
         unlink($fileName);
         $file_url = $s3WebUrl . $uploadname;
         $file_url = $s3FileSys->generateExpiringURL($file_url);
         $uploadedToS3 = true;
     }
     $fileObj = new File();
     $fileObj->name = $fileFirst;
     $fileObj->filename = $file;
     $fileObj->file_group = "Report";
     $ok = $fileObj->Save();
     if (!$ok) {
         LogManager::getInstance()->info($fileObj->ErrorMsg());
         return array("ERROR", "Error generating report");
     }
     $headers = array_shift($data);
     if ($uploadedToS3) {
         return array("SUCCESS", array($file_url, $headers, $data));
     } else {
         return array("SUCCESS", array($file, $headers, $data));
     }
 }
Example #5
0
 protected function ProcessFolder($strFolder)
 {
     $strLabel = substr($strFolder, strlen($this->strRoot) + 1);
     if (!$strLabel) {
         $strLabel = 'root';
     }
     print 'Processing ' . $strLabel . ' [';
     $strFileArray = array();
     $strFolderArray = array();
     // Iterate through all subfolders and files in this folder
     // Be sure not to process anything with CVS, SVN or ds_store
     $objDirectory = opendir($strFolder);
     while ($strName = readdir($objDirectory)) {
         if ($strName != '.' && $strName != '..' && $strName != 'SVN' && $strName != '.svnignore' && $strName != 'CVS' && $strName != '.cvsignore' && strtolower($strName) != '.ds_store') {
             $strFullPath = $strFolder . '/' . $strName;
             if (is_dir($strFullPath)) {
                 array_push($strFolderArray, $strFullPath);
             } else {
                 array_push($strFileArray, $strFullPath);
             }
         }
     }
     $intFileCount = count($strFileArray);
     for ($intFileIndex = 0; $intFileIndex < $intFileCount; $intFileIndex++) {
         print ' ';
     }
     print ']';
     for ($intFileIndex = 0; $intFileIndex <= $intFileCount; $intFileIndex++) {
         print chr(8);
     }
     foreach ($strFileArray as $strFile) {
         print 'X';
         $strMd5 = md5_file($strFile);
         $strFullPath = $strFile;
         $strFile = substr($strFile, strlen($this->strRoot) + 1);
         // Process all files other than the root _README.txt and LICENSE.txt
         if ($strFile != '_README.txt' && $strFile != '_LICENSE.txt') {
             $intDirectoryId = null;
             $objFileDirectory = null;
             foreach ($this->objDirectoryTokens as $objDirectory) {
                 if (!$intDirectoryId) {
                     if (strpos($strFile, $objDirectory->Path) === 0) {
                         $intDirectoryId = $objDirectory->Id;
                         $objFileDirectory = $objDirectory;
                         $strFile = substr($strFile, strlen($objDirectory->Path));
                     }
                 }
             }
             if (!$intDirectoryId) {
                 var_dump($this->objDirectoryTokens);
                 exit("FATAL ERROR: No DirectoryToken resolution for " . $strFile . "\r\n");
             }
             $objFile = File::LoadByDirectoryIdPath($intDirectoryId, $strFile);
             if (!$objFile) {
                 $objFile = new File();
                 $objFile->Path = $strFile;
                 $objFile->DirectoryId = $intDirectoryId;
             } else {
                 $objFile->DeprecatedMajorVersion = null;
                 $objFile->DeprecatedMinorVersion = null;
                 $objFile->DeprecatedBuild = null;
             }
             $objFile->Save();
             $this->blnFileProcessedArray['id' . $objFile->Id] = true;
             $this->strXml .= sprintf("<file directoryToken=\"%s\" path=\"%s\" md5=\"%s\"/>\r\n", $objFileDirectory->Token, $strFile, $strMd5);
             // Parse tokens for documetation for all PHP files outside of assets and PHPUnit
             if (substr($strFile, strlen($strFile) - 4) == '.php' && strpos($strFullPath, '/assets/') === false && strpos($strFullPath, '/PHPUnit/') === false) {
                 switch ($objFileDirectory->Token) {
                     case '__INCLUDES__':
                     case '__QCODO__':
                     case '__QCODO_CORE__':
                         $objParser = new QScriptParser($strFullPath);
                         $objResult = $objParser->ParseTokens();
                         // Iterate through the Class Definitions
                         foreach ($objResult->ClassArray as $objParserClass) {
                             if ($objParserClass->Extends) {
                                 $objParentClass = QcodoClass::RestoreByName($objParserClass->Extends, $this->strVersion, null);
                             } else {
                                 $objParentClass = null;
                             }
                             // TO DO
                             // if ($strImplements) {
                             // }
                             $objClass = QcodoClass::RestoreByName($objParserClass->Name, $this->strVersion, $objFile);
                             $objClass->AbstractFlag = $objParserClass->Abstract;
                             $objClass->ParentQcodoClass = $objParentClass;
                             $objClass->Save();
                             // Class Constants
                             $strConstantArray = array();
                             foreach ($objParserClass->ConstantArray as $objParserConstant) {
                                 $objConstant = QcodoConstant::RestoreByNameForClass($objParserConstant->Name, $objClass->Id, $this->strVersion, $objFile);
                                 //										$strValue = QBuildMaker::StripQuotes($objParserConstant->Value);
                                 $strValue = $objParserConstant->Value;
                                 $objConstant->Variable->DefaultValue = $strValue;
                                 $objConstant->Variable->Save();
                                 $strConstantArray[$objParserConstant->Name] = true;
                             }
                             // Class Constants (Deprecate)
                             foreach ($objClass->GetQcodoConstantArray(QQ::Clause(QQ::Expand(QQN::QcodoConstant()->Variable))) as $objConstant) {
                                 if (!array_key_exists($objConstant->Variable->Name, $strConstantArray)) {
                                     $objConstant->Variable->LastVersion = $this->strVersion;
                                     $objConstant->Variable->Save();
                                 }
                             }
                             // Class Variables
                             $strVariableArray = array();
                             foreach ($objParserClass->VariableArray as $objParserVariable) {
                                 $strName = QBuildMaker::StripDollar($objParserVariable->Name);
                                 //										$strValue = QBuildMaker::StripQuotes($objParserVariable->DefaultValue);
                                 $strValue = $objParserVariable->DefaultValue;
                                 $objClassVariable = ClassVariable::RestoreByNameForClass($strName, $objClass->Id, $this->strVersion);
                                 $objClassVariable->Variable->DefaultValue = $strValue;
                                 $objClassVariable->Variable->Save();
                                 $objClassVariable->StaticFlag = $objParserVariable->Static;
                                 switch (strtolower($objParserVariable->Visibility)) {
                                     case 'public':
                                         $objClassVariable->ProtectionTypeId = ProtectionType::_Public;
                                         break;
                                     case 'protected':
                                         $objClassVariable->ProtectionTypeId = ProtectionType::_Protected;
                                         break;
                                     case 'private':
                                         $objClassVariable->ProtectionTypeId = ProtectionType::_Private;
                                         break;
                                     default:
                                         throw new Exception('Unknown Protection Type');
                                 }
                                 $objClassVariable->Save();
                                 $strVariableArray[$strName] = true;
                             }
                             // Class Variables (deprecate)
                             foreach ($objClass->GetClassVariableArray(QQ::Clause(QQ::Expand(QQN::ClassVariable()->Variable))) as $objClassVariable) {
                                 if (!array_key_exists($objClassVariable->Variable->Name, $strVariableArray)) {
                                     $objClassVariable->Variable->LastVersion = $this->strVersion;
                                     $objClassVariable->Variable->Save();
                                 }
                             }
                             // Class Methods
                             $strMethodArray = array();
                             foreach ($objParserClass->MethodArray as $objParserFunction) {
                                 $objOperation = Operation::RestoreByNameForClass($objParserFunction->Name, $objClass->Id, $this->strVersion, $objFile);
                                 $objOperation->StaticFlag = $objParserFunction->Static;
                                 $objOperation->FinalFlag = $objParserFunction->Final;
                                 $objOperation->AbstractFlag = $objParserFunction->Abstract;
                                 switch (strtolower($objParserFunction->Visibility)) {
                                     case 'public':
                                         $objOperation->ProtectionTypeId = ProtectionType::_Public;
                                         break;
                                     case 'protected':
                                         $objOperation->ProtectionTypeId = ProtectionType::_Protected;
                                         break;
                                     case 'private':
                                         $objOperation->ProtectionTypeId = ProtectionType::_Private;
                                         break;
                                     default:
                                         throw new Exception('Unknown Protection Type');
                                 }
                                 $objOperation->Save();
                                 $strMethodArray[$objParserFunction->Name] = true;
                                 // Figure Out the Parameters
                                 $objParserParameterArray = array();
                                 foreach ($objParserFunction->ParameterArray as $objParserParameter) {
                                     $strName = QBuildMaker::StripDollar($objParserParameter->Name);
                                     $objParserParameterArray[$strName] = $objParserParameter;
                                 }
                                 $objParameterArray = Parameter::RestoreParameterArrayByNameForOperation(array_keys($objParserParameterArray), $objOperation->Id, $this->strVersion);
                                 foreach ($objParameterArray as $objParameter) {
                                     $objParserParameter = $objParserParameterArray[$objParameter->Variable->Name];
                                     $objParameter->ReferenceFlag = $objParserParameter->Reference;
                                     $objParameter->Save();
                                     $objParameter->Variable->DefaultValue = $objParserParameter->DefaultValue;
                                     $objParameter->Variable->Save();
                                 }
                             }
                             // Class Methods (deprecate)
                             foreach ($objClass->GetOperationArray() as $objOperation) {
                                 if (!array_key_exists($objOperation->Name, $strMethodArray)) {
                                     $objOperation->LastVersion = $this->strVersion;
                                     $objOperation->Save();
                                 }
                             }
                             // Class Properties
                             $strPropertyArray = array();
                             foreach ($objParserClass->PropertyArray as $objParserProperty) {
                                 $strName = QBuildMaker::StripQuotes($objParserProperty->Name);
                                 if ($strName != 'ttf' && $strName != 'pfb' && $strName != 'afm') {
                                     $objProperty = ClassProperty::RestoreByNameForClass($strName, $objClass->Id, $this->strVersion);
                                     if ($objParserProperty->Read && !$objParserProperty->Write) {
                                         $objProperty->ReadOnlyFlag = true;
                                         $objProperty->WriteOnlyFlag = false;
                                     } else {
                                         if (!$objParserProperty->Read && $objParserProperty->Write) {
                                             $objProperty->ReadOnlyFlag = false;
                                             $objProperty->WriteOnlyFlag = true;
                                         } else {
                                             $objProperty->ReadOnlyFlag = false;
                                             $objProperty->WriteOnlyFlag = false;
                                         }
                                     }
                                     $objProperty->Save();
                                     $strPropertyArray[$strName] = true;
                                 }
                             }
                             // Class Properties (deprecate)
                             foreach ($objClass->GetClassPropertyArray() as $objProperty) {
                                 if (!array_key_exists($objProperty->Variable->Name, $strPropertyArray)) {
                                     $objProperty->Variable->LastVersion = $this->strVersion;
                                     $objProperty->Save();
                                 }
                             }
                         }
                         // Iterate through the Interfaces
                         // TODO
                         // Iterate through the Global Functions
                         foreach ($objResult->FunctionArray as $objParserFunction) {
                             $objOperation = Operation::RestoreByNameForClass($objParserFunction->Name, null, $this->strVersion, $objFile);
                             // Figure Out the Parameters
                             $objParserParameterArray = array();
                             foreach ($objParserFunction->ParameterArray as $objParserParameter) {
                                 $strName = QBuildMaker::StripDollar($objParserParameter->Name);
                                 $objParserParameterArray[$strName] = $objParserParameter;
                             }
                             $objParameterArray = Parameter::RestoreParameterArrayByNameForOperation(array_keys($objParserParameterArray), $objOperation->Id, $this->strVersion);
                             foreach ($objParameterArray as $objParameter) {
                                 $objParserParameter = $objParserParameterArray[$objParameter->Variable->Name];
                                 $objParameter->ReferenceFlag = $objParserParameter->Reference;
                                 $objParameter->Save();
                                 $objParameter->Variable->DefaultValue = $objParserParameter->DefaultValue;
                                 $objParameter->Variable->Save();
                             }
                         }
                         // Iterate through the Global Constants
                         foreach ($objResult->ConstantArray as $objParserConstant) {
                             $objConstant = QcodoConstant::RestoreByNameForClass($objParserConstant->Name, null, $this->strVersion, $objFile);
                             // $strValue = QBuildMaker::StripQuotes($objParserConstant->Value);
                             $strValue = $objParserConstant->Value;
                             $objConstant->Variable->DefaultValue = $strValue;
                             $objConstant->Variable->Save();
                         }
                         // Iterate through the Global Variables
                         // NOT SUPPORTED
                         break;
                 }
             }
         }
     }
     print "] Done.\r\n";
     foreach ($strFolderArray as $strFolder) {
         $this->ProcessFolder($strFolder);
     }
 }
Example #6
0
 private function generateReport($report, $data)
 {
     $fileFirst = "Report_" . str_replace(" ", "_", $report->name) . "-" . date("Y-m-d_H-i-s");
     $file = $fileFirst . ".csv";
     if ($report->query == "EmployeeAttendanceReport") {
         //echo MODULE_PATH.'\reportClasses\xlswriter.class.php';
         $file = $fileFirst . ".xlsx";
         require_once APP_BASE_PATH . '\\classes\\PHPExcel.php';
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getProperties()->setCreator("HRIS SGTSI")->setTitle("Employee Attendance");
         $objPHPExcel->setActiveSheetIndex(0);
         $objPHPExcel->getActiveSheet()->setTitle('Sheet1');
         $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Employee ID');
         $objPHPExcel->getActiveSheet()->setCellValue('B1', $data[1][0]);
         $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Name');
         $objPHPExcel->getActiveSheet()->setCellValue('B2', $data[1][1]);
         $objPHPExcel->getActiveSheet()->setCellValue('A3', 'From ' . date("M d, Y", strtotime($_REQUEST['date_start'])));
         $objPHPExcel->getActiveSheet()->setCellValue('B3', 'To ' . date("M d, Y", strtotime($_REQUEST['date_end'])));
         $objPHPExcel->getActiveSheet()->setCellValue('A4', 'Date');
         $objPHPExcel->getActiveSheet()->setCellValue('B4', 'Time In');
         $objPHPExcel->getActiveSheet()->setCellValue('C4', 'Time Out');
         $objPHPExcel->getActiveSheet()->setCellValue('D4', 'Notes');
         $column = 5;
         foreach ($data as $key => $row) {
             if ($key != 0) {
                 //echo PHPExcel_Shared_Date::PHPToExcel( strtotime($row[2]) ).",".strtotime($row[2])." <br/> ";
                 //echo "<br/>".PHPExcel_Shared_Date::PHPToExcel( strtotime($row[2]) );
                 $objPHPExcel->getActiveSheet()->setCellValue('A' . $column, PHPExcel_Shared_Date::PHPToExcel(strtotime($row[2])));
                 $objPHPExcel->getActiveSheet()->getStyle('A' . $column)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
                 $objPHPExcel->getActiveSheet()->setCellValue('B' . $column, PHPExcel_Shared_Date::PHPToExcel(strtotime($row[2])));
                 $objPHPExcel->getActiveSheet()->getStyle('B' . $column)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1);
                 $objPHPExcel->getActiveSheet()->setCellValue('C' . $column, PHPExcel_Shared_Date::PHPToExcel(strtotime($row[3])));
                 $objPHPExcel->getActiveSheet()->getStyle('C' . $column)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1);
                 $objPHPExcel->getActiveSheet()->setCellValue('D' . $column, $row[4]);
                 $column++;
             }
         }
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
         $objWriter->save(CLIENT_BASE_PATH . 'data/' . $file);
         // require_once MODULE_PATH.'\reportClasses\xlsxwriter.class.php';
         // $file=$fileFirst.".xlsx";
         // $writer=new XLSXWriter();
         // $writer->setAuthor('SPARK HRIS');
         // $writer->writeSheetRow('Sheet1',array('Employee ID',$data[1][0]));
         // $writer->writeSheetRow('Sheet1',array('Name',$data[1][1]));
         // $writer->writeSheetRow('Sheet1',array('From '.date("M d, Y",strtotime($_REQUEST['date_start'])),'To '.date("M d, Y",strtotime($_REQUEST['date_end']))));
         // $writer->writeSheetRow('Sheet1',array('Date','Tme IN','TimeOUT','Notes'));
         // // $sheetdata=array();
         // // $sheetdata[]=array('Employee ID',$data[1][0]);
         // // $sheetdata[]=array('Name',$data[1][1]));
         // //$sheetdata[]=array('From '.date("M d, Y",strtotime($_REQUEST['date_start'])),'To '.date("M d, Y",strtotime($_REQUEST['date_end'])));
         // //$sheetdata[]=array('Date','Tme IN','TimeOUT','Notes');
         // foreach ($data as $key=>$fields) {
         // 	if ($key<>0){
         // 		$row=array();
         // 		// $row[]=date("n/d/Y",strtotime($fields[2]));
         // 		// $row[]=date("g:i A",strtotime($fields[2]));
         // 		// $row[]=date("g:i A",strtotime($fields[3]));
         // 		$d1=new DateTime($fields[2]);
         // 		$d2=new DateTime($fields[2]);
         // 		$d3=new DateTime($fields[3]);
         // 		$row[]=$d1->format('n/d/Y');
         // 		$row[]=$d2->format('g:i A');
         // 		$row[]=$d3->format('g:i A');
         // 		$row[]=$fields[4];
         // 		$writer->MywriteSheetRow('Sheet1',$row);
         // 	}
         // }
         // $writer->writeToFile( CLIENT_BASE_PATH.'data/'.$file);
     } else {
         $fileName = CLIENT_BASE_PATH . 'data/' . $file;
         $fp = fopen($fileName, 'w');
         foreach ($data as $fields) {
             fputcsv($fp, $fields);
         }
         fclose($fp);
     }
     $uploadedToS3 = false;
     $uploadFilesToS3 = SettingsManager::getInstance()->getSetting("Files: Upload Files to S3");
     $uploadFilesToS3Key = SettingsManager::getInstance()->getSetting("Files: Amazon S3 Key for File Upload");
     $uploadFilesToS3Secret = SettingsManager::getInstance()->getSetting("Files: Amazone S3 Secret for File Upload");
     $s3Bucket = SettingsManager::getInstance()->getSetting("Files: S3 Bucket");
     $s3WebUrl = SettingsManager::getInstance()->getSetting("Files: S3 Web Url");
     if ($uploadFilesToS3 . '' == '1' && !empty($uploadFilesToS3Key) && !empty($uploadFilesToS3Secret) && !empty($s3Bucket) && !empty($s3WebUrl)) {
         $uploadname = CLIENT_NAME . "/" . $file;
         $s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
         $res = $s3FileSys->putObject($s3Bucket, $uploadname, $fileName, 'authenticated-read');
         if (empty($res)) {
             return array("ERROR", $file);
         }
         unlink($fileName);
         $file_url = $s3WebUrl . $uploadname;
         $file_url = $s3FileSys->generateExpiringURL($file_url);
         $uploadedToS3 = true;
     }
     $fileObj = new File();
     $fileObj->name = $fileFirst;
     $fileObj->filename = $file;
     $fileObj->file_group = "Report";
     $ok = $fileObj->Save();
     if (!$ok) {
         LogManager::getInstance()->info($fileObj->ErrorMsg());
         return array("ERROR", "Error generating report");
     }
     $headers = array_shift($data);
     if ($uploadedToS3) {
         return array("SUCCESS", array($file_url, $headers, $data));
     } else {
         return array("SUCCESS", array($file, $headers, $data));
     }
 }