<?php
require_once __DIR__ . '/../api/_pdo_db_connect.php';
$pdo = get_db();
$today = date('Y-m-d');
$stmt = $pdo->prepare('SELECT f.id,f.customer_id,c.name,c.phone,f.notes FROM sd_followups f JOIN sd_customers c ON c.id=f.customer_id WHERE DATE(f.scheduled_at)=? AND f.status!=?');
$stmt->execute([$today,'done']);
$rows = $stmt->fetchAll();
foreach($rows as $r){
    // send SMS / push (abstracted)
    $pdo->prepare('INSERT INTO sd_messages(customer_id, message, created_at) VALUES(?,?,NOW())')
        ->execute([$r['customer_id'], "Reminder: {$r['notes']}"]);
}
echo "Reminders processed: ".count($rows)."\n";
