Skip to main content
Sign in
Snippets Groups Projects
Commit d004d710 authored by Christophorus Dharma Winata's avatar Christophorus Dharma Winata
Browse files
parents a238ce3d 43823e32
Branches
Tags
No related merge requests found
...@@ -44,8 +44,7 @@ localhost:8008/client/pages/login-page.php ...@@ -44,8 +44,7 @@ localhost:8008/client/pages/login-page.php
Login : 13521009, 13521012 Login : 13521009, 13521012
Register : 13521009, 13521012 Register : 13521009, 13521012
Mock datas: 13521009 Mock datas: 13521009
Logout : 13521009, 13521012 Logout : 13521009
Navigation bar : 13521012
User edit profile : 13521009 User edit profile : 13521009
User making sales : 13521009 User making sales : 13521009
Database Schema : 13521009 Database Schema : 13521009
...@@ -53,7 +52,8 @@ Dockerfile, docker-compose : 13521009 ...@@ -53,7 +52,8 @@ Dockerfile, docker-compose : 13521009
Catalog : 13521012 Catalog : 13521012
Pagination : 13521012 Pagination : 13521012
Search : 13521012 Search : 13521012
User Manage : 13521012
Admin User Detail (RUD) : 13521012
### Client-side ### Client-side
Login : 13521009, 13521012 Login : 13521009, 13521012
...@@ -66,3 +66,6 @@ Sidebar : 13521009, 13521012, 13521020 ...@@ -66,3 +66,6 @@ Sidebar : 13521009, 13521012, 13521020
Catalog : 13521012 Catalog : 13521012
Pagination : 13521012 Pagination : 13521012
Search : 13521012 Search : 13521012
User Manage : 13521012
Admin User Detail (RUD) : 13521012
RWD : 13521012
\ No newline at end of file
@import url('https://fonts.googleapis.com/css?family=Inter');
*{
margin: 0;
padding: 0;
font-family: Inter;
box-sizing: border-box;
transition: 0.5;
}
.container{
max-width: 100%;
height: 100vh;
mix-blend-mode: multiply;
background-position: center;
background-size: cover;
display: flex;
flex-direction: column;
}
h1{
padding-left: 5%;
}
.Username{
text-align: center;
padding: 10px;
}
.layer{
border: outset thick;
padding-top: 2%;
padding-bottom: 2%;
background-color: #5c12b1;
color: #f2f2f2;
width: 70%;
left: 15%;
position: relative;
}
.user-stat-container{
border: ridge;
position: relative;
left: 15%;
width: 70%;
height: 20vh;
}
.stat-box{
float: left;
border: ridge;
width: 25%;
height: 20vh;
}
.detail-container{
text-align: left;
width: 70%;
left: 15%;
position: relative;
padding-top: 2%;
padding-left: 10%;
padding-right: 10%;
border:outset thick;
}
.input-field{
border: ridge;
margin: 15px 0;
border-radius: 10px;
display: flex;
align-items: center;
max-height: 65px;
transition: max-height 0.5s;
overflow: hidden;
color: black;
}
input{
width: 100%;
background: transparent;
border: 0;
outline: 0;
padding: 18px;
font-size: 20px;
}
#showpass{
border: none;
font-size: 30px;
background-color: transparent;
margin-right: 20px;
cursor: pointer;
}
.btn-field{
padding-bottom: 20px;
}
.confirm{
flex-basis: 48%;
background: #3c00a0;
width: 13%;
color: #fff;
height: 40px;
border-radius: 10px;
font-size: 20px;
border: 0;
outline: 0;
cursor: pointer;
transition: background 1s;
}
.delete-user{
float: right;
flex-basis: 48%;
width: 13%;
background: red;
color: #fff;
height: 40px;
border-radius: 10px;
font-size: 15px;
border: 0;
outline: 0;
cursor: pointer;
transition: background 1s;
}
\ No newline at end of file
function showPass(){
document.getElementById("Password").setAttribute("type", "text");
document.getElementById("showpass").setAttribute("onclick", "dontShowPass()");
}
function dontShowPass(){
document.getElementById("Password").setAttribute("type", "password");
document.getElementById("showpass").setAttribute("onclick", "showPass()");
}
function userDetail(){
var useredit = document.getElementById("detail-container");
const formdata = new FormData();
var username = localStorage.getItem("username");
formdata.append("signal", "userdetail");
formdata.append("Username", username);
const xhr = new XMLHttpRequest();
xhr.open('POST', '../../server/controllers/admin-user-detail.php', true);
xhr.send(formdata);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200){
try{
var responseData = JSON.parse(xhr.responseText);
if (responseData.success){
var itemList = responseData.data;
useredit.innerHTML = `
<h2 class="Username"><i class="fa-solid fa-user"></i> ${itemList[0][1]}</h2>
<h2><i class="fa-solid fa-envelope"></i> Email</h2>
<div class="input-field">
<input id="Email" type="text" placeholder="Email" value="${itemList[0][0]}">
</div>
<h2><i class="fa-solid fa-lock"></i> Password</h2>
<div class="input-field">
<input id="Password" type="password" placeholder="Password" value="${itemList[0][2]}">
<button id="showpass" onclick="showPass()"><i class="fa-solid fa-eye"></i></button>
</div>
<div class="btn-field">
<button class="confirm" onclick="confirmEdit()">Confirm</button>
<button class="delete-user" onclick="deleteUser()">Delete User</button>
</div>
`;
} else {
alert("error: " + responseData.message);
}
} catch (err){}
} else if (xhr.status === 404){
var response = JSON.parse(xhr.responseText);
console.log(response.message);
}
}
}
function confirmEdit(){
var username = localStorage.getItem("username");
var email = document.getElementById("Email").value;
var password = document.getElementById("Password").value;
const formdata = new FormData();
formdata.append("signal", "useredit");
formdata.append("username", username);
formdata.append("email", email);
formdata.append("password", password);
const xhr = new XMLHttpRequest();
xhr.open('POST', '../../server/controllers/admin-user-detail.php', true);
xhr.send(formdata);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200){
try{
var responseData = JSON.parse(xhr.responseText);
if (responseData.success){
alert(responseData.message);
} else {
alert("error: " + responseData.message);
}
} catch (err){}
} else if (xhr.status === 404){
var response = JSON.parse(xhr.responseText);
console.log(response.message);
}
}
console.log("sip con");
}
function deleteUser(){
var username = localStorage.getItem("username");
const formdata = new FormData();
formdata.append("signal", "userdelete");
formdata.append("username", username);
const xhr = new XMLHttpRequest();
xhr.open('POST', '../../server/controllers/admin-user-detail.php', true);
xhr.send(formdata);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200){
try{
var responseData = JSON.parse(xhr.responseText);
if (responseData.success){
alert(responseData.message);
} else {
alert("error: " + responseData.message);
}
} catch (err){}
} else if (xhr.status === 404){
var response = JSON.parse(xhr.responseText);
console.log(response.message);
}
}
localStorage.removeItem("username");
console.log("sip del");
location.href = "../pages/user-manage.php";
}
\ No newline at end of file
function sendItem(username){ function sendItem(username){
localStorage.setItem("username", username); localStorage.setItem("username", username);
location.href = "#"; location.href = "../protoype/admin-user-detail.html"
} }
function usertable(){ function usertable(){
...@@ -29,7 +29,7 @@ function usertable(){ ...@@ -29,7 +29,7 @@ function usertable(){
</tr>`; </tr>`;
for (var i = 0; i < itemList.length; i++){ for (var i = 0; i < itemList.length; i++){
tablecontainer.innerHTML += ` tablecontainer.innerHTML += `
<tr class="contenttable" href="#" onclick="sendItem('${itemList[i][1]}')"> <tr class="contenttable" onclick="sendItem('${itemList[i][1]}')">
<td>${itemList[i][1]}</td> <td>${itemList[i][1]}</td>
<td>${itemList[i][0]}</td> <td>${itemList[i][0]}</td>
<td>${itemList[i][2]}</td> <td>${itemList[i][2]}</td>
... ...
......
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial scale=1.0">
<title>Admin: User Detail</title>
<link rel="stylesheet" href="../css/admin-user-detail.css">
<link rel="stylesheet" href="../css/navbar.css">
<link rel="stylesheet" href="../css/sidebar.css">
<script src="../js/navbar.js"></script>
<script src="../js/sidebar.js"></script>
<script src="../js/admin-user-detail.js"></script>
<script src="https://kit.fontawesome.com/8505941c5b.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="tabgroup" id="tabgroup">
<script>
addnavbar();
</script>
</div>
<div class="layer">
<h1>Edit User</h1>
</div>
<div class="user-stat-container">
<div class="stat-box">
statistik pembelian
</div>
<div class="stat-box">
statistik penjualan
</div>
<div class="stat-box">
statistik pengeluaran
</div>
<div class="stat-box">
statistik pemasukan
</div>
</div>
<div class="detail-container" id="detail-container">
<script>
userDetail();
</script>
</div>
<div class="sidebar" id="sidebar">
<script>
addsidebar();
</script>
</div>
</div>
</body>
</html>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta name="viewport" content="width=device-width, initial scale=1.0"> <meta name="viewport" content="width=device-width, initial scale=1.0">
<title>Catalog</title> <title>Admin: User Manage</title>
<link rel="stylesheet" href="../css/user-manage.css"> <link rel="stylesheet" href="../css/user-manage.css">
<link rel="stylesheet" href="../css/navbar.css"> <link rel="stylesheet" href="../css/navbar.css">
<link rel="stylesheet" href="../css/sidebar.css"> <link rel="stylesheet" href="../css/sidebar.css">
... ...
......
<?php
require_once "connect_database.php";
if ($_SERVER["REQUEST_METHOD"] == "POST"){
if ($_POST["signal"] == "userdetail") {
$username = $_POST["Username"];
$conn = connect_database();
$query = "SELECT * FROM user WHERE username='$username'";
$stmt = $conn->prepare($query);
if (!$stmt){
die("Error in query preparation: ". $conn->error);
}
$result = $stmt->execute();
if (!$result){
die("Error in query execution: " . $stmt->error);
}
$resultSet = $stmt->get_result();
$rows = $resultSet->fetch_all();
if (!empty($rows)){
$response = array("success" => true, "message" => "data sent", "data" => $rows);
} else {
$response = array("success" => false, "message" => "Error: not found");
}
echo json_encode($response);
mysqli_close($conn);
} else if ($_POST["signal"] == "useredit"){
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$conn = connect_database();
$query = "UPDATE user
SET email='$email', password = '$password'
WHERE username='$username'";
$stmt = $conn->prepare($query);
if (!$stmt){
die("Error in query preparation: ". $conn->error);
}
$result = $stmt->execute();
if (!$result){
die("Error in query execution: " . $stmt->error);
} else {
$response = array("success" => true, "message" => "edit account for {$username} success");
}
} else if ($_POST["signal"] == "userdelete"){
$username = $_POST["username"];
$conn = connect_database();
$query = "DELETE FROM user WHERE username='$username'";
$stmt = $conn->prepare($query);
if (!$stmt){
die("Error in query preparation: ". $conn->error);
}
$result = $stmt->execute();
if (!$result){
die("Error in query execution: " . $stmt->error);
} else {
$response = array("success" => true, "message" => "delete account for {$username} success");
}
}
}
?>
\ No newline at end of file
...@@ -26,3 +26,4 @@ ...@@ -26,3 +26,4 @@
echo json_encode($response); echo json_encode($response);
mysqli_close($conn); mysqli_close($conn);
} }
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment