2012-06-06 Hirofumi Kosaka <kosaka@rworks.jp>
* godmode/agentes/planned_downtime.php: fixed that 'Affect' column at 'planned downtime' may show bad values. cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
308300903b
commit
d349c0ebf3
|
@ -1,3 +1,9 @@
|
|||
2012-06-06 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||
|
||||
* godmode/agentes/planned_downtime.php: fixed that 'Affect'
|
||||
column at 'planned downtime' may show bad values. cleaned
|
||||
source code style.
|
||||
|
||||
2012-06-05 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||
|
||||
* operation/tree.php: Fixed a missing group icons
|
||||
|
|
|
@ -87,9 +87,9 @@ if ($stop_downtime == 1){
|
|||
// INSERT A NEW DOWNTIME_AGENT ASSOCIATION
|
||||
if ($insert_downtime_agent == 1){
|
||||
$agents = $_POST["id_agent"];
|
||||
for ($a=0;$a <count($agents); $a++){
|
||||
for ($a=0;$a <count($agents); $a++){
|
||||
$id_agente_dt = $agents[$a];
|
||||
|
||||
|
||||
$values = array(
|
||||
'id_downtime' => $id_downtime,
|
||||
'id_agent' => $id_agente_dt);
|
||||
|
@ -101,14 +101,14 @@ if ($insert_downtime_agent == 1){
|
|||
if ($delete_downtime_agent == 1){
|
||||
|
||||
$id_da = get_parameter ("id_downtime_agent");
|
||||
|
||||
|
||||
$result = db_process_sql_delete('tplanned_downtime_agents', array('id' => $id_da));
|
||||
}
|
||||
|
||||
// DELETE WHOLE DOWNTIME!
|
||||
if ($delete_downtime) {
|
||||
$result = db_process_sql_delete('tplanned_downtime', array('id' => $id_downtime));
|
||||
|
||||
|
||||
$result2 = db_process_sql_delete('tplanned_downtime_agents', array('id' => $id_downtime));
|
||||
|
||||
if (($result === false) OR ($result2 === false)){
|
||||
|
@ -125,10 +125,10 @@ if ($create_downtime || $update_downtime) {
|
|||
$description = (string) get_parameter ('description');
|
||||
$name = (string) get_parameter ('name');
|
||||
$check = db_get_value ('name', 'tplanned_downtime', 'name', $name);
|
||||
|
||||
|
||||
$datetime_from = strtotime ($date_from.' '.$time_from);
|
||||
$datetime_to = strtotime ($date_to.' '.$time_to);
|
||||
|
||||
|
||||
if ($datetime_from > $datetime_to) {
|
||||
echo '<h3 class="error">'.__('Not created. Error inserting data').': START > END</h3>';
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ if ($create_downtime || $update_downtime) {
|
|||
echo '<h3 class="error">'.__('Planned downtime must have a name').'</h3>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
if($create_downtime) {
|
||||
echo '<h3 class="error">'.__('Could not be created').'</h3>';
|
||||
|
@ -193,91 +193,91 @@ if ($create_downtime || $update_downtime) {
|
|||
////////////////////////////////
|
||||
// Show create / update form
|
||||
////////////////////////////////
|
||||
if (($first_create != 0) OR ($first_update != 0)){
|
||||
// Have any data to show ?
|
||||
if ($id_downtime > 0) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ("SELECT `id`, `name`, `description`, `date_from`, `date_to`, `id_group`, `only_alerts`
|
||||
FROM `tplanned_downtime` WHERE `id` = %d",
|
||||
$id_downtime);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ("SELECT \"id\", \"name\", \"description\", \"date_from\", \"date_to\", \"id_group\", \"only_alerts\"
|
||||
FROM \"tplanned_downtime\" WHERE \"id\" = %d",
|
||||
$id_downtime);
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = sprintf ("SELECT id, name, description, date_from, date_to, id_group, only_alerts
|
||||
FROM tplanned_downtime WHERE id = %d",
|
||||
$id_downtime);
|
||||
break;
|
||||
}
|
||||
|
||||
$result = db_get_row_sql ($sql);
|
||||
$name = $result["name"];
|
||||
$description = $result["description"];
|
||||
$date_from = strftime ('%Y-%m-%d', $result["date_from"]);
|
||||
$date_to = strftime ('%Y-%m-%d', $result["date_to"]);
|
||||
$time_from = strftime ('%I:%M%p', $result["date_from"]);
|
||||
$time_to = strftime ('%I:%M%p', $result["date_to"]);
|
||||
$only_alerts = $result["only_alerts"];
|
||||
|
||||
if ($id_group == 0)
|
||||
$id_group = $result['id_group'];
|
||||
if (($first_create != 0) OR ($first_update != 0)){
|
||||
// Have any data to show ?
|
||||
if ($id_downtime > 0) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ("SELECT `id`, `name`, `description`, `date_from`, `date_to`, `id_group`, `only_alerts`
|
||||
FROM `tplanned_downtime` WHERE `id` = %d",
|
||||
$id_downtime);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ("SELECT \"id\", \"name\", \"description\", \"date_from\", \"date_to\", \"id_group\", \"only_alerts\"
|
||||
FROM \"tplanned_downtime\" WHERE \"id\" = %d",
|
||||
$id_downtime);
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = sprintf ("SELECT id, name, description, date_from, date_to, id_group, only_alerts
|
||||
FROM tplanned_downtime WHERE id = %d",
|
||||
$id_downtime);
|
||||
break;
|
||||
}
|
||||
|
||||
$table->class = 'databox_color';
|
||||
$table->width = '98%';
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = __('Name');
|
||||
$table->data[0][1] = html_print_input_text ('name', $name, '', 25, 40, true);
|
||||
$table->data[2][0] = __('Description');
|
||||
$table->data[2][1] = html_print_textarea ('description', 3, 35, $description, '', true);
|
||||
$table->data[3][0] = __('Timestamp from');
|
||||
$table->data[3][1] = html_print_input_text ('date_from', $date_from, '', 10, 10, true);
|
||||
$table->data[3][1] .= html_print_input_text ('time_from', $time_from, '', 7, 7, true);
|
||||
|
||||
$table->data[4][0] = __('Timestamp to');
|
||||
$table->data[4][1] = html_print_input_text ('date_to', $date_to, '', 10, 10, true);
|
||||
$table->data[4][1] .= html_print_input_text ('time_to', $time_to, '', 7, 7, true);
|
||||
|
||||
$table->data[5][0] = __('Group');
|
||||
$table->data[5][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, '', '', 0, true);
|
||||
$table->data[6][0] = __('Only alerts');
|
||||
$table->data[6][1] = html_print_checkbox('only_alerts', 1, $only_alerts, true);
|
||||
echo '<form method="POST" action="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime">';
|
||||
$result = db_get_row_sql ($sql);
|
||||
$name = $result["name"];
|
||||
$description = $result["description"];
|
||||
$date_from = strftime ('%Y-%m-%d', $result["date_from"]);
|
||||
$date_to = strftime ('%Y-%m-%d', $result["date_to"]);
|
||||
$time_from = strftime ('%I:%M%p', $result["date_from"]);
|
||||
$time_to = strftime ('%I:%M%p', $result["date_to"]);
|
||||
$only_alerts = $result["only_alerts"];
|
||||
|
||||
if ($id_group == 0)
|
||||
$id_group = $result['id_group'];
|
||||
}
|
||||
|
||||
$table->class = 'databox_color';
|
||||
$table->width = '98%';
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = __('Name');
|
||||
$table->data[0][1] = html_print_input_text ('name', $name, '', 25, 40, true);
|
||||
$table->data[2][0] = __('Description');
|
||||
$table->data[2][1] = html_print_textarea ('description', 3, 35, $description, '', true);
|
||||
$table->data[3][0] = __('Timestamp from');
|
||||
$table->data[3][1] = html_print_input_text ('date_from', $date_from, '', 10, 10, true);
|
||||
$table->data[3][1] .= html_print_input_text ('time_from', $time_from, '', 7, 7, true);
|
||||
|
||||
$table->data[4][0] = __('Timestamp to');
|
||||
$table->data[4][1] = html_print_input_text ('date_to', $date_to, '', 10, 10, true);
|
||||
$table->data[4][1] .= html_print_input_text ('time_to', $time_to, '', 7, 7, true);
|
||||
|
||||
$table->data[5][0] = __('Group');
|
||||
$table->data[5][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group, '', '', 0, true);
|
||||
$table->data[6][0] = __('Only alerts');
|
||||
$table->data[6][1] = html_print_checkbox('only_alerts', 1, $only_alerts, true);
|
||||
echo '<form method="POST" action="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime">';
|
||||
|
||||
if ($id_downtime > 0){
|
||||
echo "<table width=100% border=0 cellpadding=4 >";
|
||||
echo "<tr><td width=75% valign='top'>";
|
||||
}
|
||||
|
||||
//Editor form
|
||||
html_print_table ($table);
|
||||
|
||||
html_print_input_hidden ('id_agent', $id_agent);
|
||||
echo '<div class="action-buttons" style="width: 90%">';
|
||||
if ($id_downtime) {
|
||||
html_print_input_hidden ('update_downtime', 1);
|
||||
html_print_input_hidden ('id_downtime', $id_downtime);
|
||||
html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"');
|
||||
}
|
||||
else {
|
||||
html_print_input_hidden ('create_downtime', 1);
|
||||
html_print_submit_button (__('Add'), 'crtbutton', false, 'class="sub wand"');
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
if ($id_downtime > 0){
|
||||
echo "<table width=100% border=0 cellpadding=4 >";
|
||||
echo "<tr><td width=75% valign='top'>";
|
||||
}
|
||||
|
||||
//Editor form
|
||||
html_print_table ($table);
|
||||
|
||||
html_print_input_hidden ('id_agent', $id_agent);
|
||||
echo '<div class="action-buttons" style="width: 90%">';
|
||||
if ($id_downtime) {
|
||||
html_print_input_hidden ('update_downtime', 1);
|
||||
html_print_input_hidden ('id_downtime', $id_downtime);
|
||||
html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"');
|
||||
}
|
||||
else {
|
||||
html_print_input_hidden ('create_downtime', 1);
|
||||
html_print_submit_button (__('Add'), 'crtbutton', false, 'class="sub wand"');
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
if ($id_downtime > 0) {
|
||||
|
||||
echo "<td valign=top>";
|
||||
// Show available agents to include into downtime
|
||||
echo '<h4>'.__('Available agents').':</h4>';
|
||||
|
||||
|
||||
$filter_group = get_parameter("filter_group", 0);
|
||||
|
||||
|
||||
$filter_cond = '';
|
||||
if($filter_group > 0)
|
||||
$filter_cond = " AND id_grupo = $filter_group ";
|
||||
|
@ -293,44 +293,44 @@ if ($create_downtime || $update_downtime) {
|
|||
$downtimes = db_get_all_rows_sql ($sql);
|
||||
$data = array ();
|
||||
if ($downtimes) {
|
||||
foreach ($downtimes as $downtime) {
|
||||
foreach ($downtimes as $downtime) {
|
||||
if (check_acl ($config["id_user"], $downtime['id_grupo'], "AR")) {
|
||||
$data[$downtime['id_agente']] = $downtime['nombre'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$disabled_add_button = false;
|
||||
if (empty($data)) {
|
||||
$disabled_add_button = true;
|
||||
}
|
||||
|
||||
|
||||
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/planned_downtime&first_update=1&id_downtime=$id_downtime'>";
|
||||
|
||||
html_print_select_groups(false, "AR", true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'width:180px');
|
||||
html_print_select_groups(false, "AR", true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'width:180px');
|
||||
|
||||
echo "<br /><br />";
|
||||
html_print_submit_button (__('Filter by group'), '', false, 'class="sub next"',false);
|
||||
echo "</form>";
|
||||
|
||||
|
||||
echo "<form method=post action='index.php?sec=gagente&sec2=godmode/agentes/planned_downtime&first_update=1&insert_downtime_agent=1&id_downtime=$id_downtime'>";
|
||||
|
||||
|
||||
echo html_print_select ($data, "id_agent[]", '', '', '', 0, false, true, true, '', false, 'width: 180px;');
|
||||
echo "<br /><br /><br />";
|
||||
html_print_submit_button (__('Add'), '', $disabled_add_button, 'class="sub next"',false);
|
||||
echo "</form>";
|
||||
echo "</table>";
|
||||
|
||||
|
||||
//Start Overview of existing planned downtime
|
||||
echo '<h4>'.__('Agents planned for this downtime').':</h4>';
|
||||
|
||||
|
||||
$sql = sprintf ("SELECT tagente.nombre, tplanned_downtime_agents.id,
|
||||
tagente.id_os, tagente.id_agente, tagente.id_grupo,
|
||||
tagente.ultimo_contacto
|
||||
FROM tagente, tplanned_downtime_agents
|
||||
WHERE tplanned_downtime_agents.id_agent = tagente.id_agente
|
||||
AND tplanned_downtime_agents.id_downtime = %d ",$id_downtime);
|
||||
|
||||
|
||||
$downtimes = db_get_all_rows_sql ($sql);
|
||||
if ($downtimes === false) {
|
||||
echo '<div class="nf">'. __('There are no scheduled downtimes').'</div>';
|
||||
|
@ -346,23 +346,22 @@ if ($create_downtime || $update_downtime) {
|
|||
$table->head[3] = __('Last contact');
|
||||
$table->head[4] = __('Remove');
|
||||
$table->align[4] = "center";;
|
||||
|
||||
|
||||
foreach ($downtimes as $downtime) {
|
||||
$data = array ();
|
||||
|
||||
|
||||
$data[0] = $downtime['nombre'];
|
||||
|
||||
|
||||
$data[1] = db_get_sql ("SELECT nombre FROM tgrupo WHERE id_grupo = ". $downtime["id_grupo"]);
|
||||
|
||||
|
||||
|
||||
$data[2] = ui_print_os_icon ($downtime["id_os"], true, true);
|
||||
|
||||
|
||||
$data[3] = $downtime["ultimo_contacto"];
|
||||
|
||||
|
||||
$data[4] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime&id_agent='.
|
||||
$id_agent.'&delete_downtime_agent=1&first_update=1&id_downtime_agent='.$downtime["id"].'&id_downtime='.$id_downtime.'">' .
|
||||
html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete')));
|
||||
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
html_print_table ($table);
|
||||
|
@ -387,13 +386,13 @@ else {
|
|||
$table->head[7] = __('Update');
|
||||
$table->head[8] = __('Running');
|
||||
$table->head[9] = __('Stop downtime');
|
||||
$table->align[2] = "center";
|
||||
$table->align[2] = "center";
|
||||
$table->align[5] = "center";
|
||||
$table->align[6] = "center";
|
||||
$table->align[7] = "center";
|
||||
$table->align[8] = "center";
|
||||
$table->align[9] = "center";
|
||||
|
||||
|
||||
if(!empty($groups)) {
|
||||
$sql = "SELECT * FROM tplanned_downtime WHERE id_group IN (" . implode (",", array_keys ($groups)) . ")";
|
||||
$downtimes = db_get_all_rows_sql ($sql);
|
||||
|
@ -401,7 +400,7 @@ else {
|
|||
else {
|
||||
$downtimes = array();
|
||||
}
|
||||
|
||||
|
||||
if (!$downtimes) {
|
||||
echo '<div class="nf">'.__('No planned downtime').'</div>';
|
||||
}
|
||||
|
@ -415,11 +414,11 @@ else {
|
|||
$data[2] = ui_print_group_icon ($downtime['id_group'], true);
|
||||
$data[3] = date ("Y-m-d H:i", $downtime['date_from']);
|
||||
$data[4] = date ("Y-m-d H:i", $downtime['date_to']);
|
||||
if($only_alerts) {
|
||||
if($downtime['only_alerts']) {
|
||||
$data[5] = __('Only alerts');
|
||||
}
|
||||
else {
|
||||
$data[5] = __('All');
|
||||
$data[5] = __('All');
|
||||
}
|
||||
if ($downtime["executed"] == 0){
|
||||
$data[6] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime&id_agent='.
|
||||
|
@ -437,12 +436,12 @@ else {
|
|||
$data[8] = html_print_image ("images/pixel_green.png", true, array ('width' => 20, 'height' => 20, 'alt' => __('Executed')));
|
||||
else
|
||||
$data[8] = html_print_image ("images/pixel_red.png", true, array ('width' => 20, 'height' => 20, 'alt' => __('Not executed')));
|
||||
|
||||
|
||||
if ($downtime["executed"] != 0) {
|
||||
$data[9] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime&stop_downtime=1&id_downtime='.$downtime['id'].'">' .
|
||||
html_print_image("images/cancel.png", true, array("border" => '0', "alt" => __('Stop downtime')));
|
||||
}
|
||||
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
html_print_table ($table);
|
||||
|
@ -471,25 +470,25 @@ $(document).ready (function () {
|
|||
});
|
||||
$("#text-date_from, #text-date_to").datepicker ();
|
||||
$.datepicker.regional["<?php echo $config['language']; ?>"];
|
||||
|
||||
|
||||
|
||||
|
||||
$("#filter_group").click (
|
||||
function () {
|
||||
$(this).css ("width", "auto");
|
||||
$(this).css ("width", "auto");
|
||||
});
|
||||
|
||||
|
||||
$("#filter_group").blur (function () {
|
||||
$(this).css ("width", "180px");
|
||||
});
|
||||
|
||||
$(this).css ("width", "180px");
|
||||
});
|
||||
|
||||
$("#id_agent").click (
|
||||
function () {
|
||||
$(this).css ("width", "auto");
|
||||
$(this).css ("width", "auto");
|
||||
});
|
||||
|
||||
|
||||
$("#id_agent").blur (function () {
|
||||
$(this).css ("width", "180px");
|
||||
});
|
||||
|
||||
$(this).css ("width", "180px");
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue