Pri generovani tabulek se nyni pouziva <thead>, vylepseni CSS - nepodtrzene linky...
[mirrors/SokoMan.git] / index.php
index db9e514f7d129b11f98af87188bbe0286dbd8ae1..5c54331a1e53f5144f62b6da2eb544a8047c613b 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -34,13 +34,17 @@ require_once('Barcode.class.php');
 * @author   Tomas Mudrunka
 */
 class HTML {
-       function row($row) {
-               $html='<tr>';
+       function row($row,$type=false) {
+               $html = '';
+               if($type) $html.="<$type>";
+               $html.='<tr>';
+               $td = $type == 'thead' ? 'th' : 'td';
                foreach($row as $var) {
                        if(trim($var) == '') $var = '&nbsp;';
-                       $html.="<td>$var</td>";
+                       $html.="<$td>$var</$td>";
                }
                $html.='</tr>';
+               if($type) $html.="</$type>";
                return $html;
        }
 
@@ -49,7 +53,7 @@ class HTML {
                $header=true;
                foreach($table as $row) {
                        if($header) {
-                               $html.=$this->row(array_keys($row));
+                               $html.=$this->row(array_keys($row),'thead');
                                $header=false;
                        }
                        $html.=$this->row($row);
@@ -128,6 +132,14 @@ class HTML {
                $options = $options ? " $options" : '';
                return "<div$options>$html</div>";
        }
+
+       function head($title=false,$charset='UTF-8',$more='') {
+               $title = $title ? "\n<title>$title</title>" : '';
+               $html= '<head>';
+               $html.= '<meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" />'.$title.$more;
+               $html.= '</head>';
+               return $html;
+       }
 }
 
 /**
@@ -146,15 +158,17 @@ class Sklad_HTML extends HTML { //TODO: Split into few more methods
                $message = strip_tags(@trim($_GET['message']),'<a><b><u><i>');
                $instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : '';
                //$title = T($title); //TODO
-               $html = <<<EOF
-<head>
-       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-       <title>SōkoMan$title</title>
-</head>
+
+               $html = $this->head("SōkoMan$title");
+               $html .= <<<EOF
 <h1><a href="$script/">SōkoMan</a><small>$instance$title</small></h1>
 
 <style type="text/css">
 * { font-family: arial; }
+td,body { background-color: white; }
+table { background-color: orange; border: orange; }
+a { text-decoration:none; color: darkblue; }
+li a, a:hover { text-decoration:underline; }
 
 .menu li {
        float: left;
@@ -205,11 +219,11 @@ EOF;
        }
 
        $html .= $this->ul(array(
-               'Logout' => '?logout',
                'Home' => '',
+               'Logout' => '?logout',
                0 => $this->ul($assistants,'menu',$this->link('Assistants','#')),
-               1 => $this->ul($listable,'menu',$this->link('List','#')),
-               2 => $this->ul($insertable,'menu',$this->link('New','#'))
+               1 => $this->ul($insertable,'menu',$this->link('New','#')),
+               2 => $this->ul($listable,'menu',$this->link('List','#'))
        ),'menu', '', 'menu');
 
        $html .= '<div style="float: right;">';
@@ -321,7 +335,7 @@ EOF;
 
                $action = $action ? " action='$action'" : false;
                $html="<form$action method='POST'>"; //TODO: use $this->form()
-               if($multi_insert) $html.='<div name="input_set" style="float:left; border:1px solid grey;">';
+               if($multi_insert) $html.='<span><div name="input_set" style="float:left; border:1px solid grey; padding: 1px; margin: 1px;">';
                //$html.=$this->input('table', $class, 'hidden');
                foreach($columns as $column)    {
                        $html.=T($class).':<b>'.T($column['Field']).'</b>: ';
@@ -343,19 +357,17 @@ EOF;
                        $html.='<br />';
                }
 
-               if($multi_insert) {
-                       //TODO, move to separate JS file
+               if($multi_insert) { //TODO, move to separate JS file
                        $html.=<<<EOF
-                       </div>
-                       <span name="input_set_next"></span><br style="clear:both" />
+                       </div></span>
+                       <br style="clear:both" />
                        <script>
                                function duplicate_element(what, where) {
-                                       document.getElementsByName(where)[0].outerHTML =
-                                               document.getElementsByName(what)[0].outerHTML
-                                               + document.getElementsByName(where)[0].outerHTML;
+                                       var node = document.getElementsByName(what)[0];
+                                       node.parentNode.appendChild(node.cloneNode(true));
                                }
                        </script>
-                       <a href='#' onClick="duplicate_element('input_set', 'input_set_next')">+</a>
+                       <a href='#' onClick="duplicate_element('input_set')">+</a>
 EOF;
                }
 
@@ -646,9 +658,9 @@ class Sklad_UI {
                $html.= '-';
                $html.= $this->html->link('>>', "$class/$id_next/");
                $html.= '<br />';
+               $html.='<span style="float:right;">'.$this->html->render_barcode(BARCODE_PREFIX.strtoupper("$class/$id")).'</span>';
                $html.= $this->html->link('edit', "$class/$id/edit/");
                if($this->db->contains_history($class)) $html.= ' ][ '.$this->html->link('history', "$class/$id/history/");
-               $html.='<br />'.$this->html->render_barcode(BARCODE_PREFIX.strtoupper("$class/$id"));
                return $html;
        }
 
@@ -838,4 +850,4 @@ class Sklad_UI {
 $sklad = new Sklad_UI();
 $sklad->process_http_request();
 
-echo("<hr/>");
+echo('<br style="clear:both;" /><hr />');
This page took 0.128093 seconds and 4 git commands to generate.