<?php

/*SELECT *, Instances.ID AS IID, GROUP_CONCAT(OrdOurLanguages.NameIt ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR '; ') AS OrdOurLangs FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID LEFT JOIN InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID WHERE OurLanguages.NameIT LIKE '%italiano%' GROUP BY IID LIMIT 50*/

$cols=array(

	'Instances.Noxious'=>array('field'=>'Instances.Noxious','name'=>'[Nociva]','nameEN'=>'[Noxious]','type'=>'bool'),
	'Instances.NoxReason'=>array('field'=>'Instances.NoxReason','name'=>'Motivo nocività','nameEN'=>'Noxiousness reason','type'=>'text'),
	'Instances.NoxLastModTS'=>array('field'=>'Instances.NoxLastModTS','name'=>'Data ult. modifica motivo nocività','nameEN'=>'Last modification date of noxiousness reason','type'=>'time'),
	'Instances.Visible'=>array('field'=>'Instances.Visible','name'=>'[Visibile]','nameEN'=>'[Visible]','type'=>'bool'),
	'Instances.WasLastCheckOk'=>array('field'=>'Instances.WasLastCheckOk','name'=>'[Ha risposto all’ultimo check]','nameEN'=>'[Has answered on last check]','type'=>'bool'),
	'Instances.LastOkCheckTS'=>array('field'=>'LastOkCheckTS','name'=>'Timestamp dell’ultimo check riuscito','nameEN'=>'Last ok check timestamp','type'=>'int'),	'Instances.Priority'=>array('field'=>'Instances.Priority','name'=>'Priorità','nameEN'=>'Priority','type'=>'int'),
	'Instances.URI'=>array('field'=>'Instances.URI','name'=>'URI','nameEN'=>'URI','type'=>'text'),
	'Instances.Title'=>array('field'=>'Instances.Title','name'=>'Titolo','nameEN'=>'Title','type'=>'text'),
	'Instances.ShortDesc'=>array('field'=>'Instances.ShortDesc','name'=>'Descrizione breve','nameEN'=>'Short description','type'=>'text'),
	'Instances.LongDesc'=>array('field'=>'Instances.LongDesc','name'=>'Descrizione lunga','nameEN'=>'Long description','type'=>'text'),
	'Instances.OurDesc'=>array('field'=>'Instances.OurDesc','name'=>'[Descrizione nostra (in lingua originale)]','nameEN'=>'[Our description (in original language)]','type'=>'text'),
	'Instances.OurDescEN'=>array('field'=>'Instances.OurDescEN','name'=>'[Descrizione nostra (in inglese)]','nameEN'=>'[Our description (in english)]','type'=>'text'),

//--------------------------------

	'Instances.GuestID'=>array('field'=>'Instances.GuestID','name'=>'[Email admin invitat@] ►','nameEN'=>'[Guest admin email] ►','type'=>'join','join'=>array(),'ord'=>false),
	'Admins.Email'=>array('field'=>'Admins.Email','name'=>'[Email admin invitat@]','nameEN'=>'[Guest admin email]','type'=>'joini','join'=>array('Admins ON Admins.ID=Instances.GuestID'),'subtype'=>'text'),

	'Instances.LastGuestEdit'=>array('field'=>'Instances.LastGuestEdit','name'=>'[Ultima modifica fatta dall’admin invitat@]','nameEN'=>'[Last modification by guest admin]','type'=>'time'),

//--------------------------------

	'Instances.LocalityID'=>array('field'=>'Instances.LocalityID','name'=>'[Località] ►','nameEN'=>'[Location] ►','type'=>'join','join'=>array(),'ord'=>false),
	'Localities.Name'=>array('field'=>'Localities.Name'.$dlang,'name'=>'[Località]','nameEN'=>'[Location]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID'),'subtype'=>'text'),

//--------------------------------

	'Instances.Email'=>array('field'=>'Instances.Email','name'=>'Email di contatto','nameEN'=>'Contact email','type'=>'text'),
	'Instances.Software'=>array('field'=>'Instances.Software','name'=>'Software','nameEN'=>'Software','type'=>'text'),
	'Instances.Version'=>array('field'=>'Instances.Version','name'=>'Versione','nameEN'=>'Version','type'=>'text'),
	'Instances.UserCount'=>array('field'=>'Instances.UserCount','name'=>'Numero utenti','nameEN'=>'Number of users','type'=>'int'),
	'Instances.StatusCount'=>array('field'=>'Instances.StatusCount','name'=>'Numero stati','nameEN'=>'Number of statuses','type'=>'int'),
	'Instances.DomainCount'=>array('field'=>'Instances.DomainCount','name'=>'Numero istanze note','nameEN'=>'Number of known instances','type'=>'int'),
	'Instances.ActiveUsersMonth'=>array('field'=>'Instances.ActiveUsersMonth','name'=>'Numero utenti attivi (mese)','nameEN'=>'Number of active users (month)','type'=>'int'),
	'Instances.ActiveUsersHalfYear'=>array('field'=>'Instances.ActiveUsersHalfYear','name'=>'Numero utenti attivi (6 mesi)','nameEN'=>'Number of active users (6 months)','type'=>'int'),
	'Instances.Thumb'=>array('field'=>'Instances.Thumb','name'=>'Logo','nameEN'=>'Logo','type'=>'text','search'=>false,'ord'=>false),
	'Instances.RegOpen'=>array('field'=>'Instances.RegOpen','name'=>'Registrazioni aperte','nameEN'=>'Opened registrations','type'=>'bool'),
	'Instances.RegReqApproval'=>array('field'=>'Instances.RegReqApproval','name'=>'Approvazione registrazioni','nameEN'=>'Registrations approval','type'=>'bool'),
	'Instances.MaxTootChars'=>array('field'=>'Instances.MaxTootChars','name'=>'Limite caratteri','nameEN'=>'Max chars per toot','type'=>'int'),
	'Instances.AdmAccount'=>array('field'=>'Instances.AdmAccount','name'=>'Account admin','nameEN'=>'Admin account','type'=>'text'),
	'Instances.AdmDisplayName'=>array('field'=>'Instances.AdmDisplayName','name'=>'Nome account admin','nameEN'=>'Admin display name','type'=>'text'),
	'Instances.AdmCreatedAt'=>array('field'=>'Instances.AdmCreatedAt','name'=>'Data creazione account admin','nameEN'=>'Date and time of admin account creation','type'=>'time'),
	'Instances.AdmURL'=>array('field'=>'Instances.AdmURL','name'=>'Pagina dell’admin','nameEN'=>'Admin’s page','type'=>'text','search'=>false,'ord'=>false),
	'Instances.AdmAvatar'=>array('field'=>'Instances.AdmAvatar','name'=>'Avatar admin','nameEN'=>'Admin’s avatar','type'=>'text','search'=>false,'ord'=>false),
	'Instances.AdmNote'=>array('field'=>'Instances.AdmNote','name'=>'Note dell’admin','nameEN'=>'Admin’s notes','type'=>'text'),
	'Instances.InsertTS'=>array('field'=>'Instances.InsertTS','name'=>'Timestamp di inserimento del record','nameEN'=>'Record insert timestamp','type'=>'int'),

//--------------------------------

	'InstLangs'=>array('name'=>'Lingue dichiarate','nameEN'=>'Declared languages','search'=>false,'ord'=>false),

	'InstLangs.LangID'=>array('field'=>'InstLangs%.LangID','name'=>'Una lingua dichiarata ►','nameEN'=>'One declared language ►','type'=>'join','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID'),'ord'=>false),

	'Languages.NameXX'=>array('field'=>'Languages%.Name'.$dlang,'name'=>'Una lingua dichiarata','nameEN'=>'One declared language','type'=>'joini','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID','Languages AS Languages% ON Languages%.ID=InstLangs%.LangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue dichiarate','ordjoin'=>array('InstLangs AS OrdInstLangs ON OrdInstLangs.InstID=Instances.ID','Languages AS OrdLanguages ON OrdLanguages.ID=OrdInstLangs.LangID'),'ordselmore'=>'GROUP_CONCAT(OrdLanguages.Name'.$dlang.' ORDER BY OrdInstLangs.Pos ASC SEPARATOR \'\') AS xOrdLangs','ordby'=>'xOrdLangs'),

	'InstLangs.LangID.First'=>array('field'=>'InstLangs.LangID','name'=>'Lingua primaria dichiarata ►','nameEN'=>'Primary declared language ►','type'=>'join','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1'),'ord'=>false),

	'Languages.NameXX.First'=>array('field'=>'Languages.Name'.$dlang,'name'=>'Lingua primaria dichiarata','nameEN'=>'Primaria declared language','type'=>'joini','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1','Languages AS Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','ord'=>false),

//--------------------------------

	'InstOurLangs'=>array('name'=>'[Lingue impostate da noi]','nameEN'=>'[Languages defined by us]','search'=>false,'ord'=>false),

	'InstOurLangs.OurLangID'=>array('field'=>'InstOurLangs%.OurLangID','name'=>'[Una lingua impostata da noi] ►','nameEN'=>'[One of the languages defined by us] ►','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID'),'ord'=>false),

	'OurLanguages.NameXX'=>array('field'=>'OurLanguages%.Name'.$dlang,'name'=>'[Una lingua impostata da noi]','nameEN'=>'[One of the languages defined by us]','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID','Languages AS OurLanguages% ON OurLanguages%.ID=InstOurLangs%.OurLangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue impostate da noi','ordjoin'=>array('InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID','Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID'),'ordselmore'=>'GROUP_CONCAT(OrdOurLanguages.Name'.$dlang.' ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR \'\') AS xOrdOurLangs','ordby'=>'xOrdOurLangs'),

	'InstOurLangs.OurLangID.First'=>array('field'=>'InstOurLangs.OurLangID','name'=>'[Lingua primaria impostata da noi] ►','nameEN'=>'[Primary language defined by us] ►','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1'),'ord'=>false),

	'OurLanguages.NameXX.First'=>array('field'=>'OurLanguages.Name'.$dlang,'name'=>'[Lingua primaria impostata da noi]','nameEN'=>'[Primary language defined by us]','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','ord'=>false),

	'Instances.OurLangsLock'=>array('field'=>'Instances.OurLangsLock','name'=>'[Blocco lingue impostate da noi]','nameEN'=>'[Lock on languages defined by us]','type'=>'bool'),

//--------------------------------

	'InstFinancing'=>array('name'=>'[Modalità di finanziamento]','nameEN'=>'[Financing methods]','search'=>false,'ord'=>false),

	'InstFinancing.FinID'=>array('field'=>'InstFinancing%.FinID','name'=>'[Una modalità di finanziamento] ►','nameEN'=>'[One financing method] ►','type'=>'join','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID'),'ord'=>false),

	'Financing.Type'=>array('field'=>'Financing%.Type','name'=>'[Una modalità di finanziamento]','nameEN'=>'[One financing method]','type'=>'joini','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID','Financing AS Financing% ON Financing%.ID=InstFinancing%.FinID'),'subtype'=>'text','ord'=>true,'ordname'=>'Modalità di finanziamento','ordjoin'=>array('InstFinancing AS OrdInstFinancing ON OrdInstFinancing.InstID=Instances.ID','Financing AS OrdFinancing ON OrdFinancing.ID=OrdInstFinancing.FinID'),'ordselmore'=>'GROUP_CONCAT(OrdFinancing.Type ORDER BY OrdInstFinancing.Pos ASC SEPARATOR \'\') AS xOrdFinancing','ordby'=>'xOrdFinancing'),

	'InstFinancing.FinID.First'=>array('field'=>'InstFinancing.FinID','name'=>'[Modalità di finanziamento primaria] ►','nameEN'=>'[Primary financing method] ►','type'=>'join','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1'),'ord'=>false),

	'Financing.Type.First'=>array('field'=>'Financing.Type','name'=>'[Modalità di finanziamento primaria]','nameEN'=>'[Primary financing method]','type'=>'joini','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1','Financing AS Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','ord'=>false),

//--------------------------------

	'InstPolicies'=>array('name'=>'[Policies]','nameEN'=>'[Policies]','search'=>false,'ord'=>false),

	'InstPolicies.PolID'=>array('field'=>'InstPolicies%.PolID','name'=>'[Una policy] ►','nameEN'=>'[One policy] ►','type'=>'join','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID'),'ord'=>false),

	'Policies.Name'=>array('field'=>'Policies%.Name','name'=>'[Una policy]','nameEN'=>'[One policy]','type'=>'joini','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID','Policies AS Policies% ON Policies%.ID=InstPolicies%.PolID'),'subtype'=>'text','ord'=>true,'ordname'=>'Policies','ordjoin'=>array('InstPolicies AS OrdInstPolicies ON OrdInstPolicies.InstID=Instances.ID','Policies AS OrdPolicies ON OrdPolicies.ID=OrdInstPolicies.PolID'),'ordselmore'=>'GROUP_CONCAT(OrdPolicies.Name ORDER BY OrdInstPolicies.Pos ASC SEPARATOR \'\') AS xOrdPolicies','ordby'=>'xOrdPolicies'),

// Questi qui sotto sono disabilitati perché le policy non sono "pesate"
	/*'InstPolicies.PolID.First'=>array('field'=>'InstPolicies.PolID','name'=>'[Policy primaria] ►','nameEN'=>'[Primary policy] ►','type'=>'join','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1'),'ord'=>false),

	'Policies.Name.First'=>array('field'=>'Policies.Name','name'=>'[Policy primaria]','nameEN'=>'[Primary policy]','type'=>'joini','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1','Policies AS Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','ord'=>false),*/

//--------------------------------

	'InstTags'=>array('name'=>'[Categorie]','nameEN'=>'[Categories]','search'=>false,'ord'=>false),

	'InstTags.TagID'=>array('field'=>'InstTags%.TagID','name'=>'[Una categoria] ►','nameEN'=>'[One category] ►','type'=>'join','join'=>array('InstTags AS InstTags% ON InstTags%.InstID=Instances.ID'),'ord'=>false),

	'Tags.Name'=>array('field'=>'Tags%.Name','name'=>'[Una tag]','nameEN'=>'[One category]','type'=>'joini','join'=>array('InstTags AS InstTags% ON InstTags%.InstID=Instances.ID','Tags AS Tags% ON Tags%.ID=InstTags%.TagID'),'subtype'=>'text','ord'=>true,'ordname'=>'Tags','ordjoin'=>array('InstTags AS OrdInstTags ON OrdInstTags.InstID=Instances.ID','Tags AS OrdTags ON OrdTags.ID=OrdInstTags.TagID'),'ordselmore'=>'GROUP_CONCAT(OrdTags.Name ORDER BY OrdInstTags.Pos ASC SEPARATOR \'\') AS xOrdTags','ordby'=>'xOrdTags'),

	'InstTags.TagID.First'=>array('field'=>'InstTags.TagID','name'=>'[Tag primaria] ►','nameEN'=>'[Primary category] ►','type'=>'join','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1'),'ord'=>false),

	'Tags.Name.First'=>array('field'=>'Tags.Name','name'=>'[Tag primaria]','nameEN'=>'[Primary category]','type'=>'joini','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1','Tags AS Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','ord'=>false),

//--------------------------------

	'InstActivity.Statuses.First'=>array('field'=>'InstActivity.Statuses','name'=>'Stati ultima settimana','nameEN'=>'Last week’s statuses number','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Statuses'),

	'InstActivity.Logins.First'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','nameEN'=>'Last week’s logins number','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Logins'),

	'IntstActivity.Registrations.First'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','nameEN'=>'Last week’s registrations number','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Registrations'),

//--------------------------------

	/*'InstActivity.Statuses.AVG'=>array('field'=>'InstActivity.Statuses','name'=>'Media stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID'),'ordselmore'=>'AVG(InstActivity.Statuses) AS avgstatuses'),
	'InstActivity.Logins.AVG'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),
	'IntstActivity.Registrations.AVG'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),*/

//---------------------------------

	//'IntstChecks.Status'=>array('field'=>'InstChecks.Status','name'=>'OK all’ultimo check','nameEN'=>'OK on last check','type'=>'joini','join'=>array('InstChecks AS InstChecks ON InstChecks.InstID=Instances.ID AND InstChecks.Time=(SELECT MAX(InstChecks.Time) AS MaxTime FROM InstChecks WHERE InstChecks.InstID=Instances.ID)'),'subtype'=>'bool','ord'=>false),

);

?>
