<?php
require_once "../../includes/db.php";
header('Content-Type: application/json');

$comp_id = isset($_GET['comp_id']) ? (int)$_GET['comp_id'] : 0;

$stmt = $pdo->prepare("
    SELECT id, acc_name
    FROM accounts
    WHERE acc_categ = 'supplier'
    AND status = 'active'
    AND co_id = :comp_id
    ORDER BY acc_name ASC
");

$stmt->execute(['comp_id' => $comp_id]);

echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));