Skip to content

Commit

Permalink
2.1.24 pre-production
Browse files Browse the repository at this point in the history
* Improved Folders page
* 1069 - fix for KB table
* 1067 - fix and improvement of suggestion page (motification added)
  • Loading branch information
nilsteampassnet committed Oct 29, 2015
1 parent 2db1592 commit a465ed1
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 371 deletions.
297 changes: 162 additions & 135 deletions folders.load.php
Expand Up @@ -20,49 +20,113 @@
<script type="text/javascript">

$(function() {

//Launch the datatables pluggin
var tableFolders = $("#t_folders").dataTable({
"order": [[ 1, "asc" ]],
"ordering": false,
"searching": false,
"paging": false,
"processing": true,
"serverSide": true,
"ajax": {
url: "sources/datatable/datatable.folders.php"
},
"language": {
"url": "includes/language/datatables.<?php echo $_SESSION['user_language'];?>.txt"
},
"columns": [
{"width": "7%"},
{"width": "5%"},
{className: "dt-body-left"},
{"width": "15%"},
{"width": "10%"},
{"width": "10%"},
{"width": "5%"},
{"width": "5%"},
{"width": "5%"}
]
})
.on('xhr.dt', function ( e, settings, json, xhr ) {
//$(".tip").tooltipster();
} );


$("#div_add_group").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 250,
height: 330,
width: 280,
height: 390,
title: "<?php echo $LANG['add_new_group'];?>",
open: function(event, ui) {
$("#new_folder_wait").hide();

//empty dialogbox
$("#div_add_group input, #div_add_group select").val("");
},
buttons: {
"<?php echo $LANG['save_button'];?>": function() {
add_new_folder();
$("#new_folder_wait").show();
//Check if renewal_period is an integer
if (isInteger(document.getElementById("add_node_renewal_period").value) == false) {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_renawal_period_not_integer'];?>";
$("#addgroup_show_error").show();
} else if (document.getElementById("new_rep_complexite").value == "") {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_group_complex'];?>";
$("#addgroup_show_error").show();
} else {
if (document.getElementById("ajouter_groupe_titre").value != "" && document.getElementById("parent_id").value != "na") {
$("#addgroup_show_error").hide();
//prepare data
var data = '{"title":"'+$('#ajouter_groupe_titre').val().replace(/"/g,'&quot;') + '", "complexity":"'+$('#new_rep_complexite').val().replace(/"/g,'&quot;')+'", '+
'"parent_id":"'+$('#parent_id').val().replace(/"/g,'&quot;')+'", "renewal_period":"'+$('#add_node_renewal_period').val().replace(/"/g,'&quot;')+'"}';
//send query
$.post(
"sources/folders.queries.php",
{
type : "add_folder",
data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>")
},
function(data) {
//Check errors
if (data[0].error == "error_group_exist") {
$("#div_add_group").dialog("open");
$("#addgroup_show_error").html("<?php echo $LANG['error_group_exist'];?>");
$("#addgroup_show_error").show();
} else if (data[0].error == "error_html_codes") {
$("#div_add_group").dialog("open");
$("#addgroup_show_error").html("<?php echo $LANG['error_html_codes'];?>");
$("#addgroup_show_error").show();
} else {
tableFolders.api().ajax.reload();
$("#div_add_group").dialog("close");
}
},
"json"
);
} else {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_fields_2'];?>";
$("#addgroup_show_error").show();
}
}
},
"<?php echo $LANG['cancel_button'];?>": function() {
$(this).dialog("close");
}
}
});

$("#help_on_folders").dialog({
bgiframe: false,
modal: false,
autoOpen: false,
width: 850,
height: 500,
title: "<?php echo $LANG["admin_help"];?>",
buttons: {
"<?php echo $LANG["close"];?>": function() {
$(this).dialog("close");
}
},
open: function() {
$("#accordion").accordion({ autoHeight: false, navigation: true, collapsible: true, active: false });
}
});

$("#div_edit_folder").dialog({
bgiframe: true,
modal: true,
autoOpen: false,
width: 250,
height: 330,
height: 380,
title: "<?php echo $LANG['at_category'];?>",
open: function(event, ui) {
var id = $("#folder_id_to_edit").val();
$("#edit_folder_wait").hide();

//update dialogbox with data
$("#edit_folder_title").val($("#title_"+id).text());
Expand All @@ -71,7 +135,27 @@
$("#edit_parent_id").val($("#parent_id_"+id).val());
},
buttons: {
"<?php echo $LANG['delete'];?>": function() {
if (confirm("<?php echo $LANG['confirm_delete_group'];?>")) {
//send query
$.post(
"sources/folders.queries.php",
{
type : "delete_folder",
id : $("#folder_id_to_edit").val()
},
function(data) {
tableFolders.api().ajax.reload();
$("#div_edit_folder").dialog("close");
}
);
}

//Close
$("#div_edit_folder").dialog("close");
},
"<?php echo $LANG['save_button'];?>": function() {
$("#edit_folder_wait").show();
if ($('#edit_folder_complexite').val() == "") {
$("#edit_folder_show_error").html("<?php echo $LANG['error_group_complex'];?>").show();
return;
Expand Down Expand Up @@ -100,8 +184,11 @@ function(data) {
LoadingPage();
} else {
$("#folder_id_to_edit").val(""); //clear id
window.location.href = "index.php?page=manage_folders";
tableFolders.api().ajax.reload();
$("#parent_id, #edit_parent_id").empty().append(data[0].droplist);
$("#div_edit_folder").dialog("close");
}
$("#edit_folder_wait").hide();
},
"json"
);
Expand All @@ -111,7 +198,7 @@ function(data) {
$("#folder_id_to_edit").val("");

//Close
$(this).dialog("close");
$("#div_edit_folder").dialog("close");
}
}
});
Expand All @@ -126,93 +213,64 @@ function(data) {
$("#title_"+elem[1]).css({"background-color":"#FFF"});
}
});
});

function supprimer_groupe(id)
{
if (confirm("<?php echo $LANG['confirm_delete_group'];?>")) {
//send query
$.post(
"sources/folders.queries.php",
{
type : "delete_folder",
id : id
},
function(data) {
RefreshPage("form_groupes");
}
);
}
}

function Changer_Droit_Complexite(id,type)
{
var droit = 0;
if (type == "creation") {
if ($("#cb_droit_"+id).prop("checked") == true) droit = 1;
type = "modif_droit_autorisation_sans_complexite";
} else if (type == "modification") {
if ($("#cb_droit_modif_"+id).prop("checked") == true) droit = 1;
type = "modif_droit_modification_sans_complexite";
}
//send query
$.post(
"sources/folders.queries.php",
{
type : type,
id : id,
droit : droit
}
);
}

function add_new_folder()
{
//Check if renewal_period is an integer
if (isInteger(document.getElementById("add_node_renewal_period").value) == false) {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_renawal_period_not_integer'];?>";
$("#addgroup_show_error").show();
} else if (document.getElementById("new_rep_complexite").value == "") {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_group_complex'];?>";
$("#addgroup_show_error").show();
} else {
if (document.getElementById("ajouter_groupe_titre").value != "" && document.getElementById("parent_id").value != "na") {
$("#addgroup_show_error").hide();
LoadingPage();
//prepare data
var data = '{"title":"'+$('#ajouter_groupe_titre').val().replace(/"/g,'&quot;') + '", "complexity":"'+$('#new_rep_complexite').val().replace(/"/g,'&quot;')+'", '+
'"parent_id":"'+$('#parent_id').val().replace(/"/g,'&quot;')+'", "renewal_period":"'+$('#add_node_renewal_period').val().replace(/"/g,'&quot;')+'"}';
//send query

// manage the click on toggle icons
$(document).on({
click: function (event) {
$("#div_loading").show();
var tmp = $(this).attr('tp').split('-'); //[0]>ID ; [1]>action ; [2]>NewValue

// send change to be stored
$.post(
"sources/folders.queries.php",
{
type : "add_folder",
data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>")
type : tmp[1],
value : tmp[2],
id : tmp[0],
key : "<?php echo $_SESSION['key'];?>"
},
function(data) {
//Check errors
if (data[0].error == "error_group_exist") {
$("#div_add_group").dialog("open");
$("#addgroup_show_error").html("<?php echo $LANG['error_group_exist'];?>");
$("#addgroup_show_error").show();
LoadingPage();
} else if (data[0].error == "error_html_codes") {
$("#div_add_group").dialog("open");
$("#addgroup_show_error").html("<?php echo $LANG['error_html_codes'];?>");
$("#addgroup_show_error").show();
LoadingPage();
} else {
window.location.href = "index.php?page=manage_folders";
}
},
"json"
);
} else {
document.getElementById("addgroup_show_error").innerHTML = "<?php echo $LANG['error_fields_2'];?>";
$("#addgroup_show_error").show();
$("#div_loading").hide();
// refresh table content
tableFolders.api().ajax.reload();
}
);
}
}
}
}, ".fa-toggle-off, .fa-toggle-on");

$( "#click_delete_multiple_folders" ).click(function() {
var list_i = "";
$(".cb_selected_folder:checked").each(function() {
var elem = $(this).attr("id").split("-");
if (list_i == "") list_i = elem[1];
else list_i = list_i+';'+elem[1];
});
if (list_i != "" && $("#action_on_going").val() == "" && confirm("<?php echo addslashes($LANG['confirm_deletion']);?>")) {
$("#div_loading").show();
$("#action_on_going").val("multiple_folders");
var data = '{"foldersList":"'+list_i+'"}';
//send query
$.post(
"sources/folders.queries.php",
{
type : "delete_multiple_folders",
data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>")
},
function(data) {
tableFolders.api().ajax.reload();
$("#action_on_going").val("");
$("#div_loading").hide();
},
"json"
);
}
});

$("#click_refresh_folders_list").click(function() {
tableFolders.api().ajax.reload();
});
});


/**
*
Expand All @@ -225,35 +283,4 @@ function open_edit_folder_dialog(id)
$("#div_edit_folder").dialog("open");
}

/**
*
**/
function delete_multiple_folders()
{
var list_i = "";
$(".cb_selected_folder:checked").each(function() {
var elem = $(this).attr("id").split("-");
if (list_i == "") list_i = elem[1];
else list_i = list_i+';'+elem[1];
});
if (list_i != "" && $("#action_on_going").val("") == "") {
LoadingPage();
$("#action_on_going").val("multiple_folders");
var data = '{"foldersList":"'+list_i+'"}';
//send query
$.post(
"sources/folders.queries.php",
{
type : "delete_multiple_folders",
data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key'];?>")
},
function(data) {
RefreshPage("form_groupes");
$("#action_on_going").val("");
LoadingPage();
},
"json"
);
}
}
</script>

0 comments on commit a465ed1

Please sign in to comment.