<?php
/**
 * Store Keeper Module - Demo Data Seeding Script
 * Run this to populate sample data for testing
 */

include 'config.php';

echo "<h1>Loading Demo Data for Store Keeper Module</h1>";

// Create sample store keeper if not exists
$email = 'store_keeper@demo.com';
$name = 'Demo Store Keeper';
$phone = '+91-9999999999';
$password = password_hash('password123', PASSWORD_BCRYPT);

$checkSql = "SELECT id FROM store_keepers WHERE email = ?";
$checkStmt = $conn->prepare($checkSql);
$checkStmt->bind_param('s', $email);
$checkStmt->execute();
$result = $checkStmt->get_result();

if ($result->num_rows === 0) {
    $insertSql = "INSERT INTO store_keepers (name, email, password, phone, status) VALUES (?, ?, ?, ?, 'active')";
    $insertStmt = $conn->prepare($insertSql);
    $insertStmt->bind_param('ssss', $name, $email, $password, $phone);
    if ($insertStmt->execute()) {
        echo "<p style='color: green;'><strong>✓ Demo Store Keeper Created</strong></p>";
        echo "<p>Email: <code>$email</code></p>";
        echo "<p>Password: <code>password123</code></p>";
    }
    $insertStmt->close();
} else {
    echo "<p style='color: blue;'><strong>ℹ Demo Store Keeper Already Exists</strong></p>";
    echo "<p>Email: <code>$email</code></p>";
}

$checkStmt->close();

echo "<hr>";
echo "<h2>Sample Data Loaded Successfully!</h2>";
echo "<p>You can now login with the demo account.</p>";
echo "<p><a href='../store_keeper/index.php'>Go to Store Keeper Login</a></p>";

$conn->close();
?>
