diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 8a1965268f..6b0274229e 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1562,4 +1562,68 @@ function round_with_decimals (value, multiplier = 1) { return Math.round(value * multiplier) / multiplier; } return round_with_decimals (value, multiplier * 10); +} + +/* + + $("body").append('

' + '' + '

'); + $("#event_delete_confirm_dialog").dialog({ + resizable: false, + draggable: false, + modal: true, + height: 280, + width: 330, + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); } + }); +*/ + +/** + * Display a confirm dialog box + * + * @param string Text to display + * @param string Ok button text + * @param string Cancel button text + * @param function Callback to action when ok button is pressed +*/ +function display_confirm_dialog ( + message = '', + ok_text = '', + cancel_text = '', + ok_function = function () {} +) { + // Clean function to close the dialog + var clean_function = function () { + $("#pandora_confirm_dialog_text").hide(); + $("#pandora_confirm_dialog_text").remove(); + } + + // Modify the ok function to close the dialog too + var ok_function_clean = function () { + ok_function(); + clean_function(); + } + + // Display the dialog + $("body").append('

' + message + '

'); + $("#pandora_confirm_dialog_text").dialog({ + resizable: false, + draggable: true, + modal: true, + dialogClass: "pandora_confirm_dialog", + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: true, + modal: true, + buttons: { + Cancel: clean_function, + "Confirm": ok_function_clean + } + }); } \ No newline at end of file diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 751ef52ed0..b1467fa7d1 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4634,3 +4634,19 @@ form ul.form_flex li ul li{ width: auto!important; } +.pandora_confirm_dialog .ui-dialog-buttonset { + display: flex; + width: 100%; + margin-left: 10px; + float: none !important; +} + +.pandora_confirm_dialog .ui-dialog-buttonset button{ + flex: 50%; +} + +#pandora_confirm_dialog_text h3{ + margin-left: 20px; + margin-right: 20px; + text-align: center; +} \ No newline at end of file diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 8a506c979e..01373c8358 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -666,8 +666,12 @@ else { if ($i != 0 && $allow_action) { //Actions - $data[$i] = ''; - + $data[$i] = ''; + $data[$i] .= html_print_input_hidden('event_title_'.$event["id_evento"], "#".$event["id_evento"]." - " . strip_tags(io_safe_output($event["evento"])), true); + $data[$i] .= html_print_image ("images/eye.png", true, + array ("title" => __('Show more'))); + $data[$i] .= ''; + if(!$readonly) { // Validate event if (($event["estado"] != 1) && (tags_checks_event_acl ($config["id_user"], $event["id_grupo"], "EW", $event['clean_tags'], $childrens_ids))) { @@ -676,6 +680,13 @@ else { $data[$i] .= html_print_image ("images/ok.png", true, array ("title" => __('Validate event'))); $data[$i] .= ''; + // Display the go to in progress status button + if ($event["estado"] != 2) { + $data[$i] .= ''; + $data[$i] .= html_print_image ("images/hourglass.png", true, + array ("title" => __('Change to in progress status'))); + $data[$i] .= ''; + } } // Delete event @@ -688,18 +699,19 @@ else { $data[$i] .= ''; } else { - $data[$i] .= html_print_image ("images/cross.disabled.png", true, - array ("title" => __('Is not allowed delete events in process'))).' '; + $data[$i] .= html_print_image ( + "images/cross.disabled.png", + true, + array ( + "title" => __('Is not allowed delete events in process'), + "id" => "delete-" . $event['id_evento'] + ) + ); + $data[$i] .= ' '; } } } - - $data[$i] .= ''; - $data[$i] .= html_print_input_hidden('event_title_'.$event["id_evento"], "#".$event["id_evento"]." - " . strip_tags(io_safe_output($event["evento"])), true); - $data[$i] .= html_print_image ("images/eye.png", true, - array ("title" => __('Show more'))); - $data[$i] .= ''; - + $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;'; $i++; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 9564e87b5e..03101d09b4 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -873,41 +873,45 @@ $(document).ready( function() { "html" ); }); - - $("a.delete_event").click (function () { - confirmation = confirm(""); - if (!confirmation) { - return; - } - meta = $('#hidden-meta').val(); - history_var = $('#hidden-history').val(); - - $tr = $(this).parents ("tr"); - id = this.id.split ("-").pop (); - - $("#delete_cross_"+id).attr ("src", "images/spinner.gif"); - - jQuery.post ("", - {"page" : "operation/events/events", - "delete_event" : 1, - "id" : id, - "similars" : , - "meta" : meta, - "history" : history_var - }, - function (data, status) { - if (data == "ok") { - $tr.remove (); - $('#show_message_error').html('

'); - } - else - $('#show_message_error').html('

'); - }, - "html" + + $("td").on('click', 'a.delete_event', function () { + var click_element = this; + display_confirm_dialog( + "", + "", + "", + function () { + meta = $('#hidden-meta').val(); + history_var = $('#hidden-history').val(); + + $tr = $(click_element).parents ("tr"); + id = click_element.id.split ("-").pop (); + + $("#delete_cross_"+id).attr ("src", "images/spinner.gif"); + + jQuery.post ("", + {"page" : "operation/events/events", + "delete_event" : 1, + "id" : id, + "similars" : , + "meta" : meta, + "history" : history_var + }, + function (data, status) { + if (data == "ok") { + $tr.remove (); + $('#show_message_error').html('

'); + } + else + $('#show_message_error').html('

'); + }, + "html" + ); + return false; + } ); - return false; }); - + function toggleDiv (divid) { if (document.getElementById(divid).style.display == 'none') { document.getElementById(divid).style.display = 'block'; @@ -940,6 +944,11 @@ function validate_event_advanced(id, new_status) { $tr = $('#validate-'+id).parents ("tr"); var grouped = $('#group_rep').val(); + + // Get images url + var hourglass_image = ""; + var cross_disabled_image = ""; + var cross_image = ""; var similar_ids; similar_ids = $('#hidden-similar_ids_'+id).val(); @@ -964,31 +973,46 @@ function validate_event_advanced(id, new_status) { // Change status description $("#status_row_"+id).html(); - // Change state image + // Change delete icon + $("#delete-"+id).remove(); + $("#validate-"+id).parent().append(''); + $("#delete-"+id).append(""); + $("#delete-"+id + " img").attr ("id", "delete_cross_" + id); + $("#delete-"+id + " img").attr ("data-title", ); + $("#delete-"+id + " img").attr ("alt", ); + $("#delete-"+id + " img").attr ("data-use_title_for_force_title", 1); + $("#delete-"+id + " img").attr ("class", "forced_title"); + + // Change other buttons actions $("#validate-"+id).css("display", "none"); + $("#in-progress-"+id).css("display", "none"); $("#status_img_"+id).attr ("src", "images/tick.png"); - $("#status_img_"+id).attr ("title", ); - $("#status_img_"+id).attr ("alt", ); + $("#status_img_"+id).attr ("data-title", ); + $("#status_img_"+id).attr ("alt", ); + $("#status_img_"+id).attr ("data-use_title_for_force_title", 1); + $("#status_img_"+id).attr ("class", "forced_title"); } // In process else if (new_status == 2) { // Change status description $("#status_row_"+id).html(); - // Remove delete link (if event is not grouped and there is more than one event) - if (grouped == 1) { - if (parseInt($("#count_event_group_"+id).text()) <= 1) { - $("#delete-"+id).replaceWith('' + <?php echo + '" title="' + + '" src="images/cross.disabled.png">'); - } - } - else { // Remove delete link (if event is not grouped) - $("#delete-"+id).replaceWith('' + <?php echo + '" title="' + + '" src="images/cross.disabled.png">'); - } - // Change state image - $("#status_img_"+id).attr ("src", "images/hourglass.png"); - $("#status_img_"+id).attr ("title", ); + $("#status_img_"+id).attr ("src", hourglass_image); + $("#status_img_"+id).attr ("data-title", ); $("#status_img_"+id).attr ("alt", ); - + $("#status_img_"+id).attr ("data-use_title_for_force_title", 1); + $("#status_img_"+id).attr ("class", "forced_title"); + + // Change the actions buttons + $("#delete-"+id).remove(); + $("#in-progress-"+id).remove(); + // Format the new disabled delete icon. + $("#validate-"+id).parent().append(""); + $("#delete-"+id).attr ("data-title", ); + $("#delete-"+id).attr ("alt", ); + $("#delete-"+id).attr ("data-use_title_for_force_title", 1); + $("#delete-"+id).attr ("class", "forced_title"); + // Remove row due to new state if (($("#status").val() == 0) || ($("#status").val() == 1)) {