diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 455f80c9e6..78659ac569 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-02-23 Juan Manuel Ramon + + * operation/events/events_list.php + operation/events/events.php: Changed functionality of state events + to javascript. Don't need to refresh all view. + 2012-02-23 Sancho Lerena * include/help/en/help_ff_threshold.php diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index c17a7985e7..70a4838195 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -37,6 +37,8 @@ if (is_ajax ()) { $delete_event = (bool) get_parameter ('delete_event'); $get_events_fired = (bool) get_parameter('get_events_fired'); $standby_alert = (bool) get_parameter('standby_alert'); + $get_comment = (bool) get_parameter('get_comment'); + $get_comment_header = (bool) get_parameter('get_comment_header'); if ($get_event_tooltip) { $id = (int) get_parameter ('id'); @@ -149,6 +151,26 @@ if (is_ajax ()) { echo json_encode($return); } + if ($get_comment){ + $id = (int) get_parameter ("id"); + $event = events_get_event ($id); + + if ($event === false) + echo ''; + else + echo $event['user_comment']; + } + + if ($get_comment_header){ + $id = (int) get_parameter ("id"); + $event = events_get_event ($id); + + if ($event === false) + echo ''; + else + echo ui_print_truncate_text(strip_tags($event["user_comment"])); + } + return; } @@ -402,6 +424,11 @@ $(document).ready( function() { $("a.validate_event").click (function () { $tr = $(this).parents ("tr"); + + + + + id = this.id.split ("-").pop (); var comment = $('#textarea_comment_'+id).val(); var select_validate = $('#select_validate_'+id).val(); // 1 validate, 2 in process, 3 add comment @@ -439,8 +466,140 @@ $(document).ready( function() { }, function (data, status) { if (data == "ok") { - $("#status_img_"+id).attr ("src", "images/spinner.gif"); - location.reload(); + + // Refresh interface elements, don't reload (awfull) + // Validate + if (select_validate == 1){ + $("#status_img_"+id).attr ("src", "images/spinner.gif"); + // Change status description + $("#status_row_"+id).html(); + + // Get event comment + jQuery.post ("ajax.php", + {"page" : "operation/events/events", + "get_comment" : 1, + "id" : id + }, + function (data, status) { + $("#comment_row_"+id).html(data); + }); + + // Get event comment in header + jQuery.post ("ajax.php", + {"page" : "operation/events/events", + "get_comment_header" : 1, + "id" : id + }, + function (data, status) { + $("#comment_header_"+id).html(data); + }); + + // Change state image + $("#validate-"+id).css("display", "none"); + $("#status_img_"+id).attr ("src", "images/tick.png"); + $("#status_img_"+id).attr ("title", ); + $("#status_img_"+id).attr ("alt", ); + + // Remove row due to new state + if (($("#status").val() == 2) || ($("#status").val() == 0) || ($("#status").val() == 3)){ + + $.each($tr, function(index, value){ + row = value; + + if ($(row).attr('id') != ''){ + + row_id_name = $(row).attr('id').split('-').shift(); + row_id_number = $(row).attr('id').split('-').pop() - 1; + previous_row_id = $(row).attr('id'); + current_row_id = row_id_name + "-" + row_id_number; + selected_row_id = row_id_name + "-" + row_id_number + "-0"; + + $("#"+previous_row_id).css('display', 'none'); + $("#"+current_row_id).css('display', 'none'); + $("#"+selected_row_id).css('display', 'none'); + } + }); + } + + } // In process + else if (select_validate == 2){ + $("#status_img_"+id).attr ("src", "images/spinner.gif"); + // Change status description + $("#status_row_"+id).html(); + + // Get event comment + jQuery.post ("ajax.php", + {"page" : "operation/events/events", + "get_comment" : 1, + "id" : id + }, + function (data, status) { + $("#comment_row_"+id).html(data); + }); + + // Get event comment in header + jQuery.post ("ajax.php", + {"page" : "operation/events/events", + "get_comment_header" : 1, + "id" : id + }, + function (data, status) { + $("#comment_header_"+id).html(data); + }); + + // Remove delete link + $("#delete-"+id).replaceWith('' + <?php echo + '" title="' + + '" src="/trunk/pandora_console/images/cross.disabled.png">'); + + // Change state image + $("#status_img_"+id).attr ("src", "images/hourglass.png"); + $("#status_img_"+id).attr ("title", ); + $("#status_img_"+id).attr ("alt", ); + + // Remove row due to new state + if (($("#status").val() == 0) || ($("#status").val() == 1)){ + + $.each($tr, function(index, value){ + row = value; + + if ($(row).attr('id') != ''){ + + row_id_name = $(row).attr('id').split('-').shift(); + row_id_number = $(row).attr('id').split('-').pop() - 1; + previous_row_id = $(row).attr('id'); + current_row_id = row_id_name + "-" + row_id_number; + selected_row_id = row_id_name + "-" + row_id_number + "-0"; + + $("#"+previous_row_id).css('display', 'none'); + $("#"+current_row_id).css('display', 'none'); + $("#"+selected_row_id).css('display', 'none'); + } + }); + + } + } // Add comment + else if (select_validate == 3){ + // Get event comment + jQuery.post ("ajax.php", + {"page" : "operation/events/events", + "get_comment" : 1, + "id" : id + }, + function (data, status) { + $("#comment_row_"+id).html(data); + }); + + // Get event comment in header + jQuery.post ("ajax.php", + {"page" : "operation/events/events", + "get_comment_header" : 1, + "id" : id + }, + function (data, status) { + $("#comment_header_"+id).html(data); + }); + } + + //location.reload(); } else { $("#result") .showMessage ("") diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index fb20847edf..fdaed5e69c 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -772,7 +772,7 @@ foreach ($result as $event) { } if (in_array('user_comment',$show_fields)) { - $data[$i] = ui_print_truncate_text(strip_tags($event["user_comment"]), 30); + $data[$i] = '' .ui_print_truncate_text(strip_tags($event["user_comment"])) . ''; $i++; } @@ -825,7 +825,7 @@ foreach ($result as $event) { if($event['estado'] != 2) { $data[$i] .= ''; $data[$i] .= html_print_image ("images/cross.png", true, - array ("title" => __('Delete event'))); + array ("title" => __('Delete event'), "id" => 'delete_cross_' . $event['id_evento'])); $data[$i] .= ' '; } else { @@ -918,7 +918,7 @@ foreach ($result as $event) { $string .= events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true); $string .= ''; $string .= ''; - $string .= '' . __('Status') . ''; + $string .= '' . __('Status') . ''; $string .= $title_st; $string .= ''; $string .= ''; @@ -1030,7 +1030,7 @@ foreach ($result as $event) { $string .= ''; $odd = ($odd == '')? 'rowOdd' : ''; - $string .= '' . '' . __('Comments') . ''; + $string .= '' . '' . __('Comments') . ''; if($event["user_comment"] != '') { $string .= $event["user_comment"]; } else {