<?php
$tdatapurchases = array();
$tdatapurchases[".searchableFields"] = array();
$tdatapurchases[".ShortName"] = "purchases";
$tdatapurchases[".OwnerID"] = "";
$tdatapurchases[".OriginalTable"] = "purchases";


$tdatapurchases[".pagesByType"] = my_json_decode( "{\"add\":[\"add\"],\"edit\":[\"edit\"],\"export\":[\"export\"],\"import\":[\"import\"],\"list\":[\"list\"],\"masterlist\":[\"masterlist\"],\"masterprint\":[\"masterprint\"],\"print\":[\"print\"],\"search\":[\"search\"],\"view\":[\"view\"]}" );
$tdatapurchases[".originalPagesByType"] = $tdatapurchases[".pagesByType"];
$tdatapurchases[".pages"] = types2pages( my_json_decode( "{\"add\":[\"add\"],\"edit\":[\"edit\"],\"export\":[\"export\"],\"import\":[\"import\"],\"list\":[\"list\"],\"masterlist\":[\"masterlist\"],\"masterprint\":[\"masterprint\"],\"print\":[\"print\"],\"search\":[\"search\"],\"view\":[\"view\"]}" ) );
$tdatapurchases[".originalPages"] = $tdatapurchases[".pages"];
$tdatapurchases[".defaultPages"] = my_json_decode( "{\"add\":\"add\",\"edit\":\"edit\",\"export\":\"export\",\"import\":\"import\",\"list\":\"list\",\"masterlist\":\"masterlist\",\"masterprint\":\"masterprint\",\"print\":\"print\",\"search\":\"search\",\"view\":\"view\"}" );
$tdatapurchases[".originalDefaultPages"] = $tdatapurchases[".defaultPages"];

//	field labels
$fieldLabelspurchases = array();
$fieldToolTipspurchases = array();
$pageTitlespurchases = array();
$placeHolderspurchases = array();

if(mlang_getcurrentlang()=="English")
{
	$fieldLabelspurchases["English"] = array();
	$fieldToolTipspurchases["English"] = array();
	$placeHolderspurchases["English"] = array();
	$pageTitlespurchases["English"] = array();
	$fieldLabelspurchases["English"]["id"] = "Id";
	$fieldToolTipspurchases["English"]["id"] = "";
	$placeHolderspurchases["English"]["id"] = "";
	$fieldLabelspurchases["English"]["purchase_date"] = "Purchase Date";
	$fieldToolTipspurchases["English"]["purchase_date"] = "";
	$placeHolderspurchases["English"]["purchase_date"] = "";
	$fieldLabelspurchases["English"]["seller"] = "Seller";
	$fieldToolTipspurchases["English"]["seller"] = "";
	$placeHolderspurchases["English"]["seller"] = "";
	$fieldLabelspurchases["English"]["transport_by"] = "Transport By";
	$fieldToolTipspurchases["English"]["transport_by"] = "";
	$placeHolderspurchases["English"]["transport_by"] = "";
	$fieldLabelspurchases["English"]["transport_cost"] = "Transport Cost";
	$fieldToolTipspurchases["English"]["transport_cost"] = "";
	$placeHolderspurchases["English"]["transport_cost"] = "";
	$fieldLabelspurchases["English"]["invoice_image"] = "Invoice Image";
	$fieldToolTipspurchases["English"]["invoice_image"] = "";
	$placeHolderspurchases["English"]["invoice_image"] = "";
	$fieldLabelspurchases["English"]["other_expenses"] = "Other Expenses";
	$fieldToolTipspurchases["English"]["other_expenses"] = "";
	$placeHolderspurchases["English"]["other_expenses"] = "";
	$fieldLabelspurchases["English"]["note"] = "Note";
	$fieldToolTipspurchases["English"]["note"] = "";
	$placeHolderspurchases["English"]["note"] = "";
	$fieldLabelspurchases["English"]["total_handling_cost"] = "total handling cost";
	$fieldToolTipspurchases["English"]["total_handling_cost"] = "";
	$placeHolderspurchases["English"]["total_handling_cost"] = "";
	$fieldLabelspurchases["English"]["handling_cost_per_unit"] = "handling cost per unit";
	$fieldToolTipspurchases["English"]["handling_cost_per_unit"] = "";
	$placeHolderspurchases["English"]["handling_cost_per_unit"] = "";
	$fieldLabelspurchases["English"]["total_cost"] = "Total Cost";
	$fieldToolTipspurchases["English"]["total_cost"] = "";
	$placeHolderspurchases["English"]["total_cost"] = "";
	if (count($fieldToolTipspurchases["English"]))
		$tdatapurchases[".isUseToolTips"] = true;
}


	$tdatapurchases[".NCSearch"] = true;



$tdatapurchases[".shortTableName"] = "purchases";
$tdatapurchases[".nSecOptions"] = 0;

$tdatapurchases[".mainTableOwnerID"] = "";
$tdatapurchases[".entityType"] = 0;
$tdatapurchases[".connId"] = "new_lakmini_at_localhost";


$tdatapurchases[".strOriginalTableName"] = "purchases";

	



$tdatapurchases[".showAddInPopup"] = false;

$tdatapurchases[".showEditInPopup"] = false;

$tdatapurchases[".showViewInPopup"] = false;

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


$tdatapurchases[".listAjax"] = false;
//	temporary
$tdatapurchases[".listAjax"] = false;

	$tdatapurchases[".audit"] = false;

	$tdatapurchases[".locking"] = false;


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

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

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

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



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




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

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

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

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



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

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

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

$tdatapurchases[".isUseAjaxSuggest"] = true;

$tdatapurchases[".rowHighlite"] = true;



			

$tdatapurchases[".ajaxCodeSnippetAdded"] = false;

$tdatapurchases[".buttonsAdded"] = false;

$tdatapurchases[".addPageEvents"] = false;

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


$tdatapurchases[".badgeColor"] = "B22222";


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

$tdatapurchases[".googleLikeFields"] = array();
$tdatapurchases[".googleLikeFields"][] = "id";
$tdatapurchases[".googleLikeFields"][] = "purchase_date";
$tdatapurchases[".googleLikeFields"][] = "seller";
$tdatapurchases[".googleLikeFields"][] = "transport_by";
$tdatapurchases[".googleLikeFields"][] = "transport_cost";
$tdatapurchases[".googleLikeFields"][] = "invoice_image";
$tdatapurchases[".googleLikeFields"][] = "other_expenses";
$tdatapurchases[".googleLikeFields"][] = "note";
$tdatapurchases[".googleLikeFields"][] = "total handling cost";
$tdatapurchases[".googleLikeFields"][] = "handling cost per unit";
$tdatapurchases[".googleLikeFields"][] = "total_cost";



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

$tdatapurchases[".printerPageOrientation"] = 0;
$tdatapurchases[".nPrinterPageScale"] = 100;

$tdatapurchases[".nPrinterSplitRecords"] = 40;

$tdatapurchases[".geocodingEnabled"] = false;










$tdatapurchases[".pageSize"] = 20;

$tdatapurchases[".warnLeavingPages"] = true;



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

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


$tdatapurchases[".sqlHead"] = "SELECT purchases.id,  purchases.purchase_date,  purchases.seller,  purchases.transport_by,  purchases.transport_cost,  purchases.invoice_image,  purchases.other_expenses,  purchases.note,  purchases.total_cost + purchases.transport_cost AS `total handling cost`,  ( purchases.total_cost + purchases.transport_cost)/ SUM(pd.quantity) AS `handling cost per unit`,  SUM(pd.quantity * pd.unit_price)+ (purchases.total_cost + purchases.transport_cost) AS total_cost";
$tdatapurchases[".sqlFrom"] = "FROM purchases  LEFT OUTER JOIN purchase_details AS pd ON purchases.id = pd.purchase_id";
$tdatapurchases[".sqlWhereExpr"] = "";
$tdatapurchases[".sqlTail"] = "";










//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;
$tdatapurchases[".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;
$tdatapurchases[".arrGroupsPerPage"] = $arrGPP;

$tdatapurchases[".highlightSearchResults"] = true;

$tableKeyspurchases = array();
$tableKeyspurchases[] = "id";
$tdatapurchases[".Keys"] = $tableKeyspurchases;


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




//	id
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 1;
	$fdata["strName"] = "id";
	$fdata["GoodName"] = "id";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","id");
	$fdata["FieldType"] = 3;

	
		$fdata["AutoInc"] = true;

	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.id";

	
	
				$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["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


	$tdatapurchases["id"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "id";
//	purchase_date
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 2;
	$fdata["strName"] = "purchase_date";
	$fdata["GoodName"] = "purchase_date";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","purchase_date");
	$fdata["FieldType"] = 135;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.purchase_date";

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

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

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

	
	
	
	
	
	
	
	
	
	
	
		
	
		$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" => "Date");

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


	
	



		$edata["IsRequired"] = true;

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

		$edata["maxNumberOfFiles"] = 1;

	
	
		$edata["DateEditType"] = 13;
	$edata["InitialYearFactor"] = 100;
	$edata["LastYearFactor"] = 10;

	
	
	
		$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("Equals", "More than", "Less than", "Between", EMPTY_SEARCH, 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


	$tdatapurchases["purchase_date"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "purchase_date";
//	seller
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 3;
	$fdata["strName"] = "seller";
	$fdata["GoodName"] = "seller";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","seller");
	$fdata["FieldType"] = 200;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.seller";

	
	
				$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"] = "supplier";
			$edata["autoCompleteFieldsOnEdit"] = 0;
	$edata["autoCompleteFields"] = array();
		$edata["LCType"] = 1;

	
		
	$edata["LinkField"] = "id";
	$edata["LinkFieldType"] = 0;
	$edata["DisplayField"] = "supplier_name";

	

	
	$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"] = "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


	$tdatapurchases["seller"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "seller";
//	transport_by
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 4;
	$fdata["strName"] = "transport_by";
	$fdata["GoodName"] = "transport_by";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","transport_by");
	$fdata["FieldType"] = 200;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.transport_by";

	
	
				$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"] = "purchases";
			$edata["freeInput"] = true;
	$edata["autoCompleteFieldsOnEdit"] = 0;
	$edata["autoCompleteFields"] = array();
		$edata["LCType"] = 1;

	
			$edata["LookupUnique"] = true;

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

	

	
	$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"] = "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


	$tdatapurchases["transport_by"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "transport_by";
//	transport_cost
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 5;
	$fdata["strName"] = "transport_cost";
	$fdata["GoodName"] = "transport_cost";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","transport_cost");
	$fdata["FieldType"] = 14;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.transport_cost";

	
	
				$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"] = "number";

		$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


	$tdatapurchases["transport_cost"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "transport_cost";
//	invoice_image
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 6;
	$fdata["strName"] = "invoice_image";
	$fdata["GoodName"] = "invoice_image";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","invoice_image");
	$fdata["FieldType"] = 200;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.invoice_image";

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

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

	$vdata = array("ViewFormat" => "File-based Image");

	
	
				$vdata["ImageWidth"] = 100;
	$vdata["ImageHeight"] = 100;

			$vdata["multipleImgMode"] = 3;
	$vdata["maxImages"] = 2;

			$vdata["showGallery"] = true;
	$vdata["galleryMode"] = 2;
	$vdata["captionMode"] = 3;
	$vdata["captionField"] = "product_name";

	$vdata["imageBorder"] = 0;
	$vdata["imageFullWidth"] = 0;


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

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

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

	$edata = array("EditFormat" => "Document upload");

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


	
	



	
	
	
	
			$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

		$edata["CreateThumbnail"] = true;
	$edata["StrThumbnail"] = "th";
			$edata["ThumbnailSize"] = 75;

				$edata["ResizeImage"] = true;
				$edata["NewSize"] = 600;

	
	
	
	$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


	$tdatapurchases["invoice_image"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "invoice_image";
//	other_expenses
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 7;
	$fdata["strName"] = "other_expenses";
	$fdata["GoodName"] = "other_expenses";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","other_expenses");
	$fdata["FieldType"] = 14;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.other_expenses";

	
	
				$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"] = "number";

		$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


	$tdatapurchases["other_expenses"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "other_expenses";
//	note
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 8;
	$fdata["strName"] = "note";
	$fdata["GoodName"] = "note";
	$fdata["ownerTable"] = "purchases";
	$fdata["Label"] = GetFieldLabel("purchases","note");
	$fdata["FieldType"] = 200;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.note";

	
	
				$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["EditParams"].= " maxlength=300";

		$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


	$tdatapurchases["note"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "note";
//	total handling cost
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 9;
	$fdata["strName"] = "total handling cost";
	$fdata["GoodName"] = "total_handling_cost";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("purchases","total_handling_cost");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "total handling cost";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "purchases.total_cost + purchases.transport_cost";

	
	
				$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


	$tdatapurchases["total handling cost"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "total handling cost";
//	handling cost per unit
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 10;
	$fdata["strName"] = "handling cost per unit";
	$fdata["GoodName"] = "handling_cost_per_unit";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("purchases","handling_cost_per_unit");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "handling cost per unit";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "( purchases.total_cost + purchases.transport_cost)/ SUM(pd.quantity)";

	
	
				$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


	$tdatapurchases["handling cost per unit"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "handling cost per unit";
//	total_cost
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 11;
	$fdata["strName"] = "total_cost";
	$fdata["GoodName"] = "total_cost";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("purchases","total_cost");
	$fdata["FieldType"] = 14;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "SUM(pd.quantity * pd.unit_price)+ (purchases.total_cost + purchases.transport_cost)";

	
	
				$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["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");
							
	
	//	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


	$tdatapurchases["total_cost"] = $fdata;
		$tdatapurchases[".searchableFields"][] = "total_cost";


$tables_data["purchases"]=&$tdatapurchases;
$field_labels["purchases"] = &$fieldLabelspurchases;
$fieldToolTips["purchases"] = &$fieldToolTipspurchases;
$placeHolders["purchases"] = &$placeHolderspurchases;
$page_titles["purchases"] = &$pageTitlespurchases;

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

		$dIndex = 0;
	$detailsParam = array();
	$detailsParam["dDataSourceTable"]="purchase_details";
		$detailsParam["dOriginalTable"] = "purchase_details";



		
		$detailsParam["dType"]=PAGE_LIST;
	$detailsParam["dShortTable"] = "purchase_details";
	$detailsParam["dCaptionTable"] = GetTableCaption("purchase_details");
	$detailsParam["masterKeys"] =array();
	$detailsParam["detailKeys"] =array();


		
	$detailsTablesData["purchases"][$dIndex] = $detailsParam;

	
		$detailsTablesData["purchases"][$dIndex]["masterKeys"] = array();

	$detailsTablesData["purchases"][$dIndex]["masterKeys"][]="id";

				$detailsTablesData["purchases"][$dIndex]["detailKeys"] = array();

	$detailsTablesData["purchases"][$dIndex]["detailKeys"][]="purchase_id";

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



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



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











function createSqlQuery_purchases()
{
$proto0=array();
$proto0["m_strHead"] = "SELECT";
$proto0["m_strFieldList"] = "purchases.id,  purchases.purchase_date,  purchases.seller,  purchases.transport_by,  purchases.transport_cost,  purchases.invoice_image,  purchases.other_expenses,  purchases.note,  purchases.total_cost + purchases.transport_cost AS `total handling cost`,  ( purchases.total_cost + purchases.transport_cost)/ SUM(pd.quantity) AS `handling cost per unit`,  SUM(pd.quantity * pd.unit_price)+ (purchases.total_cost + purchases.transport_cost) AS total_cost";
$proto0["m_strFrom"] = "FROM purchases  LEFT OUTER JOIN purchase_details AS pd ON purchases.id = pd.purchase_id";
$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" => "id",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto6["m_sql"] = "purchases.id";
$proto6["m_srcTableName"] = "purchases";
$proto6["m_expr"]=$obj;
$proto6["m_alias"] = "";
$obj = new SQLFieldListItem($proto6);

$proto0["m_fieldlist"][]=$obj;
						$proto8=array();
			$obj = new SQLField(array(
	"m_strName" => "purchase_date",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto8["m_sql"] = "purchases.purchase_date";
$proto8["m_srcTableName"] = "purchases";
$proto8["m_expr"]=$obj;
$proto8["m_alias"] = "";
$obj = new SQLFieldListItem($proto8);

$proto0["m_fieldlist"][]=$obj;
						$proto10=array();
			$obj = new SQLField(array(
	"m_strName" => "seller",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto10["m_sql"] = "purchases.seller";
$proto10["m_srcTableName"] = "purchases";
$proto10["m_expr"]=$obj;
$proto10["m_alias"] = "";
$obj = new SQLFieldListItem($proto10);

$proto0["m_fieldlist"][]=$obj;
						$proto12=array();
			$obj = new SQLField(array(
	"m_strName" => "transport_by",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto12["m_sql"] = "purchases.transport_by";
$proto12["m_srcTableName"] = "purchases";
$proto12["m_expr"]=$obj;
$proto12["m_alias"] = "";
$obj = new SQLFieldListItem($proto12);

$proto0["m_fieldlist"][]=$obj;
						$proto14=array();
			$obj = new SQLField(array(
	"m_strName" => "transport_cost",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto14["m_sql"] = "purchases.transport_cost";
$proto14["m_srcTableName"] = "purchases";
$proto14["m_expr"]=$obj;
$proto14["m_alias"] = "";
$obj = new SQLFieldListItem($proto14);

$proto0["m_fieldlist"][]=$obj;
						$proto16=array();
			$obj = new SQLField(array(
	"m_strName" => "invoice_image",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto16["m_sql"] = "purchases.invoice_image";
$proto16["m_srcTableName"] = "purchases";
$proto16["m_expr"]=$obj;
$proto16["m_alias"] = "";
$obj = new SQLFieldListItem($proto16);

$proto0["m_fieldlist"][]=$obj;
						$proto18=array();
			$obj = new SQLField(array(
	"m_strName" => "other_expenses",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto18["m_sql"] = "purchases.other_expenses";
$proto18["m_srcTableName"] = "purchases";
$proto18["m_expr"]=$obj;
$proto18["m_alias"] = "";
$obj = new SQLFieldListItem($proto18);

$proto0["m_fieldlist"][]=$obj;
						$proto20=array();
			$obj = new SQLField(array(
	"m_strName" => "note",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto20["m_sql"] = "purchases.note";
$proto20["m_srcTableName"] = "purchases";
$proto20["m_expr"]=$obj;
$proto20["m_alias"] = "";
$obj = new SQLFieldListItem($proto20);

$proto0["m_fieldlist"][]=$obj;
						$proto22=array();
			$obj = new SQLNonParsed(array(
	"m_sql" => "purchases.total_cost + purchases.transport_cost"
));

$proto22["m_sql"] = "purchases.total_cost + purchases.transport_cost";
$proto22["m_srcTableName"] = "purchases";
$proto22["m_expr"]=$obj;
$proto22["m_alias"] = "total handling cost";
$obj = new SQLFieldListItem($proto22);

$proto0["m_fieldlist"][]=$obj;
						$proto24=array();
			$obj = new SQLNonParsed(array(
	"m_sql" => "( purchases.total_cost + purchases.transport_cost)/ SUM(pd.quantity)"
));

$proto24["m_sql"] = "( purchases.total_cost + purchases.transport_cost)/ SUM(pd.quantity)";
$proto24["m_srcTableName"] = "purchases";
$proto24["m_expr"]=$obj;
$proto24["m_alias"] = "handling cost per unit";
$obj = new SQLFieldListItem($proto24);

$proto0["m_fieldlist"][]=$obj;
						$proto26=array();
			$obj = new SQLNonParsed(array(
	"m_sql" => "SUM(pd.quantity * pd.unit_price)+ (purchases.total_cost + purchases.transport_cost)"
));

$proto26["m_sql"] = "SUM(pd.quantity * pd.unit_price)+ (purchases.total_cost + purchases.transport_cost)";
$proto26["m_srcTableName"] = "purchases";
$proto26["m_expr"]=$obj;
$proto26["m_alias"] = "total_cost";
$obj = new SQLFieldListItem($proto26);

$proto0["m_fieldlist"][]=$obj;
$proto0["m_fromlist"] = array();
												$proto28=array();
$proto28["m_link"] = "SQLL_MAIN";
			$proto29=array();
$proto29["m_strName"] = "purchases";
$proto29["m_srcTableName"] = "purchases";
$proto29["m_columns"] = array();
$proto29["m_columns"][] = "id";
$proto29["m_columns"][] = "purchase_date";
$proto29["m_columns"][] = "seller";
$proto29["m_columns"][] = "transport_by";
$proto29["m_columns"][] = "transport_cost";
$proto29["m_columns"][] = "invoice_image";
$proto29["m_columns"][] = "other_expenses";
$proto29["m_columns"][] = "total_cost";
$proto29["m_columns"][] = "tbid";
$proto29["m_columns"][] = "note";
$obj = new SQLTable($proto29);

$proto28["m_table"] = $obj;
$proto28["m_sql"] = "purchases";
$proto28["m_alias"] = "";
$proto28["m_srcTableName"] = "purchases";
$proto30=array();
$proto30["m_sql"] = "";
$proto30["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

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

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

$proto0["m_fromlist"][]=$obj;
												$proto32=array();
$proto32["m_link"] = "SQLL_LEFTJOIN";
			$proto33=array();
$proto33["m_strName"] = "purchase_details";
$proto33["m_srcTableName"] = "purchases";
$proto33["m_columns"] = array();
$proto33["m_columns"][] = "id";
$proto33["m_columns"][] = "purchase_id";
$proto33["m_columns"][] = "product_code";
$proto33["m_columns"][] = "purchase_date";
$proto33["m_columns"][] = "product_type";
$proto33["m_columns"][] = "quantity";
$proto33["m_columns"][] = "unit_price";
$proto33["m_columns"][] = "tbid";
$obj = new SQLTable($proto33);

$proto32["m_table"] = $obj;
$proto32["m_sql"] = "LEFT OUTER JOIN purchase_details AS pd ON purchases.id = pd.purchase_id";
$proto32["m_alias"] = "pd";
$proto32["m_srcTableName"] = "purchases";
$proto34=array();
$proto34["m_sql"] = "purchases.id = pd.purchase_id";
$proto34["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "id",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

$proto34["m_column"]=$obj;
$proto34["m_contained"] = array();
$proto34["m_strCase"] = "= pd.purchase_id";
$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;
$proto0["m_groupby"] = array();
												$proto36=array();
						$obj = new SQLField(array(
	"m_strName" => "id",
	"m_strTable" => "purchases",
	"m_srcTableName" => "purchases"
));

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

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

	return $obj;
}
$queryData_purchases = createSqlQuery_purchases();


	
		;

											

$tdatapurchases[".sqlquery"] = $queryData_purchases;



$tableEvents["purchases"] = new eventsBase;
$tdatapurchases[".hasEvents"] = false;

?>