Oprava google linku
[mirrors/SokoMan.git] / index.php
index 9da2fab2b99256a6859599184569f4265e4f3e4b..389587fd29c96ebdad887d7355e473313d5d2fb7 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -37,10 +37,10 @@ require_once('Fortune.php');
 class HTML {
        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>";
-               $tr="<tr$class$parameters>";
-               $html.=$tr;
+               $html.="<tr$class$parameters>";
                $td = $type == 'thead' ? 'th' : 'td';
                foreach($row as $id => $var) {
                        $tdclass = " class='cell_$id'";
@@ -48,7 +48,7 @@ class HTML {
                        $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;
+                       if(in_array($id,$break_after,true)) $html.='</tr>'."<tr$class_br$parameters>";
                }
                $html.='</tr>';
                if($type) $html.="</$type>";
@@ -129,11 +129,11 @@ class HTML {
 
                if(!is_bool($default)) {
                        $value=$default; $title=$selectbox[$value];
-                       $html .= "<option value='$value'>$value :: $title</option>";
+                       $html .= "<option value='$value'>$title (($value))</option>";
                        unset($selectbox[$value]);
                }
                foreach($selectbox as $value => $title) {
-                       $html .= "<option value='$value'>$value :: $title</option>";
+                       $html .= "<option value='$value'>$title (($value))</option>";
                }
                $html .= "</select>";
                return $html;
@@ -207,19 +207,24 @@ 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; }
+td textarea { width:100%; height:100%; }
 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; }
+.floating_barcode { margin: 5px; }
+.disabled { color: grey; }
 /* 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;
        padding: 0.2em;
@@ -369,8 +374,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) {
@@ -385,7 +390,7 @@ EOF;
                                                        //$condition = $relations_conditions[$destination[2]]($table,$id);
                                                        if(!eval($relations_conditions[$destination[2]])) continue;
                                                }
-                                               @$table[$id][$class.$suffix_relations] .= $this->link($destination[0], $destination_url).',';
+                                               @$table[$id][$class.$suffix_relations] .= $this->link($destination[0], $destination_url, false).',';
                                        }
                                }
                        }
@@ -484,16 +489,16 @@ EOF;
                        'item' => array('item_note'),
                        'model' => array('model_descript')
                );
-               $html = '';
+               $html = '<table>';
                foreach($columns as $column)    {
-                       $html.=T($class).':<b>'.T($column['Field']).'</b>: ';
+                       $html.='<tr><td>'.T($class).':<b>'.T($column['Field']).'</b>:&nbsp;</td><td>';
                        $name="values[$class][".$column['Field'].'][]';
                        $val = $update && isset($current[$column['Field']]) ? $current[$column['Field']] : false;
                        switch(true) {
                                case (preg_match('/auto_increment/', $column['Extra']) || in_array($column['Field'], $hidecols)):
                                        if(is_bool($val) && !$val) $val = '';
                                        $html.=$this->input($name, $val, 'hidden');
-                                       $html.=$val.'(AUTO)';
+                                       $html.='<span class="disabled"><i>[AUTO]</i> '.$val.'</span>';
                                        break;
                                case isset($selectbox[$column['Field']]):
                                        $html.=$this->select($name,$selectbox[$column['Field']],$val);
@@ -505,8 +510,9 @@ EOF;
                                        $html.=$this->input($name, $val);
                                        break;
                        }
-                       $html.='<br />';
+                       $html.='</td></tr>';
                }
+               $html.='</table>';
                return $html;
        }
 
@@ -722,7 +728,9 @@ class Sklad_DB extends PDO {
                        foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name];
                }
                //echo('<pre>'); print_r($selectbox);
-               return array_filter($selectbox, 'ksort');
+               //return array_filter($selectbox, 'ksort');
+               return array_filter($selectbox, 'natcasesort');
+               //array_multisort($selectbox); return $selectbox;
        }
 
        function map_unique($key, $value, $select, $table, $fatal=true) { //TODO: Guess $select and $table if not passed
@@ -874,7 +882,7 @@ class Sklad_UI {
                return $this->html->render_insert_form($class, $columns, $selectbox, $current, false, false, $multi_insert);
        }
 
-       function render_single_record_details($class, $id) {
+       function render_single_record_details($class, $id, $barcode=true) {
                $id_next = $id + 1;
                $id_prev = $id - 1 > 0 ? $id - 1 : 0;
                $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : '';
@@ -882,8 +890,8 @@ class Sklad_UI {
                $html.= $this->html->link('<<', "$class/$id_prev/");
                $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.= '&nbsp;&nbsp;&nbsp;';
+               $barcode && $html.='<span style="float:right;" class="floating_barcode">'.$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/");
                return $html;
@@ -897,19 +905,19 @@ class Sklad_UI {
                $html.= $this->html->link('<<', "$class/$id/$limit/$offset_prev/$get");
                $html.= '-';
                $html.= $this->html->link('>>', "$class/$id/$limit/$offset_next/$get");
-               $html.= '<br />';
+               $html.= '&nbsp;&nbsp;&nbsp;';
                $html.= $this->html->link('new', "$class/new/$get");
                return $html;
        }
 
-       function render_listing_extensions($class, $id, $limit, $offset, $edit=false) {
+       function render_listing_extensions($class, $id, $limit, $offset, $edit=false, $barcode=true) {
                $html='';
                if(is_numeric($id)) {
-                       $html.=$this->render_single_record_details($class, $id);
+                       $html.=$this->render_single_record_details($class, $id, $barcode);
                } else {
                        $html.=$this->render_listing_navigation($class, '*', $limit, $offset);
                }
-               if($edit)       {
+               if($edit && $barcode)   {
                        $html.= $this->render_form_edit($class, $id, false);
                        $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete";
                        $html.=$this->html->form($action,'POST',array(
@@ -1085,6 +1093,7 @@ class Sklad_UI {
                                                                $limit  = is_numeric($PATH_CHUNKS[3]) ? (int) $PATH_CHUNKS[3] : FRONTEND_LISTING_LIMIT;
                                                                $offset = isset($PATH_CHUNKS[4]) ? (int) $PATH_CHUNKS[4] : 0;
                                                                $where = @is_array($_GET['where']) ? $_GET['where'] : false;
+                                                               echo $this->render_listing_extensions($class, $id, $limit, $offset, $edit, false);
                                                                echo $this->render_items($class, $id, $limit, $offset, $where, $search, $history);
                                                                echo $this->render_listing_extensions($class, $id, $limit, $offset, $edit);
                                                                //print_r(array("<pre>",$_SERVER));
This page took 1.121977 seconds and 4 git commands to generate.