diff --git a/.DS_Store b/.DS_Store index 62830ba..b1c6bd4 100755 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/._dataset.json b/._dataset.json new file mode 100755 index 0000000..65f76e0 Binary files /dev/null and b/._dataset.json differ diff --git a/.gitignore b/.gitignore index faa0ae2..4e37a88 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ # env folder env/ faces/ -image1.jpg -image2.jpg -image3.jpg \ No newline at end of file +__pycache__/ +*.jpg \ No newline at end of file diff --git a/absensi.json b/absensi.json index 3f055e8..45faf86 100755 --- a/absensi.json +++ b/absensi.json @@ -1,50 +1,319 @@ [ { - "date": "22/09/2023", - "absensi": [ - { - "name": "Aran", - "jam_masuk": "00:04:01", - "jam_keluar": "13:14:01" - } - ] - }, - { - "date": "22/10/2023", - "absensi": [ - { - "name": "Aran", - "jam_masuk": "00:04:01", - "jam_keluar": "13:14:01" - } - ] - }, - { - "date": "23/11/2023", - "absensi": [ - { - "name": "Aran", - "jam_masuk": "00:04:01", - "jam_keluar": "13:14:01" - } - ] - }, - { - "date": "23/11/2023", + "date": "23/02/2024", "absensi": [ { "name": "Naufal", - "jam_masuk": "00:04:01", - "jam_keluar": "13:14:01" + "jam_masuk": "20:28:59", + "jam_keluar": "20:50:27" + }, + { + "name": "Aran", + "jam_masuk": "20:29:03", + "jam_keluar": "20:29:06" } ] }, { - "date": "25/11/2023", + "date": "27/02/2024", + "absensi": [ + { + "name": "Naufal", + "jam_masuk": "16:31:23", + "jam_keluar": "16:31:35" + } + ] + }, + { + "date": "07/03/2024", "absensi": [ { "name": "Aran", - "jam_masuk": "00:14:28" + "jam_masuk": "16:58:46", + "jam_keluar": "17:02:35" + }, + { + "name": "Naufal", + "jam_masuk": "16:58:46", + "jam_keluar": "17:02:35" + } + ] + }, + { + "date": "13/03/2024", + "absensi": [ + { + "name": "Naufal", + "jam_masuk": "23:34:34", + "jam_keluar": "23:35:15" + } + ] + }, + { + "date": "24/03/2024", + "absensi": [ + { + "name": "Naufal", + "jam_masuk": "13:09:36", + "jam_keluar": "13:10:54" + } + ] + }, + { + "date": "25/03/2024", + "absensi": [ + { + "name": "Armin", + "jam_masuk": "10:35:37" + }, + { + "name": "Naufal", + "jam_masuk": "10:42:31", + "jam_keluar": "12:57:56" + }, + { + "name": "Zul", + "jam_masuk": "10:42:42" + }, + { + "name": "Ramli", + "jam_masuk": "10:42:58" + }, + { + "name": "Dyah", + "jam_masuk": "10:43:15" + }, + { + "name": "Radit", + "jam_masuk": "11:03:55" + } + ] + }, + { + "date": "27/03/2024", + "absensi": [ + { + "name": "Armin", + "jam_masuk": "08:51:09", + "jam_keluar": "13:10:15" + }, + { + "name": "Dyah", + "jam_masuk": "08:53:23", + "jam_keluar": "13:06:21" + }, + { + "name": "Arjun", + "jam_masuk": "08:54:03", + "jam_keluar": "13:10:03" + }, + { + "name": "Ayyub", + "jam_masuk": "08:54:35", + "jam_keluar": "13:10:01" + }, + { + "name": "Zul", + "jam_masuk": "08:54:45", + "jam_keluar": "13:10:08" + }, + { + "name": "Naufal", + "jam_masuk": "09:01:23", + "jam_keluar": "13:11:09" + }, + { + "name": "Adit", + "jam_masuk": "09:01:57", + "jam_keluar": "13:09:55" + }, + { + "name": "Ramli", + "jam_masuk": "09:07:24", + "jam_keluar": "13:10:12" + }, + { + "name": "Radit", + "jam_masuk": "09:24:40", + "jam_keluar": "13:09:58" + }, + { + "name": "Adi", + "jam_masuk": "09:24:43", + "jam_keluar": "13:06:34" + } + ] + }, + { + "date": "28/03/2024", + "absensi": [ + { + "name": "Naufal", + "jam_masuk": "11:03:55", + "jam_keluar": "13:48:18" + }, + { + "name": "Aran", + "jam_masuk": "11:03:57" + }, + { + "name": "Radit", + "jam_masuk": "11:04:12", + "jam_keluar": "13:47:00" + }, + { + "name": "Dyah", + "jam_masuk": "11:05:12", + "jam_keluar": "13:47:14" + }, + { + "name": "Adi", + "jam_masuk": "11:05:16", + "jam_keluar": "13:47:11" + }, + { + "name": "Adit", + "jam_masuk": "11:05:21", + "jam_keluar": "13:47:03" + }, + { + "name": "Ayyub", + "jam_masuk": "11:05:28", + "jam_keluar": "13:46:57" + }, + { + "name": "Arjun", + "jam_masuk": "11:05:31", + "jam_keluar": "13:46:52" + }, + { + "name": "Zul", + "jam_masuk": "11:05:33", + "jam_keluar": "13:48:18" + }, + { + "name": "Ramli", + "jam_masuk": "11:05:36", + "jam_keluar": "13:46:36" + }, + { + "name": "Armin", + "jam_masuk": "11:05:38", + "jam_keluar": "13:46:29" + } + ] + }, + { + "date": "29/03/2024", + "absensi": [ + { + "name": "Radit", + "jam_masuk": "10:30:09", + "jam_keluar": "16:05:32" + }, + { + "name": "Naufal", + "jam_masuk": "10:30:09", + "jam_keluar": "16:04:09" + }, + { + "name": "Dyah", + "jam_masuk": "10:34:38", + "jam_keluar": "16:06:05" + }, + { + "name": "Adit", + "jam_masuk": "10:34:52", + "jam_keluar": "16:06:03" + }, + { + "name": "Adi", + "jam_masuk": "10:34:56", + "jam_keluar": "16:05:40" + }, + { + "name": "Arjun", + "jam_masuk": "10:35:08", + "jam_keluar": "16:05:19" + }, + { + "name": "Zul", + "jam_masuk": "10:35:24", + "jam_keluar": "16:05:12" + }, + { + "name": "Armin", + "jam_masuk": "10:35:34", + "jam_keluar": "16:05:02" + }, + { + "name": "Ramli", + "jam_masuk": "10:35:38", + "jam_keluar": "16:05:06" + }, + { + "name": "Ayyub", + "jam_masuk": "10:36:00", + "jam_keluar": "16:05:26" + } + ] + }, + { + "date": "03/04/2024", + "absensi": [ + { + "name": "Naufal", + "jam_masuk": "10:15:09", + "jam_keluar": "15:04:09" + }, + { + "name": "Radit", + "jam_masuk": "10:15:11", + "jam_keluar": "15:04:26" + }, + { + "name": "Armin", + "jam_masuk": "10:15:29", + "jam_keluar": "15:04:10" + }, + { + "name": "Dyah", + "jam_masuk": "10:15:30", + "jam_keluar": "15:04:35" + }, + { + "name": "Ramli", + "jam_masuk": "10:16:08", + "jam_keluar": "15:04:15" + }, + { + "name": "Ayyub", + "jam_masuk": "10:17:00", + "jam_keluar": "15:04:29" + }, + { + "name": "Aran", + "jam_masuk": "10:20:02" + }, + { + "name": "Zul", + "jam_masuk": "10:20:34", + "jam_keluar": "15:04:23" + }, + { + "name": "Adi", + "jam_masuk": "10:26:48", + "jam_keluar": "15:04:38" + }, + { + "name": "Arjun", + "jam_masuk": "10:28:08", + "jam_keluar": "15:04:20" + }, + { + "name": "Adit", + "jam_masuk": "10:30:32", + "jam_keluar": "15:04:31" } ] } diff --git a/data absensi/._ABSEN KELUAR 27 MARET 2024.wmv b/data absensi/._ABSEN KELUAR 27 MARET 2024.wmv new file mode 100755 index 0000000..29f9a7e Binary files /dev/null and b/data absensi/._ABSEN KELUAR 27 MARET 2024.wmv differ diff --git a/data absensi/._ABSEN KELUAR 3 APRIL 2024.wmv b/data absensi/._ABSEN KELUAR 3 APRIL 2024.wmv new file mode 100755 index 0000000..1b011d4 Binary files /dev/null and b/data absensi/._ABSEN KELUAR 3 APRIL 2024.wmv differ diff --git a/data absensi/._ABSEN MASUK 27 MARET 2024 (1).wmv b/data absensi/._ABSEN MASUK 27 MARET 2024 (1).wmv new file mode 100755 index 0000000..0574530 Binary files /dev/null and b/data absensi/._ABSEN MASUK 27 MARET 2024 (1).wmv differ diff --git a/data absensi/._ABSEN MASUK 3 APRIL 2024.wmv b/data absensi/._ABSEN MASUK 3 APRIL 2024.wmv new file mode 100755 index 0000000..db05d1c Binary files /dev/null and b/data absensi/._ABSEN MASUK 3 APRIL 2024.wmv differ diff --git a/data absensi/ABSEN KELUAR 27 MARET 2024.wmv b/data absensi/ABSEN KELUAR 27 MARET 2024.wmv new file mode 100755 index 0000000..67a0e90 Binary files /dev/null and b/data absensi/ABSEN KELUAR 27 MARET 2024.wmv differ diff --git a/data absensi/ABSEN KELUAR 3 APRIL 2024.wmv b/data absensi/ABSEN KELUAR 3 APRIL 2024.wmv new file mode 100755 index 0000000..f33993c Binary files /dev/null and b/data absensi/ABSEN KELUAR 3 APRIL 2024.wmv differ diff --git a/data absensi/ABSEN MASUK 27 MARET 2024 (1).wmv b/data absensi/ABSEN MASUK 27 MARET 2024 (1).wmv new file mode 100755 index 0000000..501fafa Binary files /dev/null and b/data absensi/ABSEN MASUK 27 MARET 2024 (1).wmv differ diff --git a/data absensi/ABSEN MASUK 27 MARET 2024 (2)).wmv b/data absensi/ABSEN MASUK 27 MARET 2024 (2)).wmv new file mode 100755 index 0000000..217100d Binary files /dev/null and b/data absensi/ABSEN MASUK 27 MARET 2024 (2)).wmv differ diff --git a/data absensi/ABSEN MASUK 27 MARET 2024 (3).wmv b/data absensi/ABSEN MASUK 27 MARET 2024 (3).wmv new file mode 100755 index 0000000..bff3340 Binary files /dev/null and b/data absensi/ABSEN MASUK 27 MARET 2024 (3).wmv differ diff --git a/data absensi/ABSEN MASUK 3 APRIL 2024.wmv b/data absensi/ABSEN MASUK 3 APRIL 2024.wmv new file mode 100755 index 0000000..e21f528 Binary files /dev/null and b/data absensi/ABSEN MASUK 3 APRIL 2024.wmv differ diff --git a/data absensi/Video_2024-04-03_103346.wmv b/data absensi/Video_2024-04-03_103346.wmv new file mode 100755 index 0000000..f997b3f Binary files /dev/null and b/data absensi/Video_2024-04-03_103346.wmv differ diff --git a/dataset.json b/dataset.json index 2e72427..a8906bf 100755 --- a/dataset.json +++ b/dataset.json @@ -1 +1 @@ -[{"name": "Naufal", "nik": "1", "gaji": 50000}, {"name": "Aran", "nik": "12345", "gaji": 20000}] \ No newline at end of file +[{"name": "Naufal", "nik": "1", "gaji": 50000}, {"name": "Armin", "nik": "7372033007880005", "gaji": 50000}, {"name": "Dyah", "nik": "7372017112850107", "gaji": 50000}, {"name": "Ramli", "nik": "7372011502720001", "gaji": 50000}, {"name": "Zul", "nik": "7372012010010006", "gaji": 30000}, {"name": "Ayyub", "nik": "7372032007840005", "gaji": 50000}, {"name": "Adit", "nik": "7372021506960009", "gaji": 100000}, {"name": "Arjun", "nik": "73720416604010002", "gaji": 50000}, {"name": "Radit", "nik": "7372043112880024", "gaji": 50000}, {"name": "Adi", "nik": "7372041012970004", "gaji": 50000}] \ No newline at end of file diff --git a/flask_app.py b/flask_app.py index 899f765..6363580 100755 --- a/flask_app.py +++ b/flask_app.py @@ -1,8 +1,10 @@ -from flask import Flask, render_template , request +from flask import Flask, render_template , request,send_from_directory, abort import subprocess import threading import json import time +from werkzeug.utils import secure_filename +import os dataset = "dataset.json" absensi = "absensi.json" @@ -60,6 +62,14 @@ def home(): return render_template('index.html', data=all_data, length=len_all_data, today_date=today_date) + +@app.route('/faces/') +def serve_image(filename): + try: + return send_from_directory('faces', filename) + except FileNotFoundError: + abort(404) + @app.route('/cek_absensi') def cek_absensi(): today_date = time.strftime("%d/%m/%Y") @@ -150,9 +160,14 @@ def tambah_karyawan_post(): nama = request.form['nama'] nik = request.form['nik'] gaji = int(request.form['gaji']) + foto = request.files['file'] # print(nama) # print(nik) + if foto: + foto_filename = secure_filename(nama + '.jpg') + foto.save(os.path.join('faces', foto_filename)) + # open the dataset file with open(dataset, 'r') as f: data = json.load(f) diff --git a/main.py b/main.py index c09f911..9d959fd 100755 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ today_date = time.strftime("%d/%m/%Y") with open(absensi_file, 'r') as f: data = json.load(f) -def face_confidence(face_distance, face_match_threshold=0.6): +def face_confidence(face_distance, face_match_threshold=0.6): #jika nilai face distance lebih kecil dari 0.6 range = (1.0 - face_match_threshold) linear_val = (1.0 - face_distance) / (range * 2.0) @@ -26,6 +26,7 @@ def face_confidence(face_distance, face_match_threshold=0.6): value = (linear_val + ((1.0 - linear_val) * math.pow((linear_val - 0.5) * 2, 0.2))) * 100 return str(round(value, 2)) + "%" +# melakukan fungsi face recognition class FaceRecognition: face_locations = [] face_encodings = [] @@ -59,7 +60,7 @@ class FaceRecognition: sys.exit('Video capture is not opened') no_face_timer = 0 - no_face_threshold = 5 # Adjust this to your desired timeout in seconds + no_face_threshold = 60 # Adjust this to your desired timeout in seconds while True: ret, frame = video_capture.read() diff --git a/main2.py b/main2.py index 05f6a55..b154ff7 100755 --- a/main2.py +++ b/main2.py @@ -1,7 +1,8 @@ +# daftar karyawan baru menggunakan haarcascade import cv2 import json -dataset = "dataset.json" +dataset = "dataset.json" # dataset karyawan @@ -24,6 +25,7 @@ cv2.namedWindow('Image Capture', cv2.WINDOW_NORMAL) # Set the window to full screen cv2.setWindowProperty('Image Capture', cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN) + face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') while True: diff --git a/templates/index.html b/templates/index.html index 94518ce..79d10ac 100755 --- a/templates/index.html +++ b/templates/index.html @@ -51,14 +51,14 @@
-
+ +
Tambah Data Karyawan
- +
-
+
-->
Lakukan @@ -127,7 +127,7 @@
    -
  • 2023 © Naufal.
  • +
  • 2024 ©CV.TIRTA RAHMAN PAREPARE.
  • diff --git a/templates/index2.html b/templates/index2.html index f850f2e..882b3f7 100755 --- a/templates/index2.html +++ b/templates/index2.html @@ -2,257 +2,260 @@ - - - - - + + + + + - Sistem Absensi - Halaman Utama + Sistem Absensi - Cek Absensi - - + + - - + + - - + + - - + + - - - - + + + + -
    -
    -
    - - +
    +
    +
    + + - -
    - -
    - + +
    + +
    + - -
    - + + + +
    +
    +
    +
    +
    +
    +

    Tanggal : {{today_date}}

    +
    + + + + + + + + + + {%if data %} {% for i in range(0, length) %} + + + + {% if data[i]['jam_keluar'] %} + + + {% else %} + + + {% endif %} + + {% endfor %} {% else %} + + + + {% endif %} + +
    NamaJam MasukJam Keluar
    {{data[i]['name']}}{{data[i]['jam_masuk']}}{{data[i]['jam_keluar']}}{{data[i]['jam_masuk']}}-
    Tidak ada data
    +
    +
    +
    +
    +
    -
    -
    +
    +
    +
    +
    +

    Bulan/Tahun : {{bulan_ini}}

    +
    + + + + + + + + + + + {%if data_karyawan %} {% for i in range(0, length_karyawan) %} -
    -
    -
    -
    -

    Tanggal : {{today_date}}

    -
    -
    NamaGaji/HariPendapatan/BulanAksi
    - - - - - + + + + - - - - {%if data %} + + + {% endfor %} {% else %} + + + + {% endif %} + +
    NamaJam MasukJam Keluar
    {{data_karyawan[i]['name']}}{{data_karyawan[i]['gaji']}}{{data_karyawan[i]['pendapatan']}}
    + + +
    Tidak ada data
    +
    +
    +
    +
    +
    - {% for i in range(0, length) %} - - - {{data[i]['name']}} - - {% if data[i]['jam_keluar'] %} - {{data[i]['jam_masuk']}} - {{data[i]['jam_keluar']}} - {% else %} - {{data[i]['jam_masuk']}} - - - {% endif %} - - {% endfor %} - {% else %} - - Tidak ada data - - {% endif %} - - - -
    -
    -
    -
    - - - -
    - -
    -
    -
    -
    -

    Bulan/Tahun : {{bulan_ini}}

    -
    - - - - - - - - - - - - {%if data_karyawan %} - - {% for i in range(0, length_karyawan) %} - - - - - - - - - - - {% endfor %} - {% else %} - - - - {% endif %} - -
    NamaGaji/HariPendapatan/BulanAksi
    {{data_karyawan[i]['name']}}{{data_karyawan[i]['gaji']}}{{data_karyawan[i]['pendapatan']}} - - -
    Tidak ada data
    - -
    -
    -
    -
    - - - -
    - - -
    -
      -
    • 2023 © Naufal.
    • - -
    -
    -
- - - - - + + + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - + + function printDiv(name, gaji, pendapatan) { + var this_month = getMonthName(new Date().getMonth()); // Get the current month name + var printWindow = window.open("", "", "height=600,width=400"); + printWindow.document.write("Slip Gaji Bulan " + this_month + ""); + printWindow.document.write(""); + printWindow.document.write(""); + printWindow.document.write("

Slip Gaji Bulan " + this_month + "

"); + printWindow.document.write("
"); + printWindow.document.write("
"); + printWindow.document.write("Foto Karyawan"); + printWindow.document.write("
"); + printWindow.document.write("

Nama: " + name + "

"); + printWindow.document.write("

Gaji: Rp." + addThousandSeparator(gaji) + "

"); + printWindow.document.write("

Pendapatan: Rp. " + addThousandSeparator(pendapatan) + "

"); + printWindow.document.write("

Tanggal: {{today_date}}

"); + printWindow.document.write("
"); + printWindow.document.write("
"); + printWindow.document.write("

Terima kasih atas kerja keras Anda

"); + printWindow.document.write("
"); + printWindow.document.write("



"); + printWindow.document.write(""); + printWindow.document.write(""); + printWindow.document.close(); + printWindow.print(); +} + function getMonthName(month) { + var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; + return months[month]; + } + \ No newline at end of file diff --git a/templates/scan_face.html b/templates/scan_face.html index 0239077..8910d0a 100755 --- a/templates/scan_face.html +++ b/templates/scan_face.html @@ -1,84 +1,78 @@ + + + + + + - - - - - - - - Sistem Absensi - Halaman Utama + Sistem Absensi - Halaman Scan - + - + - + - + - - + + - +
-
-
- - +
+
+ + - -
- +
- + +
+ - +
- -
-
-
-
-
-

Loading...

- -
- -
- +
+
+
+
+

Loading...

- + +
+
+ - - -
-
    -
  • 2023 © Naufal.
  • - -
-
-
- -
+ + +
+ +
+ + + + @@ -95,43 +89,41 @@ - - - - \ No newline at end of file + + diff --git a/templates/tambah_karyawan.html b/templates/tambah_karyawan.html index a8a9bfb..e06a72e 100755 --- a/templates/tambah_karyawan.html +++ b/templates/tambah_karyawan.html @@ -1,264 +1,323 @@ + + + + + + - - - - - - + Sistem Absensi - Halaman Tambah Karyawan - Sistem Absensi - Halaman Tambah Karyawan + + - - + + - - + + - - + + - - + + + + + + #preview { max-width: 300px; max-height: 300px; margin-top: 20px; } + - - - - - - + +
+
+
+ + - -
-
-
- - + +
+ +
+ - -
- -
- + +
+ - - - - - - -
-
-
+
+
+ +
+ onclick="goto('tambah_karyawan')">

Tambah Data Karyawan

- +
-
- -
-
-
-
-

Informasi Karyawan

-
-
-
- - -
-
- - -
+
--> + +
+
+
+
+

Informasi Karyawan

+
+ +
+ + +
+
+ + +
-
- - -
+
+ + +
-
- -
- -
-
-
-
-
+
+ + -
-
-
-
-

Jumlah Karyawan : {{length}} Orang

-
- - - - - - - + + + - - - - {%if data %} +
+ +
+ + + + +
+ - {% for i in range(0, length) %} +
+
+
+
+

Jumlah Karyawan : {{length}} Orang

+
+
NoNIKNamaGaji/Hari
+ + + + + + + + + + {%if data %} {% for i in range(0, length) %} - - - - - - - {% endfor %} - {% endif %} - -
NoNIKNamaGaji/Hari
{{i+1}}{{data[i]['nik']}}{{data[i]['name']}}{{data[i]['gaji']}}
+ + {{i+1}} + {{data[i]['nik']}} + {{data[i]['name']}} + {{data[i]['gaji']}} + + {% endfor %} {% endif %} + + +
+
+
+
+
-
-
-
-
- - - -
- - - -
-
    -
  • 2023 © Naufal.
  • - -
-
-
- -
- - - +
+ + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - + + // Use a regular expression to add commas as thousand separators + numStr = numStr.replace(/\B(?=(\d{3})+(?!\d))/g, ","); - + return numStr; + } - \ No newline at end of file + // Get all elements with the class "ini dia" + const tdElements = document.querySelectorAll("td.gajinya"); + + // Iterate through each element + tdElements.forEach((td) => { + // Get the current value of the + let currentValue = parseFloat(td.textContent); + + // Check if the value is a valid number + if (!isNaN(currentValue)) { + // Update the content of the with the formatted value + td.textContent = "Rp. " + addThousandSeparator(currentValue); + } + }); + + + diff --git a/app.py b/test/app.py similarity index 100% rename from app.py rename to test/app.py diff --git a/app2.py b/test/app2.py similarity index 100% rename from app2.py rename to test/app2.py diff --git a/app3.py b/test/app3.py similarity index 100% rename from app3.py rename to test/app3.py