Merge branch 'ent-1888-anadir-nueva-feature-para-poder-cambiar-los-eventos-a-estado-en-proceso' into 'develop'

Ent 1888 anadir nueva feature para poder cambiar los eventos a estado en proceso

See merge request artica/pandorafms!1442
This commit is contained in:
vgilc 2018-05-09 10:24:19 +02:00
commit d746af9c28
4 changed files with 176 additions and 60 deletions

View File

@ -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('<div id="event_delete_confirm_dialog"><h4>' + '<?php echo __('Are you sure?'); ?>' + '</h4></div>');
$("#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('<div id="pandora_confirm_dialog_text"><h3>' + message + '</h3></div>');
$("#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
}
});
}

View File

@ -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;
}

View File

@ -666,8 +666,12 @@ else {
if ($i != 0 && $allow_action) {
//Actions
$data[$i] = '';
$data[$i] = '<a href="javascript:" onclick="show_event_dialog(' . $event["id_evento"] . ', '.$group_rep.');">';
$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] .= '</a>';
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] .= '</a>';
// Display the go to in progress status button
if ($event["estado"] != 2) {
$data[$i] .= '<a href="javascript:validate_event_advanced('.$event["id_evento"].', 2)" id="in-progress-'.$event["id_evento"].'">';
$data[$i] .= html_print_image ("images/hourglass.png", true,
array ("title" => __('Change to in progress status')));
$data[$i] .= '</a>';
}
}
// Delete event
@ -688,18 +699,19 @@ else {
$data[$i] .= '</a>';
}
else {
$data[$i] .= html_print_image ("images/cross.disabled.png", true,
array ("title" => __('Is not allowed delete events in process'))).'&nbsp;';
$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] .= '&nbsp;';
}
}
}
$data[$i] .= '<a href="javascript:" onclick="show_event_dialog(' . $event["id_evento"] . ', '.$group_rep.');">';
$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] .= '</a>';
$table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;';
$i++;

View File

@ -873,41 +873,45 @@ $(document).ready( function() {
"html"
);
});
$("a.delete_event").click (function () {
confirmation = confirm("<?php echo __('Are you sure?'); ?>");
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 ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
{"page" : "operation/events/events",
"delete_event" : 1,
"id" : id,
"similars" : <?php echo ($group_rep ? 1 : 0) ?>,
"meta" : meta,
"history" : history_var
},
function (data, status) {
if (data == "ok") {
$tr.remove ();
$('#show_message_error').html('<h3 class="suc"> <?php echo __('Successfully delete'); ?> </h3>');
}
else
$('#show_message_error').html('<h3 class="error"> <?php echo __('Error deleting event'); ?> </h3>');
},
"html"
$("td").on('click', 'a.delete_event', function () {
var click_element = this;
display_confirm_dialog(
"<?php echo __('Are you sure?'); ?>",
"<?php echo __('Confirm'); ?>",
"<?php echo __('Cancel'); ?>",
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 ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
{"page" : "operation/events/events",
"delete_event" : 1,
"id" : id,
"similars" : <?php echo ($group_rep ? 1 : 0) ?>,
"meta" : meta,
"history" : history_var
},
function (data, status) {
if (data == "ok") {
$tr.remove ();
$('#show_message_error').html('<h3 class="suc"> <?php echo __('Successfully delete'); ?> </h3>');
}
else
$('#show_message_error').html('<h3 class="error"> <?php echo __('Error deleting event'); ?> </h3>');
},
"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 = "<?php echo ui_get_full_url("images/hourglass.png", false, false, false); ?>";
var cross_disabled_image = "<?php echo ui_get_full_url("images/cross.disabled.png", false, false, false); ?>";
var cross_image = "<?php echo ui_get_full_url("images/cross.png", false, false, false); ?>";
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(<?php echo "'" . __('Event validated') . "'"; ?>);
// Change state image
// Change delete icon
$("#delete-"+id).remove();
$("#validate-"+id).parent().append('<a class="delete_event" href="javascript:" id="delete-' + id + '"></a>');
$("#delete-"+id).append("<img src='" + cross_image + "' />");
$("#delete-"+id + " img").attr ("id", "delete_cross_" + id);
$("#delete-"+id + " img").attr ("data-title", <?php echo "'" . __('Delete event') . "'"; ?>);
$("#delete-"+id + " img").attr ("alt", <?php echo "'" . __('Delete event') . "'"; ?>);
$("#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", <?php echo "'" . __('Event validated') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event validated') . "'"; ?>);
$("#status_img_"+id).attr ("data-title", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#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(<?php echo "'" . __('Event in process') . "'"; ?>);
// 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('<img alt="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" title="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" src="images/cross.disabled.png">');
}
}
else { // Remove delete link (if event is not grouped)
$("#delete-"+id).replaceWith('<img alt="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" title="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" src="images/cross.disabled.png">');
}
// Change state image
$("#status_img_"+id).attr ("src", "images/hourglass.png");
$("#status_img_"+id).attr ("title", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("src", hourglass_image);
$("#status_img_"+id).attr ("data-title", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#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("<img id='delete-" + id + "' src='" + cross_disabled_image + "' />");
$("#delete-"+id).attr ("data-title", <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?>);
$("#delete-"+id).attr ("alt", <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?>);
$("#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)) {