<?php
require_once "config.php";

$email = 'admin@royaltransport.com';
$password = 'admin123';
$name = 'Administrator';
$role = 'admin';

// Generate password hash
$password_hash = password_hash($password, PASSWORD_DEFAULT);

// Check if admin already exists
$stmt = $conn->prepare("SELECT id FROM users WHERE email = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows > 0) {
    echo "Admin korisnik već postoji.\n";
} else {
    // Insert admin user
    $stmt = $conn->prepare("INSERT INTO users (email, password, name, role, active) VALUES (?, ?, ?, ?, 1)");
    $stmt->bind_param("ssss", $email, $password_hash, $name, $role);
    
    if ($stmt->execute()) {
        echo "Admin korisnik je uspešno kreiran.\n";
        echo "Email: " . $email . "\n";
        echo "Lozinka: " . $password . "\n";
    } else {
        echo "Greška prilikom kreiranja admin korisnika.\n";
    }
} 