-
Notifications
You must be signed in to change notification settings - Fork 1
/
transaksi_edit_process.php
70 lines (61 loc) · 3.54 KB
/
transaksi_edit_process.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
session_start();
require_once 'config/config.php';
if (empty($_SESSION['loggedin'])) {
header("Location: ./");
die();
} else {
if (isset($_POST['simpan'])) {
$id_transaksi = $_POST['id_transaksi'];
$id_transaksidetail = $_POST['id_transaksidetail'];
$id_transaksidetail2 = $_POST['id_transaksidetail2'];
$kode_pelanggan = filter_input(INPUT_POST, 'nama_pelanggan', FILTER_SANITIZE_STRING);
$tipe_mobil = filter_input(INPUT_POST, 'tipe_mobil', FILTER_SANITIZE_STRING);
$nopol = filter_input(INPUT_POST, 'nopol', FILTER_SANITIZE_STRING);
$paket = filter_input(INPUT_POST, 'paket', FILTER_SANITIZE_STRING);
$paket2 = filter_input(INPUT_POST, 'paket2', FILTER_SANITIZE_STRING);
$bayar = filter_input(INPUT_POST, 'bayar', FILTER_SANITIZE_STRING);
$kembali = filter_input(INPUT_POST, 'kembali', FILTER_SANITIZE_STRING);
$total = filter_input(INPUT_POST, 'total', FILTER_SANITIZE_STRING);
$id_user = $_SESSION['id_user'];
$updated_at = date('Y-m-d H:i:s');
$bayar2 = (int)str_replace(".", "", $bayar);
if (!empty($paket) AND !empty($paket2)) {
$sql = "UPDATE tb_transaksi SET id_user = '$id_user', updated_at = '$updated_at', updated_by = '$id_user' WHERE id_transaksi='$id_transaksi'";
$query = mysqli_query($db, $sql);
$sql2 = "UPDATE tb_transaksi_detail SET id_paket = '$paket', bayar = '$bayar2', updated_at = '$updated_at', updated_by = '$id_user' WHERE id_transaksi='$id_transaksi' AND id_transaksi_detail='$id_transaksidetail'";
$query2 = mysqli_query($db, $sql2);
$sql3 = "UPDATE tb_transaksi_detail SET id_paket = '$paket2', bayar = '$bayar2', updated_at = '$updated_at', updated_by = '$id_user' WHERE id_transaksi='$id_transaksi' AND id_transaksi_detail='$id_transaksidetail2'";
$query3 = mysqli_query($db, $sql3);
if ($query AND $query2 AND $query3) {
$_SESSION['success'] = 'Data transaksi berhasil diperbarui.';
header('Location: transaksi.php');
} else {
$_SESSION['error'] = 'Data transaksi gagal diperbarui.';
header('Location: transaksi_edit.php');
}
} elseif (empty($paket2)) {
$sql = "UPDATE tb_transaksi SET id_user = '$id_user', updated_at = '$updated_at', updated_by = '$id_user' WHERE id_transaksi='$id_transaksi'";
$query = mysqli_query($db, $sql);
if ($query) {
$sql2 = "UPDATE tb_transaksi_detail SET id_paket = '$paket', bayar = '$bayar2', updated_at = '$updated_at', updated_by = '$id_user' WHERE id_transaksi='$id_transaksi'";
$query2 = mysqli_query($db, $sql2);
if ($query2) {
$_SESSION['success'] = 'Data transaksi berhasil diperbarui.';
header('Location: transaksi.php');
} else {
$_SESSION['error'] = 'Data transaksi gagal diperbarui.';
header('Location: transaksi_edit.php');
}
} else {
$_SESSION['error'] = 'Data transaksi gagal diperbarui.';
header('Location: transaksi_edit.php');
}
}
} else {
header('Location: transaksi.php');
}
?>
<?php
}
?>