connect_error) {
die(“Database connection failed: ” . $conn->connect_error);
}
// Handle form submission
if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’) {
$date = $_POST[‘date’] ?? ”;
$cash_sales = (float) $_POST[‘cash_sales’];
$card_sales = (float) $_POST[‘card_sales’];
$online_cash = (float) $_POST[‘online_cash’];
$online_card = (float) $_POST[‘online_card’];
$deliveroo = (float) $_POST[‘deliveroo’];
$justeat = (float) $_POST[‘justeat’];
$tips = (float) $_POST[‘tips’];
$expense = (float) $_POST[‘expense’];
$notes = trim($_POST[‘notes’]);
// Server-side calculations
$total_cash = $cash_sales + $online_cash;
$total_card = $card_sales + $online_card + $deliveroo + $justeat;
$total_sales = $total_cash + $total_card;
$cash_in_hand = $total_cash – $expense;
// Insert into DB
$stmt = $conn->prepare(“INSERT INTO sales
(sale_date, cash_sales, card_sales, online_cash, online_card, deliveroo, justeat, total_cash, total_card, tips, expense, total_sales, cash_in_hand, notes)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)”);
$stmt->bind_param(“sdddddddddddds”,
$date, $cash_sales, $card_sales, $online_cash, $online_card, $deliveroo, $justeat,
$total_cash, $total_card, $tips, $expense, $total_sales, $cash_in_hand, $notes
);
if ($stmt->execute()) {
echo “
✅ Sales record saved successfully!
“;
} else {
echo “
❌ Error: ” . $stmt->error . “
“;
}
$stmt->close();
}
?>
Daily Sales Entry
Daily Sales Form