-
-
-
-
-
-
-
+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";
+ }
+
+ $html .= $this->ul(array(
+ 'Home' => '',
+ 'Logout' => '?logout',
+ 0 => $this->ul($assistants,'menu',$this->link('Assistants','#')),
+ 1 => $this->ul($insertable,'menu',$this->link('New','#')),
+ 2 => $this->ul($listable,'menu',$this->link('List','#'))
+ ),'menu', '', 'menu');
+
+ $html .= '
';
+
+ $html .= $this->form("$script/api/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
+
+$fortune
+
EOF;
+
+ return $html;
}
function internal_url($link) {
@@ -218,7 +298,53 @@ EOF;
foreach($image as $column) if(isset($table[$id][$column])) {
$type = @array_shift(preg_split('/_/', $column));
$src=URL_IMAGES."/$type/".$table[$id][$column].'.jpg';
- $table[$id][$type.'_image']=$this->img($src, $table[$id][$column]);
+ $table[$id][$type.'_image']=$this->img_link($src, $src, $table[$id][$column], false, false);
+ }
+ }
+ }
+
+ function render_barcode($barcode,$opts=false) {
+ return $this->img_link($this->internal_url("barcode/$barcode"),$this->internal_url("barcode/$barcode"),$barcode,false,false,$opts);
+ }
+
+ 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_add_relations(&$table, $class, $suffix_relations='_relations') {
+ $where_url = '%d/?where[%c]==%v';
+ $relations = array( //TODO: Autodetect???
+ 'model' => array(
+ 'model_id' => array(array('item',$where_url)),
+ 'model_barcode' => array(array('store','assistant/%d?barcode=%v')),
+ 'model_name' => array(array('google','http://google.com/search?q=%v',true)) //TODO: add manufacturer to google query
+ ),
+ '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), 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)))
+ );
+ foreach($table as $id => $row) {
+ foreach($row as $column => $value) {
+ if(isset($relations[$class][$column])) {
+ foreach($relations[$class][$column] as $destination) {
+ $destination_url = str_replace(
+ array('%d','%c','%v'),
+ array(urlencode($destination[0]),urlencode($column),urlencode($value)),
+ $destination[1]
+ );
+ @$table[$id][$class.$suffix_relations] .= $this->link($destination[0], $destination_url, !isset($destination[2])).',';
+ }
+ }
}
}
}
@@ -258,28 +384,33 @@ EOF;
$table = $table_sorted;
}
- function render_item_table($table) {
+ function table_hide_columns(&$table, $class) { //TODO: Move to build_query_select() !!! :-)))
+ $fields_hide = array(
+ 'item' => array('model_descript','model_price_in','model_price_out','model_barcode','model_countable','model_reserve','model_eshop_hide','room_descript','room_author','producer_name','producer_note','vendor_note')
+ );
+ //print_r($table); die();
+ if(isset($fields_hide[$class])) foreach($table as $id => $row) {
+ foreach($fields_hide[$class] as $field) unset($table[$id][$field]);
+ }
+ }
+
+ function render_item_table($table,$class=false) {
+ if(empty($table)) return ''.T('holy primordial emptiness is all you can find here...').'
';
$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);
}
- 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;
- if(is_array($current)) {
- $update = true;
- $current = array_shift($current);
- }
-
- if(!is_array($hidecols)) $hidecols = array('item_author', 'item_valid_from', 'item_valid_till'); //TODO Autodetect
-
- $action = $action ? " action='$action'" : false;
- $html="