Reorganizace kodu pro generovani statistik
[mirrors/SokoMan.git] / index.php
index 18ba761eba9784cab1c3f61450456eca400a4e0f..02aa5252b21644ec018d8950ece2b365574d7289 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -34,10 +34,11 @@ require_once('Barcode.class.php');
 * @author   Tomas Mudrunka
 */
 class HTML {
-       function row($row,$type=false) {
+       function row($row,$type=false,$class=false) {
                $html = '';
+               $class = $class ? $class=" class='$class' " : '';
                if($type) $html.="<$type>";
-               $html.='<tr>';
+               $html.="<tr$class>";
                $td = $type == 'thead' ? 'th' : 'td';
                foreach($row as $var) {
                        if(trim($var) == '') $var = '&nbsp;';
@@ -48,15 +49,18 @@ class HTML {
                return $html;
        }
 
-       function table(&$table, $params='border=1') {
+       function table(&$table, $parity_class=array('tr_odd','tr_even'), $params='border=1') {
                $html="<table $params>";
                $header=true;
+               $even=false;
                foreach($table as $row) {
                        if($header) {
                                $html.=$this->row(array_keys($row),'thead');
                                $header=false;
                        }
-                       $html.=$this->row($row);
+                       $class = $parity_class ? $parity_class[$even] : false;
+                       $html.=$this->row($row,false,$class);
+                       $even = !$even;
                }
                $html.='</table>';
                return $html;
@@ -181,6 +185,7 @@ td,body { background-color: white; }
 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; }
 
 .menu li {
        float: left;
@@ -219,8 +224,8 @@ EOF;
        $assistants=array();
        foreach(scandir(DIR_ASSISTANTS) as $item) {
                if($item == '.' || $item == '..') continue;
-               $item = preg_replace('/\.inc\.php$/','',$item);
-               $assistants[$item] = "assistant/$item";
+               $item = preg_replace('/\.inc\.php$/','',$item,-1,$count);
+               if($count) $assistants[$item] = "assistant/$item";
        }
 
        $tables=array('item','model','category','producer','vendor','room','status');
@@ -302,8 +307,8 @@ EOF;
                        'item' => array(
                                'item_serial' => array(array('dispose','assistant/%d?serial=%v'),array('sell','assistant/%d?serial=%v'))
                        ),
-                       'category' => array('category_id' => array(array('item',$where_url))),
-                       'producer' => array('producer_id' => array(array('item',$where_url))),
+                       'category' => array('category_id' => array(array('item',$where_url), array('model',$where_url))),
+                       'producer' => array('producer_id' => array(array('item',$where_url), array('model',$where_url))),
                        'vendor' => array('vendor_id' => array(array('item',$where_url))),
                        'room' => array('room_id' => array(array('item',$where_url))),
                        'status' => array('status_id' => array(array('item',$where_url)))
@@ -360,6 +365,7 @@ EOF;
        }
 
        function render_item_table($table,$class=false) {
+               if(empty($table)) return '<h3>'.T('holy primordial emptiness is all you can find here...').'</h3><br />';
                $this->table_add_images($table);
                if($class) $this->table_add_relations($table,$class);
                $this->table_add_barcodes($table);
@@ -490,7 +496,8 @@ class Sklad_DB extends PDO {
                        'model' => array('category', 'producer')
                ); //TODO Autodetect using foreign keys?
                $search_fields = array(
-                       'item'  => array('item_id','item_serial','model_name','model_barcode','model_descript','producer_name','vendor_name')
+                       'item'  => array('item_id','item_serial','model_name','model_barcode','model_descript','producer_name','vendor_name'),
+                       'model' => array('model_id','model_name','model_barcode','model_descript','producer_name')
                ); //TODO Autodetect
 
                //Init
@@ -515,7 +522,7 @@ class Sklad_DB extends PDO {
 
                if($where) $sql .= 'WHERE ('.implode(') AND (', $where).")\n";
                //ORDER
-               if(!$order) $order = $class.$suffix_id;
+               if(!$order) $order = $class.$suffix_id.' DESC';
                if($this->contains_history($class)) $order .= ",${class}_valid_from DESC";
                $sql .= "ORDER BY $order\n";
                //LIMIT/OFFSET
@@ -904,6 +911,7 @@ class Sklad_UI {
                }
 
                $PATH_INFO=@trim($_SERVER[PATH_INFO]);
+               if($PATH_INFO == '' || $PATH_INFO == '/') $PATH_INFO = FRONTEND_PAGE_WELCOME;
                $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
                //Sephirot:
                if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]='';
This page took 0.148356 seconds and 4 git commands to generate.