From 894fcbd37a517831b57602018117752d8b385853 Mon Sep 17 00:00:00 2001 From: vitalif Date: Thu, 2 Dec 2010 15:05:19 +0000 Subject: [PATCH] Slight debug of selects --- olap.php | 33 ++++++++++++++++++++++++++------ templates/default/admin_olap.tpl | 2 +- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/olap.php b/olap.php index 9a89e29..ed8686d 100644 --- a/olap.php +++ b/olap.php @@ -10,6 +10,21 @@ require_once 'lib/templating.php'; require_once 'olap_config.php'; +foreach ($_REQUEST as $k => $v) +{ + if ($v === "") + { + unset($_GET[$k]); + unset($_POST[$k]); + $modified = true; + } +} +if ($modified) +{ + header("Location: ?".http_build_query($_GET+$_POST)); + exit; +} + OLAP::execute($_REQUEST); exit; @@ -110,11 +125,11 @@ class OLAP if (substr($k, 0, 6) == 'where-') { list($t, $f) = explode('-', substr($k, 6), 2); - $fd = self::$current_src['fielddescs'][$f]; + $fd = &self::$current_src['fielddescs'][$f]; if (!$fd) { $f = str_replace('_', ' ', $f); - $fd = self::$current_src['fielddescs'][$f]; + $fd = &self::$current_src['fielddescs'][$f]; } if (!$fd || !strlen($v)) continue; @@ -124,13 +139,19 @@ class OLAP $dn = $fd['sql']; if (!$dn) $dn = $f; - $v = mysql_ecranize($v); + $ve = mysql_ecranize($v); if ($t == 'eq') - $where[] = "$dn = $v"; + { + $where[] = "$dn = $ve"; + if ($fd['options']) + foreach ($fd['options'] as &$o) + if ("$o[id]" === $v) + $o['selected'] = true; + } elseif ($t == 'ge' && $fd['le_ge']) - $where[] = "$dn >= $v"; + $where[] = "$dn >= $ve"; elseif ($t == 'le' && $fd['le_ge']) - $where[] = "$dn <= $v"; + $where[] = "$dn <= $ve"; else unset($wh[$k]); } diff --git a/templates/default/admin_olap.tpl b/templates/default/admin_olap.tpl index f19618a..7c00346 100644 --- a/templates/default/admin_olap.tpl +++ b/templates/default/admin_olap.tpl @@ -76,7 +76,7 @@