diff --git a/website/public/API/adminChangeUser.php b/website/public/API/adminChangeUser.php index 067a7ba..5c9384c 100644 --- a/website/public/API/adminChangeUser.php +++ b/website/public/API/adminChangeUser.php @@ -15,6 +15,3 @@ if (isset($_POST["actions"]) && isset($_POST["userID"])) { } else if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) { changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]); } - -//header("location: ../admin.php"); -print_r($_POST); \ No newline at end of file diff --git a/website/public/API/adminSearchUsers.php b/website/public/API/adminSearchUsers.php index c809db7..f1d7fc1 100644 --- a/website/public/API/adminSearchUsers.php +++ b/website/public/API/adminSearchUsers.php @@ -35,6 +35,8 @@ if (isset($_POST['groupstatus'])) { $groupstatus = $_POST["groupstatus"]; } +$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC); + if ($pagetype == "user") { include ("../../views/adminpanel-table.php"); } else if ($pagetype == "group") { diff --git a/website/public/admin.php b/website/public/admin.php index 2785606..13a025d 100644 --- a/website/public/admin.php +++ b/website/public/admin.php @@ -8,7 +8,7 @@ - +
input, label").click(function(){ + $("#admin-filter, #admin-groupfilter > input, label").change(function(){ adminSearch(); }); $("#pagetype").change(function(){ adminSearch(); }); + /* Update hidden input to be equal to submit pressed, + because serialize doesn't take submit values. */ + $('#admin-batchform > button').click(function () { + $('#batchinput').prop('value', $(this).prop('value')); + console.log($('#batchinput').prop('value')); + }); + + $('#admin-groupbatchform > button').click(function () { + $('#groupbatchinput').prop('value', $(this).prop('value')); + console.log($('#batchinput').prop('value')); + }); + adminSearch(); }); -function checkAll(allbox) { - var checkboxes = document.getElementsByClassName('checkbox-list'); - - for (var i = 0; i < checkboxes.length; i++) { - if (checkboxes[i].type == 'checkbox') { - checkboxes[i].checked = allbox.checked; - } - } +function checkAll() { + $('.checkbox-list').each(function () { + $(this).prop('checked', $('#checkall').prop('checked')); + }); } -function checkCheckAll(allbox) { - var checkboxes = document.getElementsByClassName('checkbox-list'); +function checkCheckAll() { var checked = true; - for (var i = 0; i < checkboxes.length; i++) { - if (checkboxes[i].type == 'checkbox') { - if (checkboxes[i].checked == false) { - checked = false; - break; - } + $('.checkbox-list').each(function () { + if ($(this).prop('checked') == false) { + checked = false; + return; } - } - allbox.checked = checked; + }); + + $('#checkall').prop('checked', checked); } function changeFilter() { @@ -60,11 +66,21 @@ function adminSearch() { "API/adminSearchUsers.php", $("#admin-searchform").serialize() ).done(function (data) { - console.log(data); + // console.log(data); $("#usertable").html(data); }) } +function adminUpdate(form) { + console.log($(form).serialize()); + $.post( + "API/adminChangeUser.php", + $(form).serialize() + ).done(function () { + adminSearch(); + }) +} + function updatePageN() { $.post( "API/adminPageNumber.php", diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index f9410e1..75fa8b1 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -44,7 +44,7 @@ padding: 3px; } -.usertable tr { +.usertable th, tr { text-align: left; } diff --git a/website/views/adminpanel-grouptable.php b/website/views/adminpanel-grouptable.php index 4999666..9d2c8e8 100644 --- a/website/views/adminpanel-grouptable.php +++ b/website/views/adminpanel-grouptable.php @@ -16,7 +16,6 @@ while ($group = $q->fetch(PDO::FETCH_ASSOC)) { $name = $group['name']; $role = $group['status']; $description = $group['description']; - $function = "checkCheckAll(document.getElementById('checkall'))"; echo("