<?php



$tdatavinha_report_todos = array();
$tdatavinha_report_todos[".searchableFields"] = array();
$tdatavinha_report_todos[".ShortName"] = "vinha_report_todos";
$tdatavinha_report_todos[".OwnerID"] = "";
$tdatavinha_report_todos[".OriginalTable"] = "Vinha";


$tdatavinha_report_todos[".pagesByType"] = my_json_decode( "{\"report\":[\"report\"],\"rprint\":[\"rprint\"],\"search\":[\"search\"]}" );
$tdatavinha_report_todos[".originalPagesByType"] = $tdatavinha_report_todos[".pagesByType"];
$tdatavinha_report_todos[".pages"] = types2pages( my_json_decode( "{\"report\":[\"report\"],\"rprint\":[\"rprint\"],\"search\":[\"search\"]}" ) );
$tdatavinha_report_todos[".originalPages"] = $tdatavinha_report_todos[".pages"];
$tdatavinha_report_todos[".defaultPages"] = my_json_decode( "{\"report\":\"report\",\"rprint\":\"rprint\",\"search\":\"search\"}" );
$tdatavinha_report_todos[".originalDefaultPages"] = $tdatavinha_report_todos[".defaultPages"];

//	field labels
$fieldLabelsvinha_report_todos = array();
$fieldToolTipsvinha_report_todos = array();
$pageTitlesvinha_report_todos = array();
$placeHoldersvinha_report_todos = array();

if(mlang_getcurrentlang()=="Portuguese(Standard)")
{
	$fieldLabelsvinha_report_todos["Portuguese(Standard)"] = array();
	$fieldToolTipsvinha_report_todos["Portuguese(Standard)"] = array();
	$placeHoldersvinha_report_todos["Portuguese(Standard)"] = array();
	$pageTitlesvinha_report_todos["Portuguese(Standard)"] = array();
	$fieldLabelsvinha_report_todos["Portuguese(Standard)"]["Marza"] = "Marza";
	$fieldToolTipsvinha_report_todos["Portuguese(Standard)"]["Marza"] = "";
	$placeHoldersvinha_report_todos["Portuguese(Standard)"]["Marza"] = "";
	$fieldLabelsvinha_report_todos["Portuguese(Standard)"]["Quantidade_Vendida"] = "Quantidade Vendida";
	$fieldToolTipsvinha_report_todos["Portuguese(Standard)"]["Quantidade_Vendida"] = "";
	$placeHoldersvinha_report_todos["Portuguese(Standard)"]["Quantidade_Vendida"] = "";
	$fieldLabelsvinha_report_todos["Portuguese(Standard)"]["Stock"] = "Stock";
	$fieldToolTipsvinha_report_todos["Portuguese(Standard)"]["Stock"] = "";
	$placeHoldersvinha_report_todos["Portuguese(Standard)"]["Stock"] = "";
	$fieldLabelsvinha_report_todos["Portuguese(Standard)"]["SUM_Totale_"] = "SUM(Totale)";
	$fieldToolTipsvinha_report_todos["Portuguese(Standard)"]["SUM_Totale_"] = "";
	$placeHoldersvinha_report_todos["Portuguese(Standard)"]["SUM_Totale_"] = "";
	if (count($fieldToolTipsvinha_report_todos["Portuguese(Standard)"]))
		$tdatavinha_report_todos[".isUseToolTips"] = true;
}


	$tdatavinha_report_todos[".NCSearch"] = true;



$tdatavinha_report_todos[".shortTableName"] = "vinha_report_todos";
$tdatavinha_report_todos[".nSecOptions"] = 0;

$tdatavinha_report_todos[".mainTableOwnerID"] = "";
$tdatavinha_report_todos[".entityType"] = 2;

$tdatavinha_report_todos[".strOriginalTableName"] = "Vinha";

	



$tdatavinha_report_todos[".showAddInPopup"] = false;

$tdatavinha_report_todos[".showEditInPopup"] = false;

$tdatavinha_report_todos[".showViewInPopup"] = false;

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


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

	$tdatavinha_report_todos[".audit"] = false;

	$tdatavinha_report_todos[".locking"] = false;


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

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

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

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



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




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

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

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

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



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

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

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

$tdatavinha_report_todos[".isUseAjaxSuggest"] = true;




			

$tdatavinha_report_todos[".ajaxCodeSnippetAdded"] = false;

$tdatavinha_report_todos[".buttonsAdded"] = false;

$tdatavinha_report_todos[".addPageEvents"] = false;

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


$tdatavinha_report_todos[".badgeColor"] = "5F9EA0";


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

$tdatavinha_report_todos[".googleLikeFields"] = array();
$tdatavinha_report_todos[".googleLikeFields"][] = "SUM(Totale)";



$tdatavinha_report_todos[".tableType"] = "report";

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

$tdatavinha_report_todos[".nPrinterSplitRecords"] = 40;

$tdatavinha_report_todos[".geocodingEnabled"] = false;

//report settings
$tdatavinha_report_todos[".printReportLayout"] = 6;

$tdatavinha_report_todos[".reportPrintPartitionType"] = 1;
$tdatavinha_report_todos[".reportPrintGroupsPerPage"] = 40;
$tdatavinha_report_todos[".lowGroup"] = 0;



$tdatavinha_report_todos[".pageSize"] = 999;


$tdatavinha_report_todos[".isExistTotalFields"] = true;



$tdatavinha_report_todos[".reportGlobalSummary"] = true;

$tdatavinha_report_todos[".repShowDet"] = true;

$tdatavinha_report_todos[".reportLayout"] = 6;

//end of report settings










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

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

$tdatavinha_report_todos[".sqlHead"] = "SELECT `Assegnatos`.`Marza`,  SUM(`Vinha`.`Quantidade`) AS `Quantidade Vendida`,  COALESCE(Assegnatos.Totale,0)-SUM(COALESCE(Vinha.Quantidade,0)) AS `Stock`,  SUM(`Assegnatos`.`Totale`) AS `SUM(Totale)`";
$tdatavinha_report_todos[".sqlFrom"] = "FROM `Vinha`  RIGHT OUTER JOIN `Assegnatos` ON `Assegnatos`.`Codice` = `Vinha`.`CodPlanta`";
$tdatavinha_report_todos[".sqlWhereExpr"] = "";
$tdatavinha_report_todos[".sqlTail"] = "";

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

$tdatavinha_report_todos[".highlightSearchResults"] = true;

$tableKeysvinha_report_todos = array();
$tdatavinha_report_todos[".Keys"] = $tableKeysvinha_report_todos;


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




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

		// report field settings
					// end of report field settings

	
	
			

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

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

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

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

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

	
	
	
	
	
	
	
	
	
	
	
	
		$vdata["NeedEncode"] = true;

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

	$fdata["ViewFormats"]["report"] = $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"] = "Assegnatos";
			$edata["autoCompleteFieldsOnEdit"] = 0;
	$edata["autoCompleteFields"] = array();
		$edata["LCType"] = 0;

	
			$edata["LookupUnique"] = true;

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

	

	
	$edata["LookupOrderBy"] = "";

	
	
	
	

	
	
		$edata["SelectSize"] = 1;

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


	$tdatavinha_report_todos["Marza"] = $fdata;
		$tdatavinha_report_todos[".searchableFields"][] = "Marza";
//	Quantidade Vendida
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 2;
	$fdata["strName"] = "Quantidade Vendida";
	$fdata["GoodName"] = "Quantidade_Vendida";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("Vinha_Report_Todos","Quantidade_Vendida");
	$fdata["FieldType"] = 14;

		// report field settings
					$fdata["isTotalSum"] = true;
	// end of report field settings

	
	
			

		$fdata["strField"] = "Quantidade Vendida";

		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "SUM(`Vinha`.`Quantidade`)";

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


	$tdatavinha_report_todos["Quantidade Vendida"] = $fdata;
		$tdatavinha_report_todos[".searchableFields"][] = "Quantidade Vendida";
//	Stock
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 3;
	$fdata["strName"] = "Stock";
	$fdata["GoodName"] = "Stock";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("Vinha_Report_Todos","Stock");
	$fdata["FieldType"] = 14;

		// report field settings
					$fdata["isTotalSum"] = true;
	// end of report field settings

	
	
			

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

		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "COALESCE(Assegnatos.Totale,0)-SUM(COALESCE(Vinha.Quantidade,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"]["report"] = $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"]["search"] = $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


	$tdatavinha_report_todos["Stock"] = $fdata;
		$tdatavinha_report_todos[".searchableFields"][] = "Stock";
//	SUM(Totale)
//	Custom field settings
	$fdata = array();
	$fdata["Index"] = 4;
	$fdata["strName"] = "SUM(Totale)";
	$fdata["GoodName"] = "SUM_Totale_";
	$fdata["ownerTable"] = "";
	$fdata["Label"] = GetFieldLabel("Vinha_Report_Todos","SUM_Totale_");
	$fdata["FieldType"] = 14;

		// report field settings
					$fdata["isTotalSum"] = true;
	// end of report field settings

	
	
			

		$fdata["strField"] = "SUM(Totale)";

		$fdata["isSQLExpression"] = true;
	$fdata["FullName"] = "SUM(`Assegnatos`.`Totale`)";

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


	$tdatavinha_report_todos["SUM(Totale)"] = $fdata;
		$tdatavinha_report_todos[".searchableFields"][] = "SUM(Totale)";


$tables_data["Vinha Report Todos"]=&$tdatavinha_report_todos;
$field_labels["Vinha_Report_Todos"] = &$fieldLabelsvinha_report_todos;
$fieldToolTips["Vinha_Report_Todos"] = &$fieldToolTipsvinha_report_todos;
$placeHolders["Vinha_Report_Todos"] = &$placeHoldersvinha_report_todos;
$page_titles["Vinha_Report_Todos"] = &$pageTitlesvinha_report_todos;

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

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



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


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










function createSqlQuery_vinha_report_todos()
{
$proto0=array();
$proto0["m_strHead"] = "SELECT";
$proto0["m_strFieldList"] = "`Assegnatos`.`Marza`,  SUM(`Vinha`.`Quantidade`) AS `Quantidade Vendida`,  COALESCE(Assegnatos.Totale,0)-SUM(COALESCE(Vinha.Quantidade,0)) AS `Stock`,  SUM(`Assegnatos`.`Totale`) AS `SUM(Totale)`";
$proto0["m_strFrom"] = "FROM `Vinha`  RIGHT OUTER JOIN `Assegnatos` ON `Assegnatos`.`Codice` = `Vinha`.`CodPlanta`";
$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" => "Marza",
	"m_strTable" => "Assegnatos",
	"m_srcTableName" => "Vinha Report Todos"
));

$proto6["m_sql"] = "`Assegnatos`.`Marza`";
$proto6["m_srcTableName"] = "Vinha Report Todos";
$proto6["m_expr"]=$obj;
$proto6["m_alias"] = "";
$obj = new SQLFieldListItem($proto6);

$proto0["m_fieldlist"][]=$obj;
						$proto8=array();
			$proto9=array();
$proto9["m_functiontype"] = "SQLF_SUM";
$proto9["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "Quantidade",
	"m_strTable" => "Vinha",
	"m_srcTableName" => "Vinha Report Todos"
));

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

$proto8["m_sql"] = "SUM(`Vinha`.`Quantidade`)";
$proto8["m_srcTableName"] = "Vinha Report Todos";
$proto8["m_expr"]=$obj;
$proto8["m_alias"] = "Quantidade Vendida";
$obj = new SQLFieldListItem($proto8);

$proto0["m_fieldlist"][]=$obj;
						$proto11=array();
			$obj = new SQLNonParsed(array(
	"m_sql" => "COALESCE(Assegnatos.Totale,0)-SUM(COALESCE(Vinha.Quantidade,0))"
));

$proto11["m_sql"] = "COALESCE(Assegnatos.Totale,0)-SUM(COALESCE(Vinha.Quantidade,0))";
$proto11["m_srcTableName"] = "Vinha Report Todos";
$proto11["m_expr"]=$obj;
$proto11["m_alias"] = "Stock";
$obj = new SQLFieldListItem($proto11);

$proto0["m_fieldlist"][]=$obj;
						$proto13=array();
			$proto14=array();
$proto14["m_functiontype"] = "SQLF_SUM";
$proto14["m_arguments"] = array();
						$obj = new SQLField(array(
	"m_strName" => "Totale",
	"m_strTable" => "Assegnatos",
	"m_srcTableName" => "Vinha Report Todos"
));

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

$proto13["m_sql"] = "SUM(`Assegnatos`.`Totale`)";
$proto13["m_srcTableName"] = "Vinha Report Todos";
$proto13["m_expr"]=$obj;
$proto13["m_alias"] = "SUM(Totale)";
$obj = new SQLFieldListItem($proto13);

$proto0["m_fieldlist"][]=$obj;
$proto0["m_fromlist"] = array();
												$proto16=array();
$proto16["m_link"] = "SQLL_MAIN";
			$proto17=array();
$proto17["m_strName"] = "Vinha";
$proto17["m_srcTableName"] = "Vinha Report Todos";
$proto17["m_columns"] = array();
$proto17["m_columns"][] = "CodVenda";
$proto17["m_columns"][] = "CodUser";
$proto17["m_columns"][] = "Data";
$proto17["m_columns"][] = "CodPlanta";
$proto17["m_columns"][] = "CodCliente";
$proto17["m_columns"][] = "Quantidade";
$proto17["m_columns"][] = "Confirmado";
$proto17["m_columns"][] = "Pago20%";
$proto17["m_columns"][] = "Encomendado";
$proto17["m_columns"][] = "PagoTotal";
$proto17["m_columns"][] = "Fornecido";
$proto17["m_columns"][] = "NEntrega";
$proto17["m_columns"][] = "PE";
$proto17["m_columns"][] = "Clone";
$proto17["m_columns"][] = "NE";
$proto17["m_columns"][] = "Saldo";
$proto17["m_columns"][] = "CodMarza";
$proto17["m_columns"][] = "Saldo1";
$proto17["m_columns"][] = "Escolha";
$obj = new SQLTable($proto17);

$proto16["m_table"] = $obj;
$proto16["m_sql"] = "`Vinha`";
$proto16["m_alias"] = "";
$proto16["m_srcTableName"] = "Vinha Report Todos";
$proto18=array();
$proto18["m_sql"] = "";
$proto18["m_uniontype"] = "SQLL_UNKNOWN";
	$obj = new SQLNonParsed(array(
	"m_sql" => ""
));

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

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

$proto0["m_fromlist"][]=$obj;
												$proto20=array();
$proto20["m_link"] = "SQLL_RIGHTJOIN";
			$proto21=array();
$proto21["m_strName"] = "Assegnatos";
$proto21["m_srcTableName"] = "Vinha Report Todos";
$proto21["m_columns"] = array();
$proto21["m_columns"][] = "Data";
$proto21["m_columns"][] = "Marza";
$proto21["m_columns"][] = "Talea";
$proto21["m_columns"][] = "Varieta";
$proto21["m_columns"][] = "Totale";
$proto21["m_columns"][] = "Codice";
$proto21["m_columns"][] = "Clone";
$obj = new SQLTable($proto21);

$proto20["m_table"] = $obj;
$proto20["m_sql"] = "RIGHT OUTER JOIN `Assegnatos` ON `Assegnatos`.`Codice` = `Vinha`.`CodPlanta`";
$proto20["m_alias"] = "";
$proto20["m_srcTableName"] = "Vinha Report Todos";
$proto22=array();
$proto22["m_sql"] = "`Assegnatos`.`Codice` = `Vinha`.`CodPlanta`";
$proto22["m_uniontype"] = "SQLL_UNKNOWN";
						$obj = new SQLField(array(
	"m_strName" => "Codice",
	"m_strTable" => "Assegnatos",
	"m_srcTableName" => "Vinha Report Todos"
));

$proto22["m_column"]=$obj;
$proto22["m_contained"] = array();
$proto22["m_strCase"] = "= `Vinha`.`CodPlanta`";
$proto22["m_havingmode"] = false;
$proto22["m_inBrackets"] = false;
$proto22["m_useAlias"] = false;
$obj = new SQLLogicalExpr($proto22);

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

$proto0["m_fromlist"][]=$obj;
$proto0["m_groupby"] = array();
												$proto24=array();
						$obj = new SQLField(array(
	"m_strName" => "Marza",
	"m_strTable" => "Assegnatos",
	"m_srcTableName" => "Vinha Report Todos"
));

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

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

	return $obj;
}
$queryData_vinha_report_todos = createSqlQuery_vinha_report_todos();


	
		;

				

$tdatavinha_report_todos[".sqlquery"] = $queryData_vinha_report_todos;

$tableEvents["Vinha Report Todos"] = new eventsBase;
$tdatavinha_report_todos[".hasEvents"] = false;

?>