From 99b63e0c76ce4dad41a60ae1f159fe1d27738907 Mon Sep 17 00:00:00 2001 From: kicap1992 Date: Sat, 15 Jan 2022 02:22:55 +0800 Subject: [PATCH] added process to BE --- admin/admin_index.html | 465 +++++++++++++++++++++++++++ admin/index.html | 607 ++++++++++------------------------- admin/main.js | 95 ++++++ admin/penambahan_produk.html | 106 ++++-- 4 files changed, 807 insertions(+), 466 deletions(-) create mode 100644 admin/admin_index.html create mode 100644 admin/main.js diff --git a/admin/admin_index.html b/admin/admin_index.html new file mode 100644 index 0000000..eb3052f --- /dev/null +++ b/admin/admin_index.html @@ -0,0 +1,465 @@ + + + + + Halaman Utama Admin + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
HexaBit +
+

Loading...

+
+
+ +
+ +
+ + + + + + +
+
+
+
+

Halaman Penjualan

+
+
+ +
+
+
+ +
+ + +
+
+ +
+
+
+ + +
+
+
+
+
+ +
+
+ + + + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/admin/index.html b/admin/index.html index ea53845..be5b5ad 100644 --- a/admin/index.html +++ b/admin/index.html @@ -1,464 +1,183 @@ - + - Halaman Utama Admin - - - - - + + + + Halaman Login + + - - - -
-
-
HexaBit -
-

Loading...

-
+ +
+ +
+
Login
- -
- -
- - - - - - -
-
-
-
-

Halaman Penjualan

-
-
- -
-
-
- -
- - -
-
- -
-
-
- - -
-
-
-
-
- -
-
- - - - - -
-
- +
+
+
+
+ +
+ + + - - - - - - - - - - - - - - + + } + \ No newline at end of file diff --git a/admin/main.js b/admin/main.js new file mode 100644 index 0000000..efa5dcb --- /dev/null +++ b/admin/main.js @@ -0,0 +1,95 @@ +async function check_user() { + //create let variable no_user = localStorage.getItem('no_user') , username = localStorage.getItem('username') , password = localStorage.getItem('password') + let no_user = localStorage.getItem('no_user') + let username = localStorage.getItem('username') + let password = localStorage.getItem('password') + try { + //create fetch + const response = await fetch(`http://localhost/ilham/server/api/cek_user?id=${no_user}&username=${username}&password=${password}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Basic ' + btoa('Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73') + } + }); + //if response status = 200 then console.log("ok") else console.log("not ok") + if (response.status === 200) { + //create json + const json = await response.json(); + console.log(json) + } + else { + localStorage.removeItem('no_user') + localStorage.removeItem('username') + localStorage.removeItem('password') + window.location.href = 'index.html' + } + } catch (error) { + localStorage.removeItem('no_user') + localStorage.removeItem('username') + localStorage.removeItem('password') + window.location.href = 'index.html' + } +} + +check_user() + +// create function to check the file name and size +function check_file(file) { + //create let variable file_name = file.name , file_size = file.size + let file_name = file.name + let file_size = file.size + //create if file_size > 1000000 then alert("File size is too big") else if file_name.length > 50 then alert("File name is too long") else return true + if (file_size > 1500000) { + toastr.error("Maksimal ukuran file adalah 1.5 MB") + //input id=foto = null + document.getElementById('foto').value = null + document.getElementById('foto').focus() + return false + } + // else if filename != .jpg .png then toast("File type is not allowed") + + else if (file_name.substr(file_name.length - 4) != ".jpg" && file_name.substr(file_name.length - 4) != ".png") { + toastr.error("File type is not allowed") + document.getElementById('foto').value = null + document.getElementById('foto').focus() + return false + } + + else { + return true + } +} + +const elem =[document.getElementById("harga_jual"),document.getElementById("harga_pembelian_stok")] ; + +for (let i = 0; i < elem.length; i++) { + let elem1 = elem[i] + elem1.addEventListener("keydown", function (event) { + var key = event.which; + if ((key < 48 || key > 57) && key != 8) event.preventDefault(); + }); + + elem1.addEventListener("keyup", function (event) { + var value = this.value.replace(/,/g, ""); + this.dataset.currentValue = parseInt(value); + var caret = value.length - 1; + while ((caret - 3) > -1) { + caret -= 3; + value = value.split(''); + value.splice(caret + 1, 0, ","); + value = value.join(''); + } + this.value = value; + }); + +} + +function isNumberKey(evt){ + var charCode = (evt.which) ? evt.which : evt.keyCode + if (charCode > 31 && (charCode < 48 || charCode > 57 )) + return false; + return true; + // console.log(evt.key) +} + diff --git a/admin/penambahan_produk.html b/admin/penambahan_produk.html index a9161bd..5f8cdd4 100644 --- a/admin/penambahan_produk.html +++ b/admin/penambahan_produk.html @@ -165,16 +165,19 @@
- +
- +
- +
@@ -184,13 +187,14 @@ Rp.
+ placeholder="Masukkan Harga Produk per Helai" id="harga_jual" maxlength="7">
- +
@@ -200,7 +204,8 @@ Rp.
+ placeholder="Masukkan Harga Pembelian Stok" id="harga_pembelian_stok" + maxlength="10">
@@ -237,25 +242,82 @@ +