X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=index.php;h=8e702dce6ad0a18a90c5de5aff811e394ee03bc0;hb=117817be986b8b046a99e20a82182016c9016026;hp=89a221032d2c7698abdf7949fd08f5bc2be0a26c;hpb=cdfce7c291830a69e3e91aac21f75c4fd3f09448;p=mirrors%2FSokoMan.git diff --git a/index.php b/index.php index 89a2210..8e702dc 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"; } @@ -76,6 +63,133 @@ 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 + +
  • 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) { @@ -121,40 +235,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 = "'); print_r($selectbox); - $html = ""; - return $html; + return $this->table($table); } - 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, $multi_insert=true) { //echo('
    '); print_r($selectbox);
     		//echo('
    '); print_r($current);
     		$update = false;
    @@ -163,33 +251,34 @@ 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 + + $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 ? $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 <<