diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d9a7a48a59..4bd2fbb5ac 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-08-09 Vanessa Gil + + * godmode/reporting/reporting_builer.list_items.php + godmode/reporting/reporting_builer.php: Added button to masively + delete all the selected report items and massively delete these + items from position X and above/below. + 2012-08-06 Sergio Martin * godmode/modules/manage_network_components_form_plugin.php: diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 38a57685bc..a54795bc64 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -205,7 +205,7 @@ if ($items) { $table->size[0] = '5px'; $table->size[1] = '15%'; $table->size[4] = '8%'; - $table->size[6] = '50px'; + $table->size[6] = '60px'; $table->size[7] = '30px'; $table->head[0] = '' . __('P.') . ''; @@ -323,6 +323,7 @@ foreach ($items as $item) { $row[6] .= '' . html_print_image("images/wrench_orange.png", true, array("title" => __('Edit'))) . ''; $row[6] .= '  '; $row[6] .= '' . html_print_image("images/cross.png", true, array("title" => __('Delete'))) .''; + $row[6] .= html_print_checkbox_extended ('delete_multiple[]', $item['id_rc'], false, false, '', 'class="check_delete"', true); $row[7] = ''; //You can sort the items if the filter is not enable. @@ -340,6 +341,14 @@ ui_pagination ($countItems, 'index.php?sec=reporting&sec2=godmode/reporting/repo html_print_table($table); ui_pagination ($countItems, 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $idReport . $urlFilter); +echo "
"; + echo "
"; + html_print_input_hidden('ids_items_to_delete', ''); + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); + echo "
"; +echo "
"; + $table = null; $table->width = '60%'; $table->colspan[0][0] = 3; @@ -357,6 +366,25 @@ echo "
"; html_print_table($table); echo "
"; + +$table = null; +$table->width = '60%'; +$table->colspan[0][0] = 3; +$table->data[0][0] = "". __("Delete items") . ""; +$table->data[1][0] = __('Delete selected items from position: '); +$table->data[1][1] = html_print_select_style( + array('above' => __('Delete above to'), 'below' => __('Delete below to')), 'delete_m', + '', '', '', '', 0, true); +$table->data[1][2] = html_print_input_text_extended('position_to_delete', 1, + 'text-position_to_delete', '', 3, 10, false, "only_numbers('position_to_delete');", '', true); +$table->data[1][2] .= html_print_input_hidden('ids_items_to_delete', '', true); +$table->data[1][3] = html_print_submit_button(__('Delete'), 'delete_submit', false, 'class="sub upd"', true); + +echo "
"; +html_print_table($table); +echo "
"; + ?> diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index e0cc46af5e..25a14bcbc9 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -134,6 +134,61 @@ switch ($action) { break; } break; + case 'delete_items': + $resultOperationDB = null; + $ids_serialize = (string)get_parameter('ids_items_to_delete', ''); + + if (!empty($ids_serialize)) { + $sql = "DELETE FROM treport_content WHERE id_rc IN ($ids_serialize)"; + $resultOperationDB = db_process_sql($sql); + } else { + $resultOperationDB = false; + } + + break; + case 'delete_items_pos': + $resultOperationDB = null; + $position_to_delete = (int)get_parameter('position_to_delete', 1); + $pos_delete = (string)get_parameter('delete_m', 'below'); + + $countItems = db_get_sql('SELECT COUNT(id_rc) + FROM treport_content WHERE id_report = ' . $idReport); + + if (($countItems < $position_to_delete) || ($position_to_delete < 1)) { + $resultOperationDB = false; + } else { + $sql = "SELECT id_rc FROM treport_content WHERE id_report=$idReport ORDER BY '`order`'"; + $items = db_get_all_rows_sql($sql); + switch ($pos_delete) { + case 'below': + if ($position_to_delete == 1) { + $resultOperationDB = false; + } else { + $i = 1; + foreach ($items as $key => $item) { + if ($i < $position_to_delete) { + $resultOperationDB = db_process_sql_delete('treport_content', array('id_rc' => $item['id_rc'])); + } + $i++; + } + } + break; + case 'above': + if ($position_to_delete == $countItems) { + $resultOperationDB = false; + } else { + $i = 1; + foreach ($items as $key => $item) { + if ($i > $position_to_delete) { + $resultOperationDB = db_process_sql_delete('treport_content', array('id_rc' => $item['id_rc'])); + } + $i++; + } + } + break; + } + } + break; case 'delete_report': case 'list': $buttons = array(