diff --git a/.DS_Store b/.DS_Store
index dd00aa5..62830ba 100755
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/absensi.json b/absensi.json
index 0637a08..3f055e8 100755
--- a/absensi.json
+++ b/absensi.json
@@ -1 +1,51 @@
-[]
\ No newline at end of file
+[
+ {
+ "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",
+ "absensi": [
+ {
+ "name": "Naufal",
+ "jam_masuk": "00:04:01",
+ "jam_keluar": "13:14:01"
+ }
+ ]
+ },
+ {
+ "date": "25/11/2023",
+ "absensi": [
+ {
+ "name": "Aran",
+ "jam_masuk": "00:14:28"
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/dataset.json b/dataset.json
index 6018942..2e72427 100755
--- a/dataset.json
+++ b/dataset.json
@@ -1 +1 @@
-[{"name": "Naufal", "nik": "1"}, {"name": "Aran", "nik": "12345"}]
+[{"name": "Naufal", "nik": "1", "gaji": 50000}, {"name": "Aran", "nik": "12345", "gaji": 20000}]
\ No newline at end of file
diff --git a/flask_app.py b/flask_app.py
index c3eb2c2..899f765 100755
--- a/flask_app.py
+++ b/flask_app.py
@@ -63,6 +63,7 @@ def home():
@app.route('/cek_absensi')
def cek_absensi():
today_date = time.strftime("%d/%m/%Y")
+ this_month_and_year = time.strftime("%m/%Y")
all_data = None
len_all_data = 0
# open absensi file
@@ -80,11 +81,39 @@ def cek_absensi():
all_data = last_data['absensi']
# get the length of the "absensi" data
len_all_data = len(all_data)
-
-
+
+
+ len_karyawan = 0
+ data_karyawan = None
+
+ # open the dataset file
+ with open(dataset, 'r') as f:
+ data_karyawan = json.load(f)
+ len_karyawan = len(data_karyawan)
+
+ this_month_absensi = []
+ # print(data)
+ for i in range(len_data):
+ # print(all_data[i])
+ if data[i]['date'][3:] == this_month_and_year:
+ this_month_absensi.append(data[i])
+
+ # print(this_month_absensi)
+ # print(data_karyawan)
+
+ # loop data_karyawan and then loop this_month_absensi to check if the name is exist, if exist then add the gaji
+ for i in range(len_karyawan):
+ pendapatan = 0
+ for j in range(len(this_month_absensi)):
+ for k in range(len(this_month_absensi[j]['absensi'])):
+ if data_karyawan[i]['name'] == this_month_absensi[j]['absensi'][k]['name']:
+ pendapatan += data_karyawan[i]['gaji']
+ data_karyawan[i]['pendapatan'] = pendapatan
+
+ print(data_karyawan)
- return render_template('index2.html', data=all_data, length=len_all_data, today_date=today_date)
+ return render_template('index2.html', data=all_data, length=len_all_data, today_date=today_date, data_karyawan=data_karyawan, length_karyawan=len_karyawan , bulan_ini=this_month_and_year)
@app.route('/scan_face')
def scan_face():
@@ -120,6 +149,7 @@ def tambah_karyawan():
def tambah_karyawan_post():
nama = request.form['nama']
nik = request.form['nik']
+ gaji = int(request.form['gaji'])
# print(nama)
# print(nik)
@@ -130,7 +160,8 @@ def tambah_karyawan_post():
# insert the new data
data.append({
'name': nama,
- 'nik': nik
+ 'nik': nik,
+ 'gaji': gaji
})
# save the dataset file
@@ -140,6 +171,9 @@ def tambah_karyawan_post():
# return the json
return {'status': 'OK'}
+
+
+
# dibawah ni untuk buka main2.py dan loading page
@app.route('/scan_face2')
def scan_face2():
diff --git a/templates/index2.html b/templates/index2.html
index 6f2fc34..f850f2e 100755
--- a/templates/index2.html
+++ b/templates/index2.html
@@ -51,7 +51,7 @@
-
+
@@ -99,6 +99,59 @@
+
+
+
+
+
+
+
Bulan/Tahun : {{bulan_ini}}
+
+
+
+
+
Nama
+
Gaji/Hari
+
Pendapatan/Bulan
+
Aksi
+
+
+
+
+ {%if data_karyawan %}
+
+ {% for i in range(0, length_karyawan) %}
+
+
+
{{data_karyawan[i]['name']}}
+
{{data_karyawan[i]['gaji']}}
+
{{data_karyawan[i]['pendapatan']}}
+
+
+
+
+
+
+
+
+ {% endfor %}
+ {% else %}
+
+
Tidak ada data
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
@@ -144,6 +197,60 @@
window.location.href = "{{url_for('tambah_karyawan')}}";
}
}
+
+ // create a function that addn thousand separator using comma
+ function addThousandSeparator(number) {
+ // Convert the number to a string
+ let numStr = number.toString();
+
+ // Use a regular expression to add commas as thousand separators
+ numStr = numStr.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
+
+ return numStr;
+ }
+
+ // 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);
+ }
+ });
+
+
+ function addThousandSeparators(value) {
+ return value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+ }
+
+
+ function printDiv(name, gaji, pendapatan) {
+ console.log(name, gaji, pendapatan);
+ var printWindow = window.open('', '', 'height=400,width=800');
+ printWindow.document.write('DIV Contents');
+ printWindow.document.write('');
+ printWindow.document.write('