<?php
session_start();
require 'config/db.php';
if (!isset($_SESSION['admin_id'])) {
    header("Location: login.php");
    exit;
}

if($_POST){

$s=$pdo->prepare("
INSERT INTO marketing_monthly_budget
(month,year,total_budget,created_by)
VALUES(?,?,?,?)
ON DUPLICATE KEY UPDATE
total_budget=VALUES(total_budget),
created_by=VALUES(created_by)
");

$s->execute([
 $_POST['month'],
 $_POST['year'],
 $_POST['total_budget'],
 $_SESSION['manager_id'] ?? $_SESSION['admin_id']
]);
}
?>

<form method="post">
Month <input type="number" name="month" min=1 max=12>
Year <input type="number" name="year">
Budget <input type="number" step="0.01" name="total_budget">
<button>Save</button>
</form>
