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

$coid   = $_SESSION['co_id'];

session_write_close();

$ledger_limit  = $_GET['ledger_limit'] ?? 10;
$ledger_offset = $_GET['ledger_offset'] ?? 0;

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

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

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