<?php
session_start();
include 'koneksi.php';

if(!isset($_SESSION['user'])){
    header("Location: index.php");
    exit;
}

$username = $_SESSION['user'];
$tanggal  = $_GET['id'];

// 🔥 update hanya transaksi ini saja
mysqli_query($conn, "
    UPDATE orders 
    SET status='Selesai'
    WHERE username='$username' 
    AND tanggal='$tanggal'
    AND status='Dikirim'
");

// 🔥 langsung ke invoice
header("Location: invoice.php?tgl=".$tanggal);
exit;
?>