CSS Zprehledneno
[mirrors/SokoMan.git] / index.php
index 6b5df8b9d7f95f640af0e9cd059afae5ad33a1aa..a131b22c886159f6f73e5d543a649793dcb6c4d5 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -24,6 +24,7 @@ require_once('Sklad_Auth.class/common.php');
 require_once('HTTP_Auth.class.php');
 require_once('Locale.class.php');
 require_once('Barcode.class.php');
+require_once('Fortune.php');
 
 /**
 * Trida poskytuje vseobecne funkce pro generovani HTML kodu
@@ -34,32 +35,40 @@ require_once('Barcode.class.php');
 * @author   Tomas Mudrunka
 */
 class HTML {
-       function row($row,$type=false,$class=false) {
+       function row($row,$type=false,$class=false,$parameters='',$colspan=array(),$rowspan=array(),$break_after=array()) {
                $html = '';
-               $class = $class ? $class=" class='$class' " : '';
+               $class_br = $class ? " class='$class' " : '';
+               $class = $class ? " class='$class tr_nobr' " : '';
                if($type) $html.="<$type>";
-               $html.="<tr$class>";
+               $html.="<tr$class$parameters>";
                $td = $type == 'thead' ? 'th' : 'td';
-               foreach($row as $var) {
+               foreach($row as $id => $var) {
+                       $tdclass = " class='cell_$id'";
                        if(trim($var) == '') $var = '&nbsp;';
-                       $html.="<$td>$var</$td>";
+                       $rs = isset($rowspan[$id]) ? " rowspan='$rowspan[$id]'" : '';
+                       $cs = isset($colspan[$id]) ? " colspan='$colspan[$id]'" : '';
+                       $html.="<$td$rs$cs$tdclass>$var</$td>";
+                       if(in_array($id,$break_after,true)) $html.='</tr>'."<tr$class_br$parameters>";
                }
                $html.='</tr>';
                if($type) $html.="</$type>";
                return $html;
        }
 
-       function table(&$table, $parity_class=array('tr_odd','tr_even'), $params='border=1') {
+       function table(&$table,$colspan=array(),$rowspan=array(),$break_after=array(),$parity_class=array('tr_odd','tr_even'),$params='border=1',$row_classes_field='_row_classes') {
                $html="<table $params>";
                $header=true;
                $even=false;
                foreach($table as $row) {
+                       $params = isset($row[$row_classes_field]) ? $row[$row_classes_field] : '';
+                       unset($row[$row_classes_field]);
                        if($header) {
-                               $html.=$this->row(array_keys($row),'thead');
+                               $keys = array(); foreach($row as $key => $val) $keys[$key]=$key;
+                               $html.=$this->row(T($keys),'thead',false,'',$colspan,$rowspan,$break_after);
                                $header=false;
                        }
                        $class = $parity_class ? $parity_class[$even] : false;
-                       $html.=$this->row($row,false,$class);
+                       $html.=$this->row($row,false,$class.$params,'',$colspan,$rowspan,$break_after);
                        $even = !$even;
                }
                $html.='</table>';
@@ -72,12 +81,12 @@ class HTML {
                return "<a href='$link'>".$title."</a>";
        }
 
-       function img($src='#void', $title='img', $options='width=64') {
+       function img($src='#void', $title='img', $options='height=64') {
                $options = $options ? " $options" : '';
                return "<img src='$src' alt='$title' title='$title'$options; />";
        }
 
-       function img_link($src, $link='#void', $title='img_link', $internal=true, $translate=true, $options='width=64') {
+       function img_link($src, $link='#void', $title='img_link', $internal=true, $translate=true, $options='height=64') {
                return $this->link($this->img($src,$title,$options),$link,$internal,$translate);
        }
 
@@ -180,7 +189,7 @@ class Sklad_HTML extends HTML { //TODO: Split into few more methods
                $script = $_SERVER['SCRIPT_NAME'];
                $search = htmlspecialchars(@trim($_GET['q']));
                $message = strip_tags(@trim($_GET['message']),'<a><b><u><i><br>');
-               $fortune = 'test';
+               $fortune = fortune();
                $instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : '';
                $user_id = htmlspecialchars($user['id']);
                $user_gid = htmlspecialchars($user['gid']);
@@ -198,11 +207,21 @@ class Sklad_HTML extends HTML { //TODO: Split into few more methods
 
 <style type="text/css">
 * { font-family: arial; }
-td,body { background-color: white; }
+td,body { background-color: white; border: orange; }
+.tr_nobr td { border-top: 3px solid orange; }
 table { background-color: orange; border: orange; }
 a, a img { text-decoration:none; color: darkblue; border:none; }
 li a, a:hover { text-decoration:underline; }
 .tr_even td { background-color: lemonchiffon; }
+.tr_nobr.tr_even td:first-child { border-left: 5px solid orange; }
+.tr_nobr.tr_odd td:first-child { border-left: 5px solid white; }
+.item_status_stored td { font-weight:bold; }
+.item_status_deleted td { text-decoration:line-through; }
+.item_status_destroyed td { font-style:italic; }
+/* table, table * { table-layout:fixed; width:100%; overflow:hidden; word-wrap:break-word; } */
+/* td { position:absolute; } */
+/* .cell_model_name { float:left; } */
+
 
 .menu li {
        float: left;
@@ -288,7 +307,7 @@ EOF;
 <div style="background-color:#FFDDDD;">
        <font color="red">$message</font>
 </div>
-<div style="text-align:right;">
+<div style="text-align:right; color:darkgreen;">
 $fortune
 </div>
 EOF;
@@ -324,6 +343,15 @@ EOF;
                }
        }
 
+       function table_add_row_classes(&$table, $class_col='_row_classes') {
+               $image = array('status_name' => ' item_status_');
+               foreach($table as $id => $row) {
+                       foreach($image as $column => $param) if(isset($table[$id][$column])) {
+                               @$table[$id][$class_col] .= $param.$table[$id][$column];
+                       }
+               }
+       }
+
        function table_add_relations(&$table, $class, $suffix_relations='_relations') {
                $where_url = '%d/?where[%c]==%v';
                $relations = array( //TODO: Autodetect???
@@ -344,8 +372,8 @@ EOF;
                );
                $relations_conditions=array(
                        'in_stock' => 'return(@$table[$id]["status_name"] == "stored");',
-                       'not_sold' => 'return(@$table[$id]["status_name"] != "saled");',
-                       'not_sold_or_disposed' => 'return(@$table[$id]["status_name"] != "saled" && @$table[$id]["status_name"] != "disposed");'
+                       'not_sold' => 'return(@$table[$id]["status_name"] != "sold");',
+                       'not_sold_or_disposed' => 'return(@$table[$id]["status_name"] != "sold" && @$table[$id]["status_name"] != "disposed");'
                );
                foreach($table as $id => $row) {
                        foreach($row as $column => $value) {
@@ -404,11 +432,11 @@ EOF;
                foreach($table as $id => $row) {
                        $table_sorted[$id] = array();
                        foreach($precedence as $column) if(isset($table[$id][$column])) {
-                               $table_sorted[$id][T($column)]=$table[$id][$column];
+                               $table_sorted[$id][$column]=$table[$id][$column];
                                unset($table[$id][$column]);
                        }
-                       //$table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]);
-                       foreach($table[$id] as $key => $val) $table_sorted[$id][T($key)] = $val; //array_merge with T() translating
+                       $table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]);
+                       //foreach($table[$id] as $key => $val) $table_sorted[$id][T($key)] = $val; //array_merge with T() translating
                }
                $table = $table_sorted;
        }
@@ -424,14 +452,34 @@ EOF;
        }
 
        function render_item_table($table,$class=false) {
+
+               $cellspan = array(
+                       'break_after' => array(
+                               'item' => array('category_name'),
+                               'model'=> array('model_descript')
+                       ),
+                       'rowspan' => array(
+                               'item' => array('model_image'=>2,'item_id'=>2),
+                               'model'=> array('model_image'=>2)
+                       ),
+                       'colspan' => array(
+                               'item' => array('model_name'=>6,'category_name'=>'100%'),
+                               'model'=> array('model_name'=>4,'model_descript'=>'100%')
+                       )
+               );
+
+               foreach(array_keys($cellspan) as $vari)
+                       $$vari = isset($cellspan[$vari][$class]) ? $cellspan[$vari][$class] : array();
+
                if(empty($table)) return '<h3>'.T('holy primordial emptiness is all you can find here...').'</h3><br />';
+               $this->table_add_row_classes($table);
                $this->table_add_images($table);
                if($class) $this->table_add_relations($table,$class);
                $this->table_add_barcodes($table);
                $this->table_collapse($table);
                if($class) $this->table_hide_columns($table,$class);
                $this->table_sort($table);
-               return $this->table($table);
+               return $this->table($table,$colspan,$rowspan,$break_after);
        }
 
        function render_insert_inputs($class,$columns,$selectbox,$current,$hidecols,$update) {
This page took 0.149625 seconds and 4 git commands to generate.