<?php
$tdatamain_ledger = array();
$tdatamain_ledger[".searchableFields"] = array();
$tdatamain_ledger[".ShortName"] = "main_ledger";
$tdatamain_ledger[".OwnerID"] = "md";
$tdatamain_ledger[".OriginalTable"] = "expenditure_code";


$tdatamain_ledger[".pagesByType"] = my_json_decode( "{\"export\":[\"export\"],\"list\":[\"list\"],\"print\":[\"print\"],\"search\":[\"search\"]}" );
$tdatamain_ledger[".originalPagesByType"] = $tdatamain_ledger[".pagesByType"];
$tdatamain_ledger[".pages"] = types2pages( my_json_decode( "{\"export\":[\"export\"],\"list\":[\"list\"],\"print\":[\"print\"],\"search\":[\"search\"]}" ) );
$tdatamain_ledger[".originalPages"] = $tdatamain_ledger[".pages"];
$tdatamain_ledger[".defaultPages"] = my_json_decode( "{\"export\":\"export\",\"list\":\"list\",\"print\":\"print\",\"search\":\"search\"}" );
$tdatamain_ledger[".originalDefaultPages"] = $tdatamain_ledger[".defaultPages"];

//	field labels
$fieldLabelsmain_ledger = array();
$fieldToolTipsmain_ledger = array();
$pageTitlesmain_ledger = array();
$placeHoldersmain_ledger = array();

if(mlang_getcurrentlang()=="English")
{
	$fieldLabelsmain_ledger["English"] = array();
	$fieldToolTipsmain_ledger["English"] = array();
	$placeHoldersmain_ledger["English"] = array();
	$pageTitlesmain_ledger["English"] = array();
	$fieldLabelsmain_ledger["English"]["department_code"] = "Department Code";
	$fieldToolTipsmain_ledger["English"]["department_code"] = "";
	$placeHoldersmain_ledger["English"]["department_code"] = "";
	$fieldLabelsmain_ledger["English"]["expendite_code"] = "Expendite Code";
	$fieldToolTipsmain_ledger["English"]["expendite_code"] = "";
	$placeHoldersmain_ledger["English"]["expendite_code"] = "";
	$fieldLabelsmain_ledger["English"]["Issue"] = "Issue";
	$fieldToolTipsmain_ledger["English"]["Issue"] = "";
	$placeHoldersmain_ledger["English"]["Issue"] = "";
	$fieldLabelsmain_ledger["English"]["description"] = "Description";
	$fieldToolTipsmain_ledger["English"]["description"] = "";
	$placeHoldersmain_ledger["English"]["description"] = "";
	$fieldLabelsmain_ledger["English"]["department_name"] = "Department Name";
	$fieldToolTipsmain_ledger["English"]["department_name"] = "";
	$placeHoldersmain_ledger["English"]["department_name"] = "";
	$fieldLabelsmain_ledger["English"]["Allocation"] = "Allocation";
	$fieldToolTipsmain_ledger["English"]["Allocation"] = "";
	$placeHoldersmain_ledger["English"]["Allocation"] = "";
	$fieldLabelsmain_ledger["English"]["Sub_offive_expence"] = "Sub offive expence";
	$fieldToolTipsmain_ledger["English"]["Sub_offive_expence"] = "";
	$placeHoldersmain_ledger["English"]["Sub_offive_expence"] = "";
	$fieldLabelsmain_ledger["English"]["On_hand"] = "On Hand";
	$fieldToolTipsmain_ledger["English"]["On_hand"] = "";
	$placeHoldersmain_ledger["English"]["On_hand"] = "";
	$fieldLabelsmain_ledger["English"]["Sub_offive_surcharge"] = "Sub offive surcharge";
	$fieldToolTipsmain_ledger["English"]["Sub_offive_surcharge"] = "";
	$placeHoldersmain_ledger["English"]["Sub_offive_surcharge"] = "";
	if (count($fieldToolTipsmain_ledger["English"]))
		$tdatamain_ledger[".isUseToolTips"] = true;
}
if(mlang_getcurrentlang()=="sinhala")
{
	$fieldLabelsmain_ledger["sinhala"] = array();
	$fieldToolTipsmain_ledger["sinhala"] = array();
	$placeHoldersmain_ledger["sinhala"] = array();
	$pageTitlesmain_ledger["sinhala"] = array();
	$fieldLabelsmain_ledger["sinhala"]["department_code"] = "දේපාර්පතමේන්තු කේතය";
	$fieldToolTipsmain_ledger["sinhala"]["department_code"] = "";
	$placeHoldersmain_ledger["sinhala"]["department_code"] = "";
	$fieldLabelsmain_ledger["sinhala"]["expendite_code"] = "Expendite Code";
	$fieldToolTipsmain_ledger["sinhala"]["expendite_code"] = "";
	$placeHoldersmain_ledger["sinhala"]["expendite_code"] = "";
	$fieldLabelsmain_ledger["sinhala"]["Issue"] = "Issue";
	$fieldToolTipsmain_ledger["sinhala"]["Issue"] = "";
	$placeHoldersmain_ledger["sinhala"]["Issue"] = "";
	$fieldLabelsmain_ledger["sinhala"]["description"] = "විස්තරය";
	$fieldToolTipsmain_ledger["sinhala"]["description"] = "";
	$placeHoldersmain_ledger["sinhala"]["description"] = "";
	$fieldLabelsmain_ledger["sinhala"]["department_name"] = "දේපාර්පතමේන්තුවේ නම";
	$fieldToolTipsmain_ledger["sinhala"]["department_name"] = "";
	$placeHoldersmain_ledger["sinhala"]["department_name"] = "";
	$fieldLabelsmain_ledger["sinhala"]["Allocation"] = "Allocation";
	$fieldToolTipsmain_ledger["sinhala"]["Allocation"] = "";
	$placeHoldersmain_ledger["sinhala"]["Allocation"] = "";
	$fieldLabelsmain_ledger["sinhala"]["Sub_offive_expence"] = "Sub offive expence";
	$fieldToolTipsmain_ledger["sinhala"]["Sub_offive_expence"] = "";
	$placeHoldersmain_ledger["sinhala"]["Sub_offive_expence"] = "";
	$fieldLabelsmain_ledger["sinhala"]["On_hand"] = "On Hand";
	$fieldToolTipsmain_ledger["sinhala"]["On_hand"] = "";
	$placeHoldersmain_ledger["sinhala"]["On_hand"] = "";
	$fieldLabelsmain_ledger["sinhala"]["Sub_offive_surcharge"] = "Sub offive surcharge";
	$fieldToolTipsmain_ledger["sinhala"]["Sub_offive_surcharge"] = "";
	$placeHoldersmain_ledger["sinhala"]["Sub_offive_surcharge"] = "";
	if (count($fieldToolTipsmain_ledger["sinhala"]))
		$tdatamain_ledger[".isUseToolTips"] = true;
}


	$tdatamain_ledger[".NCSearch"] = true;



$tdatamain_ledger[".shortTableName"] = "main_ledger";
$tdatamain_ledger[".nSecOptions"] = 0;

$tdatamain_ledger[".mainTableOwnerID"] = "md";
$tdatamain_ledger[".entityType"] = 1;
$tdatamain_ledger[".connId"] = "allo_at_localhost";


$tdatamain_ledger[".strOriginalTableName"] = "expenditure_code";

	



$tdatamain_ledger[".showAddInPopup"] = false;

$tdatamain_ledger[".showEditInPopup"] = false;

$tdatamain_ledger[".showViewInPopup"] = false;

//page's base css files names
$popupPagesLayoutNames = array();
$tdatamain_ledger[".popupPagesLayoutNames"] = $popupPagesLayoutNames;


	$tdatamain_ledger[".listAjax"] = true;
//	temporary
$tdatamain_ledger[".listAjax"] = false;

	$tdatamain_ledger[".audit"] = true;

	$tdatamain_ledger[".locking"] = true;


$pages = $tdatamain_ledger[".defaultPages"];

if( $pages[PAGE_EDIT] ) {
	$tdatamain_ledger[".edit"] = true;
	$tdatamain_ledger[".afterEditAction"] = 1;
	$tdatamain_ledger[".closePopupAfterEdit"] = 1;
	$tdatamain_ledger[".afterEditActionDetTable"] = "";
}

if( $pages[PAGE_ADD] ) {
$tdatamain_ledger[".add"] = true;
$tdatamain_ledger[".afterAddAction"] = 1;
$tdatamain_ledger[".closePopupAfterAdd"] = 1;
$tdatamain_ledger[".afterAddActionDetTable"] = "";
}

if( $pages[PAGE_LIST] ) {
	$tdatamain_ledger[".list"] = true;
}



$tdatamain_ledger[".strSortControlSettingsJSON"] = "";




if( $pages[PAGE_VIEW] ) {
$tdatamain_ledger[".view"] = true;
}

if( $pages[PAGE_IMPORT] ) {
$tdatamain_ledger[".import"] = true;
}

if( $pages[PAGE_EXPORT] ) {
$tdatamain_ledger[".exportTo"] = true;
}

if( $pages[PAGE_PRINT] ) {
$tdatamain_ledger[".printFriendly"] = true;
}



$tdatamain_ledger[".showSimpleSearchOptions"] = true; // temp fix #13449

// Allow Show/Hide Fields in GRID
$tdatamain_ledger[".allowShowHideFields"] = true; // temp fix #13449
//

// Allow Fields Reordering in GRID
$tdatamain_ledger[".allowFieldsReordering"] = true; // temp fix #13449
//

$tdatamain_ledger[".isUseAjaxSuggest"] = true;

$tdatamain_ledger[".rowHighlite"] = true;



																								

$tdatamain_ledger[".ajaxCodeSnippetAdded"] = false;

$tdatamain_ledger[".buttonsAdded"] = false;

$tdatamain_ledger[".addPageEvents"] = false;

// use timepicker for search panel
$tdatamain_ledger[".isUseTimeForSearch"] = false;


$tdatamain_ledger[".badgeColor"] = "DB7093";


$tdatamain_ledger[".allSearchFields"] = array();
$tdatamain_ledger[".filterFields"] = array();
$tdatamain_ledger[".requiredSearchFields"] = array();

$tdatamain_ledger[".googleLikeFields"] = array();
$tdatamain_ledger[".googleLikeFields"][] = "expendite_code";
$tdatamain_ledger[".googleLikeFields"][] = "department_code";
$tdatamain_ledger[".googleLikeFields"][] = "description";
$tdatamain_ledger[".googleLikeFields"][] = "Issue";
$tdatamain_ledger[".googleLikeFields"][] = "Allocation";
$tdatamain_ledger[".googleLikeFields"][] = "Sub offive expence";
$tdatamain_ledger[".googleLikeFields"][] = "Sub offive surcharge";
$tdatamain_ledger[".googleLikeFields"][] = "On hand";
$tdatamain_ledger[".googleLikeFields"][] = "department_name";



$tdatamain_ledger[".tableType"] = "list";

$tdatamain_ledger[".printerPageOrientation"] = 0;
$tdatamain_ledger[".isPrinterPageFitToPage"] = 0;
$tdatamain_ledger[".nPrinterPageScale"] = 100;

$tdatamain_ledger[".nPrinterSplitRecords"] = 40;

$tdatamain_ledger[".geocodingEnabled"] = false;










$tdatamain_ledger[".pageSize"] = 20;

$tdatamain_ledger[".warnLeavingPages"] = true;



$tstrOrderBy = "";
if(strlen($tstrOrderBy) && strtolower(substr($tstrOrderBy,0,8))!="order by")
	$tstrOrderBy = "order by ".$tstrOrderBy;
$tdatamain_ledger[".strOrderBy"] = $tstrOrderBy;

$tdatamain_ledger[".orderindexes"] = array();


$tdatamain_ledger[".sqlHead"] = "SELECT expenditure_code.`expenditure_code` as\"expendite_code\",  `department_code`,  description,  ifnull(pur.st1,0) as \"Issue\",  ifnull(pur2.st2,0) as \"Allocation\" ,  ifnull(pur3.st3,0) as \"Sub offive expence\",  ifnull(pur3.st4,0) as \"Sub offive surcharge\",  ifnull(pur2.st2,0)-ifnull(pur.st1,0) as \"On hand\",  department_name";
$tdatamain_ledger[".sqlFrom"] = "FROM expenditure_code  LEFT JOIN (select expenditure_code, sum(amount) as st1 from allocation_detail where c_acc=2 group by expenditure_code ) as pur on expenditure_code.`expenditure_code` = pur.expenditure_code  LEFT JOIN (select expenditure_code, sum(amount) as st2 from allocation_from_departments group by expenditure_code ) as pur2 on expenditure_code.`expenditure_code` = pur2.expenditure_code  LEFT JOIN (SELECT  `code`,  SUM(`expenditure_for_month`) as st3 ,SUM(`surcharge_for_month`) as st4 FROM `expenditure_statement` where status='Correct' group by `code` ) as pur3 on expenditure_code.`expenditure_code` = pur3.code";
$tdatamain_ledger[".sqlWhereExpr"] = "";
$tdatamain_ledger[".sqlTail"] = "";

//fill array of tabs for list page
$arrGridTabs = array();
$arrGridTabs[] = array(
	'tabId' => "",
	'name' => "All data",
	'nameType' => 'Text',
	'where' => "",
	'showRowCount' => 0,
	'hideEmpty' => 0,
);
$tdatamain_ledger[".arrGridTabs"] = $arrGridTabs;









//fill array of records per page for list and report without group fields
$arrRPP = array();
$arrRPP[] = 10;
$arrRPP[] = 20;
$arrRPP[] = 30;
$arrRPP[] = 50;
$arrRPP[] = 100;
$arrRPP[] = 500;
$arrRPP[] = -1;
$tdatamain_ledger[".arrRecsPerPage"] = $arrRPP;

//fill array of groups per page for report with group fields
$arrGPP = array();
$arrGPP[] = 1;
$arrGPP[] = 3;
$arrGPP[] = 5;
$arrGPP[] = 10;
$arrGPP[] = 50;
$arrGPP[] = 100;
$arrGPP[] = -1;
$tdatamain_ledger[".arrGroupsPerPage"] = $arrGPP;

$tdatamain_ledger[".highlightSearchResults"] = true;

$tableKeysmain_ledger = array();
$tdatamain_ledger[".Keys"] = $tableKeysmain_ledger;


$tdatamain_ledger[".hideMobileList"] = array();




//	expendite_code
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 1;
	$fdata["strName"] = "expendite_code";
	$fdata["GoodName"] = "expendite_code";
	$fdata["ownerTable"] = "expenditure_code";
	$fdata["Label"] = GetFieldLabel("main_ledger","expendite_code");
	$fdata["FieldType"] = 200;

	
	
	
			

		$fdata["strField"] = "expenditure_code";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "expenditure_code.`expenditure_code`";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Text field");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	



	
	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
			$edata["HTML5InuptType"] = "text";

		$edata["EditParams"] = "";
		
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
	
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["expendite_code"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "expendite_code";
//	department_code
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 2;
	$fdata["strName"] = "department_code";
	$fdata["GoodName"] = "department_code";
	$fdata["ownerTable"] = "expenditure_code";
	$fdata["Label"] = GetFieldLabel("main_ledger","department_code");
	$fdata["FieldType"] = 200;

	
	
	
			

		$fdata["strField"] = "department_code";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "`department_code`";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Lookup wizard");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	

// Begin Lookup settings
				$edata["LookupType"] = 2;
	$edata["LookupTable"] = "department";
		$edata["listPageId"] = "list";
		$edata["autoCompleteFieldsOnEdit"] = 0;
	$edata["autoCompleteFields"] = array();
		$edata["autoCompleteFields"][] = array('masterF'=>"department_name", 'lookupF'=>"department_name");
	$edata["autoCompleteFields"][] = array('masterF'=>"md", 'lookupF'=>"md");
	$edata["LCType"] = 1;

	
		
	$edata["LinkField"] = "department_code";
	$edata["LinkFieldType"] = 0;
	$edata["DisplayField"] = "department_code";

	

	
	$edata["LookupOrderBy"] = "";

	
	
		$edata["AllowToAdd"] = true;
		
	

	
	
	
// End Lookup Settings


		$edata["IsRequired"] = true;

	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
	
	
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
						$edata["validateAs"]["basicValidate"][] = "IsRequired";
		
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Equals";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["department_code"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "department_code";
//	description
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 3;
	$fdata["strName"] = "description";
	$fdata["GoodName"] = "description";
	$fdata["ownerTable"] = "expenditure_code";
	$fdata["Label"] = GetFieldLabel("main_ledger","description");
	$fdata["FieldType"] = 200;

	
	
	
			

		$fdata["strField"] = "description";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "description";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Lookup wizard");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	

// Begin Lookup settings
				$edata["LookupType"] = 2;
	$edata["LookupTable"] = "description";
		$edata["listPageId"] = "list";
		$edata["autoCompleteFieldsOnEdit"] = 0;
	$edata["autoCompleteFields"] = array();
		$edata["LCType"] = 2;

	
		
	$edata["LinkField"] = "description";
	$edata["LinkFieldType"] = 0;
	$edata["DisplayField"] = "description";

	

	
	$edata["LookupOrderBy"] = "";

	
	
		$edata["AllowToAdd"] = true;
			$edata["addPageId"] = "add";

	

	
	
	
// End Lookup Settings


		$edata["IsRequired"] = true;

	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
	
	
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
						$edata["validateAs"]["basicValidate"][] = "IsRequired";
		
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["description"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "description";
//	Issue
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 4;
	$fdata["strName"] = "Issue";
	$fdata["GoodName"] = "Issue";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("main_ledger","Issue");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "Issue";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(pur.st1,0)";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "Number");

	
	
	
	
	
	
		$vdata["DecimalDigits"] = 2;

	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Text field");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	



		$edata["IsRequired"] = true;

	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
			$edata["HTML5InuptType"] = "text";

		$edata["EditParams"] = "";
		
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
				$edata["validateAs"]["basicValidate"][] = getJsValidatorName("Number");
						$edata["validateAs"]["basicValidate"][] = "IsRequired";
		
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["Issue"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "Issue";
//	Allocation
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 5;
	$fdata["strName"] = "Allocation";
	$fdata["GoodName"] = "Allocation";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("main_ledger","Allocation");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "Allocation";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(pur2.st2,0)";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "Number");

	
	
	
	
	
	
		$vdata["DecimalDigits"] = 2;

	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Text field");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	



		$edata["IsRequired"] = true;

	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
			$edata["HTML5InuptType"] = "text";

		$edata["EditParams"] = "";
		
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
				$edata["validateAs"]["basicValidate"][] = getJsValidatorName("Number");
						$edata["validateAs"]["basicValidate"][] = "IsRequired";
		
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["Allocation"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "Allocation";
//	Sub offive expence
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 6;
	$fdata["strName"] = "Sub offive expence";
	$fdata["GoodName"] = "Sub_offive_expence";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("main_ledger","Sub_offive_expence");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "Sub offive expence";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(pur3.st3,0)";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "Number");

	
	
	
	
	
	
		$vdata["DecimalDigits"] = 2;

	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Text field");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	



		$edata["IsRequired"] = true;

	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
			$edata["HTML5InuptType"] = "text";

		$edata["EditParams"] = "";
		
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
				$edata["validateAs"]["basicValidate"][] = getJsValidatorName("Number");
						$edata["validateAs"]["basicValidate"][] = "IsRequired";
		
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["Sub offive expence"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "Sub offive expence";
//	Sub offive surcharge
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 7;
	$fdata["strName"] = "Sub offive surcharge";
	$fdata["GoodName"] = "Sub_offive_surcharge";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("main_ledger","Sub_offive_surcharge");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "Sub offive surcharge";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(pur3.st4,0)";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "Number");

	
	
	
	
	
	
		$vdata["DecimalDigits"] = 0;

	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Text field");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	



		$edata["IsRequired"] = true;

	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
			$edata["HTML5InuptType"] = "text";

		$edata["EditParams"] = "";
		
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
				$edata["validateAs"]["basicValidate"][] = getJsValidatorName("Number");
						$edata["validateAs"]["basicValidate"][] = "IsRequired";
		
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["Sub offive surcharge"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "Sub offive surcharge";
//	On hand
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 8;
	$fdata["strName"] = "On hand";
	$fdata["GoodName"] = "On_hand";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("main_ledger","On_hand");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "On hand";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(pur2.st2,0)-ifnull(pur.st1,0)";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "Number");

	
	
	
	
	
	
		$vdata["DecimalDigits"] = 2;

	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Text field");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	



		$edata["IsRequired"] = true;

	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
			$edata["HTML5InuptType"] = "text";

		$edata["EditParams"] = "";
		
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
				$edata["validateAs"]["basicValidate"][] = getJsValidatorName("Number");
						$edata["validateAs"]["basicValidate"][] = "IsRequired";
		
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["On hand"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "On hand";
//	department_name
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 9;
	$fdata["strName"] = "department_name";
	$fdata["GoodName"] = "department_name";
	$fdata["ownerTable"] = "expenditure_code";
	$fdata["Label"] = GetFieldLabel("main_ledger","department_name");
	$fdata["FieldType"] = 200;

	
	
	
			

		$fdata["strField"] = "department_name";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "department_name";

	
	
				$fdata["UploadFolder"] = "files";

//  Begin View Formats
	$fdata["ViewFormats"] = array();

	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

	
		$vdata["truncateText"] = true;
	$vdata["NumberOfChars"] = 80;

	$fdata["ViewFormats"]["view"] = $vdata;
//  End View Formats

//	Begin Edit Formats
	$fdata["EditFormats"] = array();

	$edata = array("EditFormat" => "Lookup wizard");

	
		$edata["weekdayMessage"] = array("message" => "", "messageType" => "Text");
	$edata["weekdays"] = "[]";


	
	

// Begin Lookup settings
				$edata["LookupType"] = 2;
	$edata["LookupTable"] = "department";
			$edata["autoCompleteFieldsOnEdit"] = 1;
	$edata["autoCompleteFields"] = array();
		$edata["autoCompleteFields"][] = array('masterF'=>"department_code", 'lookupF'=>"department_code");
	$edata["LCType"] = 1;

	
		
	$edata["LinkField"] = "department_name";
	$edata["LinkFieldType"] = 0;
	$edata["DisplayField"] = "department_name";

	

	
	$edata["LookupOrderBy"] = "";

	
	
	
	

	
	
	
// End Lookup Settings


	
	
	
	
			$edata["acceptFileTypes"] = ".+$";
		$edata["acceptFileTypesHtml"] = "";

		$edata["maxNumberOfFiles"] = 1;

	
	
	
	
	
	
		$edata["controlWidth"] = 200;

//	Begin validation
	$edata["validateAs"] = array();
	$edata["validateAs"]["basicValidate"] = array();
	$edata["validateAs"]["customMessages"] = array();
	
	
	//	End validation

	
			
	
	
	
	$fdata["EditFormats"]["edit"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = false;




// the field's search options settings
		$fdata["defaultSearchOption"] = "Contains";

			// the default search options list
				$fdata["searchOptionsList"] = array("Contains", "Equals", "Starts with", "More than", "Less than", "Between", "Empty", NOT_EMPTY);
// the end of search options settings


//Filters settings
	$fdata["filterTotals"] = 0;
		$fdata["filterMultiSelect"] = 0;
			$fdata["filterFormat"] = "Values list";
		$fdata["showCollapsed"] = false;

		$fdata["sortValueType"] = 0;
		$fdata["numberOfVisibleItems"] = 10;

		$fdata["filterBy"] = 0;

	

	
	
//end of Filters settings


	$tdatamain_ledger["department_name"] = $fdata;
		$tdatamain_ledger[".searchableFields"][] = "department_name";


$tables_data["main ledger"]=&$tdatamain_ledger;
$field_labels["main_ledger"] = &$fieldLabelsmain_ledger;
$fieldToolTips["main_ledger"] = &$fieldToolTipsmain_ledger;
$placeHolders["main_ledger"] = &$placeHoldersmain_ledger;
$page_titles["main_ledger"] = &$pageTitlesmain_ledger;

// -----------------start  prepare master-details data arrays ------------------------------//
// tables which are detail tables for current table (master)
$detailsTablesData["main ledger"] = array();

// tables which are master tables for current table (detail)
$masterTablesData["main ledger"] = array();



// -----------------end  prepare master-details data arrays ------------------------------//



require_once(getabspath("classes/sql.php"));











function createSqlQuery_main_ledger()
{
$proto0=array();
$proto0["m_strHead"] = "SELECT";
$proto0["m_strFieldList"] = "expenditure_code.`expenditure_code` as\"expendite_code\",  `department_code`,  description,  ifnull(pur.st1,0) as \"Issue\",  ifnull(pur2.st2,0) as \"Allocation\" ,  ifnull(pur3.st3,0) as \"Sub offive expence\",  ifnull(pur3.st4,0) as \"Sub offive surcharge\",  ifnull(pur2.st2,0)-ifnull(pur.st1,0) as \"On hand\",  department_name";
$proto0["m_strFrom"] = "FROM expenditure_code  LEFT JOIN (select expenditure_code, sum(amount) as st1 from allocation_detail where c_acc=2 group by expenditure_code ) as pur on expenditure_code.`expenditure_code` = pur.expenditure_code  LEFT JOIN (select expenditure_code, sum(amount) as st2 from allocation_from_departments group by expenditure_code ) as pur2 on expenditure_code.`expenditure_code` = pur2.expenditure_code  LEFT JOIN (SELECT  `code`,  SUM(`expenditure_for_month`) as st3 ,SUM(`surcharge_for_month`) as st4 FROM `expenditure_statement` where status='Correct' group by `code` ) as pur3 on expenditure_code.`expenditure_code` = pur3.code";
$proto0["m_strWhere"] = "";
$proto0["m_strOrderBy"] = "";
	
		;
			$proto0["cipherer"] = null;
$proto2=array();
$proto2["m_sql"] = "";
$proto2["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto2["m_column"]=$obj;
$proto2["m_contained"] = array();
$proto2["m_strCase"] = "";
$proto2["m_havingmode"] = false;
$proto2["m_inBrackets"] = false;
$proto2["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto2);

$proto0["m_where"] = $obj;
$proto4=array();
$proto4["m_sql"] = "";
$proto4["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto4["m_column"]=$obj;
$proto4["m_contained"] = array();
$proto4["m_strCase"] = "";
$proto4["m_havingmode"] = false;
$proto4["m_inBrackets"] = false;
$proto4["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto4);

$proto0["m_having"] = $obj;
$proto0["m_fieldlist"] = array();
						$proto6=array();
			$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "expenditure_code",
	"m_srcTableName" => "main ledger"
));

$proto6["m_sql"] = "expenditure_code.`expenditure_code`";
$proto6["m_srcTableName"] = "main ledger";
$proto6["m_expr"]=$obj;
$proto6["m_alias"] = "expendite_code";
$obj = new SQLFieldListItem($proto6);

$proto0["m_fieldlist"][]=$obj;
						$proto8=array();
			$obj = new SQLField(array(
	"m_strName" => "department_code",
	"m_strTable" => "expenditure_code",
	"m_srcTableName" => "main ledger"
));

$proto8["m_sql"] = "`department_code`";
$proto8["m_srcTableName"] = "main ledger";
$proto8["m_expr"]=$obj;
$proto8["m_alias"] = "";
$obj = new SQLFieldListItem($proto8);

$proto0["m_fieldlist"][]=$obj;
						$proto10=array();
			$obj = new SQLField(array(
	"m_strName" => "description",
	"m_strTable" => "expenditure_code",
	"m_srcTableName" => "main ledger"
));

$proto10["m_sql"] = "description";
$proto10["m_srcTableName"] = "main ledger";
$proto10["m_expr"]=$obj;
$proto10["m_alias"] = "";
$obj = new SQLFieldListItem($proto10);

$proto0["m_fieldlist"][]=$obj;
						$proto12=array();
			$proto13=array();
$proto13["m_functiontype"] = "SQLF_CUSTOM";
$proto13["m_arguments"] = array();
						$obj = new SQLNonParsed(array(
	"m_sql" => "pur.st1"
));

$proto13["m_arguments"][]=$obj;
						$obj = new SQLNonParsed(array(
	"m_sql" => "0"
));

$proto13["m_arguments"][]=$obj;
$proto13["m_strFunctionName"] = "ifnull";
$obj = new SQLFunctionCall($proto13);

$proto12["m_sql"] = "ifnull(pur.st1,0)";
$proto12["m_srcTableName"] = "main ledger";
$proto12["m_expr"]=$obj;
$proto12["m_alias"] = "Issue";
$obj = new SQLFieldListItem($proto12);

$proto0["m_fieldlist"][]=$obj;
						$proto16=array();
			$proto17=array();
$proto17["m_functiontype"] = "SQLF_CUSTOM";
$proto17["m_arguments"] = array();
						$obj = new SQLNonParsed(array(
	"m_sql" => "pur2.st2"
));

$proto17["m_arguments"][]=$obj;
						$obj = new SQLNonParsed(array(
	"m_sql" => "0"
));

$proto17["m_arguments"][]=$obj;
$proto17["m_strFunctionName"] = "ifnull";
$obj = new SQLFunctionCall($proto17);

$proto16["m_sql"] = "ifnull(pur2.st2,0)";
$proto16["m_srcTableName"] = "main ledger";
$proto16["m_expr"]=$obj;
$proto16["m_alias"] = "Allocation";
$obj = new SQLFieldListItem($proto16);

$proto0["m_fieldlist"][]=$obj;
						$proto20=array();
			$proto21=array();
$proto21["m_functiontype"] = "SQLF_CUSTOM";
$proto21["m_arguments"] = array();
						$obj = new SQLNonParsed(array(
	"m_sql" => "pur3.st3"
));

$proto21["m_arguments"][]=$obj;
						$obj = new SQLNonParsed(array(
	"m_sql" => "0"
));

$proto21["m_arguments"][]=$obj;
$proto21["m_strFunctionName"] = "ifnull";
$obj = new SQLFunctionCall($proto21);

$proto20["m_sql"] = "ifnull(pur3.st3,0)";
$proto20["m_srcTableName"] = "main ledger";
$proto20["m_expr"]=$obj;
$proto20["m_alias"] = "Sub offive expence";
$obj = new SQLFieldListItem($proto20);

$proto0["m_fieldlist"][]=$obj;
						$proto24=array();
			$proto25=array();
$proto25["m_functiontype"] = "SQLF_CUSTOM";
$proto25["m_arguments"] = array();
						$obj = new SQLNonParsed(array(
	"m_sql" => "pur3.st4"
));

$proto25["m_arguments"][]=$obj;
						$obj = new SQLNonParsed(array(
	"m_sql" => "0"
));

$proto25["m_arguments"][]=$obj;
$proto25["m_strFunctionName"] = "ifnull";
$obj = new SQLFunctionCall($proto25);

$proto24["m_sql"] = "ifnull(pur3.st4,0)";
$proto24["m_srcTableName"] = "main ledger";
$proto24["m_expr"]=$obj;
$proto24["m_alias"] = "Sub offive surcharge";
$obj = new SQLFieldListItem($proto24);

$proto0["m_fieldlist"][]=$obj;
						$proto28=array();
			$obj = new SQLNonParsed(array(
	"m_sql" => "ifnull(pur2.st2,0)-ifnull(pur.st1,0)"
));

$proto28["m_sql"] = "ifnull(pur2.st2,0)-ifnull(pur.st1,0)";
$proto28["m_srcTableName"] = "main ledger";
$proto28["m_expr"]=$obj;
$proto28["m_alias"] = "On hand";
$obj = new SQLFieldListItem($proto28);

$proto0["m_fieldlist"][]=$obj;
						$proto30=array();
			$obj = new SQLField(array(
	"m_strName" => "department_name",
	"m_strTable" => "expenditure_code",
	"m_srcTableName" => "main ledger"
));

$proto30["m_sql"] = "department_name";
$proto30["m_srcTableName"] = "main ledger";
$proto30["m_expr"]=$obj;
$proto30["m_alias"] = "";
$obj = new SQLFieldListItem($proto30);

$proto0["m_fieldlist"][]=$obj;
$proto0["m_fromlist"] = array();
												$proto32=array();
$proto32["m_link"] = "SQLL_MAIN";
			$proto33=array();
$proto33["m_strName"] = "expenditure_code";
$proto33["m_srcTableName"] = "main ledger";
$proto33["m_columns"] = array();
$proto33["m_columns"][] = "id";
$proto33["m_columns"][] = "department_code";
$proto33["m_columns"][] = "department_name";
$proto33["m_columns"][] = "expenditure_code";
$proto33["m_columns"][] = "description";
$proto33["m_columns"][] = "user";
$proto33["m_columns"][] = "md";
$obj = new SQLTable($proto33);

$proto32["m_table"] = $obj;
$proto32["m_sql"] = "expenditure_code";
$proto32["m_alias"] = "";
$proto32["m_srcTableName"] = "main ledger";
$proto34=array();
$proto34["m_sql"] = "";
$proto34["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto34["m_column"]=$obj;
$proto34["m_contained"] = array();
$proto34["m_strCase"] = "";
$proto34["m_havingmode"] = false;
$proto34["m_inBrackets"] = false;
$proto34["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto34);

$proto32["m_joinon"] = $obj;
$obj = new SQLFromListItem($proto32);

$proto0["m_fromlist"][]=$obj;
												$proto36=array();
$proto36["m_link"] = "SQLL_LEFTJOIN";
			$proto37=array();
$proto37["m_strHead"] = "select";
$proto37["m_strFieldList"] = "expenditure_code, sum(amount) as st1";
$proto37["m_strFrom"] = "from allocation_detail";
$proto37["m_strWhere"] = "c_acc=2";
$proto37["m_strOrderBy"] = "";
	
		;
			$proto37["cipherer"] = null;
$proto39=array();
$proto39["m_sql"] = "c_acc=2";
$proto39["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "c_acc",
	"m_strTable" => "allocation_detail",
	"m_srcTableName" => "main ledger"
));

$proto39["m_column"]=$obj;
$proto39["m_contained"] = array();
$proto39["m_strCase"] = "=2";
$proto39["m_havingmode"] = false;
$proto39["m_inBrackets"] = false;
$proto39["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto39);

$proto37["m_where"] = $obj;
$proto41=array();
$proto41["m_sql"] = "";
$proto41["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto41["m_column"]=$obj;
$proto41["m_contained"] = array();
$proto41["m_strCase"] = "";
$proto41["m_havingmode"] = false;
$proto41["m_inBrackets"] = false;
$proto41["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto41);

$proto37["m_having"] = $obj;
$proto37["m_fieldlist"] = array();
						$proto43=array();
			$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "allocation_detail",
	"m_srcTableName" => "main ledger"
));

$proto43["m_sql"] = "expenditure_code";
$proto43["m_srcTableName"] = "main ledger";
$proto43["m_expr"]=$obj;
$proto43["m_alias"] = "";
$obj = new SQLFieldListItem($proto43);

$proto37["m_fieldlist"][]=$obj;
						$proto45=array();
			$proto46=array();
$proto46["m_functiontype"] = "SQLF_SUM";
$proto46["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "amount",
	"m_strTable" => "allocation_detail",
	"m_srcTableName" => "main ledger"
));

$proto46["m_arguments"][]=$obj;
$proto46["m_strFunctionName"] = "sum";
$obj = new SQLFunctionCall($proto46);

$proto45["m_sql"] = "sum(amount)";
$proto45["m_srcTableName"] = "main ledger";
$proto45["m_expr"]=$obj;
$proto45["m_alias"] = "st1";
$obj = new SQLFieldListItem($proto45);

$proto37["m_fieldlist"][]=$obj;
$proto37["m_fromlist"] = array();
												$proto48=array();
$proto48["m_link"] = "SQLL_MAIN";
			$proto49=array();
$proto49["m_strName"] = "allocation_detail";
$proto49["m_srcTableName"] = "main ledger";
$proto49["m_columns"] = array();
$proto49["m_columns"][] = "id";
$proto49["m_columns"][] = "sub_office_code";
$proto49["m_columns"][] = "sub_office";
$proto49["m_columns"][] = "expenditure_code";
$proto49["m_columns"][] = "department";
$proto49["m_columns"][] = "amount";
$proto49["m_columns"][] = "date";
$proto49["m_columns"][] = "user";
$proto49["m_columns"][] = "on_time";
$proto49["m_columns"][] = "fk";
$proto49["m_columns"][] = "action";
$proto49["m_columns"][] = "ud";
$proto49["m_columns"][] = "md";
$proto49["m_columns"][] = "comment";
$proto49["m_columns"][] = "description";
$proto49["m_columns"][] = "c_acc";
$proto49["m_columns"][] = "delete";
$proto49["m_columns"][] = "accounting_code";
$obj = new SQLTable($proto49);

$proto48["m_table"] = $obj;
$proto48["m_sql"] = "allocation_detail";
$proto48["m_alias"] = "";
$proto48["m_srcTableName"] = "main ledger";
$proto50=array();
$proto50["m_sql"] = "";
$proto50["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto50["m_column"]=$obj;
$proto50["m_contained"] = array();
$proto50["m_strCase"] = "";
$proto50["m_havingmode"] = false;
$proto50["m_inBrackets"] = false;
$proto50["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto50);

$proto48["m_joinon"] = $obj;
$obj = new SQLFromListItem($proto48);

$proto37["m_fromlist"][]=$obj;
$proto37["m_groupby"] = array();
												$proto52=array();
						$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "allocation_detail",
	"m_srcTableName" => "main ledger"
));

$proto52["m_column"]=$obj;
$obj = new SQLGroupByItem($proto52);

$proto37["m_groupby"][]=$obj;
$proto37["m_orderby"] = array();
$proto37["m_srcTableName"]="main ledger";		
$obj = new SQLQuery($proto37);

$proto36["m_table"] = $obj;
$proto36["m_sql"] = "LEFT JOIN (select expenditure_code, sum(amount) as st1 from allocation_detail where c_acc=2 group by expenditure_code ) as pur on expenditure_code.`expenditure_code` = pur.expenditure_code";
$proto36["m_alias"] = "pur";
$proto36["m_srcTableName"] = "main ledger";
$proto54=array();
$proto54["m_sql"] = "expenditure_code.`expenditure_code` = pur.expenditure_code";
$proto54["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "expenditure_code",
	"m_srcTableName" => "main ledger"
));

$proto54["m_column"]=$obj;
$proto54["m_contained"] = array();
$proto54["m_strCase"] = "= pur.expenditure_code";
$proto54["m_havingmode"] = false;
$proto54["m_inBrackets"] = false;
$proto54["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto54);

$proto36["m_joinon"] = $obj;
$obj = new SQLFromListItem($proto36);

$proto0["m_fromlist"][]=$obj;
												$proto56=array();
$proto56["m_link"] = "SQLL_LEFTJOIN";
			$proto57=array();
$proto57["m_strHead"] = "select";
$proto57["m_strFieldList"] = "expenditure_code, sum(amount) as st2";
$proto57["m_strFrom"] = "from allocation_from_departments";
$proto57["m_strWhere"] = "";
$proto57["m_strOrderBy"] = "";
	
		;
			$proto57["cipherer"] = null;
$proto59=array();
$proto59["m_sql"] = "";
$proto59["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto59["m_column"]=$obj;
$proto59["m_contained"] = array();
$proto59["m_strCase"] = "";
$proto59["m_havingmode"] = false;
$proto59["m_inBrackets"] = false;
$proto59["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto59);

$proto57["m_where"] = $obj;
$proto61=array();
$proto61["m_sql"] = "";
$proto61["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto61["m_column"]=$obj;
$proto61["m_contained"] = array();
$proto61["m_strCase"] = "";
$proto61["m_havingmode"] = false;
$proto61["m_inBrackets"] = false;
$proto61["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto61);

$proto57["m_having"] = $obj;
$proto57["m_fieldlist"] = array();
						$proto63=array();
			$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "allocation_from_departments",
	"m_srcTableName" => "main ledger"
));

$proto63["m_sql"] = "expenditure_code";
$proto63["m_srcTableName"] = "main ledger";
$proto63["m_expr"]=$obj;
$proto63["m_alias"] = "";
$obj = new SQLFieldListItem($proto63);

$proto57["m_fieldlist"][]=$obj;
						$proto65=array();
			$proto66=array();
$proto66["m_functiontype"] = "SQLF_SUM";
$proto66["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "amount",
	"m_strTable" => "allocation_from_departments",
	"m_srcTableName" => "main ledger"
));

$proto66["m_arguments"][]=$obj;
$proto66["m_strFunctionName"] = "sum";
$obj = new SQLFunctionCall($proto66);

$proto65["m_sql"] = "sum(amount)";
$proto65["m_srcTableName"] = "main ledger";
$proto65["m_expr"]=$obj;
$proto65["m_alias"] = "st2";
$obj = new SQLFieldListItem($proto65);

$proto57["m_fieldlist"][]=$obj;
$proto57["m_fromlist"] = array();
												$proto68=array();
$proto68["m_link"] = "SQLL_MAIN";
			$proto69=array();
$proto69["m_strName"] = "allocation_from_departments";
$proto69["m_srcTableName"] = "main ledger";
$proto69["m_columns"] = array();
$proto69["m_columns"][] = "id";
$proto69["m_columns"][] = "expenditure_code";
$proto69["m_columns"][] = "department_name";
$proto69["m_columns"][] = "amount";
$proto69["m_columns"][] = "action";
$proto69["m_columns"][] = "date";
$proto69["m_columns"][] = "user";
$proto69["m_columns"][] = "md";
$obj = new SQLTable($proto69);

$proto68["m_table"] = $obj;
$proto68["m_sql"] = "allocation_from_departments";
$proto68["m_alias"] = "";
$proto68["m_srcTableName"] = "main ledger";
$proto70=array();
$proto70["m_sql"] = "";
$proto70["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto70["m_column"]=$obj;
$proto70["m_contained"] = array();
$proto70["m_strCase"] = "";
$proto70["m_havingmode"] = false;
$proto70["m_inBrackets"] = false;
$proto70["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto70);

$proto68["m_joinon"] = $obj;
$obj = new SQLFromListItem($proto68);

$proto57["m_fromlist"][]=$obj;
$proto57["m_groupby"] = array();
												$proto72=array();
						$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "allocation_from_departments",
	"m_srcTableName" => "main ledger"
));

$proto72["m_column"]=$obj;
$obj = new SQLGroupByItem($proto72);

$proto57["m_groupby"][]=$obj;
$proto57["m_orderby"] = array();
$proto57["m_srcTableName"]="main ledger";		
$obj = new SQLQuery($proto57);

$proto56["m_table"] = $obj;
$proto56["m_sql"] = "LEFT JOIN (select expenditure_code, sum(amount) as st2 from allocation_from_departments group by expenditure_code ) as pur2 on expenditure_code.`expenditure_code` = pur2.expenditure_code";
$proto56["m_alias"] = "pur2";
$proto56["m_srcTableName"] = "main ledger";
$proto74=array();
$proto74["m_sql"] = "expenditure_code.`expenditure_code` = pur2.expenditure_code";
$proto74["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "expenditure_code",
	"m_srcTableName" => "main ledger"
));

$proto74["m_column"]=$obj;
$proto74["m_contained"] = array();
$proto74["m_strCase"] = "= pur2.expenditure_code";
$proto74["m_havingmode"] = false;
$proto74["m_inBrackets"] = false;
$proto74["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto74);

$proto56["m_joinon"] = $obj;
$obj = new SQLFromListItem($proto56);

$proto0["m_fromlist"][]=$obj;
												$proto76=array();
$proto76["m_link"] = "SQLL_LEFTJOIN";
			$proto77=array();
$proto77["m_strHead"] = "SELECT";
$proto77["m_strFieldList"] = "`code`,  SUM(`expenditure_for_month`) as st3 ,SUM(`surcharge_for_month`) as st4";
$proto77["m_strFrom"] = "FROM `expenditure_statement`";
$proto77["m_strWhere"] = "status='Correct'";
$proto77["m_strOrderBy"] = "";
	
		;
			$proto77["cipherer"] = null;
$proto79=array();
$proto79["m_sql"] = "status='Correct'";
$proto79["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "status",
	"m_strTable" => "expenditure_statement",
	"m_srcTableName" => "main ledger"
));

$proto79["m_column"]=$obj;
$proto79["m_contained"] = array();
$proto79["m_strCase"] = "='Correct'";
$proto79["m_havingmode"] = false;
$proto79["m_inBrackets"] = false;
$proto79["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto79);

$proto77["m_where"] = $obj;
$proto81=array();
$proto81["m_sql"] = "";
$proto81["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto81["m_column"]=$obj;
$proto81["m_contained"] = array();
$proto81["m_strCase"] = "";
$proto81["m_havingmode"] = false;
$proto81["m_inBrackets"] = false;
$proto81["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto81);

$proto77["m_having"] = $obj;
$proto77["m_fieldlist"] = array();
						$proto83=array();
			$obj = new SQLField(array(
	"m_strName" => "code",
	"m_strTable" => "expenditure_statement",
	"m_srcTableName" => "main ledger"
));

$proto83["m_sql"] = "`code`";
$proto83["m_srcTableName"] = "main ledger";
$proto83["m_expr"]=$obj;
$proto83["m_alias"] = "";
$obj = new SQLFieldListItem($proto83);

$proto77["m_fieldlist"][]=$obj;
						$proto85=array();
			$proto86=array();
$proto86["m_functiontype"] = "SQLF_SUM";
$proto86["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "expenditure_for_month",
	"m_strTable" => "expenditure_statement",
	"m_srcTableName" => "main ledger"
));

$proto86["m_arguments"][]=$obj;
$proto86["m_strFunctionName"] = "SUM";
$obj = new SQLFunctionCall($proto86);

$proto85["m_sql"] = "SUM(`expenditure_for_month`)";
$proto85["m_srcTableName"] = "main ledger";
$proto85["m_expr"]=$obj;
$proto85["m_alias"] = "st3";
$obj = new SQLFieldListItem($proto85);

$proto77["m_fieldlist"][]=$obj;
						$proto88=array();
			$proto89=array();
$proto89["m_functiontype"] = "SQLF_SUM";
$proto89["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "surcharge_for_month",
	"m_strTable" => "expenditure_statement",
	"m_srcTableName" => "main ledger"
));

$proto89["m_arguments"][]=$obj;
$proto89["m_strFunctionName"] = "SUM";
$obj = new SQLFunctionCall($proto89);

$proto88["m_sql"] = "SUM(`surcharge_for_month`)";
$proto88["m_srcTableName"] = "main ledger";
$proto88["m_expr"]=$obj;
$proto88["m_alias"] = "st4";
$obj = new SQLFieldListItem($proto88);

$proto77["m_fieldlist"][]=$obj;
$proto77["m_fromlist"] = array();
												$proto91=array();
$proto91["m_link"] = "SQLL_MAIN";
			$proto92=array();
$proto92["m_strName"] = "expenditure_statement";
$proto92["m_srcTableName"] = "main ledger";
$proto92["m_columns"] = array();
$proto92["m_columns"][] = "id";
$proto92["m_columns"][] = "code";
$proto92["m_columns"][] = "allocation";
$proto92["m_columns"][] = "expenditure_up_to";
$proto92["m_columns"][] = "expenditure_for_month";
$proto92["m_columns"][] = "surcharge_for_month";
$proto92["m_columns"][] = "net_expenditure";
$proto92["m_columns"][] = "balance";
$proto92["m_columns"][] = "ud";
$proto92["m_columns"][] = "user";
$proto92["m_columns"][] = "month";
$proto92["m_columns"][] = "status";
$proto92["m_columns"][] = "accounting_code";
$obj = new SQLTable($proto92);

$proto91["m_table"] = $obj;
$proto91["m_sql"] = "`expenditure_statement`";
$proto91["m_alias"] = "";
$proto91["m_srcTableName"] = "main ledger";
$proto93=array();
$proto93["m_sql"] = "";
$proto93["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

$proto93["m_column"]=$obj;
$proto93["m_contained"] = array();
$proto93["m_strCase"] = "";
$proto93["m_havingmode"] = false;
$proto93["m_inBrackets"] = false;
$proto93["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto93);

$proto91["m_joinon"] = $obj;
$obj = new SQLFromListItem($proto91);

$proto77["m_fromlist"][]=$obj;
$proto77["m_groupby"] = array();
												$proto95=array();
						$obj = new SQLField(array(
	"m_strName" => "code",
	"m_strTable" => "expenditure_statement",
	"m_srcTableName" => "main ledger"
));

$proto95["m_column"]=$obj;
$obj = new SQLGroupByItem($proto95);

$proto77["m_groupby"][]=$obj;
$proto77["m_orderby"] = array();
$proto77["m_srcTableName"]="main ledger";		
$obj = new SQLQuery($proto77);

$proto76["m_table"] = $obj;
$proto76["m_sql"] = "LEFT JOIN (SELECT  `code`,  SUM(`expenditure_for_month`) as st3 ,SUM(`surcharge_for_month`) as st4 FROM `expenditure_statement` where status='Correct' group by `code` ) as pur3 on expenditure_code.`expenditure_code` = pur3.code";
$proto76["m_alias"] = "pur3";
$proto76["m_srcTableName"] = "main ledger";
$proto97=array();
$proto97["m_sql"] = "expenditure_code.`expenditure_code` = pur3.code";
$proto97["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "expenditure_code",
	"m_strTable" => "expenditure_code",
	"m_srcTableName" => "main ledger"
));

$proto97["m_column"]=$obj;
$proto97["m_contained"] = array();
$proto97["m_strCase"] = "= pur3.code";
$proto97["m_havingmode"] = false;
$proto97["m_inBrackets"] = false;
$proto97["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto97);

$proto76["m_joinon"] = $obj;
$obj = new SQLFromListItem($proto76);

$proto0["m_fromlist"][]=$obj;
$proto0["m_groupby"] = array();
$proto0["m_orderby"] = array();
$proto0["m_srcTableName"]="main ledger";		
$obj = new SQLQuery($proto0);

	return $obj;
}
$queryData_main_ledger = createSqlQuery_main_ledger();


	
		;

									

$tdatamain_ledger[".sqlquery"] = $queryData_main_ledger;



$tableEvents["main ledger"] = new eventsBase;
$tdatamain_ledger[".hasEvents"] = false;

?>