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

$coid   = $_SESSION['co_id'];

$supplier_limit  = $_GET['supplier_limit'] ?? 10;
$supplier_offset = $_GET['supplier_offset'] ?? 0;

$stmt = $pdo->prepare("
    SELECT id, acc_name,acc_type,acc_categ,status FROM accounts WHERE acc_categ='customer' AND co_id = :coid
    ORDER BY id ASC
    LIMIT :supplier_limit OFFSET :supplier_offset
");

$stmt->bindValue(':coid', $coid, PDO::PARAM_INT);
$stmt->bindValue(':supplier_limit', (int)$supplier_limit, PDO::PARAM_INT);
$stmt->bindValue(':supplier_offset', (int)$supplier_offset, PDO::PARAM_INT);
$stmt->execute();

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