fix exportation/exportation

This commit is contained in:
Daniel Barbero Martin 2020-10-23 10:47:03 +02:00
parent 002509500c
commit bebac548d3
2 changed files with 65 additions and 24 deletions

View File

@ -92,7 +92,11 @@ function output_xml_report($id)
$group = db_get_value('nombre', 'tgrupo', 'id_grupo', $report['id_group']); $group = db_get_value('nombre', 'tgrupo', 'id_grupo', $report['id_group']);
echo '<group><![CDATA['.io_safe_output($group)."]]></group>\n"; echo '<group><![CDATA['.io_safe_output($group)."]]></group>\n";
$items = db_get_all_rows_field_filter('treport_content', 'id_report', $report['id_report']); $items = db_get_all_rows_field_filter(
'treport_content',
'id_report',
$report['id_report']
);
foreach ($items as $item) { foreach ($items as $item) {
echo "<item>\n"; echo "<item>\n";
echo '<type>'.io_safe_output($item['type'])."</type>\n"; echo '<type>'.io_safe_output($item['type'])."</type>\n";

View File

@ -37,8 +37,16 @@ function insert_item_report($report_id, $values)
ui_print_result_message( ui_print_result_message(
$result, $result,
sprintf(__("Success add '%s' item in report '%s'."), $values['type'], $name), sprintf(
sprintf(__("Error create '%s' item in report '%s'."), $values['type'], $name) __("Success add '%s' item in report '%s'."),
$values['type'],
$name
),
sprintf(
__("Error create '%s' item in report '%s'."),
$values['type'],
$name
)
); );
} }
} }
@ -55,9 +63,12 @@ function process_upload_xml_report($xml, $group_filter=0)
$posible_name = $values['name']; $posible_name = $values['name'];
$exist = true; $exist = true;
$loops = 30; $loops = 30;
// Loops to exit or tries // Loops to exit or tries.
while ($exist && $loops > 0) { while ($exist && $loops > 0) {
$exist = (bool) db_get_row_filter('treport', ['name' => io_safe_input($posible_name)]); $exist = (bool) db_get_row_filter(
'treport',
['name' => io_safe_input($posible_name)]
);
if ($exist) { if ($exist) {
$loops--; $loops--;
@ -74,7 +85,7 @@ function process_upload_xml_report($xml, $group_filter=0)
); );
break; break;
} else if ($loops != 30) { } else if ($loops != 30) {
ui_print_error_message( ui_print_warning_message(
sprintf( sprintf(
__("Warning create '%s' report, the name exist, the report have a name %s."), __("Warning create '%s' report, the name exist, the report have a name %s."),
$reportElement->name, $reportElement->name,
@ -89,13 +100,22 @@ function process_upload_xml_report($xml, $group_filter=0)
break; break;
} }
$id_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $reportElement->group); if (isset($reportElement->group) === true
&& empty($reportElement->group) === false
) {
$id_group = db_get_value(
'id_grupo',
'tgrupo',
'nombre',
$reportElement->group
);
if ($id_group === false) { if ($id_group === false) {
ui_print_error_message(__("Error the report haven't group.")); ui_print_error_message(__("Error the report haven't group."));
break; break;
} }
}
if (isset($reportElement->description)) { if (isset($reportElement->description) === true) {
$values['description'] = $reportElement->description; $values['description'] = $reportElement->description;
} }
@ -108,9 +128,19 @@ function process_upload_xml_report($xml, $group_filter=0)
); );
if ($id_report) { if ($id_report) {
db_pandora_audit('Report management', 'Create report '.$id_report, false, false); db_pandora_audit(
'Report management',
'Create report '.$id_report,
false,
false
);
} else { } else {
db_pandora_audit('Report management', 'Fail to create report', false, false); db_pandora_audit(
'Report management',
'Fail to create report',
false,
false
);
break; break;
} }
@ -119,45 +149,52 @@ function process_upload_xml_report($xml, $group_filter=0)
$values = []; $values = [];
$values['id_report'] = $id_report; $values['id_report'] = $id_report;
if (isset($item['description'])) { if (isset($item['description']) === true) {
$values['description'] = io_safe_input($item['description']); $values['description'] = io_safe_input($item['description']);
} }
if (isset($item['period'])) { if (isset($item['period']) === true) {
$values['period'] = io_safe_input($item['period']); $values['period'] = io_safe_input($item['period']);
} }
if (isset($item['type'])) { if (isset($item['type']) === true) {
$values['type'] = io_safe_input($item['type']); $values['type'] = io_safe_input($item['type']);
} }
$agents_item = []; $agents_item = [];
if (isset($item['agent'])) { if (isset($item['agent']) === true) {
$agents = agents_get_agents( $agents = agents_get_agents(
['id_grupo' => $group_filter], ['id_grupo' => $group_filter],
[ [
'id_agente', 'id_agente',
'nombre', 'alias',
] ]
); );
$agent_clean = str_replace(['[', ']'], '', $item['agent']); $agent_clean = str_replace(
[
'[',
']',
],
'',
io_safe_output($item['agent'])
);
$regular_expresion = ($agent_clean != $item['agent']); $regular_expresion = ($agent_clean != $item['agent']);
foreach ($agents as $agent) { foreach ($agents as $agent) {
if ($regular_expresion) { if ($regular_expresion) {
if ((bool) preg_match('/'.$agent_clean.'/', io_safe_output($agent['nombre']))) { if ((bool) preg_match('/'.$agent_clean.'/', io_safe_output($agent['alias']))) {
$agents_item[$agent['id_agente']]['name'] = $agent['nombre']; $agents_item[$agent['id_agente']]['name'] = $agent['alias'];
} }
} else { } else {
if ($agent_clean == io_safe_output($agent['nombre'])) { if ($agent_clean == io_safe_output($agent['alias'])) {
$agents_item[$agent['id_agente']]['name'] = $agent['nombre']; $agents_item[$agent['id_agente']]['name'] = $agent['alias'];
} }
} }
} }
} }
if (isset($item['module'])) { if (isset($item['module']) === true) {
$module_clean = str_replace(['[', ']'], '', $item['module']); $module_clean = str_replace(['[', ']'], '', $item['module']);
$regular_expresion = ($module_clean != $item['module']); $regular_expresion = ($module_clean != $item['module']);