X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=index.php;h=c2ffb64d242e70f108db455368826f2657745168;hb=ec28d06c976780c7cba78aa7d85d8d8d06095df3;hp=96bfce3262814958fda3d3c96158ea14826f6c76;hpb=10562613e3993be2741043c8e8b882319aa6da85;p=mirrors%2FSokoMan.git diff --git a/index.php b/index.php index 96bfce3..c2ffb64 100755 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ - - -

SystémSklad$title

-
- -
  • Logout
  • -
  • Home
  • -
    -
    - - -
    - -
    -EOF; - } - - function row_print($row) { - echo(''); +/** +* Trida poskytuje vseobecne funkce pro generovani HTML kodu +* +* Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)! +* +* @package HTML +* @author Tomas Mudrunka +*/ +class HTML { + function row($row) { + $html=''; foreach($row as $var) { if(trim($var) == '') $var = ' '; - echo("$var"); + $html.="$var"; } - echo(''); + $html.=''; + return $html; } - function table_print(&$table, $params='border=1') { - echo(""); + function table(&$table, $params='border=1') { + $html="
    "; $header=true; foreach($table as $row) { if($header) { - $this->row_print(array_keys($row)); + $html.=$this->row(array_keys($row)); $header=false; } - $this->row_print($row); + $html.=$this->row($row); } - echo('
    '); + $html.=''; + return $html; } function link($title='n/a', $link='#void', $internal=true) { - if($internal) $link = $_SERVER['SCRIPT_NAME'].'/'.$link; + if($internal) $link = $this->internal_url($link); return "$title"; } @@ -79,6 +63,144 @@ EOF; return "$title"; } + function input($name=false, $value=false, $type='text', $placeholder=false, $options=false) { + $html = "'); print_r($selectbox); + $html = ""; + return $html; + } +} + +/** +* Trida poskytuje podpurne funkce pro generovani HTML kodu specificke pro sklad +* +* Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)! +* +* @package Sklad_HTML +* @author Tomas Mudrunka +*/ +class Sklad_HTML extends HTML { + function header($title='') { + $home = URL_HOME; + $script = $_SERVER['SCRIPT_NAME']; + $search = htmlspecialchars(@trim($_GET['q'])); + $message = strip_tags(@trim($_GET['message']),''); + return << + + +

    SystémSklad$title

    + + + +
    + +
  • Logout
  • +
  • Home
  • +
  • Assistants + +
  • store
  • +
  • dispose
  • +
  • sell
  • +
  • ↓↓ BETA ↓↓
  • +
  • new-item
  • +
    +
  • +
  • List + +
  • item
  • +
  • model
  • +
  • category
  • +
  • producer
  • +
  • vendor
  • +
  • room
  • +
  • status
  • +
    +
  • +
  • New + +
  • item
  • +
  • model
  • +
  • category
  • +
  • producer
  • +
  • vendor
  • +
  • room
  • +
  • status
  • +
    +
  • +
    + +
    +
    + + +
    + +
    +
    +
    +
    + $message +
    +EOF; + } + + function internal_url($link) { + return $_SERVER['SCRIPT_NAME'].'/'.$link; + } + function table_add_images(&$table) { $image = array('model_id'); foreach($table as $id => $row) { @@ -124,40 +246,14 @@ EOF; $table = $table_sorted; } - function print_item_table($table) { + function render_item_table($table) { $this->table_add_images($table); $this->table_collapse($table); $this->table_sort($table); - return $this->table_print($table); - } - - function input($name=false, $value=false, $type='text', $placeholder=false, $options=false) { - $html = "table($table); } - function select($name, $selectbox, $default=false) { - //echo('
    '); print_r($selectbox);
    -		$html = "";
    -		return $html;
    -	}
    -
    -	function print_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) {
    +	function render_insert_form($class, $columns, $selectbox=array(), $current=false, $hidecols=false, $action=false, $multi_insert=true) {
     		//echo('
    '); print_r($selectbox);
     		//echo('
    '); print_r($current);
     		$update = false;
    @@ -166,33 +262,35 @@ EOF;
     			$current = array_shift($current);
     		}
     
    -		echo('
    '); - if($multi_insert) echo('
    '); - echo $this->input('table', $class, 'hidden'); + if(!is_array($hidecols)) $hidecols = array('item_author', 'item_valid_from', 'item_valid_till'); //TODO Autodetect + + $action = $action ? " action='$action'" : false; + $html=""; + if($multi_insert) $html.='
    '; + //$html.=$this->input('table', $class, 'hidden'); foreach($columns as $column) { - echo($column['Field'].': '); - $name='value:'.$column['Field'].'[]'; + $html.=$class.':'.$column['Field'].': '; + $name="values[$class][".$column['Field'].'][]'; + $val = $update && isset($current[$column['Field']]) ? $current[$column['Field']] : false; switch(true) { - case preg_match('/auto_increment/', $column['Extra']): - $val = $update ? $current[$column['Field']] : ''; //opakuje se (skoro) zbytecne - echo $this->input($name, $val, 'hidden'); - echo($val.'(AUTO)'); + case (preg_match('/auto_increment/', $column['Extra']) || in_array($column['Field'], $hidecols)): + if(!$val) $val = ''; + $html.=$this->input($name, $val, 'hidden'); + $html.=$val.'(AUTO)'; break; case isset($selectbox[$column['Field']]): - $val = $update ? $current[$column['Field']] : false; - echo $this->select($name,$selectbox[$column['Field']],$val); //opakuje se + $html.=$this->select($name,$selectbox[$column['Field']],$val); break; default: - $val = $update ? $current[$column['Field']] : false; //opakuje se - echo $this->input($name, $val); + $html.=$this->input($name, $val); break; } - echo('
    '); + $html.='
    '; } if($multi_insert) { //TODO, move to separate JS file - echo <<