<?php
$tdatasales_history = array();
$tdatasales_history[".searchableFields"] = array();
$tdatasales_history[".ShortName"] = "sales_history";
$tdatasales_history[".OwnerID"] = "";
$tdatasales_history[".OriginalTable"] = "sales";


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

//	field labels
$fieldLabelssales_history = array();
$fieldToolTipssales_history = array();
$pageTitlessales_history = array();
$placeHolderssales_history = array();

if(mlang_getcurrentlang()=="English")
{
	$fieldLabelssales_history["English"] = array();
	$fieldToolTipssales_history["English"] = array();
	$placeHolderssales_history["English"] = array();
	$pageTitlessales_history["English"] = array();
	$fieldLabelssales_history["English"]["id"] = "Id";
	$fieldToolTipssales_history["English"]["id"] = "";
	$placeHolderssales_history["English"]["id"] = "";
	$fieldLabelssales_history["English"]["customer_name"] = "Customer Name";
	$fieldToolTipssales_history["English"]["customer_name"] = "";
	$placeHolderssales_history["English"]["customer_name"] = "";
	$fieldLabelssales_history["English"]["date___time"] = "Date & Time";
	$fieldToolTipssales_history["English"]["date___time"] = "";
	$placeHolderssales_history["English"]["date___time"] = "";
	$fieldLabelssales_history["English"]["user"] = "User";
	$fieldToolTipssales_history["English"]["user"] = "";
	$placeHolderssales_history["English"]["user"] = "";
	$fieldLabelssales_history["English"]["total_amount"] = "Total Amount";
	$fieldToolTipssales_history["English"]["total_amount"] = "";
	$placeHolderssales_history["English"]["total_amount"] = "";
	$fieldLabelssales_history["English"]["difect"] = "Difect";
	$fieldToolTipssales_history["English"]["difect"] = "";
	$placeHolderssales_history["English"]["difect"] = "";
	$fieldLabelssales_history["English"]["paid"] = "Paid";
	$fieldToolTipssales_history["English"]["paid"] = "";
	$placeHolderssales_history["English"]["paid"] = "";
	$fieldLabelssales_history["English"]["tt"] = "";
	$fieldToolTipssales_history["English"]["tt"] = "";
	$placeHolderssales_history["English"]["tt"] = "";
	$fieldLabelssales_history["English"]["advance_id"] = "Advance Id";
	$fieldToolTipssales_history["English"]["advance_id"] = "";
	$placeHolderssales_history["English"]["advance_id"] = "";
	$fieldLabelssales_history["English"]["amount"] = "Amount";
	$fieldToolTipssales_history["English"]["amount"] = "";
	$placeHolderssales_history["English"]["amount"] = "";
	$fieldLabelssales_history["English"]["customer_id"] = "Customer Id";
	$fieldToolTipssales_history["English"]["customer_id"] = "";
	$placeHolderssales_history["English"]["customer_id"] = "";
	if (count($fieldToolTipssales_history["English"]))
		$tdatasales_history[".isUseToolTips"] = true;
}


	$tdatasales_history[".NCSearch"] = true;



$tdatasales_history[".shortTableName"] = "sales_history";
$tdatasales_history[".nSecOptions"] = 0;

$tdatasales_history[".mainTableOwnerID"] = "";
$tdatasales_history[".entityType"] = 1;
$tdatasales_history[".connId"] = "test2_at_localhost";


$tdatasales_history[".strOriginalTableName"] = "sales";

	



$tdatasales_history[".showAddInPopup"] = false;

$tdatasales_history[".showEditInPopup"] = false;

$tdatasales_history[".showViewInPopup"] = false;

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


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

	$tdatasales_history[".audit"] = true;

	$tdatasales_history[".locking"] = false;


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

if( $pages[PAGE_EDIT] ) {
	$tdatasales_history[".edit"] = true;
	$tdatasales_history[".afterEditAction"] = 2;
	$tdatasales_history[".closePopupAfterEdit"] = 0;
	$tdatasales_history[".afterEditActionDetTable"] = "table5";
}

if( $pages[PAGE_ADD] ) {
$tdatasales_history[".add"] = true;
$tdatasales_history[".afterAddAction"] = 2;
$tdatasales_history[".closePopupAfterAdd"] = 0;
$tdatasales_history[".afterAddActionDetTable"] = "payments";
}

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



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




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

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

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

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



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

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

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

$tdatasales_history[".isUseAjaxSuggest"] = true;

$tdatasales_history[".rowHighlite"] = true;



																																																																																																						

$tdatasales_history[".ajaxCodeSnippetAdded"] = false;

$tdatasales_history[".buttonsAdded"] = false;

$tdatasales_history[".addPageEvents"] = true;

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


$tdatasales_history[".badgeColor"] = "d2af80";


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

$tdatasales_history[".googleLikeFields"] = array();
$tdatasales_history[".googleLikeFields"][] = "id";
$tdatasales_history[".googleLikeFields"][] = "customer_name";
$tdatasales_history[".googleLikeFields"][] = "date_&_time";
$tdatasales_history[".googleLikeFields"][] = "user";
$tdatasales_history[".googleLikeFields"][] = "tt";
$tdatasales_history[".googleLikeFields"][] = "advance_id";
$tdatasales_history[".googleLikeFields"][] = "amount";
$tdatasales_history[".googleLikeFields"][] = "customer_id";
$tdatasales_history[".googleLikeFields"][] = "paid";
$tdatasales_history[".googleLikeFields"][] = "total amount";
$tdatasales_history[".googleLikeFields"][] = "difect";



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

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

$tdatasales_history[".nPrinterSplitRecords"] = 40;

$tdatasales_history[".geocodingEnabled"] = false;










$tdatasales_history[".pageSize"] = 20;

$tdatasales_history[".warnLeavingPages"] = true;



$tstrOrderBy = "ORDER BY `sales`.`id`  DESC";
if(strlen($tstrOrderBy) && strtolower(substr($tstrOrderBy,0,8))!="order by")
	$tstrOrderBy = "order by ".$tstrOrderBy;
$tdatasales_history[".strOrderBy"] = $tstrOrderBy;

$tdatasales_history[".orderindexes"] = array();
	$tdatasales_history[".orderindexes"][] = array(1, (0 ? "ASC" : "DESC"), "sales.id");



$tdatasales_history[".sqlHead"] = "SELECT sales.id,  sales.customer_name,  sales.`date_&_time`,  sales.`user`,tt,  `advance_id`,`amount`,customer_id,  ifnull(purch.pur,0)as \"paid\" ,  ifnull(sold.sol,0) AS \"total amount\",  ifnull(case when (ifnull(sold.sol,0)> ifnull(purch.pur,0)) then  ((ifnull(sold.sol,0)) - (ifnull(purch.pur,0))-(ifnull(`amount`,0)) )end,0) as \"difect\"";
$tdatasales_history[".sqlFrom"] = "FROM sales  LEFT JOIN (select `m_id`,sum(`sub_total`) as sol from sales_details where 1 group by `m_id` ) as sold on sales.`id` = sold.`m_id`  left join (SELECT `sales_id`,SUM(`amount`) as pur from payments group by `sales_id`) as purch on sales.id = purch.sales_id  LEFT OUTER JOIN sys_manage ON sales.`user` = sys_manage.username  INNER JOIN company_profile ON sys_manage.outlet_code = company_profile.id";
$tdatasales_history[".sqlWhereExpr"] = "";
$tdatasales_history[".sqlTail"] = "";

//fill array of tabs for list page
$arrGridTabs = array();
$arrGridTabs[] = array(
	'tabId' => "",
	'name' => "All data",
	'nameType' => 'Text',
	'where' => "",
	'showRowCount' => 0,
	'hideEmpty' => 0,
);
$tdatasales_history[".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;
$tdatasales_history[".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;
$tdatasales_history[".arrGroupsPerPage"] = $arrGPP;

$tdatasales_history[".highlightSearchResults"] = true;

$tableKeyssales_history = array();
$tableKeyssales_history[] = "id";
$tdatasales_history[".Keys"] = $tableKeyssales_history;


$tdatasales_history[".hideMobileList"] = array();
		$tdatasales_history[".hideMobileList"][1] = array();
$tdatasales_history[".hideMobileList"][1]["user"] = true;
		$tdatasales_history[".hideMobileList"][1]["amount"] = true;
		$tdatasales_history[".hideMobileList"][5] = array();
$tdatasales_history[".hideMobileList"][5]["user"] = true;
		$tdatasales_history[".hideMobileList"][5]["amount"] = true;




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

	
		$fdata["AutoInc"] = true;

	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "sales.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


	$tdatasales_history["id"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "id";
//	customer_name
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 2;
	$fdata["strName"] = "customer_name";
	$fdata["GoodName"] = "customer_name";
	$fdata["ownerTable"] = "sales";
	$fdata["Label"] = GetFieldLabel("sales_history","customer_name");
	$fdata["FieldType"] = 200;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "sales.customer_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;
	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

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

	$fdata["ViewFormats"]["list"] = $vdata;
	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

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

	$fdata["ViewFormats"]["print"] = $vdata;
	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

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

	$fdata["ViewFormats"]["export"] = $vdata;
	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

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

	$fdata["ViewFormats"]["masterlist"] = $vdata;
	$vdata = array("ViewFormat" => "");

	
	
	
	
	
	
	
	
	
	
	
		
	
		$vdata["NeedEncode"] = true;

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

	$fdata["ViewFormats"]["masterprint"] = $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"] = "buyers1advance";
			$edata["autoCompleteFieldsOnEdit"] = 1;
	$edata["autoCompleteFields"] = array();
		$edata["autoCompleteFields"][] = array('masterF'=>"advance_id", 'lookupF'=>"advance_id");
	$edata["autoCompleteFields"][] = array('masterF'=>"amount", 'lookupF'=>"left");
	$edata["autoCompleteFields"][] = array('masterF'=>"left_advance", 'lookupF'=>"left");
	$edata["autoCompleteFields"][] = array('masterF'=>"details", 'lookupF'=>"details");
	$edata["autoCompleteFields"][] = array('masterF'=>"customer_id", 'lookupF'=>"id");
	$edata["LCType"] = 1;

	
		
	$edata["LinkField"] = "unic_id";
	$edata["LinkFieldType"] = 0;
	$edata["DisplayField"] = "buyers_name";

	

	
	$edata["LookupOrderBy"] = "buyer_name";

	
	
	
	

	
	
	
// 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;
	$edata = array("EditFormat" => "Lookup wizard");

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


	
	

// Begin Lookup settings
				$edata["LookupType"] = 2;
	$edata["LookupTable"] = "buyers1advance";
			$edata["autoCompleteFieldsOnEdit"] = 1;
	$edata["autoCompleteFields"] = array();
		$edata["autoCompleteFields"][] = array('masterF'=>"advance_id", 'lookupF'=>"advance_id");
	$edata["autoCompleteFields"][] = array('masterF'=>"amount", 'lookupF'=>"left");
	$edata["autoCompleteFields"][] = array('masterF'=>"left_advance", 'lookupF'=>"left");
	$edata["autoCompleteFields"][] = array('masterF'=>"details", 'lookupF'=>"details");
	$edata["autoCompleteFields"][] = array('masterF'=>"customer_id", 'lookupF'=>"id");
	$edata["LCType"] = 1;

	
		
	$edata["LinkField"] = "unic_id";
	$edata["LinkFieldType"] = 0;
	$edata["DisplayField"] = "buyers_name";

	

	
	$edata["LookupOrderBy"] = "buyer_name";

	
	
	
	

	
	
	
// 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"]["add"] = $edata;
	$edata = array("EditFormat" => "Lookup wizard");

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


	
	

// Begin Lookup settings
				$edata["LookupType"] = 2;
	$edata["LookupTable"] = "buyers1advance";
			$edata["autoCompleteFieldsOnEdit"] = 1;
	$edata["autoCompleteFields"] = array();
		$edata["LCType"] = 1;

	
		
	$edata["LinkField"] = "unic_id";
	$edata["LinkFieldType"] = 0;
	$edata["DisplayField"] = "buyer_name";

	

	
	$edata["LookupOrderBy"] = "buyer_name";

	
	
	
	

	
	
	
// 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"]["search"] = $edata;
//	End Edit Formats


	$fdata["isSeparate"] = true;




// 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


	$tdatasales_history["customer_name"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "customer_name";
//	date_&_time
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 3;
	$fdata["strName"] = "date_&_time";
	$fdata["GoodName"] = "date___time";
	$fdata["ownerTable"] = "sales";
	$fdata["Label"] = GetFieldLabel("sales_history","date___time");
	$fdata["FieldType"] = 135;

	
	
	
			

		$fdata["strField"] = "date_&_time";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "sales.`date_&_time`";

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

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

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

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

	
		$edata["weekdayMessage"] = array("message" => "Invalid week day", "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();
	
		$edata["autoUpdatable"] = true;

	//	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["filterTotalFields"] = "id";
		$fdata["filterFormat"] = "Interval slider";
		$fdata["showCollapsed"] = false;

	
	
	
	

	$fdata["filterKnobsType"] = 0;
		$fdata["filterSliderStepType"] = 3;
	$fdata["filterSliderStepValue"] = 1;
//end of Filters settings


	$tdatasales_history["date_&_time"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "date_&_time";
//	user
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 4;
	$fdata["strName"] = "user";
	$fdata["GoodName"] = "user";
	$fdata["ownerTable"] = "sales";
	$fdata["Label"] = GetFieldLabel("sales_history","user");
	$fdata["FieldType"] = 200;

	
	
	
			

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

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

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

	
		$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();
	
		$edata["autoUpdatable"] = true;

	//	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


	$tdatasales_history["user"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "user";
//	tt
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 5;
	$fdata["strName"] = "tt";
	$fdata["GoodName"] = "tt";
	$fdata["ownerTable"] = "sales";
	$fdata["Label"] = GetFieldLabel("sales_history","tt");
	$fdata["FieldType"] = 14;

	
	
	
			

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

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

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

		$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


	$tdatasales_history["tt"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "tt";
//	advance_id
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 6;
	$fdata["strName"] = "advance_id";
	$fdata["GoodName"] = "advance_id";
	$fdata["ownerTable"] = "sales";
	$fdata["Label"] = GetFieldLabel("sales_history","advance_id");
	$fdata["FieldType"] = 14;

	
	
	
			

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

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

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

	
		$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

	
			
	
	
	
	$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


	$tdatasales_history["advance_id"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "advance_id";
//	amount
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 7;
	$fdata["strName"] = "amount";
	$fdata["GoodName"] = "amount";
	$fdata["ownerTable"] = "sales";
	$fdata["Label"] = GetFieldLabel("sales_history","amount");
	$fdata["FieldType"] = 14;

	
	
	
			

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

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

	
	
				$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


	$tdatasales_history["amount"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "amount";
//	customer_id
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 8;
	$fdata["strName"] = "customer_id";
	$fdata["GoodName"] = "customer_id";
	$fdata["ownerTable"] = "sales";
	$fdata["Label"] = GetFieldLabel("sales_history","customer_id");
	$fdata["FieldType"] = 3;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "customer_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" => "Readonly");

	
		$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

	
			
	
	
	
	$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


	$tdatasales_history["customer_id"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "customer_id";
//	paid
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 9;
	$fdata["strName"] = "paid";
	$fdata["GoodName"] = "paid";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("sales_history","paid");
	$fdata["FieldType"] = 14;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(purch.pur,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


	$tdatasales_history["paid"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "paid";
//	total amount
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 10;
	$fdata["strName"] = "total amount";
	$fdata["GoodName"] = "total_amount";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("sales_history","total_amount");
	$fdata["FieldType"] = 14;

	
	
	
			

		$fdata["strField"] = "total amount";

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(sold.sol,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


	$tdatasales_history["total amount"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "total amount";
//	difect
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 11;
	$fdata["strName"] = "difect";
	$fdata["GoodName"] = "difect";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("sales_history","difect");
	$fdata["FieldType"] = 14;

	
	
	
			

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

	
		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "ifnull(case when (ifnull(sold.sol,0)> ifnull(purch.pur,0)) then  ((ifnull(sold.sol,0)) - (ifnull(purch.pur,0))-(ifnull(`amount`,0)) )end,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


	$tdatasales_history["difect"] = $fdata;
		$tdatasales_history[".searchableFields"][] = "difect";


$tables_data["sales_history"]=&$tdatasales_history;
$field_labels["sales_history"] = &$fieldLabelssales_history;
$fieldToolTips["sales_history"] = &$fieldToolTipssales_history;
$placeHolders["sales_history"] = &$placeHolderssales_history;
$page_titles["sales_history"] = &$pageTitlessales_history;

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

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



	
				$strOriginalDetailsTable="buyers";
	$masterParams = array();
	$masterParams["mDataSourceTable"]="buyers";
	$masterParams["mOriginalTable"]= $strOriginalDetailsTable;
	$masterParams["mShortTable"]= "buyers";
	$masterParams["masterKeys"]= array();
	$masterParams["detailKeys"]= array();

	$masterParams["type"] = PAGE_LIST;
					$masterTablesData["sales_history"][0] = $masterParams;
				$masterTablesData["sales_history"][0]["masterKeys"] = array();
	$masterTablesData["sales_history"][0]["masterKeys"][]="id";
				$masterTablesData["sales_history"][0]["detailKeys"] = array();
	$masterTablesData["sales_history"][0]["detailKeys"][]="customer_id";
		
// -----------------end  prepare master-details data arrays ------------------------------//



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











function createSqlQuery_sales_history()
{
$proto0=array();
$proto0["m_strHead"] = "SELECT";
$proto0["m_strFieldList"] = "sales.id,  sales.customer_name,  sales.`date_&_time`,  sales.`user`,tt,  `advance_id`,`amount`,customer_id,  ifnull(purch.pur,0)as \"paid\" ,  ifnull(sold.sol,0) AS \"total amount\",  ifnull(case when (ifnull(sold.sol,0)> ifnull(purch.pur,0)) then  ((ifnull(sold.sol,0)) - (ifnull(purch.pur,0))-(ifnull(`amount`,0)) )end,0) as \"difect\"";
$proto0["m_strFrom"] = "FROM sales  LEFT JOIN (select `m_id`,sum(`sub_total`) as sol from sales_details where 1 group by `m_id` ) as sold on sales.`id` = sold.`m_id`  left join (SELECT `sales_id`,SUM(`amount`) as pur from payments group by `sales_id`) as purch on sales.id = purch.sales_id  LEFT OUTER JOIN sys_manage ON sales.`user` = sys_manage.username  INNER JOIN company_profile ON sys_manage.outlet_code = company_profile.id";
$proto0["m_strWhere"] = "";
$proto0["m_strOrderBy"] = "ORDER BY `sales`.`id`  DESC";
	
		;
			$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" => "sales",
	"m_srcTableName" => "sales_history"
));

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

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

$proto8["m_sql"] = "sales.customer_name";
$proto8["m_srcTableName"] = "sales_history";
$proto8["m_expr"]=$obj;
$proto8["m_alias"] = "";
$obj = new SQLFieldListItem($proto8);

$proto0["m_fieldlist"][]=$obj;
						$proto10=array();
			$obj = new SQLField(array(
	"m_strName" => "date_&_time",
	"m_strTable" => "sales",
	"m_srcTableName" => "sales_history"
));

$proto10["m_sql"] = "sales.`date_&_time`";
$proto10["m_srcTableName"] = "sales_history";
$proto10["m_expr"]=$obj;
$proto10["m_alias"] = "";
$obj = new SQLFieldListItem($proto10);

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

$proto12["m_sql"] = "sales.`user`";
$proto12["m_srcTableName"] = "sales_history";
$proto12["m_expr"]=$obj;
$proto12["m_alias"] = "";
$obj = new SQLFieldListItem($proto12);

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

$proto14["m_sql"] = "tt";
$proto14["m_srcTableName"] = "sales_history";
$proto14["m_expr"]=$obj;
$proto14["m_alias"] = "";
$obj = new SQLFieldListItem($proto14);

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

$proto16["m_sql"] = "`advance_id`";
$proto16["m_srcTableName"] = "sales_history";
$proto16["m_expr"]=$obj;
$proto16["m_alias"] = "";
$obj = new SQLFieldListItem($proto16);

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

$proto18["m_sql"] = "`amount`";
$proto18["m_srcTableName"] = "sales_history";
$proto18["m_expr"]=$obj;
$proto18["m_alias"] = "";
$obj = new SQLFieldListItem($proto18);

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

$proto20["m_sql"] = "customer_id";
$proto20["m_srcTableName"] = "sales_history";
$proto20["m_expr"]=$obj;
$proto20["m_alias"] = "";
$obj = new SQLFieldListItem($proto20);

$proto0["m_fieldlist"][]=$obj;
						$proto22=array();
			$proto23=array();
$proto23["m_functiontype"] = "SQLF_CUSTOM";
$proto23["m_arguments"] = array();
						$obj = new SQLNonParsed(array(
	"m_sql" => "purch.pur"
));

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

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

$proto22["m_sql"] = "ifnull(purch.pur,0)";
$proto22["m_srcTableName"] = "sales_history";
$proto22["m_expr"]=$obj;
$proto22["m_alias"] = "paid";
$obj = new SQLFieldListItem($proto22);

$proto0["m_fieldlist"][]=$obj;
						$proto26=array();
			$proto27=array();
$proto27["m_functiontype"] = "SQLF_CUSTOM";
$proto27["m_arguments"] = array();
						$obj = new SQLNonParsed(array(
	"m_sql" => "sold.sol"
));

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

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

$proto26["m_sql"] = "ifnull(sold.sol,0)";
$proto26["m_srcTableName"] = "sales_history";
$proto26["m_expr"]=$obj;
$proto26["m_alias"] = "total amount";
$obj = new SQLFieldListItem($proto26);

$proto0["m_fieldlist"][]=$obj;
						$proto30=array();
			$proto31=array();
$proto31["m_functiontype"] = "SQLF_CUSTOM";
$proto31["m_arguments"] = array();
						$obj = new SQLNonParsed(array(
	"m_sql" => "case when (ifnull(sold.sol,0)> ifnull(purch.pur,0)) then  ((ifnull(sold.sol,0)) - (ifnull(purch.pur,0))-(ifnull(`amount`,0)) )end"
));

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

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

$proto30["m_sql"] = "ifnull(case when (ifnull(sold.sol,0)> ifnull(purch.pur,0)) then  ((ifnull(sold.sol,0)) - (ifnull(purch.pur,0))-(ifnull(`amount`,0)) )end,0)";
$proto30["m_srcTableName"] = "sales_history";
$proto30["m_expr"]=$obj;
$proto30["m_alias"] = "difect";
$obj = new SQLFieldListItem($proto30);

$proto0["m_fieldlist"][]=$obj;
$proto0["m_fromlist"] = array();
												$proto34=array();
$proto34["m_link"] = "SQLL_MAIN";
			$proto35=array();
$proto35["m_strName"] = "sales";
$proto35["m_srcTableName"] = "sales_history";
$proto35["m_columns"] = array();
$proto35["m_columns"][] = "id";
$proto35["m_columns"][] = "customer_name";
$proto35["m_columns"][] = "cash";
$proto35["m_columns"][] = "tt";
$proto35["m_columns"][] = "date_&_time";
$proto35["m_columns"][] = "branch_code";
$proto35["m_columns"][] = "user";
$proto35["m_columns"][] = "outlet_code";
$proto35["m_columns"][] = "h";
$proto35["m_columns"][] = "f";
$proto35["m_columns"][] = "advance_id";
$proto35["m_columns"][] = "amount";
$proto35["m_columns"][] = "left_advance";
$proto35["m_columns"][] = "details";
$proto35["m_columns"][] = "status";
$proto35["m_columns"][] = "customer_id";
$obj = new SQLTable($proto35);

$proto34["m_table"] = $obj;
$proto34["m_sql"] = "sales";
$proto34["m_alias"] = "";
$proto34["m_srcTableName"] = "sales_history";
$proto36=array();
$proto36["m_sql"] = "";
$proto36["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

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

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

$proto0["m_fromlist"][]=$obj;
												$proto38=array();
$proto38["m_link"] = "SQLL_LEFTJOIN";
			$proto39=array();
$proto39["m_strHead"] = "select";
$proto39["m_strFieldList"] = "`m_id`,sum(`sub_total`) as sol";
$proto39["m_strFrom"] = "from sales_details";
$proto39["m_strWhere"] = "1";
$proto39["m_strOrderBy"] = "";
	
		;
			$proto39["cipherer"] = null;
$proto41=array();
$proto41["m_sql"] = "1";
$proto41["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLNonParsed(array(
	"m_sql" => "1"
));

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

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

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

$proto39["m_having"] = $obj;
$proto39["m_fieldlist"] = array();
						$proto45=array();
			$obj = new SQLField(array(
	"m_strName" => "m_id",
	"m_strTable" => "sales_details",
	"m_srcTableName" => "sales_history"
));

$proto45["m_sql"] = "`m_id`";
$proto45["m_srcTableName"] = "sales_history";
$proto45["m_expr"]=$obj;
$proto45["m_alias"] = "";
$obj = new SQLFieldListItem($proto45);

$proto39["m_fieldlist"][]=$obj;
						$proto47=array();
			$proto48=array();
$proto48["m_functiontype"] = "SQLF_SUM";
$proto48["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "sub_total",
	"m_strTable" => "sales_details",
	"m_srcTableName" => "sales_history"
));

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

$proto47["m_sql"] = "sum(`sub_total`)";
$proto47["m_srcTableName"] = "sales_history";
$proto47["m_expr"]=$obj;
$proto47["m_alias"] = "sol";
$obj = new SQLFieldListItem($proto47);

$proto39["m_fieldlist"][]=$obj;
$proto39["m_fromlist"] = array();
												$proto50=array();
$proto50["m_link"] = "SQLL_MAIN";
			$proto51=array();
$proto51["m_strName"] = "sales_details";
$proto51["m_srcTableName"] = "sales_history";
$proto51["m_columns"] = array();
$proto51["m_columns"][] = "id";
$proto51["m_columns"][] = "bar_code";
$proto51["m_columns"][] = "product";
$proto51["m_columns"][] = "quntity";
$proto51["m_columns"][] = "price";
$proto51["m_columns"][] = "m_id";
$proto51["m_columns"][] = "sub_total";
$proto51["m_columns"][] = "user";
$proto51["m_columns"][] = "discount";
$proto51["m_columns"][] = "tax";
$proto51["m_columns"][] = "newp";
$proto51["m_columns"][] = "stk_tra";
$proto51["m_columns"][] = "unit";
$proto51["m_columns"][] = "stk_tra_status";
$proto51["m_columns"][] = "package_details";
$proto51["m_columns"][] = "date_time";
$proto51["m_columns"][] = "outlet_code";
$obj = new SQLTable($proto51);

$proto50["m_table"] = $obj;
$proto50["m_sql"] = "sales_details";
$proto50["m_alias"] = "";
$proto50["m_srcTableName"] = "sales_history";
$proto52=array();
$proto52["m_sql"] = "";
$proto52["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

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

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

$proto39["m_fromlist"][]=$obj;
$proto39["m_groupby"] = array();
												$proto54=array();
						$obj = new SQLField(array(
	"m_strName" => "m_id",
	"m_strTable" => "sales_details",
	"m_srcTableName" => "sales_history"
));

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

$proto39["m_groupby"][]=$obj;
$proto39["m_orderby"] = array();
$proto39["m_srcTableName"]="sales_history";		
$obj = new SQLQuery($proto39);

$proto38["m_table"] = $obj;
$proto38["m_sql"] = "LEFT JOIN (select `m_id`,sum(`sub_total`) as sol from sales_details where 1 group by `m_id` ) as sold on sales.`id` = sold.`m_id`";
$proto38["m_alias"] = "sold";
$proto38["m_srcTableName"] = "sales_history";
$proto56=array();
$proto56["m_sql"] = "sales.`id` = sold.`m_id`";
$proto56["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "id",
	"m_strTable" => "sales",
	"m_srcTableName" => "sales_history"
));

$proto56["m_column"]=$obj;
$proto56["m_contained"] = array();
$proto56["m_strCase"] = "= sold.`m_id`";
$proto56["m_havingmode"] = false;
$proto56["m_inBrackets"] = false;
$proto56["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto56);

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

$proto0["m_fromlist"][]=$obj;
												$proto58=array();
$proto58["m_link"] = "SQLL_LEFTJOIN";
			$proto59=array();
$proto59["m_strHead"] = "SELECT";
$proto59["m_strFieldList"] = "`sales_id`,SUM(`amount`) as pur";
$proto59["m_strFrom"] = "from payments";
$proto59["m_strWhere"] = "";
$proto59["m_strOrderBy"] = "";
	
		;
			$proto59["cipherer"] = null;
$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);

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

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

$proto59["m_having"] = $obj;
$proto59["m_fieldlist"] = array();
						$proto65=array();
			$obj = new SQLField(array(
	"m_strName" => "sales_id",
	"m_strTable" => "payments",
	"m_srcTableName" => "sales_history"
));

$proto65["m_sql"] = "`sales_id`";
$proto65["m_srcTableName"] = "sales_history";
$proto65["m_expr"]=$obj;
$proto65["m_alias"] = "";
$obj = new SQLFieldListItem($proto65);

$proto59["m_fieldlist"][]=$obj;
						$proto67=array();
			$proto68=array();
$proto68["m_functiontype"] = "SQLF_SUM";
$proto68["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "amount",
	"m_strTable" => "payments",
	"m_srcTableName" => "sales_history"
));

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

$proto67["m_sql"] = "SUM(`amount`)";
$proto67["m_srcTableName"] = "sales_history";
$proto67["m_expr"]=$obj;
$proto67["m_alias"] = "pur";
$obj = new SQLFieldListItem($proto67);

$proto59["m_fieldlist"][]=$obj;
$proto59["m_fromlist"] = array();
												$proto70=array();
$proto70["m_link"] = "SQLL_MAIN";
			$proto71=array();
$proto71["m_strName"] = "payments";
$proto71["m_srcTableName"] = "sales_history";
$proto71["m_columns"] = array();
$proto71["m_columns"][] = "id";
$proto71["m_columns"][] = "sales_id";
$proto71["m_columns"][] = "type";
$proto71["m_columns"][] = "amount";
$proto71["m_columns"][] = "cheque_number";
$proto71["m_columns"][] = "cheque_date";
$proto71["m_columns"][] = "hide";
$proto71["m_columns"][] = "status";
$proto71["m_columns"][] = "opening_balance_id";
$proto71["m_columns"][] = "outlet";
$proto71["m_columns"][] = "date_time";
$proto71["m_columns"][] = "user";
$proto71["m_columns"][] = "status_2";
$obj = new SQLTable($proto71);

$proto70["m_table"] = $obj;
$proto70["m_sql"] = "payments";
$proto70["m_alias"] = "";
$proto70["m_srcTableName"] = "sales_history";
$proto72=array();
$proto72["m_sql"] = "";
$proto72["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

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

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

$proto59["m_fromlist"][]=$obj;
$proto59["m_groupby"] = array();
												$proto74=array();
						$obj = new SQLField(array(
	"m_strName" => "sales_id",
	"m_strTable" => "payments",
	"m_srcTableName" => "sales_history"
));

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

$proto59["m_groupby"][]=$obj;
$proto59["m_orderby"] = array();
$proto59["m_srcTableName"]="sales_history";		
$obj = new SQLQuery($proto59);

$proto58["m_table"] = $obj;
$proto58["m_sql"] = "left join (SELECT `sales_id`,SUM(`amount`) as pur from payments group by `sales_id`) as purch on sales.id = purch.sales_id";
$proto58["m_alias"] = "purch";
$proto58["m_srcTableName"] = "sales_history";
$proto76=array();
$proto76["m_sql"] = "sales.id = purch.sales_id";
$proto76["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "id",
	"m_strTable" => "sales",
	"m_srcTableName" => "sales_history"
));

$proto76["m_column"]=$obj;
$proto76["m_contained"] = array();
$proto76["m_strCase"] = "= purch.sales_id";
$proto76["m_havingmode"] = false;
$proto76["m_inBrackets"] = false;
$proto76["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto76);

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

$proto0["m_fromlist"][]=$obj;
												$proto78=array();
$proto78["m_link"] = "SQLL_LEFTJOIN";
			$proto79=array();
$proto79["m_strName"] = "sys_manage";
$proto79["m_srcTableName"] = "sales_history";
$proto79["m_columns"] = array();
$proto79["m_columns"][] = "ID";
$proto79["m_columns"][] = "username";
$proto79["m_columns"][] = "password";
$proto79["m_columns"][] = "email";
$proto79["m_columns"][] = "fullname";
$proto79["m_columns"][] = "groupid";
$proto79["m_columns"][] = "active";
$proto79["m_columns"][] = "ext_security_id";
$proto79["m_columns"][] = "reset_token";
$proto79["m_columns"][] = "reset_date";
$proto79["m_columns"][] = "teliphone_number";
$proto79["m_columns"][] = "date";
$proto79["m_columns"][] = "branch_code";
$proto79["m_columns"][] = "outlet_code";
$proto79["m_columns"][] = "MyTheme";
$proto79["m_columns"][] = "MyThemeSize";
$proto79["m_columns"][] = "password2";
$obj = new SQLTable($proto79);

$proto78["m_table"] = $obj;
$proto78["m_sql"] = "LEFT OUTER JOIN sys_manage ON sales.`user` = sys_manage.username";
$proto78["m_alias"] = "";
$proto78["m_srcTableName"] = "sales_history";
$proto80=array();
$proto80["m_sql"] = "sales.`user` = sys_manage.username";
$proto80["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "user",
	"m_strTable" => "sales",
	"m_srcTableName" => "sales_history"
));

$proto80["m_column"]=$obj;
$proto80["m_contained"] = array();
$proto80["m_strCase"] = "= sys_manage.username";
$proto80["m_havingmode"] = false;
$proto80["m_inBrackets"] = false;
$proto80["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto80);

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

$proto0["m_fromlist"][]=$obj;
												$proto82=array();
$proto82["m_link"] = "SQLL_INNERJOIN";
			$proto83=array();
$proto83["m_strName"] = "company_profile";
$proto83["m_srcTableName"] = "sales_history";
$proto83["m_columns"] = array();
$proto83["m_columns"][] = "id";
$proto83["m_columns"][] = "company_name";
$proto83["m_columns"][] = "address_line_1";
$proto83["m_columns"][] = "address_line_2";
$proto83["m_columns"][] = "country";
$proto83["m_columns"][] = "provinces";
$proto83["m_columns"][] = "districts";
$proto83["m_columns"][] = "postal_code";
$proto83["m_columns"][] = "hot_line";
$proto83["m_columns"][] = "Fax";
$proto83["m_columns"][] = "email";
$proto83["m_columns"][] = "logo";
$proto83["m_columns"][] = "branch_code";
$proto83["m_columns"][] = "header";
$proto83["m_columns"][] = "footer";
$proto83["m_columns"][] = "time_calibration";
$obj = new SQLTable($proto83);

$proto82["m_table"] = $obj;
$proto82["m_sql"] = "INNER JOIN company_profile ON sys_manage.outlet_code = company_profile.id";
$proto82["m_alias"] = "";
$proto82["m_srcTableName"] = "sales_history";
$proto84=array();
$proto84["m_sql"] = "sys_manage.outlet_code = company_profile.id";
$proto84["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "outlet_code",
	"m_strTable" => "sys_manage",
	"m_srcTableName" => "sales_history"
));

$proto84["m_column"]=$obj;
$proto84["m_contained"] = array();
$proto84["m_strCase"] = "= company_profile.id";
$proto84["m_havingmode"] = false;
$proto84["m_inBrackets"] = false;
$proto84["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto84);

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

$proto0["m_fromlist"][]=$obj;
$proto0["m_groupby"] = array();
$proto0["m_orderby"] = array();
												$proto86=array();
						$obj = new SQLField(array(
	"m_strName" => "id",
	"m_strTable" => "sales",
	"m_srcTableName" => "sales_history"
));

$proto86["m_column"]=$obj;
$proto86["m_bAsc"] = 0;
$proto86["m_nColumn"] = 0;
$obj = new SQLOrderByItem($proto86);

$proto0["m_orderby"][]=$obj;					
$proto0["m_srcTableName"]="sales_history";		
$obj = new SQLQuery($proto0);

	return $obj;
}
$queryData_sales_history = createSqlQuery_sales_history();


	
		;

											

$tdatasales_history[".sqlquery"] = $queryData_sales_history;



include_once(getabspath("include/sales_history_events.php"));
$tableEvents["sales_history"] = new eventclass_sales_history;
$tdatasales_history[".hasEvents"] = true;

?>