<?php
include 'header.php';
include 'koneksi/koneksi.php';

// Cek apakah customer sudah login
if(!isset($_SESSION['kd_cs'])){
    header("Location: user_login.php");
    exit();
}

// Ambil data customer
$kode_customer = $_SESSION['kd_cs'];
$result = mysqli_query($conn, "SELECT * FROM customer WHERE kode_customer='$kode_customer'");
$row = mysqli_fetch_assoc($result);

?>

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - UMKM Galeri 3D</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<style>
body {
    background: #f3f4f6;
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
}
.container {
    max-width: 1200px;
    margin: 5px auto;
    padding: 0 30px;
}
</style>
</head>
<body>
<div class="container">
   	<h2 style=" width: 100%; border-bottom: 2px solid #000;  padding-bottom: 10px;"><b><i class="fas fa-user"></i> Profil Saya </b></h2>

    <form action="proses/edit_customer.php" method="post">
       <input type="hidden" name="kode_customer" value="<?= $row['kode_customer']; ?>">
        
        <div class="row">
        <div class="col-md-6">
            <div class="form-group">
                <label>Nama</label>
                <input type="text" name="nama" class="form-control" 
                       value="<?= $row['nama']; ?>" required>
            </div>

             <div class="form-group">
                <label>Username</label>
                <input type="text" name="username" class="form-control" 
                       value="<?= $row['username']; ?>" required>
            </div>

             <div class="form-group">
                <label>Email</label>
                <input type="text" name="email" class="form-control" 
                       value="<?= $row['email']; ?>" required>
            </div>
        </div>

        <!-- Kolom kanan -->
        <div class="col-md-6">
            <div class="form-group">
                <label>Nomor Telepon</label>
                <input type="text" name="telp" class="form-control" 
                       value="<?= $row['telp']; ?>" required>
            </div>

            <div class="form-group">
                <label>Password (biarkan kosong jika tidak ingin diubah)</label>
                <input type="password" name="password" class="form-control">
            </div>
        </div>
    </div>
		   <div class="row button-row" style="margin-top: 20px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 40px;">
            <div class="col-md-6 mb-2">
                <button type="submit" class="btn btn-warning btn-block">
                    <i class="glyphicon glyphicon-edit"></i> Edit
                </button>
            </div>
        </div>
    </form>

</div>

</body>
</html>
