diff --git a/src/admin/reports.php b/src/admin/reports.php index 44c0193..5b6316d 100644 --- a/src/admin/reports.php +++ b/src/admin/reports.php @@ -323,6 +323,9 @@ if ( isset($_GET['op']) ) // Create Outputtargetlist $content['outputTarget'] = REPORT_TARGET_STDOUT; CreateOutputtargetList( $content['outputTarget'] ); + + // Init other outputTarget properties + $content['outputTarget_filename'] = ""; // Other settings ... TODO! // $content['customFilters'] = ""; @@ -400,8 +403,12 @@ if ( isset($_GET['op']) ) CreateOutputformatList( $content['outputFormat'] ); // Create Outputtargetlist - $content['outputTarget'] = $mySavedReport['outputFormat']; + $content['outputTarget'] = $mySavedReport['outputTarget']; CreateOutputtargetList( $content['outputTarget'] ); + + // Init other outputTarget properties + $content['outputTarget_filename'] = ""; + InitOutputtargetDefinitions($myReport, $mySavedReport['outputTargetDetails']); // Other settings ... TODO! // $content['customFilters'] = ""; @@ -839,6 +846,7 @@ if ( isset($_POST['op']) ) if ( isset($_POST['report_filterString']) ) { $content['filterString'] = DB_RemoveBadChars($_POST['report_filterString']); } else {$content['report_filterString'] = ""; } if ( isset($_POST['outputFormat']) ) { $content['outputFormat'] = DB_RemoveBadChars($_POST['outputFormat']); } if ( isset($_POST['outputTarget']) ) { $content['outputTarget'] = DB_RemoveBadChars($_POST['outputTarget']); } + if ( isset($_POST['outputTarget_filename']) ) { $content['outputTarget_filename'] = DB_RemoveBadChars($_POST['outputTarget_filename']); } // Read Custom Filters foreach ( $content['CUSTOMFILTERS'] as &$tmpCustomFilter ) @@ -881,6 +889,11 @@ if ( isset($_POST['op']) ) $content['ISERROR'] = true; $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_MISSINGPARAM'], $content['LN_REPORTS_OUTPUTFORMAT'] ); } + else if ( !isset($content['outputTarget']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_MISSINGPARAM'], $content['LN_REPORTS_OUTPUTTARGET'] ); + } // --- @@ -895,6 +908,10 @@ if ( isset($_POST['op']) ) $tmpSavedReport["outputFormat"] = $content['outputFormat']; $tmpSavedReport["outputTarget"] = $content['outputTarget']; $tmpSavedReport["scheduleSettings"] = $content['scheduleSettings']; + $tmpSavedReport["outputTargetDetails"] = ""; // Init Value + if ( isset($content['outputTarget_filename']) ) + $tmpSavedReport["outputTargetDetails"] .= "filename=>" . $content['outputTarget_filename'] . ","; + $content["outputTargetDetails"] = $tmpSavedReport["outputTargetDetails"]; // Copy into content var // Get Objectreference to report $myReportObj = $myReport["ObjRef"]; @@ -921,7 +938,7 @@ if ( isset($_POST['op']) ) if ( $_POST['op'] == "addsavedreport" ) { // Add custom search now! - $sqlquery = "INSERT INTO " . DB_SAVEDREPORTS . " (reportid, sourceid, customTitle, customComment, filterString, customFilters, outputFormat, outputTarget, scheduleSettings) + $sqlquery = "INSERT INTO " . DB_SAVEDREPORTS . " (reportid, sourceid, customTitle, customComment, filterString, customFilters, outputFormat, outputTarget, outputTargetDetails, scheduleSettings) VALUES ('" . $content['ReportID'] . "', " . $content['SourceID'] . ", '" . $content['customTitle'] . "', @@ -930,6 +947,7 @@ if ( isset($_POST['op']) ) '" . $content['customFilters'] . "', '" . $content['outputFormat'] . "', '" . $content['outputTarget'] . "', + '" . $content['outputTargetDetails'] . "', '" . $content['scheduleSettings'] . "' )"; @@ -958,6 +976,7 @@ if ( isset($_POST['op']) ) customFilters = '" . $content['customFilters'] . "', outputFormat = '" . $content['outputFormat'] . "', outputTarget = '" . $content['outputTarget'] . "', + outputTargetDetails = '" . $content['outputTargetDetails'] . "', scheduleSettings = '" . $content['scheduleSettings'] . "' WHERE ID = " . $content['SavedReportID']; @@ -1062,8 +1081,9 @@ $page -> parser($content, "admin/admin_reports.html"); $page -> output(); // --- +// --- // --- BEGIN Helper functions - +// --- function InitCustomFilterDefinitions($myReport, $CustomFilterValues) { global $content; @@ -1126,6 +1146,32 @@ function InitCustomFilterDefinitions($myReport, $CustomFilterValues) } } + +function InitOutputtargetDefinitions($myReport, $outputTargetDetails) +{ + global $content; + + // Get Objectreference to report + $myReportObj = $myReport["ObjRef"]; + + // Init Detail variables manually + $myReportObj->SetOutputTargetDetails($outputTargetDetails); + + // Get Array of Custom filter Defs + $outputTargetArray = $myReportObj->GetOutputTargetDetails(); + + if ( isset($outputTargetArray) && count($outputTargetArray) > 0 ) + { + // Loop through Detail Properties + $i = 0; // Help counter! + foreach( $outputTargetArray as $propertyID => $propertyValue ) + { + // Set property Value by ID + $content['outputTarget_' . $propertyID] = $propertyValue; + } + } +} + // --- END Helper functions ?> \ No newline at end of file diff --git a/src/classes/reports/report.class.php b/src/classes/reports/report.class.php index e6063ca..61bb808 100644 --- a/src/classes/reports/report.class.php +++ b/src/classes/reports/report.class.php @@ -217,31 +217,37 @@ abstract class Report { * Helper function to set the OutputTarget */ public function SetOutputTarget($newOutputTarget) + { + // TODO: Check if Outputtarget EXISTS! + + // Set new OutputTarget + $this->_outputTarget = $newOutputTarget; + } + + /* + * Helper function to set the OutputTarget + */ + public function SetOutputTargetDetails($newOutputTargetDetailsStr) { // Only set if valid string - if ( strlen($newOutputTarget) > 0 ) + if ( strlen($newOutputTargetDetailsStr) > 0 ) { // First of all split by comma - $tmpValues = explode( ",", $newOutputTarget ); + $tmpValues = explode( ",", $newOutputTargetDetailsStr ); //Loop through mappings foreach ($tmpValues as &$myValue ) { - // Split subvalues - $tmpArray = explode( "=>", $myValue ); - - // Get tmp fieldID - $tmpFieldID = trim($tmpArray[0]); - - if ( $tmpFieldID == REPORT_TARGET_TYPE ) - { - // Set new OutputTarget - $this->_outputTarget = trim($tmpArray[1]); - } - else + if ( strlen(trim($myValue)) > 0 ) { + // Split subvalues + $tmpArray = explode( "=>", $myValue ); + + // Get tmp fieldID + $tmpFieldID = trim($tmpArray[0]); + // Set into Details Array - $this->_arrOutputTargetDetails[$tmpFieldID] == trim($tmpArray[1]); + $this->_arrOutputTargetDetails[$tmpFieldID] = trim($tmpArray[1]); } } } @@ -482,6 +488,14 @@ abstract class Report { return $this->_arrCustomFilters; } + /* + * Helper function to return the array of OutputTarget details + */ + public function GetOutputTargetDetails() + { + return $this->_arrOutputTargetDetails; + } + /* * Helper function to trigger initialisation */ @@ -505,6 +519,7 @@ abstract class Report { $this->SetCustomFilters( $mySavedReport["customFilters"] ); $this->SetOutputFormat( $mySavedReport["outputFormat"] ); $this->SetOutputTarget( $mySavedReport["outputTarget"] ); + $this->SetOutputTargetDetails( $mySavedReport["outputTargetDetails"] ); $this->SetScheduleSettings( $mySavedReport["scheduleSettings"] ); } diff --git a/src/include/db_template.txt b/src/include/db_template.txt index ee2ccf9..ff3bf4e 100644 --- a/src/include/db_template.txt +++ b/src/include/db_template.txt @@ -168,14 +168,15 @@ CREATE TABLE `logcon_dbmappings` ( -- Table structure for table `logcon_savedreports` -- CREATE TABLE `logcon_savedreports` ( -`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -`reportid` VARCHAR( 255 ) NOT NULL , -`sourceid` INT NOT NULL , -`customTitle` VARCHAR( 255 ) NOT NULL , -`customComment` TEXT NOT NULL , -`filterString` TEXT NOT NULL , -`customFilters` TEXT NOT NULL , -`outputFormat` VARCHAR( 64 ) NOT NULL , -`outputTarget` TEXT NOT NULL , -`scheduleSettings` TEXT NOT NULL + `ID` int(11) NOT NULL auto_increment, + `reportid` varchar(255) NOT NULL, + `sourceid` int(11) NOT NULL, + `customTitle` varchar(255) NOT NULL, + `customComment` text NOT NULL, + `filterString` text NOT NULL, + `customFilters` text NOT NULL, + `outputFormat` varchar(64) NOT NULL, + `outputTarget` varchar(64) NOT NULL, + `outputTargetDetails` text NOT NULL, + `scheduleSettings` text NOT NULL, ) ENGINE=MyISAM COMMENT = 'Table to store saved reports'; diff --git a/src/include/db_update_v9.txt b/src/include/db_update_v9.txt index fac0733..6273340 100644 --- a/src/include/db_update_v9.txt +++ b/src/include/db_update_v9.txt @@ -1,15 +1,16 @@ -- New Database Structure Updates CREATE TABLE `logcon_savedreports` ( -`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -`reportid` VARCHAR( 255 ) NOT NULL , -`sourceid` INT NOT NULL , -`customTitle` VARCHAR( 255 ) NOT NULL , -`customComment` TEXT NOT NULL , -`filterString` TEXT NOT NULL , -`customFilters` TEXT NOT NULL , -`outputFormat` VARCHAR( 64 ) NOT NULL , -`outputTarget` TEXT NOT NULL , -`scheduleSettings` TEXT NOT NULL + `ID` int(11) NOT NULL auto_increment, + `reportid` varchar(255) NOT NULL, + `sourceid` int(11) NOT NULL, + `customTitle` varchar(255) NOT NULL, + `customComment` text NOT NULL, + `filterString` text NOT NULL, + `customFilters` text NOT NULL, + `outputFormat` varchar(64) NOT NULL, + `outputTarget` varchar(64) NOT NULL, + `outputTargetDetails` text NOT NULL, + `scheduleSettings` text NOT NULL, ) ENGINE=MyISAM COMMENT = 'Table to store saved reports'; -- Insert data diff --git a/src/include/functions_config.php b/src/include/functions_config.php index 6ddde10..5112ffd 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -367,6 +367,7 @@ function InitReportModules() DB_SAVEDREPORTS . ".customFilters, " . DB_SAVEDREPORTS . ".outputFormat, " . DB_SAVEDREPORTS . ".outputTarget, " . + DB_SAVEDREPORTS . ".outputTargetDetails, " . DB_SAVEDREPORTS . ".scheduleSettings " . " FROM " . DB_SAVEDREPORTS . " WHERE " . DB_SAVEDREPORTS . ".reportid = '" . $myReportID . "' " . diff --git a/src/templates/admin/admin_reports.html b/src/templates/admin/admin_reports.html index 0493810..3742c15 100644 --- a/src/templates/admin/admin_reports.html +++ b/src/templates/admin/admin_reports.html @@ -297,7 +297,7 @@