diff --git a/client/css/account-page.css b/client/css/account-page.css index 646ce25066e24960886a235c3ab536cd0277e3a4..5cac9e2c5839a746249917093c6af08e6fd66f7f 100644 --- a/client/css/account-page.css +++ b/client/css/account-page.css @@ -9,21 +9,22 @@ } .container{ - position: relative; max-width: 100%; height: 100vh; mix-blend-mode: multiply; background-position: center; background-size: cover; - display: grid; - place-items: center; + display: flex; + flex-direction: column; } .account-details{ position: relative; min-width: 50%; min-height: 67%; max-width: 67%; - margin: 15%; + margin-left: 15%; + margin-right: 15%; + margin-top: 5%; border-style: ridge; display:block; border-radius: 10px; @@ -31,10 +32,10 @@ } .account-details h1 { - margin-bottom: 10%; - margin-top: 5%; + margin-bottom: 10px; + /* margin-top: 5%; */ margin-left: 5%; - font-size: 40px; + font-size: 30px; } .button-field { diff --git a/client/css/admin.css b/client/css/admin.css deleted file mode 100644 index 4158afb01d42a0f4d7e8e3f2de265257a942569c..0000000000000000000000000000000000000000 --- a/client/css/admin.css +++ /dev/null @@ -1,472 +0,0 @@ -@import url('https://fonts.googleapis.com/css?family=Inter'); - -/* admin */ -*{ -position: relative; -width: 1280px; -height: 768px; - -background: #FFFFFF; -border-radius: 10px; -} - -/* topBar */ -.topBar{ -position: absolute; -width: 1280px; -height: 116px; -left: 0px; -top: -2px; -} - - -/* Rectangle 4 */ -.topBarBox{ -position: absolute; -width: 1280px; -height: 116px; -left: 0px; -top: -2px; - -background: #AA1E1E; -} - -/* icon */ -.icon{ - position: absolute; - width: 30px; - height: 40px; - left: 1129px; - top: 37px; - - - -/* Rectangle 1 */ - .bodyIcon{ - position: absolute; - width: 30px; - height: 21px; - left: 1129px; - top: 56px; - - background: #D9D9D9; - } - -/* Ellipse 1 */ - .headIcon{ - position: absolute; - width: 20px; - height: 20px; - left: 1134px; - top: 37px; - - background: #D9D9D9; - } -} - -/* search-field */ -.search-field{ -position: absolute; -width: 411.44px; -height: 34px; -left: 500px; -top: 36px; - - - -/* search-box */ - .search-box{ - position: absolute; - width: 411.44px; - height: 34px; - left: calc(50% - 411.44px/2 + 65.72px); - top: 36px; - - background: rgba(255, 255, 255, 0.67); - border-radius: 10px; - } - -/* [CITYPNG 1 */ - .searchimg{ - position: absolute; - width: 29px; - height: 29px; - left: 877px; - top: 38px; - - background: url(../image/search.png); - } - -/* Search.. */ - .searchTxt{ - position: absolute; - width: 115.94px; - height: 24.98px; - left: 509.23px; - top: 40.86px; - - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - font-size: 20px; - line-height: 24px; - /* identical to box height */ - - color: rgba(0, 0, 0, 0.35); - } -} - -/* clipart861651 1 */ -.option-icon{ -position: absolute; -width: 36px; -height: 32px; -left: 32px; -top: 72px; - -background: url(../image/option.png); -transform: matrix(1, 0, 0, -1, 0, 0); -} - -/* LOG OUT */ -.logOutTxt{ -position: absolute; -width: 98px; -height: 24px; -left: 1182px; -top: 43px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 20px; -line-height: 24px; - -color: #FFFFFF; -} - - -/* HI, ADMIN! */ -.greetAdmin{ -position: absolute; -width: 112px; -height: 27px; -left: 1000px; -top: 43px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 20px; -line-height: 24px; - -color: #FFFFFF; -} - - -/* logo */ -.logo{ - position: relative; - top: 10%; - left: 50%; - transform: translate(-50%, 50%); - flex-shrink: 0; - min-width: 400px; - min-height: 100px; - max-width: 740px; - max-height: 199px; - background-color: transparent; - -background: url(../image/logoregis.svg); -} -/* menu-admin */ -.menu-admin{ -position: absolute; -width: 210px; -height: 654px; -left: -1px; -top: 114px; -} - - -/* menu-bar */ -.menu-bar{ -position: absolute; -width: 210px; -height: 654px; -left: -1px; -top: 114px; - -background: #012A93; -} - -/* PRODUK */ -.produk{ -position: absolute; -width: 125px; -height: 27px; -left: 13px; -top: 125px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 700; -font-size: 20px; -line-height: 24px; - -color: #FFFFFF; -} - - -/* EditProduk */ -.editProduk{ -position: absolute; -width: 125px; -height: 27px; -left: 26px; -top: 180px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; -} - - -/* DaftarProduk */ -.daftarProduk{ -position: absolute; -width: 125px; -height: 27px; -left: 26px; -top: 155px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; -} - - -/* DaftarPengguna */ -.daftarUser{ -position: absolute; -width: 125px; -height: 27px; -left: 26px; -top: 296px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; -} - - -/* DaftarTransaksi */ -.daftarTransaksi{ -position: absolute; -width: 125px; -height: 27px; -left: 26px; -top: 432px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; - -} - -/* EditTransaksi */ -.editTransaksi{ -position: absolute; -width: 125px; -height: 27px; -left: 26px; -top: 454px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; -} - - -/* HapusTransaksi */ -.hapusTransaksi{ -position: absolute; -width: 125px; -height: 27px; -left: 26px; -top: 501px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; - -} - -/* EditProfilPengguna */ -.editProfilUser{ -position: absolute; -width: 158px; -height: 16px; -left: 25px; -top: 323px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; -} - - -/* HapusPengguna */ -.deleteUser{ -position: absolute; -width: 125px; -height: 34px; -left: 25px; -top: 374px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; -} - - -/* TambahProduk */ -.addProduk{ -position: absolute; -width: 125px; -height: 27px; -left: 25px; -top: 205px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; -} - - -/* HapusProduk */ -.hapusProduk{ -position: absolute; -width: 125px; -height: 27px; -left: 27px; -top: 232px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; - -color: #FFFFFF; - -} - -/* TambahPengguna */ -.addUser{ -position: absolute; -width: 140px; -height: 19px; -left: 24px; -top: 347px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; -/* identical to box height */ - -color: #FFFFFF; -} - - -/* TambahTransaksi */ -.addTransaksi{ -position: absolute; -width: 140px; -height: 19px; -left: 25px; -top: 481px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 400; -font-size: 15px; -line-height: 18px; -/* identical to box height */ - -color: #FFFFFF; - -} - -/* PENGGUNA */ -.user{ -position: absolute; -width: 138px; -height: 27px; -left: 8px; -top: 263px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 700; -font-size: 20px; -line-height: 24px; - -color: #FFFFFF; -} - - -/* TRANSAKSI */ -.transaksi{ -position: absolute; -width: 138px; -height: 27px; -left: 12px; -top: 402px; - -font-family: 'Inter'; -font-style: normal; -font-weight: 700; -font-size: 20px; -line-height: 24px; - -color: #FFFFFF; -} diff --git a/client/css/cart.css b/client/css/cart.css index fb1e4b53d146bae71a5d4760f992888df3b66426..50f2a2aeb5fed27bc8a572889b87ea66f27f28a3 100644 --- a/client/css/cart.css +++ b/client/css/cart.css @@ -9,20 +9,19 @@ } .container{ - position: relative; max-width: 100%; height: 100vh; mix-blend-mode: multiply; background-position: center; background-size: cover; - display: block; - place-items: center; + display: flex; + flex-direction: column; } .cart-group{ - padding-top: 10%; + padding-top: 5%; display: block; - /* background-color: red; */ + position: relative; } .cart-group h1{ diff --git a/client/css/make-sale.css b/client/css/make-sale.css index 532d5bd6ffe3061d5353f0bbe1e770bd876704cd..0e79785578d8228610de2d46e2185a68696fa376 100644 --- a/client/css/make-sale.css +++ b/client/css/make-sale.css @@ -10,98 +10,134 @@ .container{ - width: 100%; + max-width: 100%; height: 100vh; - background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(../image/bg.webp); mix-blend-mode: multiply; background-position: center; background-size: cover; - position: relative; - place-items: center; - display: block; + display: flex; + flex-direction: column; } .saleform-group { + flex: 1 1 auto; position: relative; - /* width: 31%; - height: 31%; */ - margin-top: 5vh; + padding-top: 5vh; min-width: 300px; - flex-shrink: 0; - display: grid; - place-items: center; + display: flex; + flex-direction: column; + margin-left: 10%; + margin-right: 10%; } .saleform-group h1 { - color: #ffffffab; font-size: 30px; - font-style: normal; - font-weight: 800; - line-height: normal; - position: relative; - text-align: center; - margin-bottom: 21px; + padding-bottom: 10px; } -.saleform-group button { - position: relative; - left: 25%; -} -form p { - text-align : center; - font-size : 20px; - color : #ffffffab; + +#price-criteria, #quantity-criteria { + text-align : left; + font-size : small; + color: red; + padding-left: 10px; + /* color : #ffffffab; */ } -@media screen and ((max-width: 400px) or (max-height: 750px)) { - .saleform-group{ - top: -5%; +@media screen and ((max-width: 600px)) { + .input-group{ + display: flex; + flex-direction: column; } } -/* .input-group { -} */ -.input-field { - background: linear-gradient(rgba(255,255,255,0.67), rgba(255,255,255,0.67)); - margin: 15px 0; + +#saleform { + display: flex; + flex-direction: column; + flex: 1 1 auto; +} +.input-group { + display: flex; + flex: 1 1 auto; +} +.input-image-field { + width: 25vw; + max-height: 25vw; + display: inline-flex; + flex-direction: column; border-radius: 10px; + transition: max-height 0.5s; +} +.input-text-fields { + flex: 1 1 auto; + padding: 10px; display: flex; + flex-direction: column; +} +.input-field { + margin: 10px; + border-radius: 10px; align-items: center; - max-height: 65px; + background-color: #eaeaea; transition: max-height 0.5s; overflow: hidden; color: black ; } -.currency_label { - margin: 15px 15px; +#product_description-field{ + display: flex; +} + +#product_description { + flex: 1 1 auto; + resize:vertical; + background-color: transparent; + padding: 10px; + font-size: small; + border-color: transparent; } .input-field ::placeholder { color: black; } -input { +/* #product_image { + background-color: azure; +} */ + +.input-field input { width: 100%; - background: transparent; padding: 18px; + border-color: transparent; } .button-field { width: 100%; + margin-top: 4vh; display: flex; - justify-content: space-between; + flex-direction: row-reverse; } .button-field button{ - flex-basis: 48%; + /* flex-basis: 48%; */ + min-width: 25%; + height: 5vh; + border-color: transparent; + margin-right: 15px; + /* margin-bottom: 15px; */ background: #3c00a0; color: #fff; - height: 40px; - border-radius: 20px; + border-radius: 10px; font-size: 20px; border: 0; outline: 0; cursor: pointer; transition: background 1s; +} + +#image-preview { + background-color: azure; + width: 24vw; + max-height: 24vw; } \ No newline at end of file diff --git a/client/js/admin.js b/client/js/admin.js deleted file mode 100644 index 26e5803e922813f0fcefe870b137cf5a10dcfa0f..0000000000000000000000000000000000000000 --- a/client/js/admin.js +++ /dev/null @@ -1,20 +0,0 @@ -// Get the menu admin element -const menuAdmin = document.querySelector('.menu-admin'); - -// Get the content element -const content = document.querySelector('.content'); - -// Toggle the menu admin -menuAdmin.addEventListener('click', function() { - menuAdmin.classList.toggle('active'); -}); - -// Show the content when the menu admin is closed -menuAdmin.addEventListener('mouseleave', function() { - content.classList.remove('hidden'); -}); - -// Hide the content when the menu admin is opened -menuAdmin.addEventListener('mouseenter', function() { - content.classList.add('hidden'); -}); diff --git a/client/js/login-page.js b/client/js/login-page.js index e956baac46e579607507a0852b8af1cd6c3243a0..838f9306685e21ebab24ab0c9ce16c6feb08cc35 100644 --- a/client/js/login-page.js +++ b/client/js/login-page.js @@ -33,7 +33,7 @@ signinBtn.onclick = function(){ username = ""; password = ""; alert(responseData.message); - location.href = "../pages/account-page.php"; + location.href = "../pages/catalog.php"; } else { alert("error: " + responseData.message) } @@ -92,7 +92,7 @@ signupBtn.onclick = function(){ username = ""; password = ""; alert("Sign up success: " + responseData.message); - location.href = "../pages/account-page.php"; + location.href = "../pages/catalog.php"; } else { console.log("Caught exception"); console.log("error: " + responseData.message); diff --git a/client/js/make-sale.js b/client/js/make-sale.js new file mode 100644 index 0000000000000000000000000000000000000000..7d1b36fcbbc6505eabe805f2a277838ff172b9db --- /dev/null +++ b/client/js/make-sale.js @@ -0,0 +1,106 @@ +function checkValid(field, criteria, p_affected, response_if_invalid){ + if (criteria){ + //valid + resetFieldStyle(field, p_affected); + } else { + //invalid + invalidStyle(field, response_if_invalid, p_affected); + } +} + +function checkNumeric(field, field_input, p_affected) { + checkValid(field, (/^\d+$/.test(field_input) || field_input==""), p_affected, "please input numerical value"); +} + +function checkNumericPrice() { + checkNumeric( + document.getElementById("product_price-field"), + document.getElementById("product_price").value, + document.getElementById("price-criteria") + ) +} +function checkNumericQuantity() { + checkNumeric( + document.getElementById("product_quantity-field"), + document.getElementById("product_quantity").value, + document.getElementById("quantity-criteria") + ) +} + +function invalidStyle(param_field, reason, criteria_p) { + param_field.style.borderColor = "red"; + criteria_p.textContent = reason; +} + +function resetFieldStyle(param_field, criteria_p) { + param_field.style.borderColor = "black"; + criteria_p.textContent = ' '; +} + +var openFile = function(file) { + var input = file.target; + var reader = new FileReader(); + reader.onload = function(){ + var dataURL = reader.result; + var output = document.getElementById('image-preview'); + output.src = dataURL; + }; + reader.readAsDataURL(input.files[0]); +}; + +function submitSale() { + // instansiasi FormData dan menambahkan hasil dari form + var saleData = new FormData(); + // saleData.append('item_id', <tidak>) // karena item id sesuai penomoran dari 1, jadi diproses sendiri di server + saleData.append('name', document.getElementById("product_name").value); + saleData.append('picture_path', document.getElementById("product_image").files.length == 0 ? "no_picture.jpeg" : document.getElementById("product_image").files[0].name); + saleData.append('description', document.getElementById("product_description").value); + saleData.append('price',document.getElementById("product_price").value); + saleData.append('quantity', document.getElementById("product_quantity").value); + // saleData.append('Seller_username', sessionStorage.getItem("username")); + + for (const iterator of saleData.values()) { + console.log(iterator); + } + //xmlhttprequest + const xhr = new XMLHttpRequest(); + xhr.open('POST', '../../server/controllers/sell_item.php', true); + xhr.onreadystatechange = function () { + if (xhr.readyState === 4 && xhr.status === 200) { + // Process the response data here + var responseData = JSON.parse(xhr.responseText); + if (responseData.success) { + alert(responseData.message); + var file = document.getElementById("product_image").files[0]; + var imageData = new FormData(); + imageData.append('image', file); + const xhr_uploadimage = new XMLHttpRequest(); + xhr_uploadimage.open('POST', '../../server/controllers/upload_jpg.php', true); + xhr_uploadimage.onreadystatechange = function () { + if (xhr_uploadimage.readyState === 4 && xhr_uploadimage.status === 200) { + // Process the response data here + var responseData_uploadimage = JSON.parse(xhr_uploadimage.responseText); + if (responseData_uploadimage.success) { + alert(responseData_uploadimage.message); + location.href = "../pages/catalog.php"; + } else { + alert("error: " + responseData_uploadimage.message) + } + // Update the DOM or perform other actions with the data + } else if (xhr_uploadimage.status === 404) { + var responseData_uploadimage = JSON.parse(xhr_uploadimage.responseText); + console.log(responseData_uploadimage.message); + } + }; + xhr_uploadimage.send(imageData); + } else { + alert("error: " + responseData.message) + } + // Update the DOM or perform other actions with the data + } else if (xhr.status === 404) { + var responseData = JSON.parse(xhr.responseText); + alert(responseData.message); + } + }; + xhr.send(saleData); +} \ No newline at end of file diff --git a/client/js/navbar.js b/client/js/navbar.js index f51feeaecfb68f73a0ca7da74255f6718de9e0db..b2213c1ef8a9bd6a010e7b581a43b36d918b192e 100644 --- a/client/js/navbar.js +++ b/client/js/navbar.js @@ -11,7 +11,7 @@ addnavbar = () => { <i class="fa-solid fa-magnifying-glass"></i> </button> </div> - <a class="tabright" href="#"> + <a class="tabright" href="../pages/cart.php"> <i class="fa-solid fa-cart-shopping"></i> Cart </a> diff --git a/client/js/sidebar.js b/client/js/sidebar.js index d8d254719bb096cf85f4f90607434c42ecd12c3a..f04990ee4d4a850f48c9694df843bae4b219eb9b 100644 --- a/client/js/sidebar.js +++ b/client/js/sidebar.js @@ -12,7 +12,7 @@ function closeSidebar(){ addsidebar = () => { return document.getElementById("sidebar").innerHTML = ` - <li><a href='#' id="account"> + <li><a href='../pages/account-page.php' id="manageuser"> <i class="fa-solid fa-user"></i> Account </a></li> <li><a href='#' id="manageuser"> @@ -27,11 +27,11 @@ addsidebar = () => { <i class="fa-solid fa-user-plus"></i> Add User </a></li> - <li><a href='#' id="makesale"> + <li><a href='../pages/make-sale.php' id="makesale"> <i class="fa-solid fa-cart-plus"></i> Make Sale </a></li> - <li><a href='#' id="logout"> + <li><a href='../../server/controllers/signout.php' id="logout"> <i class="fa-solid fa-right-from-bracket"></i> Log Out </a></li>1` diff --git a/client/pages/account-page.php b/client/pages/account-page.php index 07844f1d5b8d70a44075a95f7e830cfc58290e01..b6e4b045d097a6453fb08faebec322a7a48224dd 100644 --- a/client/pages/account-page.php +++ b/client/pages/account-page.php @@ -1,4 +1,7 @@ -<?php session_start()?> +<?php + session_start(); + require_once "../../server/controllers/loggedout_catch.php"; +?> <!DOCTYPE html> <html> <head> @@ -6,16 +9,16 @@ <title>Account Page</title> <link rel="stylesheet" href="../css/account-page.css"> <script src="https://kit.fontawesome.com/8505941c5b.js" crossorigin="anonymous"></script> - <!-- <link rel="stylesheet" href="../css/navbar.css"> --> - <!-- <script src="../js/navbar.js"></script> --> + <link rel="stylesheet" href="../css/navbar.css"> + <script src="../js/navbar.js"></script> </head> <body> <div class="container"> - <!-- <div class="tabgroup" id="tabgroup"> + <div class="tabgroup" id="tabgroup"> <script> addnavbar(); </script> - </div> --> + </div> <div class="account-details"> <h1> Account Details @@ -23,13 +26,13 @@ <div class="text-field"> <label class="detail-label">Email</label> <input class="detail-value" type="text" id="email-value" placeholder= - <?php echo isset($_SESSION["email"])?$_SESSION['email']:"ERROR: no login"?> + <?php echo isset($_SESSION["email"])?$_SESSION['email']:"<nologin>"?> disabled> </div> <div class="text-field"> <label class="detail-label">Username</label> <input class="detail-value" type="text" id="username-value" placeholder= - <?php echo isset($_SESSION["username"])?$_SESSION['username']:"ERROR: no login"?> + <?php echo isset($_SESSION["username"])?$_SESSION['username']:"<nologin>"?> disabled> </div> <div class="text-field"> @@ -48,6 +51,11 @@ <button id="submit-edit-button" onclick="submitEdit()">Submit</button> </div> </div> + <div class="sidebar" id="sidebar"> + <script> + addsidebar(); + </script> + </div> </div> <script src="../js/account-page.js"></script> </body> diff --git a/client/pages/admin.php b/client/pages/admin.php deleted file mode 100644 index e888ae1ce1697e78951dbbbad7e0d1ffa4f09c61..0000000000000000000000000000000000000000 --- a/client/pages/admin.php +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta name="viewport" content="width=device-width, initial scale=1.0"> - <title>Admin Page</title> - <link rel="stylesheet" href="../css/login-page.css"> - <!-- <link rel="stylesheet" href="../css/navbar.css"> --> - <script src="https://kit.fontawesome.com/8505941c5b.js" crossorigin="anonymous"></script> - <!-- <script src="../js/navbar.js"></script> --> - <link rel="stylesheet" href="../css/admin.css"> -</head> -<body> - - <div class="admin"> - - <div class="topBar"> - <div class="topBarBox"> - <img src="../image/logoregis.svg" class="logo"> - <div class="search-field"> - <input type="text" class="search-box"> - <img src="../image/search.png" class="searchimg"> - </div> - <div class="option-icon"></div> - <div class="logOutTxt">Log Out</div> - </div> - </div> - - <div class="menu-admin"> - <div class="menu-bar"> - <div class="produk">Produk</div> - <div class="user">Pengguna</div> - <div class="transaksi">Transaksi</div> - </div> - </div> - - <div class="content"></div> - - </div> - - <script src="../js/admin.js"></script> - -</body> -</html> diff --git a/client/pages/cart.php b/client/pages/cart.php new file mode 100644 index 0000000000000000000000000000000000000000..9fd59ae8f99cff49b91baba0574748ec8d45e7da --- /dev/null +++ b/client/pages/cart.php @@ -0,0 +1,72 @@ +<?php session_start(); + require_once "../../server/controllers/loggedout_catch.php"; +?> +<!DOCTYPE html> +<html> + <head> + <meta name="viewport" content="width=device-width, initial scale=1.0"> + <title>Cart</title> + <link rel="stylesheet" href="../css/cart.css"> + <link rel="stylesheet" href="../css/navbar.css"> + <script src="https://kit.fontawesome.com/8505941c5b.js" crossorigin="anonymous"></script> + <script src="../js/navbar.js"></script> + <script src="../js/cart.js"></script> + </head> + <body> + <div class="container"> + <div class="tabgroup" id="tabgroup"> + <script> + addnavbar(); + </script> + </div> + <div class="cart-group"> + <h1> + Cart + </h1> + <div class="cart-list"> + <div class="item"> + <div class="item-picture-group"> + <image src="#" class="item-picture"></image> + </div> + <div class="item-text-fields"> + <label class="item-label">Name</label> + <label class="item-label">Quantity</label> + <label class="item-label">Price</label> + </div> + </div> + <div class="item"> + <div class="item-picture-group"> + <image src="#" class="item-picture"></image> + </div> + <div class="item-text-fields"> + <label class="item-label">Name</label> + <label class="item-label">Quantity</label> + <label class="item-label">Price</label> + </div> + </div> + <div class="item"> + <div class="item-picture-group"> + <image src="#" class="item-picture"></image> + </div> + <div class="item-text-fields"> + <label class="item-label">Name</label> + <label class="item-label">Quantity</label> + <label class="item-label">Price</label> + </div> + </div> + <!-- contains item divs according to data --> + </div> + <div class="button-field"> + <button id="checkout-button" onclick="submitCheckout()"> + Checkout + </button> + </div> + </div> + <div class="sidebar" id="sidebar"> + <script> + addsidebar(); + </script> + </div> + </div> + </body> +</html> \ No newline at end of file diff --git a/client/pages/login-page.php b/client/pages/login-page.php index e64817c34ac3ef3a50716735114add3c57f92adf..20b3da0cef01ffae8e81755eeb5affdf93cba6a7 100644 --- a/client/pages/login-page.php +++ b/client/pages/login-page.php @@ -16,18 +16,18 @@ <meta name="viewport" content="width=device-width, initial scale=1.0"> <title>Sign In and Sign Up</title> <link rel="stylesheet" href="../css/login-page.css"> - <!-- <link rel="stylesheet" href="../css/navbar.css"> --> + <link rel="stylesheet" href="../css/navbar.css"> <script src="https://kit.fontawesome.com/8505941c5b.js" crossorigin="anonymous"></script> - <!-- <script src="../js/navbar.js"></script> --> + <script src="../js/navbar.js"></script> </head> <body> <div class="container"> - <!-- <div class="tabgroup" id="tabgroup"> + <div class="tabgroup" id="tabgroup"> <script> addnavbar(); </script> - </div> --> + </div> <img class="icon" src="../image/logoregis.svg" width="58%" height="26%"> <div class="form-box"> <h1 id="title">SIGN UP</h1> diff --git a/client/pages/make-sale.php b/client/pages/make-sale.php index 2196fe8cc688710b8d73ea644fa12fff48d7177a..f5bbf4ea450ed4b97dc174a278dc346dc8fb611e 100644 --- a/client/pages/make-sale.php +++ b/client/pages/make-sale.php @@ -1,3 +1,6 @@ +<?php session_start(); + require_once "../../server/controllers/loggedout_catch.php"; +?> <!DOCTYPE html> <html> <head> @@ -7,6 +10,7 @@ <link rel="stylesheet" href="../css/make-sale.css"> <script src="../js/navbar.js"></script> <script src="https://kit.fontawesome.com/8505941c5b.js" crossorigin="anonymous"></script> + <script src="../js/make-sale.js"></script> </head> <body> @@ -18,27 +22,38 @@ <h1 id="title">Make A Sale</h1> <form id="saleform"> <div class="input-group"> - <div class="input-field"> - <input type="text" id="product_name" placeholder="Product Name"> + <div class="input-image-field"> + <img src="#" id="image-preview" alt=""> + <input accept=".jpg, .jpeg" type="file" id="product_image" placeholder="Product Image" title="Product Image" onchange="openFile(event)" required> </div> - <div class="input-field"> - <input type="text" id="product_description" placeholder="Product Description"> - </div> - <div class="input-field"> - <input type="text" id="product_price" placeholder="Price"> - </div> - <div class="input-field"> - <input type="text" id="product_qty" placeholder="Quantity"> - </div> - <div class="input-field"> - <input type="image" id="product_image" placeholder="Product Image" title="Product Image"> + <div class="input-text-fields"> + <div class="input-field"> + <input type="text" id="product_name" placeholder="Product Name" required> + </div> + <div class="input-field" id="product_description-field"> + <textarea type="text" id="product_description" placeholder="Product Description" required></textarea> + </div> + <div class="input-field" id="product_price-field"> + <input type="text" id="product_price" placeholder="Price" oninput="checkNumericPrice()" required> + </div> + <p id="price-criteria"> </p> + <div class="input-field" id="product_quantity-field"> + <input type="text" id="product_quantity" placeholder="Quantity" oninput="checkNumericQuantity()" required> + </div> + <p id="quantity-criteria"> </p> </div> + </div> <div class="button-field"> - <button type="button" id="salesubmit">Done</button> + <button type="button" id="salesubmit" onclick="submitSale()">Done</button> </div> </form> </div> + <div class="sidebar" id="sidebar"> + <script> + addsidebar(); + </script> + </div> </div> </body> </html> \ No newline at end of file diff --git a/client/protoype/cart.html b/client/prototype/cart.html similarity index 100% rename from client/protoype/cart.html rename to client/prototype/cart.html diff --git a/client/protoype/navbar.html b/client/prototype/navbar.html similarity index 100% rename from client/protoype/navbar.html rename to client/prototype/navbar.html diff --git a/client/pages/navbar.php b/client/prototype/navbar.php similarity index 100% rename from client/pages/navbar.php rename to client/prototype/navbar.php diff --git a/client/protoype/sidebar.html b/client/prototype/sidebar.html similarity index 100% rename from client/protoype/sidebar.html rename to client/prototype/sidebar.html diff --git a/client/protoype/account-page.html b/client/protoype/account-page.html deleted file mode 100644 index 4e25b413e792b5b49bc190378527a1b464d59844..0000000000000000000000000000000000000000 --- a/client/protoype/account-page.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta name="viewport" content="width=device-width, initial scale=1.0"> - <title>Account Page</title> - <link rel="stylesheet" href="../css/account-page.css"> - <script src="https://kit.fontawesome.com/8505941c5b.js" crossorigin="anonymous"></script> - <!-- <link rel="stylesheet" href="../css/navbar.css"> --> - <!-- <script src="../js/navbar.js"></script> --> - <!-- <?php session_start() ?> --> - </head> - <body> - <div class="container"> - <!-- <div class="tabgroup" id="tabgroup"> - <script> - addnavbar(); - </script> - </div> --> - <div class="account-details"> - <h1> - Account Details - </h1> - <div class="text-field"> - <label class="detail-label">Email</label> - <input class="detail-value" type="text" id="email-value" placeholder="email-value" disabled> - </div> - <div class="text-field"> - <label class="detail-label">Username</label> - <input class="detail-value" type="text" id="username-value" placeholder="username-value" disabled> - </div> - <div class="text-field"> - <label class="detail-label">Password</label> - <input class="detail-value password" type="password" id="password-value" placeholder="--------" disabled oninput="confirmPassword()" onchange="cancelConfirmPassword()"> - <p class="password-criteria"></p> - </div> - <div class="text-field" id="confirm-password-field"> - <label class="detail-label">Confirm Password</label> - <input class="detail-value password" type="password" id="confirm-password-value" placeholder="Re-Type Password" oninput="confirmCorrectRetype()"> - <p class="password-criteria"></p> - </div> - <div class="button-field"> - <button id="edit-profile-button" onclick="startEdit()">Edit profile</button> - <button id="cancel-edit-button" onclick="cancelEdit()">Cancel</button> - <button id="submit-edit-button" onclick="submitEdit()">Submit</button> - </div> - </div> - </div> - <script src="../js/account-page.js"></script> - </body> -</html> \ No newline at end of file diff --git a/server/controllers/loggedout_catch.php b/server/controllers/loggedout_catch.php new file mode 100644 index 0000000000000000000000000000000000000000..972bd9108344c81f638c996e84ac6f576b9fd368 --- /dev/null +++ b/server/controllers/loggedout_catch.php @@ -0,0 +1,13 @@ +<?php +if (!isset($_SESSION['username']) or !isset($_SESSION['email'])) { + echo '<script type = "text/javascript"> + function loggedout_catch() { + alert("You are logged out, please login first"); + location.href = "../pages/login-page.php" + } + loggedout_catch(); + </script>'; +} else if (isset($_COOKIE['username'])) { + // continue +} +?> \ No newline at end of file diff --git a/server/controllers/sell_item.php b/server/controllers/sell_item.php new file mode 100644 index 0000000000000000000000000000000000000000..ebec85d36eee3be718f7190ff3efa45a6f86eaff --- /dev/null +++ b/server/controllers/sell_item.php @@ -0,0 +1,46 @@ +<?php + session_start(); + require_once "connect_database.php"; + global $conn; $conn = connect_database(); + function itemCount_query(){ + global $conn; + $query = "SELECT COUNT(*) FROM `item`"; + $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(); + return $resultSet->fetch_all(MYSQLI_ASSOC); + } + if ($_SERVER["REQUEST_METHOD"] == "POST") { + global $conn; + $insert_query = "INSERT INTO `item` (`item_id`, `name`, `picture_path`, `description`, `price`, `quantity`, `Seller_username`) VALUES ((?), (?), (?), (?), (?), (?), (?)) + "; + $item_id = itemCount_query()[0]["COUNT(*)"] + 1; + $name = $_POST["name"]; + $picture_path = $_POST["picture_path"]; + $price = $_POST["price"]; + $quantity = $_POST["quantity"]; + $seller_username = $_SESSION["username"]; + + $stmt = $conn->prepare($insert_query); + if (!$stmt) { + die("Error in query preparation". $conn->error); + } + + $stmt->bind_param("issssss", $item_id, $name, $picture_path, $description, $price, $quantity, $seller_username); + $result = $stmt->execute(); + if (!$result) { + $response = array("success" => "false", "message" => $stmt.error); + die ("Error in query execution: " . $stmt->error); + } else { + $response = array("success" => "true", "message" => "item has been added"); + } + echo json_encode($response); + mysqli_close($conn); + } +?> \ No newline at end of file diff --git a/server/controllers/signin.php b/server/controllers/signin.php index 7c3554812126288f45ac4a26e9e35c8f5a926fd3..4378b76d029d6555300dcec7fc9ef3633150bcf4 100644 --- a/server/controllers/signin.php +++ b/server/controllers/signin.php @@ -15,9 +15,11 @@ if ($rows_user[0]["username"] == $username and $rows_user[0]["password"] == $password) { $_SESSION['username'] = $username; $_SESSION['email'] = $rows_user[0]["email"]; + setcookie("username", $username, time()+60*60); $rows_admin = signin_query($username, $password, "admin"); if (!empty($rows_admin) and $rows_admin[0]["admin_username"] == $username){ $_SESSION['admin_status'] = true; + setcookie("admin_status", true); $response = array("success" => true, "message" => "admin {$username} is found"); } else { $_SESSION['admin_status'] = false; diff --git a/server/controllers/signout.php b/server/controllers/signout.php index fc2eb82052207d48daed72574ef98839781860c6..c9d5088ec6974d97981517b384f26d537ddfd257 100644 --- a/server/controllers/signout.php +++ b/server/controllers/signout.php @@ -1,3 +1,20 @@ <?php + session_start(); + if (!isset($_SESSION['username']) or !isset($_SESSION['email'])) { + echo '<script type = "text/javascript"> + function loggedout_catch() { + alert("You are logged out, please login first"); + location.href = "../../client/pages/login-page.php" + } + loggedout_catch(); + </script>'; + } session_destroy(); + echo '<script type = "text/javascript"> + function logout_back() { + alert("Log out"); + location.href = "../../client/pages/catalog.php"; + } + logout_back(); +</script>' ?> \ No newline at end of file diff --git a/server/controllers/upload_jpg.php b/server/controllers/upload_jpg.php new file mode 100644 index 0000000000000000000000000000000000000000..2f41773e796775717dcc086573e15f4db7441957 --- /dev/null +++ b/server/controllers/upload_jpg.php @@ -0,0 +1,49 @@ +<?php +$target_dir = "../assets/uploaded/"; +$target_file = $target_dir . basename($_FILES["image"]["name"]); +$uploadOk = 1; +$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); +echo(pathinfo($target_file)); + +if(isset($_FILES["image"]) and $_SERVER["REQUEST_METHOD"] == "POST") { + // Check if image file is a actual image or fake image + $check = getimagesize($_FILES["image"]["tmp_name"]); + if($check !== false) { + echo "File is an image - " . $check["mime"] . "."; + $uploadOk = 1; + } else { + echo "File is not an image."; + $uploadOk = 0; + } + + // Check if file already exists + if (file_exists($target_file)) { + echo "Sorry, file already exists."; + $uploadOk = 0; + } + + // Check file size + if ($_FILES["image"]["size"] > 500000) { + echo "Sorry, your file is too large."; + $uploadOk = 0; + } + + // Allow certain file formats + if($imageFileType != "jpg" && $imageFileType != "jpeg") { + echo "Sorry, only JPG & JPEG files are allowed."; + $uploadOk = 0; + } + + // Check if $uploadOk is set to 0 by an error + if ($uploadOk == 0) { + echo "Sorry, your file was not uploaded."; + // if everything is ok, try to upload file + } else { + if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { + echo "The file ". htmlspecialchars( basename( $_FILES["image"]["name"])). " has been uploaded."; + } else { + echo "Sorry, there was an error uploading your file."; + } + } +} +?> \ No newline at end of file