-
Notifications
You must be signed in to change notification settings - Fork 1
/
updatePesananCustomer.php
53 lines (44 loc) · 1.47 KB
/
updatePesananCustomer.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
<?php
include_once('koneksi.php');
if (!empty($_POST['id'])) {
$address = $_POST['address'];
$description = $_POST['description'];
$jadwal = $_POST['jadwal'];
$id = $_POST['id'];
$jumlah_tukang = $_POST['jumlah_tukang'];
$harga = $_POST['harga'];
$selesai = $_POST['selesai'];
if (!empty($_POST['harga'])) {
if (empty($_FILES['foto'])) {
set_response(false, "Foto harus diisi");
} else {
$foto = $_FILES['foto']['name'];
$file = $_FILES['foto']['tmp_name'];
$dir = "foto/";
move_uploaded_file($file, $dir . $foto);
$harga = 0;
for ($i = 0; $i < $jumlah_tukang; $i++) {
$harga += 100000;
}
$query = "UPDATE pesanan set address = '$address', description = '$description', jadwal = '$jadwal', foto = '$foto', jumlah_tukang = '$jumlah_tukang', harga = '$harga', selesai = '$selesai' WHERE id = '$id'";
$update = pg_query($connect, $query);
if ($update) {
set_response(true, "Success update");
} else {
set_response(false, "Failed update");
}
}
} else {
set_response(false, "Harga diisi sistem");
}
} else {
set_response(false, "harus diisi");
}
function set_response($isSuccess, $message)
{
$result = array(
'isSuccess' => $isSuccess,
'message' => $message
);
echo json_encode($result);
}