+ function link($title='n/a', $link='#void', $internal=true, $translate=true) {
+ if($internal && (!isset($link[0]) || $link[0] != '#')) $link = $this->internal_url($link);
+ if($translate) $title = T($title);
+ return "<a href='$link'>".$title."</a>";
+ }
+
+ function img($src='#void', $title='img', $options='height=64') {
+ if(isset($_GET['noimgs'])) return "<span title='$title'>".basename($src).'</span>';
+ $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='height=64') {
+ return $this->link($this->img($src,$title,$options),$link,$internal,$translate);
+ }
+
+ function textarea($name=false, $value='', $placeholder=false, $options=false, $prefix='') {
+ $html = T($prefix)."<textarea";
+ if($name) $html.= " name='$name'";
+ if($options) $html.= " $options";
+ if($placeholder) $html.= " placeholder='$placeholder'";
+ $html .= ">$value</textarea>";
+ return $html;
+ }
+
+ function input($name=false, $value=false, $type='text', $placeholder=false, $options=false, $prefix='') {
+ if($type == 'textarea') return $this->textarea($name, $value, $placeholder, $options, $prefix);
+ $html = T($prefix)."<input type='$type' ";
+ if($name) $html.= "name='$name' ";
+ if(!is_bool($value)) {
+ if($type == 'submit') $value = T($value);
+ $html.= "value='$value' ";
+ }
+ if($options) $html.= "$options ";
+ if($placeholder) $html.= "placeholder='$placeholder' ";
+ $html .= '/>';
+ return $html;
+ }
+
+ function form($action=false, $method=false, $inputs, $options=false) {
+ $action = $action ? " action='$action'" : '';
+ $method = $method ? " method='$method'" : '';
+ $options = $options ? " $options" : '';
+ $html = "<form$action$method$options>";
+ foreach($inputs as $input) $html .= call_user_func_array(array($this,'input'), $input);
+ $html .= "</form>";
+ return $html;
+ }
+
+ function select($name, $selectbox, $default=false) {
+ //echo('<pre>'); print_r($selectbox);
+ $html = "<select name='$name'>";
+
+ if(!is_bool($default)) {
+ $value=$default; $title=$selectbox[$value];
+ $html .= "<option value='$value'>$title (($value))</option>";
+ unset($selectbox[$value]);
+ }
+ foreach($selectbox as $value => $title) {
+ $html .= "<option value='$value'>$title (($value))</option>";
+ }
+ $html .= "</select>";
+ return $html;
+ }
+
+ function ul($items,$tag=ul,$head='',$class=false) {
+ $class = $class ? " class='$class'" : '';
+ $html = "$head<$tag$class>";
+ foreach($items as $key => $value) {
+ $html .= '<li>';
+ if(is_numeric($key)) {
+ $html .= $value;
+ } else {
+ $html .= $this->link($key,$value);
+ }
+ $html .= '</li>';
+ }
+ $html .= "</$tag>";
+ return $html;
+ }
+
+ function div($html, $options) {
+ $options = $options ? " $options" : '';
+ return "<div$options>$html</div>";
+ }
+
+ function favicon($url='/favicon.ico') {
+ return '<link rel="shortcut icon" href="'.$url.'" /><link href="'.$url.'" rel="icon" type="image/gif" />';
+
+ }
+
+ 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.= $this->favicon(dirname($_SERVER['SCRIPT_NAME']).'/favicon.ico');
+ $html.= '</head>';
+ 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 { //TODO: Split into few more methods
+ function header($title='', $user=array()) {
+ $home = URL_HOME;
+ $script = $_SERVER['SCRIPT_NAME'];
+ $search = htmlspecialchars(@trim($_GET['q']));
+ $message = strip_tags(@trim($_GET['message']),'<a><b><u><i><br>');
+ $fortune = fortune();
+ $instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : '';
+ $user_id = htmlspecialchars($user['id']);
+ $user_gid = htmlspecialchars($user['gid']);
+ $user_name = htmlspecialchars($user['name']);
+ $time = date('r');
+ //$title = T($title); //TODO
+
+ $html = $this->head("SōkoMan$title");
+ $html .= <<<EOF
+<h1 style="display: inline;"><a href="$script/">SōkoMan</a><small>$instance$title</small></h1>
+<div style="float:right; text-align:right;">
+ Logged in as <b>$user_name</b> [UID: <b>$user_id</b>; GID: <b>$user_gid</b>]<br />
+ Page loaded at $time
+</div>
+
+<style type="text/css">
+* { font-family: arial; }
+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;
+}
+
+.menu * li {
+ float: none;
+}
+
+.menu * menu {
+ position: absolute;
+ padding: 0.2em;
+}
+
+.menu, .menu * menu {
+ list-style: none;
+}
+
+.menu * menu {
+ border: 1px solid orange;
+ display: none;
+ margin: 0;
+}
+
+.menu li:hover menu, .menu li:hover {
+ display: block;
+ background-color: yellow;
+}
+
+</style>
+
+<div>
+EOF;
+
+ $assistants=array();
+ foreach(scandir(DIR_ASSISTANTS) as $item) {
+ if($item == '.' || $item == '..') continue;
+ $item = preg_replace('/\.inc\.php$/','',$item,-1,$count);
+ if($count) $assistants[$item] = "assistant/$item";
+ }
+
+ $tables=array('item','model','category','producer','vendor','room','status');
+
+ foreach($tables as $table) {
+ $listable[$table] = $table;
+ $insertable[$table] = "$table/new";