mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
2010-04-27 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_reporting.php: added render html for "text" and "sql" item. * include/ajax/reporting.ajax.php: added request for the custom SQL. * include/functions_db.php: in function "get_db_value_filter" fixed the field when the field is escape string. * godmode/reporting/reporting_builder.item_editor.php: added the preview of custom SQL. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2617 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f5626d8343
commit
d1d44ae5a7
@ -1,3 +1,16 @@
|
|||||||
|
2010-04-27 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_reporting.php: added render html for "text" and "sql"
|
||||||
|
item.
|
||||||
|
|
||||||
|
* include/ajax/reporting.ajax.php: added request for the custom SQL.
|
||||||
|
|
||||||
|
* include/functions_db.php: in function "get_db_value_filter" fixed the
|
||||||
|
field when the field is escape string.
|
||||||
|
|
||||||
|
* godmode/reporting/reporting_builder.item_editor.php: added the preview of
|
||||||
|
custom SQL.
|
||||||
|
|
||||||
2010-04-27 Sergio Martin <sergio.martin@artica.es>
|
2010-04-27 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* godmode/servers/manage_recontask_form.php: Avoided
|
* godmode/servers/manage_recontask_form.php: Avoided
|
||||||
|
@ -288,7 +288,11 @@ echo '<form action="' . $urlForm . '" method="post">';
|
|||||||
</tr>
|
</tr>
|
||||||
<tr id="row_custom" style="" class="datos">
|
<tr id="row_custom" style="" class="datos">
|
||||||
<td style="vertical-align: top;"><?php echo __('Custom SQL template'); ?></td>
|
<td style="vertical-align: top;"><?php echo __('Custom SQL template'); ?></td>
|
||||||
<td style=""><?php print_select_from_sql('SELECT id, name FROM treport_custom_sql', 'id_custom', $idCustom, '', '--', '0'); ?></td>
|
<td style=""><?php print_select_from_sql('SELECT id, name FROM treport_custom_sql', 'id_custom', $idCustom, 'chooseSQLquery()', '--', '0'); ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr id="row_custom_example">
|
||||||
|
<td style="vertical-align: top;"><?php echo __('SQL preview'); ?></td>
|
||||||
|
<td style="" id="sql_example"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="row_url" style="" class="datos">
|
<tr id="row_url" style="" class="datos">
|
||||||
<td style="vertical-align: top;"><?php echo __('URL'); ?></td>
|
<td style="vertical-align: top;"><?php echo __('URL'); ?></td>
|
||||||
@ -405,8 +409,37 @@ $(document).ready (function () {
|
|||||||
agent_module_autocomplete('#text-agent', '#hidden-id_agent', '#id_agent_module');
|
agent_module_autocomplete('#text-agent', '#hidden-id_agent', '#id_agent_module');
|
||||||
agent_module_autocomplete('#text-agent_sla', '#hidden-id_agent_sla', '#id_agent_module_sla');
|
agent_module_autocomplete('#text-agent_sla', '#hidden-id_agent_sla', '#id_agent_module_sla');
|
||||||
chooseType();
|
chooseType();
|
||||||
|
chooseSQLquery();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function chooseSQLquery() {
|
||||||
|
var idCustom = $("#id_custom").val();
|
||||||
|
|
||||||
|
if (idCustom == 0) {
|
||||||
|
$("#sql_example").html('');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#sql_example").html('<img src="images/spinner.gif" />');
|
||||||
|
|
||||||
|
var params = [];
|
||||||
|
params.push("get_custom_sql=1");
|
||||||
|
params.push("id=" + idCustom);
|
||||||
|
params.push("page=include/ajax/reporting.ajax");
|
||||||
|
jQuery.ajax ({
|
||||||
|
data: params.join ("&"),
|
||||||
|
type: 'POST',
|
||||||
|
url: action="ajax.php",
|
||||||
|
timeout: 10000,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (data) {
|
||||||
|
if (data['correct']) {
|
||||||
|
$("#sql_example").html(data['sql']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function deleteSLARow(id_row) {
|
function deleteSLARow(id_row) {
|
||||||
//ajax to delete
|
//ajax to delete
|
||||||
var params = [];
|
var params = [];
|
||||||
@ -501,6 +534,7 @@ function chooseType() {
|
|||||||
$("#row_field_separator").css('display', 'none');
|
$("#row_field_separator").css('display', 'none');
|
||||||
$("#row_line_separator").css('display', 'none');
|
$("#row_line_separator").css('display', 'none');
|
||||||
$("#sla_list").css('display', 'none');
|
$("#sla_list").css('display', 'none');
|
||||||
|
$("#row_custom_example").css('display', 'none');
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'simple_graph':
|
case 'simple_graph':
|
||||||
@ -569,6 +603,7 @@ function chooseType() {
|
|||||||
$("#row_query").css('display', '');
|
$("#row_query").css('display', '');
|
||||||
$("#row_header").css('display', '');
|
$("#row_header").css('display', '');
|
||||||
$("#row_custom").css('display', '');
|
$("#row_custom").css('display', '');
|
||||||
|
$("#row_custom_example").css('display', '');
|
||||||
break;
|
break;
|
||||||
case 'url':
|
case 'url':
|
||||||
$("#row_description").css('display', '');
|
$("#row_description").css('display', '');
|
||||||
|
@ -27,6 +27,7 @@ if (! give_acl ($config['id_user'], 0, "IW")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$delete_sla_item = get_parameter('delete_sla_item', 0);
|
$delete_sla_item = get_parameter('delete_sla_item', 0);
|
||||||
|
$get_custom_sql = get_parameter('get_custom_sql', 0);
|
||||||
$add_sla = get_parameter('add_sla', 0);
|
$add_sla = get_parameter('add_sla', 0);
|
||||||
$id = get_parameter('id', 0);
|
$id = get_parameter('id', 0);
|
||||||
|
|
||||||
@ -66,4 +67,19 @@ if ($add_sla) {
|
|||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($get_custom_sql) {
|
||||||
|
$sql = get_db_value_filter('`sql`', 'treport_custom_sql', array('id' => $id));
|
||||||
|
|
||||||
|
if ($result === false) {
|
||||||
|
$data['correct'] = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$data['correct'] = 1;
|
||||||
|
$data['sql'] = $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
?>
|
?>
|
@ -1677,7 +1677,9 @@ function get_db_value_filter ($field, $table, $filter, $where_join = 'AND') {
|
|||||||
if ($result === false)
|
if ($result === false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return $result[0][$field];
|
$fieldClean = str_replace('`', '', $field);
|
||||||
|
|
||||||
|
return $result[0][$fieldClean];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1576,6 +1576,72 @@ function render_report_html_item ($content, $table, $report) {
|
|||||||
$data[0] = get_agents_detailed_event_reporting ($content['id_agent'], $content['period'], $report["datetime"]);
|
$data[0] = get_agents_detailed_event_reporting ($content['id_agent'], $content['period'], $report["datetime"]);
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
break;
|
break;
|
||||||
|
case 'text':
|
||||||
|
$data = array();
|
||||||
|
$data[0] = "<h4>" . __('Text') . "</h4>";
|
||||||
|
array_push ($table->data, $data);
|
||||||
|
$table->colspan[0][0] = 2;
|
||||||
|
|
||||||
|
// Put description at the end of the module (if exists)
|
||||||
|
if ($content["description"] != ""){
|
||||||
|
$table->colspan[0][0] = 2;
|
||||||
|
$data_desc = array();
|
||||||
|
$data_desc[0] = $content["description"];
|
||||||
|
array_push ($table->data, $data_desc);
|
||||||
|
}
|
||||||
|
$data[0] = html_entity_decode($content['text']);
|
||||||
|
array_push($table->data, $data);
|
||||||
|
$table->colspan[2][0] = 2;
|
||||||
|
break;
|
||||||
|
case 'sql':
|
||||||
|
$data = array();
|
||||||
|
$data[0] = "<h4>" . __('SQL') . "</h4>";
|
||||||
|
array_push ($table->data, $data);
|
||||||
|
$table->colspan[0][0] = 2;
|
||||||
|
|
||||||
|
// Put description at the end of the module (if exists)
|
||||||
|
if ($content["description"] != ""){
|
||||||
|
$table->colspan[0][0] = 2;
|
||||||
|
$data_desc = array();
|
||||||
|
$data_desc[0] = $content["description"];
|
||||||
|
array_push ($table->data, $data_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table2->class = 'databox';
|
||||||
|
$table2->width = '100%';
|
||||||
|
|
||||||
|
//Create the head
|
||||||
|
$table2->head = array();
|
||||||
|
if ($content['header_definition'] != '') {
|
||||||
|
$table2->head = explode('|', $content['header_definition']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($content['treport_custom_sql_id'] != 0) {
|
||||||
|
$sql = get_db_value_filter('`sql`', 'treport_custom_sql', array('id' => $content['treport_custom_sql_id']));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql = $content['external_source'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = get_db_all_rows_sql($sql);
|
||||||
|
if ($result === false) {
|
||||||
|
$result = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($result[0])) {
|
||||||
|
if (count($result[0]) > count($table2->head)) {
|
||||||
|
$table2->head = array_pad($table2->head, count($result[0]), ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$table2->data = array();
|
||||||
|
foreach ($result as $row) {
|
||||||
|
array_push($table2->data, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cellContent = print_table($table2, true);
|
||||||
|
array_push($table->data, array($cellContent));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user