-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_delete_restore_event.php
43 lines (33 loc) · 1.14 KB
/
admin_delete_restore_event.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
<?php
include 'connect.php';
header('Content-type: application/json');
date_default_timezone_set("Asia/Bangkok");
// FILE UNTUK RESPONSE DELETE DAN RESTORE EVENT
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Dapetin info dari Ajax
$id_event = $_POST['checkedIdEvent'];
$type = $_POST['type'];
$deletedAt = date("Y-m-d H:i:s");
$deletedBy = $_SESSION['email'];
// Bisa untuk DELETE dan RESTORE, kalau type nya DELETE nti isActive diubah jadi 0 dan sebaliknya
if ($type === 'DELETE') {
$isActiveStatus = 0;
} else if ($type === 'RESTORE') {
$isActiveStatus = 1;
}
// SQL untuk DELETE / RESTORE dan isi deletedAt dan deletedBy
$sql = "UPDATE event
SET isActive = ?,
deletedAt = ?,
deletedBy = ?
WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$isActiveStatus, $deletedAt, $deletedBy, $id_event]);
// Beri Notif bila sukses
$notif = 'Not Successful';
if ($stmt) {
$notif = 'Operation Done Successfuly';
}
$output = '';
echo json_encode(array('output' => $output, 'notif' => $notif));
}