From a084118b0d833341b0a70fca7f84cc7001d791a1 Mon Sep 17 00:00:00 2001 From: Thomas Mudrunka Date: Mon, 8 Aug 2011 17:34:49 +0200 Subject: [PATCH] Vylepsena podpora historie v INSERT UI pro lepsi prehlednost --- TODO | 1 + index.php | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 4547bc7..3fabff1 100644 --- a/TODO +++ b/TODO @@ -5,6 +5,7 @@ * INSERT/UPDATE to multiple tables (so brand new item can be inserted with model at once) * DB * Reference integrity + * Use INSTEAD OF triggers to maintain audit trails (currently not supported by MySQL) * UI * CSS * Templating system diff --git a/index.php b/index.php index 77fe93b..925b0e2 100755 --- a/index.php +++ b/index.php @@ -242,7 +242,7 @@ EOF; return $this->table($table); } - function render_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) { + function render_insert_form($class, $columns, $selectbox=array(), $current=false, $hidecols=false, $multi_insert=true) { //echo('
'); print_r($selectbox);
 		//echo('
'); print_r($current);
 		$update = false;
@@ -251,6 +251,8 @@ EOF;
 			$current = array_shift($current);
 		}
 
+		if(!is_array($hidecols)) $hidecols = array('item_author', 'item_valid_from', 'item_valid_till'); //TODO Autodetect
+
 		$html='
'; if($multi_insert) $html.='
'; //$html.=$this->input('table', $class, 'hidden'); @@ -259,7 +261,7 @@ EOF; $name="values[$class][".$column['Field'].'][]'; $val = $update ? $current[$column['Field']] : false; switch(true) { - case preg_match('/auto_increment/', $column['Extra']): + case (preg_match('/auto_increment/', $column['Extra']) || in_array($column['Field'], $hidecols)): if(!$val) $val = ''; $html.=$this->input($name, $val, 'hidden'); $html.=$val.'(AUTO)'; @@ -392,7 +394,8 @@ class Sklad_DB extends PDO { if(!preg_match('/'.$suffix_id.'$/', $column['Field'])) continue; $table=preg_replace('/'.$suffix_id.'$/','',$column['Field']); - $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table;"; //TODO History + $history = $this->contains_history($table) ? ' WHERE '.$table.'_valid_till=0' : ''; + $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table$history;"; $result = $this->safe_query($sql, false); if(!$result) continue; $result = $result->fetchAll(PDO::FETCH_ASSOC); -- 2.30.2