<?php

class BankTransactionSetup
{

    /*************************************************
     * / This function add new Bank Setup
     *************************************************/

    public static function AddBankTransactionSetup($data)
    {
        global $db;

        $id = $db->query_insert(TABLE_BANKTRANSACTIONSETUP, $data);
        if ($db->affected_rows > 0) {
            //$db->query_insert("vrs_logs", $data);
            return $id;
        } else {
            return false;
        }

    } // AddBankTransaction
  
  /*************************************************
 * / This function deletes a BankTransaction record by ID
 *************************************************/
public static function DeleteBankTransactionSetup($id)
{
    global $db;
    
    $query = "DELETE FROM " . TABLE_BANKTRANSACTIONSETUP . " WHERE id = '$id'";
    $db->query($query);

    if ($db->affected_rows > 0) {
        return true;
    } else {
        return false;
    }
}


    /*************************************************
     * / This function update BankTransaction
     *************************************************/

    public static function UpdateBankTransactionSetup($pid, $data)
    {
        global $db;

        $id = $db->query_update(TABLE_BANKTRANSACTIONSETUP, $data, "id='$pid'");

        if ($db->affected_rows > 0) {
            //$db->query_insert("vrs_logs", $data);
            return $id;
        } else {
            return $id;
        }

    } // UpdateBankTransaction


    public static function GetBankTransactionSetupById($id)
    {

        global $db;
        $query = "SELECT * from " . TABLE_BANKTRANSACTIONSETUP . " WHERE id ='$id'";
        //print($query);exit;
        $rows = $db->query_first($query);

        if ($db->affected_rows > 0) {

            return $rows;
        } else {

            return false;
        }
    }//BankTransaction

    public static function GetOpeningbalance($filter = "", $pageno = "null", $pagesize = "null")
    {

        global $db;
        $query = "SELECT * from " . TABLE_BANKTRANSACTIONSETUP . " " . $filter;
        //print($query);exit;
        $rows = $db->fetch_all_array($query, $pageno, $pagesize);

        if ($db->affected_rows > 0) {

            return $rows;
        } else {

            return false;
        }
    }//BankTransaction

    /**********************************************************
     * / This function will return BankTransactionSetup
     **********************************************************/

    public static function GetBankTransactionSetupList($filter = "", $pageno = "null", $pagesize = "null")
    {

        global $db;
        $query = "SELECT * from " . TABLE_BANKTRANSACTIONSETUP . " " . $filter;
     //   echo($query);
        $rows = $db->fetch_all_array($query, $pageno, $pagesize);

        if ($db->affected_rows > 0) {

            return $rows;
        } else {

            return false;
        }
    }//BankSetup

    public static function GetNumRows()
    {
        global $db;
        return $db->GetNumRows();
    }

    public static function GetNumberOfPages()
    {
        global $db;
        return $db->GetNumberOfPages();
    }
  
  public static function GetBankTransactionSetupListFast($filter = "")
{
    global $db;

    $query = "SELECT * FROM " . TABLE_BANKTRANSACTIONSETUP . " " . $filter;
    $rows = $db->fetch_all_array($query);

    if ($db->affected_rows > 0) {
        return $rows;
    } else {
        return false;
    }
}

public static function CountBankTransactionSetup($where = "")
{
    global $db;

    $query = "SELECT COUNT(*) AS total FROM " . TABLE_BANKTRANSACTIONSETUP . " " . $where;
    $row = $db->query_first($query);

    if ($row) {
        return (int)$row->total;
    } else {
        return 0;
    }
}


}

?>
