...
This commit is contained in:
parent
0eb77c4cfd
commit
d2e9bc5f95
3 changed files with 87 additions and 34 deletions
|
@ -787,8 +787,10 @@ while ($i<$cinsts) {
|
||||||
if (array_key_exists('x-activity',$info) && is_array($info['x-activity'])) {
|
if (array_key_exists('x-activity',$info) && is_array($info['x-activity'])) {
|
||||||
mysqli_query($link,'DELETE FROM InstActivity WHERE InstID='.$instid);
|
mysqli_query($link,'DELETE FROM InstActivity WHERE InstID='.$instid);
|
||||||
foreach ($info['x-activity'] as $buf) {
|
foreach ($info['x-activity'] as $buf) {
|
||||||
|
$pos=0;
|
||||||
if (akeavinn('week',$buf) && akeavinn('statuses',$buf) && akeavinn('logins',$buf) && akeavinn('registrations',$buf)) {
|
if (akeavinn('week',$buf) && akeavinn('statuses',$buf) && akeavinn('logins',$buf) && akeavinn('registrations',$buf)) {
|
||||||
$query='INSERT INTO InstActivity (InstID, Week, Statuses, Logins, Registrations) VALUES (\''.$instid.'\', \''.myesc($link,$buf['week']).'\', \''.myesc($link,$buf['statuses']).'\', \''.myesc($link,$buf['logins']).'\', \''.myesc($link,$buf['registrations']).'\')';
|
$pos++;
|
||||||
|
$query='INSERT INTO InstActivity (InstID, Week, Statuses, Logins, Registrations, Pos) VALUES (\''.$instid.'\', \''.myesc($link,$buf['week']).'\', \''.myesc($link,$buf['statuses']).'\', \''.myesc($link,$buf['logins']).'\', \''.myesc($link,$buf['registrations']).'\', '.$pos.')';
|
||||||
mysqli_query($link,$query)
|
mysqli_query($link,$query)
|
||||||
or mexit(mysqli_error($link).N,3);
|
or mexit(mysqli_error($link).N,3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,32 +135,38 @@ $cols=array(
|
||||||
|
|
||||||
'InstLangs.LangID'=>array('field'=>'InstLangs.LangID','name'=>'Lingue dichiarate ⮞','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID'),'ord'=>false),
|
'InstLangs.LangID'=>array('field'=>'InstLangs.LangID','name'=>'Lingue dichiarate ⮞','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID'),'ord'=>false),
|
||||||
'Languages.NameIT'=>array('field'=>'Languages.NameIT','name'=>'Lingue dichiarate','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','ord'=>true,'ordjoin'=>array('InstLangs AS OrdInstLangs ON OrdInstLangs.InstID=Instances.ID','Languages AS OrdLanguages ON OrdLanguages.ID=OrdInstLangs.LangID'),'ordselmore'=>'GROUP_CONCAT(OrdLanguages.NameIT ORDER BY OrdInstLangs.Pos ASC SEPARATOR \'\') AS xOrdLangs','ordby'=>'xOrdLangs'),
|
'Languages.NameIT'=>array('field'=>'Languages.NameIT','name'=>'Lingue dichiarate','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','ord'=>true,'ordjoin'=>array('InstLangs AS OrdInstLangs ON OrdInstLangs.InstID=Instances.ID','Languages AS OrdLanguages ON OrdLanguages.ID=OrdInstLangs.LangID'),'ordselmore'=>'GROUP_CONCAT(OrdLanguages.NameIT ORDER BY OrdInstLangs.Pos ASC SEPARATOR \'\') AS xOrdLangs','ordby'=>'xOrdLangs'),
|
||||||
'InstLangs.LangID.First'=>array('field'=>'InstLangs.LangID','name'=>'Lingua primaria dichiarata ⮞','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID'),'wheremore'=>'AND InstLangs.Pos=1','ord'=>false),
|
'InstLangs.LangID.First'=>array('field'=>'InstLangs.LangID','name'=>'Lingua primaria dichiarata ⮞','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID'),'wheremore'=>'InstLangs.Pos=1','ord'=>false),
|
||||||
'Languages.NameIT.First'=>array('field'=>'Languages.NameIT','name'=>'Lingua primaria dichiarata','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','wheremore'=>'AND InstLangs.Pos=1','ord'=>false),
|
'Languages.NameIT.First'=>array('field'=>'Languages.NameIT','name'=>'Lingua primaria dichiarata','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','wheremore'=>'InstLangs.Pos=1','ord'=>false),
|
||||||
|
|
||||||
'InstOurLangs.OurLangID'=>array('field'=>'InstOurLangs.OurLangID','name'=>'Lingue impostate da noi ⮞','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID'),'ord'=>false),
|
'InstOurLangs.OurLangID'=>array('field'=>'InstOurLangs.OurLangID','name'=>'Lingue impostate da noi ⮞','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID'),'ord'=>false),
|
||||||
'OurLanguages.NameIT'=>array('field'=>'OurLanguages.NameIT','name'=>'Lingue impostate da noi','type'=>'joini','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','ord'=>true,'ordjoin'=>array('InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID','Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID'),'ordselmore'=>'GROUP_CONCAT(OrdOurLanguages.NameIT ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR \'\') AS xOrdOurLangs','ordby'=>'xOrdOurLangs'),
|
'OurLanguages.NameIT'=>array('field'=>'OurLanguages.NameIT','name'=>'Lingue impostate da noi','type'=>'joini','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','ord'=>true,'ordjoin'=>array('InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID','Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID'),'ordselmore'=>'GROUP_CONCAT(OrdOurLanguages.NameIT ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR \'\') AS xOrdOurLangs','ordby'=>'xOrdOurLangs'),
|
||||||
'InstOurLangs.OurLangID.First'=>array('field'=>'InstOurLangs.OurLangID','name'=>'Lingua primaria impostata da noi ⮞','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID'),'wheremore'=>'AND InstOurLangs.Pos=1','ord'=>false),
|
'InstOurLangs.OurLangID.First'=>array('field'=>'InstOurLangs.OurLangID','name'=>'Lingua primaria impostata da noi ⮞','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID'),'wheremore'=>'InstOurLangs.Pos=1','ord'=>false),
|
||||||
'OurLanguages.NameIT.First'=>array('field'=>'OurLanguages.NameIT','name'=>'Lingua primaria impostata da noi','type'=>'joini','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','wheremore'=>'AND InstOurLangs.Pos=1','ord'=>false),
|
'OurLanguages.NameIT.First'=>array('field'=>'OurLanguages.NameIT','name'=>'Lingua primaria impostata da noi','type'=>'joini','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','wheremore'=>'InstOurLangs.Pos=1','ord'=>false),
|
||||||
|
|
||||||
'InstFinancing.FinID'=>array('field'=>'InstFinancing.FinID','name'=>'Modalità di finanziamento ⮞','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID'),'ord'=>false),
|
'InstFinancing.FinID'=>array('field'=>'InstFinancing.FinID','name'=>'Modalità di finanziamento ⮞','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID'),'ord'=>false),
|
||||||
'Financing.Type'=>array('field'=>'Financing.Type','name'=>'Modalità di finanziamento','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID','Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','ord'=>true,'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'),
|
'Financing.Type'=>array('field'=>'Financing.Type','name'=>'Modalità di finanziamento','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID','Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','ord'=>true,'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 ⮞','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID'),'wheremore'=>'AND InstFinancing.Pos=1','ord'=>false),
|
'InstFinancing.FinID.First'=>array('field'=>'InstFinancing.FinID','name'=>'Modalità di finanziamento primaria ⮞','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID'),'wheremore'=>'InstFinancing.Pos=1','ord'=>false),
|
||||||
'Financing.Type.First'=>array('field'=>'Financing.Type','name'=>'Modalità di finanziamento primaria','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID','Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','wheremore'=>'AND InstFinancing.Pos=1','ord'=>false),
|
'Financing.Type.First'=>array('field'=>'Financing.Type','name'=>'Modalità di finanziamento primaria','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID','Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','wheremore'=>'InstFinancing.Pos=1','ord'=>false),
|
||||||
|
|
||||||
'InstPolicies.PolID'=>array('field'=>'InstPolicies.PolID','name'=>'Restrizioni sui contenuti ⮞','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID'),'ord'=>false),
|
'InstPolicies.PolID'=>array('field'=>'InstPolicies.PolID','name'=>'Restrizioni sui contenuti ⮞','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID'),'ord'=>false),
|
||||||
'Policies.Name'=>array('field'=>'Policies.Name','name'=>'Restrizioni sui contenuti','type'=>'joini','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID','Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','ord'=>true,'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'),
|
'Policies.Name'=>array('field'=>'Policies.Name','name'=>'Restrizioni sui contenuti','type'=>'joini','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID','Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','ord'=>true,'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'),
|
||||||
'InstPolicies.PolID.First'=>array('field'=>'InstPolicies.PolID','name'=>'Restrizione sui contenuti primaria ⮞','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID'),'wheremore'=>'AND InstPolicies.Pos=1','ord'=>false),
|
'InstPolicies.PolID.First'=>array('field'=>'InstPolicies.PolID','name'=>'Restrizione sui contenuti primaria ⮞','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID'),'wheremore'=>'InstPolicies.Pos=1','ord'=>false),
|
||||||
'Policies.Name.First'=>array('field'=>'Policies.Name','name'=>'Restrizione sui contenuti primaria','type'=>'joini','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID','Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','wheremore'=>'AND InstPolicies.Pos=1','ord'=>false),
|
'Policies.Name.First'=>array('field'=>'Policies.Name','name'=>'Restrizione sui contenuti primaria','type'=>'joini','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID','Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','wheremore'=>'InstPolicies.Pos=1','ord'=>false),
|
||||||
|
|
||||||
'InstTags.TagID'=>array('field'=>'InstTags.TagID','name'=>'Tags ⮞','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID'),'ord'=>false),
|
'InstTags.TagID'=>array('field'=>'InstTags.TagID','name'=>'Tags ⮞','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID'),'ord'=>false),
|
||||||
'Tags.Name'=>array('field'=>'Tags.Name','name'=>'Tags','type'=>'joini','join'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','ord'=>true,'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'),
|
'Tags.Name'=>array('field'=>'Tags.Name','name'=>'Tags','type'=>'joini','join'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','ord'=>true,'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 ⮞','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID'),'wheremore'=>'AND InstTags.Pos=1','ord'=>false),
|
'InstTags.TagID.First'=>array('field'=>'InstTags.TagID','name'=>'Tag primaria ⮞','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID'),'wheremore'=>'InstTags.Pos=1','ord'=>false),
|
||||||
'Tags.Name.First'=>array('field'=>'Tags.Name','name'=>'Tag primaria','type'=>'joini','join'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','wheremore'=>'AND InstTags.Pos=1','ord'=>false),
|
'Tags.Name.First'=>array('field'=>'Tags.Name','name'=>'Tag primaria','type'=>'joini','join'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','wheremore'=>'InstTags.Pos=1','ord'=>false),
|
||||||
|
|
||||||
|
// queste 3 qui sotto se si usano sia per ricerca sia per ordinamento e/o se si usano congiuntamente per più ricerche e/o ordinamenti, producono query un po' sporche, con ridondanza di where clause "InstActivity.Pos=1", ma viva l'ottimizzatore :))
|
||||||
|
'InstActivity.Statuses.First'=>array('field'=>'InstActivity.Statuses','name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1'),
|
||||||
|
'InstActivity.Logins.First'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1'),
|
||||||
|
'IntstActivity.Registrations.First'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1'),
|
||||||
|
|
||||||
|
/*'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),*/
|
||||||
|
|
||||||
/*'Statuses'=>array('name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','selmore'=>'MAX(Week) AS maxweek'),
|
|
||||||
'Logins'=>array('name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','selmore'=>'MAX(Week) AS maxweek'),
|
|
||||||
'Registrations'=>array('name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','selmore'=>'MAX(Week) AS maxweek'),*/
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$types=array('bool','int','time','text','join','joini');
|
$types=array('bool','int','time','text','join','joini');
|
||||||
|
@ -196,6 +202,7 @@ $jsordaddrows='';
|
||||||
$jsordsetrows='';
|
$jsordsetrows='';
|
||||||
$sels=array();
|
$sels=array();
|
||||||
$joins=array();
|
$joins=array();
|
||||||
|
$havings=array();
|
||||||
$where='';
|
$where='';
|
||||||
$order='';
|
$order='';
|
||||||
foreach ($_POST as $key=>$val) {
|
foreach ($_POST as $key=>$val) {
|
||||||
|
@ -207,19 +214,23 @@ foreach ($_POST as $key=>$val) {
|
||||||
$jssetrows.='setrow('.$i.','.json_encode($val);
|
$jssetrows.='setrow('.$i.','.json_encode($val);
|
||||||
}
|
}
|
||||||
if (preg_match('/^fieldsel-\d+$/',$key)===1 && preg_match('/^(.+):(.+):(.+)$/',$val,$buf)===1) {
|
if (preg_match('/^fieldsel-\d+$/',$key)===1 && preg_match('/^(.+):(.+):(.+)$/',$val,$buf)===1) {
|
||||||
$col=$buf[1];
|
$tagk=$buf[1];
|
||||||
$type=$buf[2];
|
$type=$buf[2];
|
||||||
$subtype=$buf[3];
|
$subtype=$buf[3];
|
||||||
if (array_key_exists($col,$cols) && in_array($type,$types)) {
|
if (array_key_exists($tagk,$cols) && in_array($type,$types)) {
|
||||||
if (array_key_exists('wheremore',$cols[$col]))
|
if (array_key_exists('wheremore',$cols[$tagk]))
|
||||||
$where.='(';
|
$where.='(';
|
||||||
$where.=$cols[$col]['field'];
|
$where.=$cols[$tagk]['field'];
|
||||||
if ($type=='join' || $type=='joini') {
|
if ($type=='join' || $type=='joini') {
|
||||||
foreach ($cols[$col]['join'] as $join) {
|
foreach ($cols[$tagk]['join'] as $join) {
|
||||||
if (!in_array($join,$joins))
|
if (!in_array($join,$joins))
|
||||||
$joins[]=$join;
|
$joins[]=$join;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (array_key_exists('havings',$cols[$tagk]) && !in_array($cols[$tagk]['havings'],$havings))
|
||||||
|
$havings[]=$cols[$tagk]['havings'];
|
||||||
|
if (array_key_exists('selmore',$cols[$tagk]) && !in_array($cols[$tagk]['selmore'],$sels))
|
||||||
|
$sels[]=$cols[$tagk]['selmore'];
|
||||||
$jssetrows.=','.json_encode($val);
|
$jssetrows.=','.json_encode($val);
|
||||||
} else {
|
} else {
|
||||||
muoribene($dbg.'<br>Dati POST corrotti.<br>Puoi <a href="instances.php">riprovare resettando i parametri</a> o <a href="index.php">tornare al login</a>.',true);
|
muoribene($dbg.'<br>Dati POST corrotti.<br>Puoi <a href="instances.php">riprovare resettando i parametri</a> o <a href="index.php">tornare al login</a>.',true);
|
||||||
|
@ -235,8 +246,8 @@ foreach ($_POST as $key=>$val) {
|
||||||
}
|
}
|
||||||
if (preg_match('/^valuesel-\d+$/',$key)===1) {
|
if (preg_match('/^valuesel-\d+$/',$key)===1) {
|
||||||
$where.=$val;
|
$where.=$val;
|
||||||
if (array_key_exists('wheremore',$cols[$col]))
|
if (array_key_exists('wheremore',$cols[$tagk]))
|
||||||
$where.=' '.$cols[$col]['wheremore'].')';
|
$where.=' AND '.$cols[$tagk]['wheremore'].')';
|
||||||
$jssetrows.=','.json_encode($val);
|
$jssetrows.=','.json_encode($val);
|
||||||
$jssetrows.=',""';
|
$jssetrows.=',""';
|
||||||
}
|
}
|
||||||
|
@ -245,8 +256,8 @@ foreach ($_POST as $key=>$val) {
|
||||||
$where.='\'%'.myesc($link,$val).'%\'';
|
$where.='\'%'.myesc($link,$val).'%\'';
|
||||||
else
|
else
|
||||||
$where.='\''.myesc($link,$val).'\'';
|
$where.='\''.myesc($link,$val).'\'';
|
||||||
if (array_key_exists('wheremore',$cols[$col]))
|
if (array_key_exists('wheremore',$cols[$tagk]))
|
||||||
$where.=' '.$cols[$col]['wheremore'].')';
|
$where.=' AND '.$cols[$tagk]['wheremore'].')';
|
||||||
$jssetrows.=',"NOMMITROVIHODETTO!"';
|
$jssetrows.=',"NOMMITROVIHODETTO!"';
|
||||||
$jssetrows.=','.json_encode($val);
|
$jssetrows.=','.json_encode($val);
|
||||||
}
|
}
|
||||||
|
@ -263,26 +274,36 @@ foreach ($_POST as $key=>$val) {
|
||||||
|
|
||||||
if (preg_match('/^ordfieldsel-\d+$/',$key)===1 && preg_match('/^(.+):(.+):(.+)$/',$val,$buf)===1) {
|
if (preg_match('/^ordfieldsel-\d+$/',$key)===1 && preg_match('/^(.+):(.+):(.+)$/',$val,$buf)===1) {
|
||||||
$ii++;
|
$ii++;
|
||||||
$col=$buf[1];
|
$tagk=$buf[1];
|
||||||
$type=$buf[2];
|
$type=$buf[2];
|
||||||
$subtype=$buf[3];
|
$subtype=$buf[3];
|
||||||
if (array_key_exists($col,$cols) && in_array($type,$types)) {
|
if (array_key_exists($tagk,$cols) && in_array($type,$types)) {
|
||||||
if (!array_key_exists('ordby',$cols[$col])) {
|
if (!array_key_exists('ordby',$cols[$tagk])) {
|
||||||
$order.=$cols[$col]['field'];
|
$order.=$cols[$tagk]['field'];
|
||||||
if ($type=='join' || $type=='joini') {
|
if ($type=='join' || $type=='joini') {
|
||||||
foreach ($cols[$col]['join'] as $join)
|
foreach ($cols[$tagk]['join'] as $join)
|
||||||
if (!in_array($join,$joins))
|
if (!in_array($join,$joins))
|
||||||
$joins[]=$join;
|
$joins[]=$join;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// qui si dà per scontato che se 'ordby' esiste esistono anche 'ordselmore' e 'ordjoin'
|
// qui si dà per scontato che se 'ordby' esiste esistono anche 'ordjoin' e 'ordselmore'
|
||||||
if (!in_array($cols[$col]['ordselmore'],$sels))
|
foreach ($cols[$tagk]['ordjoin'] as $join)
|
||||||
$sels[]=$cols[$col]['ordselmore'];
|
|
||||||
foreach ($cols[$col]['ordjoin'] as $join)
|
|
||||||
if (!in_array($join,$joins))
|
if (!in_array($join,$joins))
|
||||||
$joins[]=$join;
|
$joins[]=$join;
|
||||||
$order.=$cols[$col]['ordby'];
|
if (!in_array($cols[$tagk]['ordselmore'],$sels))
|
||||||
|
$sels[]=$cols[$tagk]['ordselmore'];
|
||||||
|
$order.=$cols[$tagk]['ordby'];
|
||||||
}
|
}
|
||||||
|
if (array_key_exists('wheremore',$cols[$tagk])) {
|
||||||
|
if ($where!='')
|
||||||
|
$where.=' AND '.$cols[$tagk]['wheremore'];
|
||||||
|
else
|
||||||
|
$where.=$cols[$tagk]['wheremore'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('havings',$cols[$tagk]) && !in_array($cols[$tagk]['havings'],$havings))
|
||||||
|
$havings[]=$cols[$tagk]['havings'];
|
||||||
|
if (array_key_exists('selmore',$cols[$tagk]) && !in_array($cols[$tagk]['selmore'],$sels))
|
||||||
|
$sels[]=$cols[$tagk]['selmore'];
|
||||||
$jsordaddrows.='ordaddrow('.$ii.',false);'.N;
|
$jsordaddrows.='ordaddrow('.$ii.',false);'.N;
|
||||||
$jsordsetrows.='ordsetrow('.$ii.','.json_encode($val);
|
$jsordsetrows.='ordsetrow('.$ii.','.json_encode($val);
|
||||||
} else {
|
} else {
|
||||||
|
@ -317,8 +338,12 @@ if (count($joins)>0)
|
||||||
$joins='LEFT JOIN '.implode(' LEFT JOIN ',$joins);
|
$joins='LEFT JOIN '.implode(' LEFT JOIN ',$joins);
|
||||||
else
|
else
|
||||||
$joins='';
|
$joins='';
|
||||||
|
if (count($havings)>0)
|
||||||
|
$havings='HAVING '.implode(' AND ',$havings);
|
||||||
|
else
|
||||||
|
$havings='';
|
||||||
|
|
||||||
$query='SELECT *, Instances.ID AS IID'.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$order.' LIMIT 50';
|
$query='SELECT *, Instances.ID AS IID'.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings.' '.$order.' LIMIT 50';
|
||||||
$dbg.='QUERONA: '.$query.'<br>'.N;
|
$dbg.='QUERONA: '.$query.'<br>'.N;
|
||||||
$tini=microtime(true);
|
$tini=microtime(true);
|
||||||
$res=mysqli_query($link,$query)
|
$res=mysqli_query($link,$query)
|
||||||
|
@ -646,6 +671,7 @@ function popusels(index,valselval) {
|
||||||
valinp.style.display='none';
|
valinp.style.display='none';
|
||||||
valinp.disabled=true;
|
valinp.disabled=true;
|
||||||
truncsel('valuesel-'+index);
|
truncsel('valuesel-'+index);
|
||||||
|
pupwait(true);
|
||||||
let xhr=new XMLHttpRequest();
|
let xhr=new XMLHttpRequest();
|
||||||
xhr.open('GET','instancesh.php?key='+key);
|
xhr.open('GET','instancesh.php?key='+key);
|
||||||
xhr.responseType='json';
|
xhr.responseType='json';
|
||||||
|
@ -657,6 +683,7 @@ function popusels(index,valselval) {
|
||||||
console.log('valsel pronto!');
|
console.log('valsel pronto!');
|
||||||
if (valselval!==false)
|
if (valselval!==false)
|
||||||
selind('valuesel-'+index,valselval);
|
selind('valuesel-'+index,valselval);
|
||||||
|
pupwait(false);
|
||||||
};
|
};
|
||||||
xhr.onerror=function() {
|
xhr.onerror=function() {
|
||||||
alert('Request failed');
|
alert('Request failed');
|
||||||
|
@ -909,6 +936,20 @@ function ckf() {
|
||||||
alerta('<p>'+emsg+'</p>');
|
alerta('<p>'+emsg+'</p>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function pupwait(on) {
|
||||||
|
var pup=document.getElementById('popup'), inpup=document.getElementById('inpopup');
|
||||||
|
if (on) {
|
||||||
|
if (pup.style.display!='table') {
|
||||||
|
inpup.innerHTML='<div class="waitbub"><img src="imgs/loading.gif"><br> <br>Caricamento in corso...</div>';
|
||||||
|
pup.style.display='table';
|
||||||
|
} else {
|
||||||
|
console.log('Sto già aspettando...');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inpup.innerHTML='<div id="popupcont">...</div>';
|
||||||
|
pup.style.display='none';
|
||||||
|
}
|
||||||
|
}
|
||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -243,6 +243,16 @@ input {
|
||||||
#inpopup {
|
#inpopup {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
#inpopup .waitbub {
|
||||||
|
background-color: black;
|
||||||
|
color: #78b1e2;
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 20px;
|
||||||
|
width: 160px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
#popupcont {
|
#popupcont {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
Loading…
Reference in a new issue