-
Notifications
You must be signed in to change notification settings - Fork 1
/
insertPesanan.php
53 lines (43 loc) · 1.56 KB
/
insertPesanan.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['address']) && !empty($_POST['description']) && !empty($_POST['jadwal'])) {
$address = $_POST['address'];
$description = $_POST['description'];
$jadwal = $_POST['jadwal'];
$customer_id = $_POST['customer_id'];
$jumlah_tukang = $_POST['jumlah_tukang'];
$harga = $_POST['harga'];
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 = "INSERT INTO pesanan(address, description, jadwal, customer_id, jumlah_tukang, harga, foto, isactive, selesai) VALUES ('$address', '$description', '$jadwal', '$customer_id', '$jumlah_tukang', '$harga','$foto', FALSE, FALSE)";
$insert = pg_query($connect, $query);
if ($insert) {
set_response(true, "Success insert pesanan");
} else {
set_response(false, "Failed insert pesanan");
}
}
} 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);
}