<?php

class Ledger {

	/*************************************************
	/ This function add new Ledger
	*************************************************/
	
	public static function AddLedger($data) {
		global $db;
				
		$id = $db->query_insert(TABLE_LEDGER, $data);
		if($db->affected_rows > 0){
			//$db->query_insert("vrs_logs", $data);
			return $id;
		}else{
			return false;
		}
	
	} // AddLedger

	/*************************************************
	/ This function update Ledger
	*************************************************/
	
	public static function UpdateLedgerSetup($pid,$data) {
		global $db;
				
		$id = $db->query_update(TABLE_LEDGER,$data,"id='$pid'");
		
		if($db->affected_rows > 0){
			//$db->query_insert("vrs_logs", $data);
			
			return $id;
		}else{
			return $id;
		}
	
	} // UpdateLedger


	public static function GetLedgerSetupById($id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_LEDGER." WHERE id ='$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Ledger

	public static function GetLedgerSetupByHead($scheem_name, $head) {

		global $db;
		$query = "SELECT * from ".TABLE_LEDGER." WHERE scheem_name = '$scheem_name' AND head ='$head'";
		//print($query);exit;
		$rows = $db->query_first($query);

		if($db->affected_rows > 0){

			return $rows;
		}else{

			return false;
		}
	}//Ledger
	
	/**********************************************************
	/ This function will return Ledger
	**********************************************************/
		
	public static function GetLedgerList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_LEDGER." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Ledger

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

?>
