fixed report pdf

Former-commit-id: 442a90512fbb244154749ddefe0007cef65655c5
This commit is contained in:
daniel 2019-02-08 14:10:19 +01:00
parent 4d4b8bbc0d
commit 16c742bd83
3 changed files with 136 additions and 96 deletions

View File

@ -1822,35 +1822,36 @@ function html_get_predefined_table($model='transparent', $columns=4)
* Print a nicely formatted table. Code taken from moodle. * Print a nicely formatted table. Code taken from moodle.
* *
* @param object Object with several properties: * @param object Object with several properties:
* $table->head - An array of heading names. * $table->head - An array of heading names.
* $table->head_colspan - An array of colspans of each head column. * $table->head_colspan - An array of colspans of each head column.
* $table->headstyle - An array of styles of each head column. * $table->headstyle - An array of styles of each head column.
* $table->align - An array of column alignments * $table->align - An array of column alignments
* $table->valign - An array of column alignments * $table->valign - An array of column alignments
* $table->size - An array of column sizes * $table->size - An array of column sizes
* $table->wrap - An array of "nowrap"s or nothing * $table->wrap - An array of "nowrap"s or nothing
* $table->style - An array of personalized style for each column. * $table->style - An array of personalized style for each column.
* $table->rowid - An array of personalized ids of each row. * $table->rowid - An array of personalized ids of each row.
* $table->rowstyle - An array of personalized style of each row. * $table->rowstyle - An array of personalized style of each row.
* $table->rowclass - An array of personalized classes of each row (odd-evens classes will be ignored). * $table->rowclass - An array of personalized classes of each row (odd-evens classes will be ignored).
* $table->colspan - An array of colspans of each column. * $table->colspan - An array of colspans of each column.
* $table->rowspan - An array of rowspans of each column. * $table->rowspan - An array of rowspans of each column.
* $table->data[] - An array of arrays containing the data. * $table->data[] - An array of arrays containing the data.
* $table->width - A percentage of the page * $table->width - A percentage of the page
* $table->border - Border of the table. * $table->border - Border of the table.
* $table->tablealign - Align the whole table (float left or right) * $table->tablealign - Align the whole table (float left or right)
* $table->cellpadding - Padding on each cell * $table->cellpadding - Padding on each cell
* $table->cellspacing - Spacing between cells * $table->cellspacing - Spacing between cells
* $table->cellstyle - Style of a cell * $table->cellstyle - Style of a cell
* $table->cellclass - Class of a cell * $table->cellclass - Class of a cell
* $table->class - CSS table class * $table->class - CSS table class
* $table->id - Table ID (useful in JavaScript) * $table->id - Table ID (useful in JavaScript)
* $table->headclass[] - An array of classes for each heading * $table->headclass[] - An array of classes for each heading
* $table->title - Title of the table is a single string that will be on top of the table in the head spanning the whole table * $table->title - Title of the table is a single string that will be on top of the table in the head spanning the whole table
* $table->titlestyle - Title style * $table->titlestyle - Title style
* $table->titleclass - Title class * $table->titleclass - Title class
* $table->styleTable - Table style * $table->styleTable - Table style
* $table->caption - Table title * $table->caption - Table title
* $table->pdf_report - Table repeat title conteiner.
* @param bool Whether to return an output string or echo now * @param bool Whether to return an output string or echo now
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
@ -2990,4 +2991,3 @@ function html_print_csrf_error()
); );
return true; return true;
} }

View File

@ -672,26 +672,27 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0)
true true
); );
} else { } else {
$return_pdf .= '<tr><td colspan=3>'; $table1->title = $item['title'];
$table1->titleclass = 'title_table_pdf';
$table1->titlestyle = 'text-align:left;';
$return_pdf .= html_print_table( $return_pdf .= html_print_table(
$table1, $table1,
true true
); );
$return_pdf .= '</td></tr>'; $table2->title = $item['title'];
$table2->titleclass = 'title_table_pdf';
$return_pdf .= '<tr><td colspan=3>'; $table2->titlestyle = 'text-align:left;';
$return_pdf .= html_print_table( $return_pdf .= html_print_table(
$table2, $table2,
true true
); );
$return_pdf .= '</td></tr>'; $table3->title = $item['title'];
$table3->titleclass = 'title_table_pdf';
$return_pdf .= '<tr><td colspan=3>'; $table3->titlestyle = 'text-align:left;';
$return_pdf .= html_print_table( $return_pdf .= html_print_table(
$table3, $table3,
true true
); );
$return_pdf .= '</td></tr>';
} }
} else { } else {
$table->colspan['error']['cell'] = 3; $table->colspan['error']['cell'] = 3;
@ -699,82 +700,83 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0)
} }
if (!empty($item['charts'])) { if (!empty($item['charts'])) {
/* $table1 = new stdClass();
$table1 = new stdClass(); $table1->width = '99%';
$table1->width = '99%'; $table1->size = [];
$table1->size = []; $table1->size[0] = '10%';
$table1->size[0] = '10%';
$table1->data = []; $table1->data = [];
foreach ($item['charts'] as $chart) { foreach ($item['charts'] as $chart) {
$table1->data[] = [ $table1->data[] = [
$chart['agent'].'<br />'.$chart['module'], $chart['agent'].'<br />'.$chart['module'],
$chart['chart'], $chart['chart'],
]; ];
} }
if ($pdf === 0) { if ($pdf === 0) {
$table->colspan['charts']['cell'] = 2; $table->colspan['charts']['cell'] = 2;
$table->data['charts']['cell'] = html_print_table( $table->data['charts']['cell'] = html_print_table(
$table1, $table1,
true true
); );
} else { } else {
$table1->title = $item['title'];
$table1->titleclass = 'title_table_pdf';
$table1->titlestyle = 'text-align:left;';
$return_pdf .= html_print_table( $return_pdf .= html_print_table(
$table1, $table1,
true true
); );
} }
// Table_legend_graphs. // Table_legend_graphs.
$table1 = new stdClass(); $table1 = new stdClass();
$table1->width = '99%'; $table1->width = '99%';
$table1->data = []; $table1->data = [];
$table1->size = []; $table1->size = [];
$table1->size[0] = '2%'; $table1->size[0] = '2%';
$table1->data[0][0] = '<img src ="'.$src.'images/square_green.png">'; $table1->data[0][0] = '<img src ="'.$src.'images/square_green.png">';
$table1->size[1] = '14%'; $table1->size[1] = '14%';
$table1->data[0][1] = '<span>'.__('OK').'</span>'; $table1->data[0][1] = '<span>'.__('OK').'</span>';
$table1->size[2] = '2%'; $table1->size[2] = '2%';
$table1->data[0][2] = '<img src ="'.$src.'images/square_red.png">'; $table1->data[0][2] = '<img src ="'.$src.'images/square_red.png">';
$table1->size[3] = '14%'; $table1->size[3] = '14%';
$table1->data[0][3] = '<span>'.__('Critical').'</span>'; $table1->data[0][3] = '<span>'.__('Critical').'</span>';
$table1->size[4] = '2%'; $table1->size[4] = '2%';
$table1->data[0][4] = '<img src ="'.$src.'images/square_gray.png">'; $table1->data[0][4] = '<img src ="'.$src.'images/square_gray.png">';
$table1->size[5] = '14%'; $table1->size[5] = '14%';
$table1->data[0][5] = '<span>'.__('Unknow').'</span>'; $table1->data[0][5] = '<span>'.__('Unknow').'</span>';
$table1->size[6] = '2%'; $table1->size[6] = '2%';
$table1->data[0][6] = '<img src ="'.$src.'images/square_blue.png">'; $table1->data[0][6] = '<img src ="'.$src.'images/square_blue.png">';
$table1->size[7] = '14%'; $table1->size[7] = '14%';
$table1->data[0][7] = '<span>'.__('Not Init').'</span>'; $table1->data[0][7] = '<span>'.__('Not Init').'</span>';
$table1->size[8] = '2%'; $table1->size[8] = '2%';
$table1->data[0][8] = '<img src ="'.$src.'images/square_violet.png">'; $table1->data[0][8] = '<img src ="'.$src.'images/square_violet.png">';
$table1->size[9] = '14%'; $table1->size[9] = '14%';
$table1->data[0][9] = '<span>'.__('Downtimes').'</span>'; $table1->data[0][9] = '<span>'.__('Downtimes').'</span>';
$table1->size[10] = '2%'; $table1->size[10] = '2%';
$table1->data[0][10] = '<img src ="'.$src.'images/square_light_gray.png">'; $table1->data[0][10] = '<img src ="'.$src.'images/square_light_gray.png">';
$table1->size[11] = '15%'; $table1->size[11] = '15%';
$table1->data[0][11] = '<span>'.__('Ignore time').'</span>'; $table1->data[0][11] = '<span>'.__('Ignore time').'</span>';
if ($pdf === 0) { if ($pdf === 0) {
$table->colspan['legend']['cell'] = 2; $table->colspan['legend']['cell'] = 2;
$table->data['legend']['cell'] = html_print_table( $table->data['legend']['cell'] = html_print_table(
$table1, $table1,
true true
); );
} else { } else {
$return_pdf .= html_print_table( $return_pdf .= html_print_table(
$table1, $table1,
true true
); );
} }
*/
} }
} }
@ -2348,13 +2350,28 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e
} }
function reporting_html_increment(&$table, $item) /**
* Show a brief analysis in which the variation of the value
* of the indicated module is indicated.
*
* @param string $table
* @param array $item
* @param integer $pdf
* @return html
*/
function reporting_html_increment($table, $item, $pdf=0)
{ {
global $config; global $config;
$return_pdf = '';
if (isset($item['data']['error'])) { if (isset($item['data']['error'])) {
$table->colspan['error']['cell'] = 3; if ($pdf === 0) {
$table->data['error']['cell'] = $item['data']['message']; $table->colspan['error']['cell'] = 3;
$table->data['error']['cell'] = $item['data']['message'];
} else {
$return_pdf = $item['data']['message'];
}
} else { } else {
$table1 = new stdClass(); $table1 = new stdClass();
$table1->width = '99%'; $table1->width = '99%';
@ -2403,9 +2420,17 @@ function reporting_html_increment(&$table, $item)
$table1->data[] = $table1_row; $table1->data[] = $table1_row;
$data = []; if ($pdf === 0) {
$data[0] = html_print_table($table1, true); $data = [];
array_push($table->data, $data); $data[0] = html_print_table($table1, true);
array_push($table->data, $data);
} else {
$return_pdf = html_print_table($table1, true);
}
}
if ($pdf !== 0) {
return $return_pdf;
} }
} }

View File

@ -48,6 +48,12 @@ thead.header_tr tr th.th_first {
text-align: left; text-align: left;
} }
thead.header_tr tr th.th_description {
background-color: #f5f5f5;
color: #1c1c1c;
text-align: justify;
}
table.table_beauty { table.table_beauty {
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
@ -57,3 +63,12 @@ table.table_beauty tbody tr td {
padding: 5px; padding: 5px;
border: 0.1pt solid #acacac; border: 0.1pt solid #acacac;
} }
table.databox {
margin-bottom: 20px;
}
th.title_table_pdf {
background-color: #acacac;
padding: 15px;
}