Vylepsena podpora historie v INSERT UI pro lepsi prehlednost
authorThomas Mudrunka <tomas@mudrunka.cz>
Mon, 8 Aug 2011 15:34:49 +0000 (17:34 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Tue, 9 Aug 2011 03:11:12 +0000 (05:11 +0200)
TODO
index.php

diff --git a/TODO b/TODO
index 4547bc71bfa91998d4d04d32d0dde9e8e245bcb6..3fabff19069468ff18f71926a22c647ec2784531 100644 (file)
--- 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
index 77fe93bdf7c26d7ae9ec88f1318af581e4276c57..925b0e2447bcf052b7733227ba21693bf550eebf 100755 (executable)
--- 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('<pre>'); print_r($selectbox);
                //echo('<pre>'); 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='<form method="POST">';
                if($multi_insert) $html.='<div name="input_set" style="float:left; border:1px solid grey;">';
                //$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);
This page took 0.098862 seconds and 4 git commands to generate.