2011-12-01 Sergio Martin <sergio.martin@artica.es>

* extensions/insert_data.php: Improved the error message to
	multiple xml creations (csv) bug: 3426375



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5222 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-12-01 09:53:49 +00:00
parent 8d883f2e79
commit 2a06505f44
2 changed files with 40 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2011-12-01 Sergio Martin <sergio.martin@artica.es>
* extensions/insert_data.php: Improved the error message to
multiple xml creations (csv) bug: 3426375
2011-11-30 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_config.php: Login hash pass can be left blank.

View File

@ -41,10 +41,10 @@ function createXMLData($agent, $agentModule, $time, $data) {
io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data);
if (false === @file_put_contents($config['remote_config'] . '/' . io_safe_output($agent['nombre']) . '.' . strtotime($time) . '.data', $xml)) {
ui_print_error_message(sprintf(__('Can\'t save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']));
return false;
}
else {
ui_print_success_message(sprintf(__('Save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']));
return true;
}
}
@ -91,18 +91,49 @@ function mainInsertData() {
$date_xml = $date2 . ' ' . $time2 . ':00';
$done = 0;
$errors = 0;
if ($csv !== false) {
$file = file($csv['tmp_name']);
foreach ($file as $line) {
$tokens = explode(';', $line);
createXMLData($agent, $agentModule, trim($tokens[0]), trim($tokens[1]));
$result = createXMLData($agent, $agentModule, trim($tokens[0]), trim($tokens[1]));
if($result) {
$done++;
}
else {
$errors++;
}
}
}
else {
createXMLData($agent, $agentModule, $date_xml, $data);
$result = createXMLData($agent, $agentModule, $date_xml, $data);
if($result) {
$done++;
}
else {
$errors++;
}
}
}
if($errors > 0) {
$msg = sprintf(__('Can\'t save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']);
if($errors > 1) {
$msg .= " ($errors)";
}
ui_print_error_message($msg);
}
if($done > 0){
$msg = sprintf(__('Save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']);
if($done > 1) {
$msg .= " ($done)";
}
ui_print_success_message($msg);
}
}
echo '<div class="notify">';