+ SÅkoMan$title
-
+
+
+
+
EOF;
- }
- function row_print($row) {
- echo('');
- foreach($row as $var) {
- if(trim($var) == '') $var = ' ';
- echo("$var ");
- }
- echo(' ');
+ $assistants=array();
+ foreach(scandir(DIR_ASSISTANTS) as $item) {
+ if($item == '.' || $item == '..') continue;
+ $item = preg_replace('/\.inc\.php$/','',$item);
+ $assistants[$item] = "assistant/$item";
}
- function table_print(&$table, $params='border=1') {
- echo("");
- $header=true;
- foreach($table as $row) {
- if($header) {
- $this->row_print(array_keys($row));
- $header=false;
- }
- $this->row_print($row);
- }
- echo('
');
+ $tables=array('item','model','category','producer','vendor','room','status');
+
+ foreach($tables as $table) {
+ $listable[$table] = $table;
+ $insertable[$table] = "$table/new";
}
- function link($title='n/a', $link='#void', $internal=true) {
- if($internal) $link = $_SERVER['SCRIPT_NAME'].'/'.$link;
- return "$title ";
+ $html .= $this->ul(array(
+ 'Logout' => '?logout',
+ 'Home' => '',
+ 0 => $this->ul($assistants,'menu',$this->link('Assistants','#')),
+ 1 => $this->ul($listable,'menu',$this->link('List','#')),
+ 2 => $this->ul($insertable,'menu',$this->link('New','#'))
+ ),'menu', '', 'menu');
+
+ $html .= '';
+
+ $html .= $this->form("$script/assistant/go", 'GET', array(
+ array('q','','text','smart id...', 'autofocus'),
+ array(false,'go','submit')
+ ), 'style="float: left;"');
+
+ $html .= $this->form('?', 'GET', array(
+ array('q',$search,'text','regexp...'),
+ array(false,'filter','submit')
+ ), 'style="float: left;"');
+
+ $html .= '
';
+
+ $html .= <<
+
+
+ $message
+
+EOF;
+
+ return $html;
}
- function img($src='#void', $title='img') {
- return " ";
+ function internal_url($link) {
+ return $_SERVER['SCRIPT_NAME'].'/'.$link;
}
function table_add_images(&$table) {
@@ -96,6 +252,19 @@ EOF;
}
}
+ function render_barcode($barcode,$opts=false) {
+ return $this->link($this->img($this->internal_url("barcode/$barcode"),$barcode,$opts),"barcode/$barcode",true,false);
+ }
+
+ function table_add_barcodes(&$table) {
+ $image = array('model_barcode', 'item_serial');
+ foreach($table as $id => $row) {
+ foreach($image as $column) if(isset($table[$id][$column])) {
+ $table[$id][$column]=$this->render_barcode($table[$id][$column]);
+ }
+ }
+ }
+
function table_collapse(&$table) {
$collapse = array(
'item_id' => 'item_id',
@@ -108,7 +277,7 @@ EOF;
);
foreach($table as $id => $row) {
foreach($collapse as $link => $title)
- if(isset($table[$id][$link])) {
+ if(isset($table[$id][$link]) && isset($row[$title])) {
$type = @array_shift(preg_split('/_/', $link));
if($link != $title) unset($table[$id][$link]);
$table[$id][$title]=$this->link($row[$title], $type.'/'.$row[$link].'/');
@@ -122,48 +291,24 @@ EOF;
foreach($table as $id => $row) {
$table_sorted[$id] = array();
foreach($precedence as $column) if(isset($table[$id][$column])) {
- $table_sorted[$id][$column]=$table[$id][$column];
+ $table_sorted[$id][T($column)]=$table[$id][$column];
unset($table[$id][$column]);
}
- $table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]);
+ //$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;
}
- function print_item_table($table) {
+ function render_item_table($table) {
$this->table_add_images($table);
+ $this->table_add_barcodes($table);
$this->table_collapse($table);
$this->table_sort($table);
- return $this->table_print($table);
+ return $this->table($table);
}
- function input($name=false, $value=false, $type='text', $placeholder=false, $options=false) {
- $html = " '); print_r($selectbox);
- $html = "";
-
- if($default) {
- $value=$default; $title=$selectbox[$value];
- $html .= "$value :: $title ";
- unset($selectbox[$value]);
- }
- foreach($selectbox as $value => $title) {
- $html .= "$value :: $title ";
- }
- $html .= " ";
- return $html;
- }
-
- function print_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) {
+ function render_insert_form($class, $columns, $selectbox=array(), $current=false, $hidecols=false, $action=false, $multi_insert=true) {
//echo(''); print_r($selectbox);
//echo(''); print_r($current);
$update = false;
@@ -172,33 +317,35 @@ EOF;
$current = array_shift($current);
}
- echo('