<?php

session_start();

$path_to_root = "";
include $path_to_root . 'database.php';

$db = new database();

$id = $_GET['id'];

if ($_FILES['gambar']['name'] != ''){
	$namaFile = $_FILES['gambar']['name'];
	$namaSementara = $_FILES['gambar']['tmp_name'];

	$dirUpload = "img-bukti/";

	$terupload = move_uploaded_file($namaSementara, $dirUpload.$namaFile);

	if ($terupload) {
		$tanggal_pembayaran = date('d-m-Y');
		$sql = "UPDATE `order` SET `bukti`='".$namaFile."', `tanggal_pembayaran`='".$tanggal_pembayaran."', `status`='menunggu verifikasi pembayaran' WHERE `id`=".$id;

		$result = $db->db_query($sql);

		if ($result) {
			header("location:index.php?menu=order");
		} else {
			header("location:index.php?menu=upload_bukti&id=$id");
		}
	}
} else {
	header("location:index.php?menu=upload_bukti&id=$id");
}

?>