X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;ds=sidebyside;f=index.php;h=0ac7c4f003f58cfafc733d6c63df3bd360a3e846;hb=9ea191cb37aaf21d6c7b688687fce1baf4027674;hp=d47bbbc490c92802c05ac5a3c53c08f5b69d2a91;hpb=8fd613d60d58c1811bde2b73184794609784550b;p=mirrors%2FSokoMan.git diff --git a/index.php b/index.php index d47bbbc..0ac7c4f 100755 --- a/index.php +++ b/index.php @@ -255,10 +255,10 @@ class Sklad_DB extends PDO { $join = array( 'item' => array('model', 'category', 'producer', 'vendor', 'room', 'status'), 'model' => array('category', 'producer') - ); + ); //TODO Autodetect using foreign keys? $search_fields = array( 'item' => array('item_id','model_name','model_barcode','model_descript','producer_name','vendor_name') - ); + ); //TODO Autodetect //Escaping $class = $this->escape($class); @@ -294,7 +294,7 @@ class Sklad_DB extends PDO { $result = $this->query($sql); if(!$result) { $error = $this->errorInfo(); - die(trigger_error("QUERY FAILED ($error[0]): $error[2]

QUERY:\n
$sql
")); + die(trigger_error("QUERY FAILED ($error[0],$error[1]): $error[2]

QUERY:\n
$sql
")); } return $result; } @@ -320,15 +320,21 @@ class Sklad_DB extends PDO { if($class && $column['Field'] == $class.$suffix_id) continue; 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;"; + $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table;"; //TODO: tabulka nemusi obsahovat *_name!!! momentalne se to tyka jen tabulky user (a item - u ty to nevadi)! $result=$this->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC); foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name]; } //echo('
'); print_r($selectbox);
-		return $selectbox;
+		return ksort($selectbox);
+	}
+
+	function contains_history($table) {
+		$history_tables = array('item'); //TODO Autodetect
+		return in_array($table, $history_tables);
 	}
 
 	function build_query_insert($table, $values, $replace=true, $suffix_id='_id') {
+		//Escaping
 		$table = $this->escape($table);
 
 		//Get list of POSTed columns
@@ -438,7 +444,7 @@ class Sklad_UI {
 			$html.=$this->render_listing_navigation($class, '*', $limit, $offset);
 		}
 		if($edit)	{
-			$html.='
TODO UPDATE FORM!
'; + $html.='
TODO UPDATE FORM!
'; //TODO: Asi uz je hotovy... $html.= $this->render_form_edit($class, $id); $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete"; $html.= "
";