Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary report font code #1434

Merged
merged 12 commits into from
Sep 18, 2020
1 change: 0 additions & 1 deletion classes/DataWarehouse/Access/ReportGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ReportGenerator extends Common
const REPORT_ID_REGEX = '/^[0-9]+-(?(?=autogenerated)autogenerated-[a-z]+|[0-9\.]+)$/';
const REPORT_DATE_REGEX = '/^[0-9]{4}(-[0-9]{2}){2}$/';
const REPORT_FORMATS_REGEX = '/^doc|pdf$/';
const REPORT_FONT_REGEX = '/^Arial$/';
const REPORT_SCHEDULE_REGEX = '/^Once|Daily|Weekly|Monthly|Quarterly|Semi-annually|Annually$/';
const REPORT_DELIVERY_REGEX = '/^E-Mail$/';

Expand Down
1 change: 0 additions & 1 deletion classes/ReportTemplates/GenericReportTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function buildReportFromTemplate(array &$params = array(), $report_id_suf
$this->_report_skeleton['general']['title'],
$this->_report_skeleton['general']['header'],
$this->_report_skeleton['general']['footer'],
$this->_report_skeleton['general']['font'],
$this->_report_skeleton['general']['format'],
$this->_report_skeleton['general']['charts_per_page'],
$this->_report_skeleton['general']['schedule'],
Expand Down
1 change: 0 additions & 1 deletion classes/ReportTemplates/ParameterizedReportTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function buildReportFromTemplate(array &$params = array(), $report_id_suf
$report_title,
$report_header,
$report_footer,
$this->_report_skeleton['general']['font'],
$this->_report_skeleton['general']['format'],
$this->_report_skeleton['general']['charts_per_page'],
$this->_report_skeleton['general']['schedule'],
Expand Down
68 changes: 16 additions & 52 deletions classes/XDReportManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public function configureSelectedReport(
$report_title,
$report_header,
$report_footer,
$report_font,
$report_format,
$charts_per_page,
$report_schedule,
Expand All @@ -112,7 +111,6 @@ public function configureSelectedReport(
$this->_report_title = $report_title;
$this->_report_header = $report_header;
$this->_report_footer = $report_footer;
$this->_report_font = $report_font;
$this->_report_format = $report_format;
$this->_charts_per_page = $charts_per_page;
$this->_report_schedule = $report_schedule;
Expand All @@ -134,7 +132,6 @@ public function saveThisReport()
title = :report_title,
header = :report_header,
footer = :report_footer,
font = :font,
charts_per_page = :charts_per_page,
format = :format,
schedule = :schedule,
Expand All @@ -146,7 +143,6 @@ public function saveThisReport()
'report_title' => $this->_report_title,
'report_header' => $this->_report_header,
'report_footer' => $this->_report_footer,
'font' => $this->_report_font,
'charts_per_page' => $this->_charts_per_page,
'format' => $this->_report_format,
'schedule' => $this->_report_schedule,
Expand All @@ -156,11 +152,13 @@ public function saveThisReport()
);
}

private function fontWrapper($text, $font_name, $font_size = 12)
private function fontWrapper($text, $font_size = 12)
{
return '<span style="font-family: ' . strtolower($font_name)
. '; font-size: ' . $font_size . 'px">' . $text . '</span>';

return sprintf(
'<span style="font-family: arial, sans-serif; font-size: %dpx">%s</span>',
$font_size,
$text
);
}

public static function sanitizeFilename($filename)
Expand All @@ -175,8 +173,6 @@ public function getPreviewData($report_id, $token, $charts_per_page)
{
$report_data = $this->loadReportData($report_id, false);

$report_font = $report_data['general']['font'];

$rData = array();
$chartSlot = array();

Expand Down Expand Up @@ -224,12 +220,12 @@ public function getPreviewData($report_id, $token, $charts_per_page)
}

$chartSlot[$suffix] = array(
'report_title' => (count($rData) == 0 && !empty($report_data['general']['title'])) ? $this->fontWrapper($report_data['general']['title'], $report_font, 22) . '<br />' : '',
'header_text' => $this->fontWrapper($report_data['general']['header'], $report_font, 12),
'footer_text' => $this->fontWrapper($report_data['general']['footer'], $report_font, 12),
'chart_title_' . $suffix => $this->fontWrapper($report_chart['chart_title'], $report_font, 16),
'chart_drill_details_' . $suffix => $this->fontWrapper($report_chart['chart_drill_details'], $report_font, 12),
'chart_timeframe_' . $suffix => $this->fontWrapper($report_chart['chart_date_description'], $report_font, 14),
'report_title' => (count($rData) == 0 && !empty($report_data['general']['title'])) ? $this->fontWrapper($report_data['general']['title'], 22) . '<br />' : '',
'header_text' => $this->fontWrapper($report_data['general']['header'], 12),
'footer_text' => $this->fontWrapper($report_data['general']['footer'], 12),
'chart_title_' . $suffix => $this->fontWrapper($report_chart['chart_title'], 16),
'chart_drill_details_' . $suffix => $this->fontWrapper($report_chart['chart_drill_details'], 12),
'chart_timeframe_' . $suffix => $this->fontWrapper($report_chart['chart_date_description'], 14),
'chart_id_' . $suffix => '/report_image_renderer.php?type=report&ref=' . $report_id . ';' . $report_chart['ordering']
);

Expand Down Expand Up @@ -286,7 +282,6 @@ public function insertThisReport($report_derivation_method = 'Manual')
title,
header,
footer,
font,
format,
schedule,
delivery,
Expand All @@ -300,7 +295,6 @@ public function insertThisReport($report_derivation_method = 'Manual')
:report_title,
:report_header,
:report_footer,
:report_font,
:report_format,
:report_schedule,
:report_delivery,
Expand All @@ -316,7 +310,6 @@ public function insertThisReport($report_derivation_method = 'Manual')
'report_title' => $this->_report_title,
'report_header' => $this->_report_header,
'report_footer' => $this->_report_footer,
'report_font' => $this->_report_font,
'report_format' => $this->_report_format,
'report_schedule' => $this->_report_schedule,
'report_delivery' => $this->_report_delivery,
Expand Down Expand Up @@ -560,7 +553,6 @@ public function loadReportData($report_id)
footer,
format,
charts_per_page,
font,
schedule,
delivery
FROM Reports
Expand Down Expand Up @@ -591,7 +583,6 @@ public function loadReportData($report_id)
$return_data['general']['footer'] = $results[0]['footer'];
$return_data['general']['format'] = $results[0]['format'];
$return_data['general']['charts_per_page'] = $results[0]['charts_per_page'];
$return_data['general']['font'] = $results[0]['font'];
$return_data['general']['schedule'] = $results[0]['schedule'];
$return_data['general']['delivery'] = $results[0]['delivery'];

Expand Down Expand Up @@ -966,23 +957,6 @@ public function getReportFormat($report_id)
return $results[0]['format'];
}

public function getReportFont($report_id)
{
$results = $this->_pdo->query(
"
SELECT font
FROM Reports
WHERE user_id = :user_id AND report_id = :report_id
",
array(
'user_id' => $this->_user_id,
'report_id' => $report_id,
)
);

return $results[0]['font'];
}

public function getReportName($report_id, $sanitize = false)
{
$results = $this->_pdo->query(
Expand Down Expand Up @@ -1597,8 +1571,8 @@ public function generateChartBlob(
/*
* writeXMLConfiguration()
*
* This function generates the XML configuration file and image files for
* processing by jasper-builder. The files are placed in the supplied
* This function generates the XML configuration file and image files for
* processing by jasper-builder. The files are placed in the supplied
* directory (which must exist)
*
* \param outputdir the name of an existing, writable directory in which to put the files.
Expand Down Expand Up @@ -1811,8 +1785,6 @@ public function buildReport($report_id, $export_format)

$report_format = ($export_format != null) ? $export_format : $this->getReportFormat($report_id);

$report_font = $this->getReportFont($report_id);

// Initialize a temporary working directory for the report generation
$template_path = tempnam(sys_get_temp_dir(), $report_id . '-');

Expand All @@ -1829,8 +1801,6 @@ public function buildReport($report_id, $export_format)
}

// Copy all report templates into this working directory
// (All templates? Probably want to copy just the template of
// interest -- dictated by the font)

$paths = glob("$base_path/*.jrxml");

Expand Down Expand Up @@ -1859,7 +1829,6 @@ public function buildReport($report_id, $export_format)
$template_path,
$report_file_name,
$report_template,
$report_font,
$log_file
);

Expand All @@ -1884,14 +1853,12 @@ public function buildReport($report_id, $export_format)
* @param string $templatePath Directory containing template files.
* @param string $reportFileName Name used for report files.
* @param string $reportTemplate Template name.
* @param string $reportFont Report font name.
* @param string $logFile Log file name.
*/
protected function executeReportBuilder(
$templatePath,
$reportFileName,
$reportTemplate = 'template',
$reportFont = 'Arial',
$logFile = 'build.log'
) {
$builderPath = $templatePath;
Expand All @@ -1912,9 +1879,7 @@ protected function executeReportBuilder(
'mail' => false,
));

$templateFile = "$reportTemplate.$reportFont";

$logger->info("Using template $templateFile");
$logger->info("Using template $reportTemplate");

$currentDir = getcwd();
chdir($builderPath);
Expand Down Expand Up @@ -1952,7 +1917,7 @@ protected function executeReportBuilder(
$outputDir,
$outputFile,
$templateDir,
$templateFile,
$reportTemplate
);

$cmd = implode(' ', array_map('escapeshellarg', $args));
Expand Down Expand Up @@ -2150,7 +2115,6 @@ public static function retrieveReportTemplate($user, $template_id)
header,
footer,
format,
font,
schedule,
delivery,
charts_per_page
Expand Down
17 changes: 17 additions & 0 deletions configuration/etl/etl.d/xdmod-migration-9_0_0-9_5_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@
"schema": "moddb"
}
}
},
{
"name": "update-moddb-tables",
"description": "Update moddb tables",
"class": "ManageTables",
"definition_file_list": [
"xdb/report-templates.json",
"xdb/reports.json"
],
"endpoints": {
"destination": {
"type": "mysql",
"name": "XDMoD Database",
"config": "database",
"schema": "moddb"
}
}
}
]
}
8 changes: 4 additions & 4 deletions configuration/etl/etl_data.d/xdb/report-templates.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
["id", "name", "description", "template", "title", "header", "footer", "format", "font", "schedule", "delivery", "charts_per_page", "use_submenu"],
[1, "Quarterly Report - Center Director", "Quarterly Report - Center Director", "GenericReportTemplate", "Quarterly Report - Center Director", "", "", "Pdf", "Arial", "Quarterly", "E-mail", 1, 0],
[2, "Dashboard Tab Report", "Dashboard Tab Report", "GenericReportTemplate", "Dashboard Tab Report", "", "", "Pdf", "Arial", "Once", "E-mail", 1, 0],
[3, "Dashboard Tab Report", "Dashboard Tab Report", "GenericReportTemplate", "Dashboard Tab Report", "", "", "Pdf", "Arial", "Once", "E-mail", 1, 0]
["id", "name", "description", "template", "title", "header", "footer", "format", "schedule", "delivery", "charts_per_page", "use_submenu"],
[1, "Quarterly Report - Center Director", "Quarterly Report - Center Director", "GenericReportTemplate", "Quarterly Report - Center Director", "", "", "Pdf", "Quarterly", "E-mail", 1, 0],
[2, "Dashboard Tab Report", "Dashboard Tab Report", "GenericReportTemplate", "Dashboard Tab Report", "", "", "Pdf", "Once", "E-mail", 1, 0],
[3, "Dashboard Tab Report", "Dashboard Tab Report", "GenericReportTemplate", "Dashboard Tab Report", "", "", "Pdf", "Once", "E-mail", 1, 0]
]
5 changes: 0 additions & 5 deletions configuration/etl/etl_tables.d/xdb/report-templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
"type": "enum('Pdf','Pptx','Doc','Xls','Html')",
"nullable": true
},
{
"name": "font",
"type": "enum('Times','Arial')",
"nullable": true
},
{
"name": "schedule",
"type": "enum('Once','Daily','Weekly','Monthly','Quarterly','Semi-annually','Annually')",
Expand Down
6 changes: 0 additions & 6 deletions configuration/etl/etl_tables.d/xdb/reports.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@
"nullable": false,
"default": "Pdf"
},
{
"name": "font",
"type": "enum('Times','Arial')",
"nullable": false,
"default": "Arial"
},
{
"name": "schedule",
"type": "enum('Once','Daily','Weekly','Monthly','Quarterly','Semi-annually','Annually')",
Expand Down
Loading