This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_rekap_post.php
55 lines (50 loc) · 1.53 KB
/
edit_rekap_post.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
session_start();
require_once("./config/db.php");
require_once("./config/function.php");
if (!$_SESSION['username']) {
die(json_encode(array(
'status' => false,
'message' => 'Session kamu berakhir, Silahkan login ulang.'
)));
}
if (isset($_POST)) {
/// Validasi post name yang kosong
$postNames = array(
"rekapID",
"rekapStatus",
);
foreach ($postNames as $postname) {
/// JIka ada postname yang panjang lenghtnya 0
if (!strlen($_POST[$postname])) {
die(json_encode(array(
'status' => false,
'message' => 'Silahkan isi semua form dengan baik dan benar'
)));
}
}
$rekapID = $_POST['rekapID'];
$rekapStatus = $_POST['rekapStatus'];
if($rekapStatus != "Hadir Masuk" && $rekapStatus != "Hadir Pulang" && $rekapStatus != "Hadir Terlambat" && $rekapStatus != "Alpa")
{
die(json_encode(array(
'status' => false,
'message' => 'Rekap Status tidak valid'
)));
}
$sql = "UPDATE `rekap` SET `rekap_keterangan` = '$rekapStatus' WHERE `rekap`.`rekap_id` = '$rekapID';";
if($koneksi->query($sql) === TRUE)
{
/// Sukses
die(json_encode(array(
'status' => true,
'message' => 'Data Jabatan berhasil di Update.'
)));
}else{
/// Terjadi Kesalahan MySQL
die(json_encode(array(
'status' => false,
'message' => 'Query Gagal : '.$koneksi->error.''
)));
}
}