<?php
session_start();
require_once '../utils/errorhandler.php';
require_once '../utils/response.php';
require_once '../model/dbclass.php';
require_once '../model/model.php';
require_once '../model/glaccount.php';

$glaccount = new GLAccount();
//$atsrecord = explode("/",$_POST["atsrecordname"]);
$accountnumber = (isset($_POST["accountnumber"]) && $_POST["accountnumber"] !== "") ? $_POST["accountnumber"] : "%";
$status = (isset($_POST["status"]) && $_POST["status"] !== "") ? $_POST["status"] : "OPEN";
$pageno = $_POST["pageno"] > 0 ? $_POST["pageno"] : 1;
$limit = 3000;

$query = "accountnumber LIKE '$accountnumber' AND status LIKE '$status' ORDER BY description ASC";
$result = $glaccount->retrieveGLAccountByQuery($query, $pageno, $limit);

if($result){
	echo success($result,200, "Successful" ,"Successful");
}else{
	echo badRequest(204, "Not successful");
}
?>