query( "SELECT company_id, COUNT(*) AS count FROM td_invoice WHERE company_id > 0 AND doc_type = 'invoice' AND status = 1 AND due_date IS NOT NULL AND due_date < CURDATE() GROUP BY company_id HAVING count > 0" ); $answer['success'] = 1; $answer['alerts'] = $sth->fetchAll(PDO::FETCH_ASSOC); exit(json_encode($answer));