<?php
class GLAccount{

    public $model;
    
    public function __construct(){
        $this->model = new Model();
    }

    /***** GL Account ***************************************************************/
    public function getGLAccountInfo($condition){
        return $this->model->findOne("glaccount", $condition);
    }

    public function getRowsNumber($table){
        return count($this->model->findAll($table));
    }

    public function checkIfGLAccountExists($condition){
        return count($this->model->findOne("glaccount", $condition)) > 0 ? true : false;
    }

    public function registerGLAccount($fields, $values){
        return $this->model->insertdata("glaccount", $fields, $values);
    }

    public function retrieveGLAccountByQuery($query, $pageno, $limit,$field = "*"){
        $data = $this->model->paginate("glaccount", $query, $pageno, $limit,$field);
        return $data;
    }    


    public function getGLAccount($id, $location, $field){
        return $this->model->findOne("glaccount", "id = '$id'", "$field");
    }

    public function updateGLAccountDetails($query, $id){
        return $this->model->update('glaccount', "$query", "WHERE id = '$id'");
    }
    public function getGLAccounts(){
        return $this->model->findAll("glaccount");
    }
    /***** End of GL Account ***************************************************************/
    
  
    public function executeByQuerySelector($query){
        $res = $this->model->exec_query($query);
        return $res;
    }

}
?>