<?php 
/**
 * This is general file which contains
 * connection file, common function file, etc.,
 *
 * PHP version 5
 *
 * @category Admin_Tool
 * @package  Admin_Tool
 * @author   Aum Infosys <admin@auminfosys.com>
 * @license  ACE
 * @version  CVS:1.0.1
 * @link     http://auminfosys.com/
 * @filesource
 */
 
/**
 * This is general file which contains
 * connection file, common function file, etc.,
 *
 */

require "../commonincludefiles.php";

if($_SESSION["cCompany_id"]!="" && isset($_SESSION["cCompany_id"]))
{
	$schoolid = $_SESSION["cCompany_id"];
	$receipttype= $_REQUEST["receipttype"];
	
	$objAccountMasterMgmt = new AccountMasterMgmt();
	
	$i=0;
	$limit=0;
	$start=0;
	$condition="";
	$order_field="mstr.account_name";
	$order_type="ASC";
	
	
	if($receipttype=="Contra") {
	
		$condition = " AND (mstr.account_type  LIKE '%Bank%' OR mstr.account_type  LIKE '%CASH%') ";
	
	}else if($receipttype=="General") {
	
		$condition = " AND (mstr.account_type  NOT LIKE '%Bank%' And mstr.account_type  NOT LIKE '%CASH%') ";
	}
	
	$result = $objAccountMasterMgmt ->getAllRecords(0,0,$condition,$order_field,$order_type) ;
	$total = dbRows($result);
	
	$SubGroupData = array("total" => $total, "rows" => array());
	if	(dbRows($result) > 0) 
		   {
				$temparray = array();
				while($row = dbArray($result)){
					$temparray["account_id"]  = $row["account_id"];
					$temparray["account_groupid"]  = $row["account_groupid"];
					$temparray["account_type"]  = $row["account_type"];
					$temparray["account_name"]  = $row["account_name"];
					$temparray["account_opbalance"]  = $row["account_opbalance"];
					$temparray["account_crdr"]  = $row["account_crdr"];
					$temparray["account_baldate"]  = $row["account_baldate"];
					$temparray["account_effect"]  = $row["account_effect"];
					$temparray["account_address"]  = $row["account_address"];
					$temparray["account_phone"]  = $row["account_phone"];
					$temparray["subgroup_id"]  = $row["subgroup_id"];
					$temparray["subgroup_name"]  = $row["subgroup_name"];
					$temparray["account_groupname"]  = $row["account_groupname"];
					
					$SubGroupData["rows"][$i] = $temparray;   
				$i++;
			}										
	}				   		 
 	echo json_encode($SubGroupData);	
}
?>