Fix indentace
[mirrors/SokoMan.git] / index.php
1 <?php
2 /*
3 * SkladovySystem - Storage management system compatible with LMS
4 * Copyright (C) 2011 Tomas Mudrunka
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 require_once('sklad.conf.php');
21 set_include_path(DIR_LIB.PATH_SEPARATOR.get_include_path());
22
23 require_once('Sklad_Auth.class/common.php');
24 require_once('HTTP_Auth.class.php');
25 require_once('Locale.class.php');
26 require_once('Barcode.class.php');
27 require_once('Fortune.php');
28
29 /**
30 * Trida poskytuje vseobecne funkce pro generovani HTML kodu
31 *
32 * Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)!
33 *
34 * @package HTML
35 * @author Tomas Mudrunka
36 */
37 class HTML {
38 function row($row,$type=false,$class=false,$parameters='',$colspan=array(),$rowspan=array(),$break_after=array()) {
39 $html = '';
40 $class_br = $class ? " class='$class' " : '';
41 $class = $class ? " class='$class tr_nobr' " : '';
42 if($type) $html.="<$type>";
43 $html.="<tr$class$parameters>";
44 $td = $type == 'thead' ? 'th' : 'td';
45 foreach($row as $id => $var) {
46 $tdclass = " class='cell_$id'";
47 if(trim($var) == '') $var = '&nbsp;';
48 $rs = isset($rowspan[$id]) ? " rowspan='$rowspan[$id]'" : '';
49 $cs = isset($colspan[$id]) ? " colspan='$colspan[$id]'" : '';
50 $html.="<$td$rs$cs$tdclass>$var</$td>";
51 if(in_array($id,$break_after,true)) $html.='</tr>'."<tr$class_br$parameters>";
52 }
53 $html.='</tr>';
54 if($type) $html.="</$type>";
55 return $html;
56 }
57
58 function table(&$table,$colspan=array(),$rowspan=array(),$break_after=array(),$parity_class=array('tr_odd','tr_even'),$params='border=1',$row_classes_field='_row_classes') {
59 $html="<table $params>";
60 $header=true;
61 $even=false;
62 foreach($table as $row) {
63 $params = isset($row[$row_classes_field]) ? $row[$row_classes_field] : '';
64 unset($row[$row_classes_field]);
65 if($header) {
66 $keys = array(); foreach($row as $key => $val) $keys[$key]=$key;
67 $html.=$this->row(T($keys),'thead',false,'',$colspan,$rowspan,$break_after);
68 $header=false;
69 }
70 $class = $parity_class ? $parity_class[$even] : false;
71 $html.=$this->row($row,false,$class.$params,'',$colspan,$rowspan,$break_after);
72 $even = !$even;
73 }
74 $html.='</table>';
75 return $html;
76 }
77
78 function link($title='n/a', $link='#void', $internal=true, $translate=true) {
79 if($internal && (!isset($link[0]) || $link[0] != '#')) $link = $this->internal_url($link);
80 if($translate) $title = T($title);
81 return "<a href='$link'>".$title."</a>";
82 }
83
84 function img($src='#void', $title='img', $options='height=64') {
85 if(isset($_GET['noimgs'])) return "<span title='$title'>".basename($src).'</span>';
86 $options = $options ? " $options" : '';
87 return "<img src='$src' alt='$title' title='$title'$options; />";
88 }
89
90 function img_link($src, $link='#void', $title='img_link', $internal=true, $translate=true, $options='height=64') {
91 return $this->link($this->img($src,$title,$options),$link,$internal,$translate);
92 }
93
94 function textarea($name=false, $value='', $placeholder=false, $options=false, $prefix='') {
95 $html = T($prefix)."<textarea";
96 if($name) $html.= " name='$name'";
97 if($options) $html.= " $options";
98 if($placeholder) $html.= " placeholder='$placeholder'";
99 $html .= ">$value</textarea>";
100 return $html;
101 }
102
103 function input($name=false, $value=false, $type='text', $placeholder=false, $options=false, $prefix='') {
104 if($type == 'textarea') return $this->textarea($name, $value, $placeholder, $options, $prefix);
105 $html = T($prefix)."<input type='$type' ";
106 if($name) $html.= "name='$name' ";
107 if(!is_bool($value)) {
108 if($type == 'submit') $value = T($value);
109 $html.= "value='$value' ";
110 }
111 if($options) $html.= "$options ";
112 if($placeholder) $html.= "placeholder='$placeholder' ";
113 $html .= '/>';
114 return $html;
115 }
116
117 function form($action=false, $method=false, $inputs, $options=false) {
118 $action = $action ? " action='$action'" : '';
119 $method = $method ? " method='$method'" : '';
120 $options = $options ? " $options" : '';
121 $html = "<form$action$method$options>";
122 foreach($inputs as $input) $html .= call_user_func_array(array($this,'input'), $input);
123 $html .= "</form>";
124 return $html;
125 }
126
127 function select($name, $selectbox, $default=false) {
128 //echo('<pre>'); print_r($selectbox);
129 $html = "<select name='$name'>";
130
131 if(!is_bool($default)) {
132 $value=$default; $title=$selectbox[$value];
133 $html .= "<option value='$value'>$title (($value))</option>";
134 unset($selectbox[$value]);
135 }
136 foreach($selectbox as $value => $title) {
137 $html .= "<option value='$value'>$title (($value))</option>";
138 }
139 $html .= "</select>";
140 return $html;
141 }
142
143 function ul($items,$tag=ul,$head='',$class=false) {
144 $class = $class ? " class='$class'" : '';
145 $html = "$head<$tag$class>";
146 foreach($items as $key => $value) {
147 $html .= '<li>';
148 if(is_numeric($key)) {
149 $html .= $value;
150 } else {
151 $html .= $this->link($key,$value);
152 }
153 $html .= '</li>';
154 }
155 $html .= "</$tag>";
156 return $html;
157 }
158
159 function div($html, $options) {
160 $options = $options ? " $options" : '';
161 return "<div$options>$html</div>";
162 }
163
164 function favicon($url='/favicon.ico') {
165 return '<link rel="shortcut icon" href="'.$url.'" /><link href="'.$url.'" rel="icon" type="image/gif" />';
166
167 }
168
169 function head($title=false,$charset='UTF-8',$more='') {
170 $title = $title ? "\n<title>$title</title>" : '';
171 $html= '<head>';
172 $html.= '<meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" />'.$title.$more;
173 $html.= $this->favicon(dirname($_SERVER['SCRIPT_NAME']).'/favicon.ico');
174 $html.= '</head>';
175 return $html;
176 }
177 }
178
179 /**
180 * Trida poskytuje podpurne funkce pro generovani HTML kodu specificke pro sklad
181 *
182 * Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)!
183 *
184 * @package Sklad_HTML
185 * @author Tomas Mudrunka
186 */
187 class Sklad_HTML extends HTML { //TODO: Split into few more methods
188 function header($title='', $user=array(), $headerhtml) {
189 $home = URL_HOME;
190 $script = $_SERVER['SCRIPT_NAME'];
191 $search = htmlspecialchars(@trim($_GET['q']));
192 $message = strip_tags(@trim($_GET['message']),'<a><b><u><i><br>');
193 $fortune = fortune();
194 $instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : '';
195 $user_id = htmlspecialchars($user['id']);
196 $user_gid = htmlspecialchars($user['gid']);
197 $user_name = htmlspecialchars($user['name']);
198 $time = date('r');
199 //$title = T($title); //TODO
200
201 $html = $this->head("SōkoMan$title");
202 $html .= <<<EOF
203 <h1 style="display: inline;"><a href="$script/">SōkoMan</a><small>$instance$title</small></h1>
204 <div style="float:right; text-align:right;">
205 Logged in as <b>$user_name</b> [UID: <b>$user_id</b>; GID: <b>$user_gid</b>]<br />
206 Page loaded at $time
207 </div>
208
209 <style type="text/css">
210 * { font-family: arial; }
211 td,body { background-color: white; border: orange; }
212 .tr_nobr td { border-top: 3px solid orange; }
213 table { background-color: orange; border: orange; }
214 td textarea { width:100%; height:100%; }
215 a, a img { text-decoration:none; color: darkblue; border:none; }
216 li a, a:hover { text-decoration:underline; }
217 .tr_even td { background-color: lemonchiffon; }
218 .tr_nobr.tr_even td:first-child { border-left: 5px solid orange; }
219 .tr_nobr.tr_odd td:first-child { border-left: 5px solid white; }
220 .item_status_stored td { font-weight:bold; }
221 .item_status_deleted td { text-decoration:line-through; }
222 .item_status_destroyed td { font-style:italic; }
223 .floating_barcode { margin: 5px; }
224 .disabled { color: grey; }
225 /* table, table * { table-layout:fixed; width:100%; overflow:hidden; word-wrap:break-word; } */
226 /* td { position:absolute; } */
227 /* .cell_model_name { float:left; } */
228
229 .menu li {
230 float: left;
231 padding: 0.2em;
232 }
233
234 .menu * li {
235 float: none;
236 }
237
238 .menu * menu {
239 position: absolute;
240 padding: 0.2em;
241 }
242
243 .menu, .menu * menu {
244 list-style: none;
245 }
246
247 .menu * menu {
248 border: 1px solid orange;
249 display: none;
250 margin: 0;
251 }
252
253 .menu li:hover menu, .menu li:hover {
254 display: block;
255 background-color: yellow;
256 }
257
258 </style>
259
260 <div>
261 EOF;
262
263 $assistants=array();
264 foreach(scandir(DIR_ASSISTANTS) as $item) {
265 if($item == '.' || $item == '..') continue;
266 $item = preg_replace('/\.inc\.php$/','',$item,-1,$count);
267 if($count) $assistants[$item] = "assistant/$item";
268 }
269
270 $tables=array('item','barcode','model','category','producer','vendor','room','status','location');
271
272 foreach($tables as $table) {
273 $listable[$table] = $table;
274 $insertable[$table] = "$table/new";
275 }
276
277 $html .= $this->ul(array(
278 'Home' => '',
279 'Logout' => '?logout',
280 0 => $this->ul($assistants,'menu',$this->link('Assistants','#')),
281 1 => $this->ul($insertable,'menu',$this->link('New','#')),
282 2 => $this->ul($listable,'menu',$this->link('List','#'))
283 ),'menu', '', 'menu');
284
285 $html .= '<div style="float: right;">';
286
287 /*
288 //TODO: Do we really need this?
289 $html .= $this->form("$script/api/go", 'GET', array(
290 array('q','','text','smart id...', 'autofocus'),
291 array(false,'go','submit')
292 ), 'style="float: left;"');
293 */
294
295 $html .= $this->form('?', 'GET', array(
296 array('q',$search,'text','regexp...'),
297 array(false,'filter','submit')
298 ), 'style="float: left;"');
299
300 $html .= $this->form("$script/item", 'GET', array(
301 array('q',$search,'text','regexp...','autofocus'),
302 array(false,'search','submit')
303 ), 'style="float: left;"');
304
305 $html .= '</div>';
306
307 $html .= <<<EOF
308 </div>
309 <hr style="clear: both;" />
310 <div style="background-color:#FFDDDD;">
311 <font color="red">$headerhtml $message</font>
312 </div>
313 <div style="text-align:right; color:darkgreen;">
314 $fortune
315 </div>
316 EOF;
317
318 return $html;
319 }
320
321 function internal_url($link) {
322 return $_SERVER['SCRIPT_NAME'].'/'.$link;
323 }
324
325 function table_add_images(&$table) {
326 $image = array('model_id');
327 foreach($table as $id => $row) {
328 foreach($image as $column) if(isset($table[$id][$column])) {
329 $type = @array_shift(preg_split('/_/', $column));
330 $src=URL_IMAGES."/$type/".$table[$id][$column].'.jpg';
331 $table[$id][$type.'_image']=$this->img_link($src, $src, $table[$id][$column], false, false);
332 }
333 }
334 }
335
336 function render_barcode($barcode,$opts=false) {
337 return $this->img_link($this->internal_url("barcodeimg/$barcode"),$this->internal_url("barcodeimg/$barcode"),$barcode,false,false,$opts);
338 }
339
340 function table_add_barcodes(&$table) {
341 $image = array('barcode_name', 'model_barcode', 'item_serial');
342 foreach($table as $id => $row) {
343 foreach($image as $column) if(isset($table[$id][$column])) {
344 $table[$id][$column]=$this->render_barcode($table[$id][$column]);
345 }
346 }
347 }
348
349 function table_add_row_classes(&$table, $class_col='_row_classes') {
350 $image = array('status_name' => ' item_status_');
351 foreach($table as $id => $row) {
352 foreach($image as $column => $param) if(isset($table[$id][$column])) {
353 @$table[$id][$class_col] .= $param.$table[$id][$column];
354 }
355 }
356 }
357
358 function table_add_relations(&$table, $class, $suffix_relations='_relations') {
359 $where_url = '%d/?where[%c]==%v';
360 $insert_url = '%d/new?insert[%c]=%v';
361 $relations = array( //TODO: Autodetect??? //TODO: Add [edit] link to all classes
362 'model' => array(
363 'model_id' => array(array('item',$where_url),array('barcode',$where_url),array('edit','model/%v/edit/'),array('barcode',$insert_url)),
364 'model_barcode' => array(array('store','assistant/%d?barcode=%v')),
365 'barcode_name' => array(array('store','assistant/%d?barcode=%v')),
366 'model_name' => array(array('google','http://google.com/search?q=%v')) //TODO: add manufacturer to google query
367 ),
368 'barcode' => array(
369 'model_id' => array(array('model',$where_url)),
370 'barcode_id' => array(array('item',$where_url),array('edit','barcode/%v/edit/')),
371 'barcode_name' => array(array('store','assistant/%d?barcode=%v')),
372 ),
373 'item' => array(
374 'item_serial' => array(array('dispose','assistant/%d?serial=%v','in_stock'),array('sell','assistant/%d?serial=%v','in_stock')),
375 'item_id' => array(array('edit','item/%v/edit/'))
376 ),
377 'category' => array('category_id' => array(array('item',$where_url), array('model',$where_url))),
378 'producer' => array('producer_id' => array(array('item',$where_url), array('model',$where_url))),
379 'vendor' => array('vendor_id' => array(array('item',$where_url))),
380 'room' => array('room_id' => array(array('item',$where_url))),
381 'status' => array('status_id' => array(array('item',$where_url))),
382 'location' => array(
383 'location_id' => array(array('item',$where_url),array('edit','location/%v/edit/')),
384 'location_name' => array(array('smokeping','http://tartarus.brevnov.czf/cgi-bin/smokeping.cgi?filter=%v'))
385 )
386 );
387 $relations_conditions=array(
388 'in_stock' => 'return(@$table[$id]["status_name"] == "stored");',
389 'not_sold' => 'return(@$table[$id]["status_name"] != "sold");',
390 'not_sold_or_disposed' => 'return(@$table[$id]["status_name"] != "sold" && @$table[$id]["status_name"] != "disposed");'
391 );
392 foreach($table as $id => $row) {
393 foreach($row as $column => $value) {
394 if(isset($relations[$class][$column])) {
395 foreach($relations[$class][$column] as $destination) {
396 $destination_url = str_replace(
397 array('%d','%c','%v'),
398 array(urlencode($destination[0]),urlencode($column),urlencode($value)),
399 $destination[1]
400 );
401 if(isset($destination[2]) && isset($relations_conditions[$destination[2]])) {
402 //$condition = $relations_conditions[$destination[2]]($table,$id);
403 if(!eval($relations_conditions[$destination[2]])) continue;
404 }
405 @$table[$id][$class.$suffix_relations] .= $this->link($destination[0], $destination_url, !preg_match('/http/', $destination_url) ).',';
406 }
407 }
408 }
409 }
410 }
411
412 function table_collapse(&$table) {
413 $collapse = array(
414 'item_id' => 'item_id',
415 'model_id' => 'model_name',
416 'category_id' => 'category_name',
417 'producer_id' => 'producer_name',
418 'vendor_id' => 'vendor_name',
419 'room_id' => 'room_name',
420 'location_id' => 'location_name',
421 'status_id' => 'status_name',
422 'item_author' => 'item_author_backend',
423 'item_customer' => 'item_customer',
424 'lock_id' => 'lock_name',
425 );
426
427 foreach($table as $id => $row) {
428 foreach($collapse as $link => $title)
429 if(isset($table[$id][$link]) && isset($row[$title])) {
430 $type = @array_shift(preg_split('/_/', $link));
431 if($link != $title) unset($table[$id][$link]);
432 switch($link) { //TODO: Move to array for easy configuration
433 case 'item_author':
434 case 'item_customer':
435 $table[$id][$title]=$this->link($row[$title], "?where[$link]==".$row[$link], false);
436 break;
437 default:
438 $table[$id][$title]=$this->link($row[$title], $type.'/'.$row[$link].'/');
439 break;
440 }
441 }
442 }
443 }
444
445 function table_sort(&$table) {
446 $precedence = array('item_id', 'model_image', 'model_name','model_descript','category_name','status_name','room_name','item_quantity','item_price_in','item_price_out','model_price_in','model_price_out','item_relations','model_relations');
447 $table_sorted = array();
448 foreach($table as $id => $row) {
449 $table_sorted[$id] = array();
450 foreach($precedence as $column) if(isset($table[$id][$column])) {
451 $table_sorted[$id][$column]=$table[$id][$column];
452 unset($table[$id][$column]);
453 }
454 $table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]);
455 //foreach($table[$id] as $key => $val) $table_sorted[$id][T($key)] = $val; //array_merge with T() translating
456 }
457 $table = $table_sorted;
458 }
459
460 function table_hide_columns(&$table, $class) { //TODO: Move to build_query_select() !!! :-)))
461 $fields_hide = array(
462 'model' => array('barcode_name'),
463 'barcode' => array('model_price_in','model_price_out','model_reserve','producer_name','producer_note','model_eshop_hide','category_name','model_countable','model_descript'),
464 'item' => array('model_descript','model_price_in','model_price_out','barcode_name','model_barcode','model_countable','model_reserve','model_eshop_hide','room_descript','room_author','producer_name','producer_note','vendor_note','location_author','location_gps','location_description')
465 );
466 //print_r($table); die();
467 if(isset($fields_hide[$class])) foreach($table as $id => $row) {
468 foreach($fields_hide[$class] as $field) unset($table[$id][$field]);
469 }
470 }
471
472 function render_item_table($table,$class=false) {
473
474 $cellspan = array(
475 'break_after' => array(
476 'item' => array('category_name'),
477 'model'=> array('model_descript')
478 ),
479 'rowspan' => array(
480 'item' => array('model_image'=>2,'item_id'=>2),
481 'model'=> array('model_image'=>2)
482 ),
483 'colspan' => array(
484 'item' => array('model_name'=>6,'category_name'=>'100%'),
485 'model'=> array('model_name'=>4,'model_descript'=>'100%')
486 )
487 );
488
489 foreach(array_keys($cellspan) as $vari)
490 $$vari = isset($cellspan[$vari][$class]) ? $cellspan[$vari][$class] : array();
491
492 if(empty($table)) return '<h3>'.T('holy primordial emptiness is all you can find here...').'</h3><br />';
493 $this->table_add_row_classes($table);
494 $this->table_add_images($table);
495 if($class) $this->table_add_relations($table,$class);
496 $this->table_add_barcodes($table);
497 $this->table_collapse($table);
498 if($class) $this->table_hide_columns($table,$class);
499 $this->table_sort($table);
500 return $this->table($table,$colspan,$rowspan,$break_after);
501 }
502
503 function render_insert_inputs($class,$columns,$selectbox,$current,$hidecols,$update) {
504 $textarea = array(
505 'item' => array('item_note'),
506 'model' => array('model_descript')
507 );
508 $html = '<table>';
509 $even=false;
510 foreach($columns as $column) {
511 $html.='<tr class="'. ($even ? 'tr_even' : 'tr_odd') .'"><td>'.T($class).':<b>'.T($column['Field']).'</b>:&nbsp;</td><td>';
512 $even = !$even;
513 $name="values[$class][".$column['Field'].'][]';
514 $val = $update && isset($current[$column['Field']]) ? $current[$column['Field']] : false;
515 switch(true) {
516 case (preg_match('/auto_increment/', $column['Extra']) || in_array($column['Field'], $hidecols)):
517 if(is_bool($val) && !$val) $val = '';
518 $html.=$this->input($name, $val, 'hidden');
519 $html.='<span class="disabled"><i>[AUTO]</i> '.$val.'</span>';
520 break;
521 case isset($selectbox[$column['Field']]):
522 $html.=$this->select($name,$selectbox[$column['Field']],$val);
523 break;
524 case isset($textarea[$class]) && in_array($column['Field'],$textarea[$class]):
525 $html.=$this->input($name, $val, 'textarea');
526 break;
527 default:
528 $html.=$this->input($name, $val);
529 break;
530 }
531 $html.='</td></tr>';
532 }
533 $html.='</table>';
534 return $html;
535 }
536
537 function render_insert_form_multi($array) {
538 $html = '';
539 $head=false;
540
541 foreach($array as $key => $args) {
542 $parts=array('inputs');
543 if(!$head) { $head = true;
544 $parts[]='head';
545 }
546 if(!isset($array[$key+1])) {
547 $parts[]='foot';
548 $hr = '';
549 } else $hr = '<hr />';
550 //$args[] = false;
551 $args[] = $parts;
552
553 $html .= call_user_func_array(array($this, 'render_insert_form'), $args);
554 $html .= $hr;
555 }
556 return $html;
557 }
558
559 function render_insert_form($class, $columns, $selectbox=array(), $current=false, $hidecols=false, $action=false, $multi_insert=true, $parts=false) {
560 $html = '';
561 //print_r($parts);
562 //echo('<pre>'); print_r($selectbox);
563 //echo('<pre>'); print_r($current);
564 $update = false;
565 $current_new=array();
566 if(is_array($current)) {
567 $update = true;
568 $current_new = array_merge($current_new,array_shift($current));
569 }
570 if(isset($_GET['insert']) && is_array($_GET['insert'])) {
571 $update = true;
572 $current_new = array_merge($current_new,$_GET['insert']);
573 }
574
575 if(!is_array($hidecols)) $hidecols = array();
576 $hidecols = array_merge($hidecols, array('item_author', 'item_valid_from', 'item_valid_till')); //TODO Autodetect
577
578 if(!is_array($parts) || in_array('head', $parts)) {
579 $action = $action ? " action='$action'" : false;
580 $html.="<form$action method='POST'>"; //TODO: use $this->form()
581 $html.='<span><div name="input_set" style="float:left; border:1px solid grey; padding: 1px; margin: 1px;">';
582 }
583
584 if(!is_array($parts) || in_array('inputs', $parts))
585 $html.=$this->render_insert_inputs($class,$columns,$selectbox,$current_new,$hidecols,$update);
586
587 if(!is_array($parts) || in_array('foot', $parts)) {
588 $html .= '</div></span><br style="clear:both" />';
589 if($multi_insert) { //TODO, move to separate JS file
590 $html.=<<<EOF
591 <script>
592 function duplicate_element(what, where) {
593 var node = document.getElementsByName(what)[0];
594 node.parentNode.appendChild(node.cloneNode(true));
595 }
596 </script>
597 <a href='#' onClick="duplicate_element('input_set')">+</a>
598 EOF;
599 }
600
601 $btn = count($current_new)>0 ? 'UPDATE' : 'INSERT'; //TODO: $current may be set even when inserting...
602 $html.=$this->input(false, $btn, 'submit');
603 $html.='</form>';
604 }
605 return $html;
606 }
607 }
608
609 /**
610 * Trida poskytuje rozhrani k databazi skladu
611 *
612 * @package Sklad_DB
613 * @author Tomas Mudrunka
614 */
615 class Sklad_DB extends PDO {
616 function __construct() {
617 $this->auth = new Sklad_Auth();
618
619 parent::__construct(
620 DB_DSN, DB_USER, DB_PASS,
621 array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") //Force UTF8 for MySQL
622 );
623 }
624
625 function escape($str) {
626 return preg_replace('(^.|.$)', '', $this->quote($str)); //TODO HACK
627 }
628
629 function quote_identifier($str) {
630 return '`'.$this->escape($str).'`'; //TODO HACK
631 }
632
633 function build_query_select($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $order=false, $suffix_id='_id') {
634 //Configuration
635 $join = array(
636 'barcode' => array('model', 'category', 'producer'),
637 'item' => array('barcode', 'model', 'category', 'producer', 'vendor', 'room', 'location', 'status'),
638 'model' => array('category', 'producer')
639 ); //TODO Autodetect using foreign keys?
640 $join2 = array(
641 'model' => array('barcode'=>'model_id')
642 );
643 $fields_search = array(
644 'item' => array('item_id','item_serial','model_name','barcode_name','model_barcode','model_descript','producer_name','vendor_name'),
645 'model' => array('model_id','model_name','barcode_name','model_barcode','model_descript','producer_name')
646 ); //TODO Autodetect
647 $group_concat = array(
648 'model' => array('barcode_name'=>'model_id')
649 );
650
651 //Init
652 if(is_array($where)) foreach($where as $key => $value) $where[$key] = $key.' '.$value; //TODO: escape SQLi!!!
653
654 //Escaping
655 $class = $this->escape($class);
656
657 //GROUP_CONCAT
658 $group_concat_query = '';
659 $group_by = '';
660 if(isset($group_concat[$class])) foreach($group_concat[$class] as $gc => $gb) {
661 $group_concat_query .= ",group_concat($gc separator ', ')";
662 $group_by .= "GROUP BY $gb\n";
663 }
664
665 //SELECT
666 $sql="SELECT *$group_concat_query FROM `$class`\n";
667 //JOIN
668 if(isset($join[$class])) foreach($join[$class] as $j) $sql .= "LEFT JOIN `$j` USING($j$suffix_id)\n";
669 if(isset($join2[$class])) foreach($join2[$class] as $j => $c) $sql .= "LEFT JOIN `$j` USING($c)\n";
670 //WHERE/REGEXP
671 if($search) {
672 $search = $this->quote($search);
673 if(!isset($fields_search[$class])) die(trigger_error(T("Can't search in $class table yet :-("))); //TODO: post_redirect_get
674 $sql_search = '';
675 foreach($fields_search[$class] as $column) $sql_search .= "OR $column REGEXP $search ";
676 $where[] = "FALSE $sql_search";
677 } elseif($id) $where[] = "$class$suffix_id = $id";
678 if(!$history && $this->contains_history($class)) $where[] = $class.'_valid_till=0';
679
680 if($where) $sql .= 'WHERE ('.implode(') AND (', $where).")\n";
681
682 //GROUP BY
683 $sql.=$group_by;
684
685 //ORDER
686 if(!$order) $order = $class.$suffix_id.' DESC';
687 if($this->contains_history($class)) $order .= ",${class}_valid_from DESC";
688 $sql .= "ORDER BY $order\n";
689 //LIMIT/OFFSET
690 if($limit) {
691 $limit = $this->escape((int)$limit);
692 $offset = $this->escape((int)$offset);
693 $sql .= "LIMIT $offset,$limit\n";
694 }
695
696 return $sql;
697 }
698
699 function safe_query($sql, $fatal=true) {
700 $result = $this->query($sql);
701 if(!$result) {
702 $error = $this->errorInfo();
703 trigger_error("<font color=red><b>QUERY FAILED ($error[0],$error[1]): </b>$error[2]<br /><br /><b>QUERY:</b>\n<pre>$sql</pre></font>");
704 if($fatal) die();
705 }
706 return $result;
707 }
708
709 function translate_query_results(&$result) {
710 $translate_cols = array('item_valid_till'); //TODO: Hardcoded
711 foreach($result as $key => $row) {
712 foreach($translate_cols as $col) if(isset($result[$key][$col])){
713 $result[$key][$col] = T($result[$key][$col]);
714 }
715 }
716 }
717
718 function load_backend_data_to_query_results(&$result,$suffix_backend='_backend') {
719 $translate_cols = array(
720 'item_author' => 'return($this->auth->get_username_by_id($result[$key][$col]));'
721 ); //TODO: Hardcoded
722 foreach($result as $key => $row) {
723 foreach($translate_cols as $col => $backend) if(isset($result[$key][$col])){
724 $result[$key][$col.$suffix_backend] = eval($backend);
725 }
726 }
727 }
728
729 function safe_query_fetch($sql, $fatal=true, $fetch_flags = PDO::FETCH_ASSOC, $translate=true) {
730 $result = $this->safe_query($sql, $fatal)->fetchAll($fetch_flags);
731 $this->load_backend_data_to_query_results($result);
732 if($translate) $this->translate_query_results($result);
733 return $result;
734 }
735
736 function get_listing($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $indexed=array(), $suffix_id='_id') {
737 $sql = $this->build_query_select($class, $id, $limit, $offset, $where, $search, $history);
738 $result = $this->safe_query_fetch($sql);
739 if(!$result || !is_array($indexed)) return $result;
740
741 foreach($result as $key => $row) $indexed[$row[$class.$suffix_id]]=$row;
742 return $indexed;
743 }
744
745 function get_columns($class,$disable_cols=array()) { //TODO: Not sure if compatible with non-MySQL DBs
746 $class = $this->escape($class);
747 $sql = "SHOW COLUMNS FROM `$class`;";
748 $columns = $this->safe_query_fetch($sql);
749 /*foreach($columns as $colk => $col) foreach($col as $key => $val) {
750 if(in_array($col['Field'],$disable_cols)) $columns[$colk]['Extra']='auto_increment';
751 }*/
752 return $columns;
753 }
754
755 function columns_get_selectbox($columns, $class=false, $suffix_id='_id', $suffix_name='_name') {
756 $selectbox=array( //TODO: Hardcoded...
757 'model_countable' => array(0 => 'no', 1 => 'yes'),
758 'model_eshop_hide' => array(0 => 'no', 1 => 'yes'),
759 'vendor_id' => array('COMPULSORY' => 'select...')
760 );
761 foreach($columns as $column) {
762 if($column['Field'] == 'user_id') continue; //TODO HACK Blacklist: tabulka nemusi obsahovat *_name!!! momentalne se to tyka jen tabulky user (a item - u ty to nevadi)!
763 if($class && $column['Field'] == $class.$suffix_id) continue;
764 if(!preg_match('/'.$suffix_id.'$/', $column['Field'])) continue;
765 $table=preg_replace('/'.$suffix_id.'$/','',$column['Field']);
766
767 $history = $this->contains_history($table) ? " WHERE ${table}_valid_till=0" : '';
768 $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table$history;"; //TODO use build_query_select()!!!
769 $result = $this->safe_query_fetch($sql, false);
770 if(!$result) continue;
771 foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name];
772 }
773 //echo('<pre>'); print_r($selectbox);
774 //return array_filter($selectbox, 'ksort');
775 return array_filter($selectbox, 'natcasesort');
776 //array_multisort($selectbox); return $selectbox;
777 }
778
779 function map_unique($key, $value, $select, $table, $fatal=true) { //TODO: Guess $select and $table if not passed
780 $history = $this->contains_history($table) ? " AND ${table}_valid_till=0" : '';
781 $value=$this->quote($value);
782 $sql = "SELECT $select FROM $table WHERE $key=$value$history LIMIT 1;"; //TODO use build_query_select()!!!
783 $result = $this->safe_query_fetch($sql);
784 if(isset($result[0][$select])) return $result[0][$select]; else if($fatal) die(trigger_error(T('Record not found!'))); //TODO post_redirect_get...
785 }
786
787 function contains_history($table) {
788 $history_tables = array('item'); //TODO Autodetect
789 return in_array($table, $history_tables);
790 }
791
792 function build_query_insert($table, $values, $replace=true, $suffix_id='_id') {
793 //Init
794 $history = $this->contains_history($table);
795
796 //Escaping
797 $table = $this->escape($table);
798
799 //Get list of POSTed columns
800 $columns_array = array_map(array($this,'escape'), array_keys($values[0]));
801 $columns = implode(',',$columns_array);
802
803 //Build query
804 $sql = '';
805 //echo('<pre>'); die(print_r($values));
806
807 if($history) {
808 $history_update=false; foreach($values as $row) if(is_numeric($row[$table.'_id'])) $history_update=true;
809 if($history_update) {
810 $sql .= "UPDATE $table";
811 $sql .= " SET ${table}_valid_till=NOW()";
812 $sql .= " WHERE ${table}_valid_till=0 AND (";
813 $or = '';
814 foreach($values as $row) {
815 $sql .= $or.' '.$table.'_id='.$this->quote($row[$table.'_id']);
816 $or = ' OR';
817 }
818 $sql .= " );\n\n";
819 $replace = false;
820 }
821 }
822
823 //Insert into table (columns)
824 $sql .= "INSERT INTO $table ($columns) VALUES ";
825
826 //Values (a,b,c),(d,e,f)
827 $comma='';
828 foreach($values as $row) {
829 $row_quoted = array_map(array($this,'quote'), $row); //Check
830 if($history) {
831 foreach($row as $column => $value) {
832 switch($column) {
833 case $table.'_valid_from':
834 $row_quoted[$column] = 'NOW()';
835 break;
836 case $table.'_valid_till':
837 $row_quoted[$column] = '0';
838 break;
839 case $table.'_author':
840 $row_quoted[$column] = $this->auth->get_user_id();
841 //die($this->auth->get_user_id().'=USER');
842 break;
843 }
844 }
845 }
846 $sql .= $comma.'('.implode(',',$row_quoted).')';
847 $comma = ',';
848 }
849
850 //On duplicate key
851 if($replace) {
852 foreach($columns_array as $col) {
853 if($col == $table.'_id' || $col == $table.'_valid_till') continue;
854 $on_duplicate[] = "$col=VALUES($col)";
855 }
856 $sql .= "\nON DUPLICATE KEY UPDATE ".implode(',', $on_duplicate);
857 }
858
859 //Terminate
860 $sql .= ';';
861 return $sql;
862 }
863
864 function insert_or_update($table, $values, $replace=true) {
865 $sql = $this->build_query_insert($table, $values, $replace);
866 $this->safe_query($sql);
867 return $this->lastInsertId();
868 }
869
870 function insert_or_update_multitab($values, $replace=true) {
871 $last=false;
872 foreach($values as $table => $rows) $last = $this->insert_or_update($table, $rows, $replace);
873 return $last;
874 }
875
876 function delete($table, $id, $suffix_id='_id') {
877 if($this->contains_history($table)) return false;
878 $key = $this->escape($table.$suffix_id);
879 $table = $this->escape($table);
880 $id = $this->quote($id);
881 return $this->safe_query("DELETE FROM $table WHERE $key = $id LIMIT 1;");
882 }
883 }
884
885 /**
886 * Trida poskytuje high-level rozhrani k databazi skladu
887 *
888 * @package Sklad_DB_Abstract
889 * @author Tomas Mudrunka
890 */
891 class Sklad_DB_Abstract extends Sklad_DB {
892 //TODO Code
893 }
894
895 /**
896 * Trida implementuje uzivatelske rozhrani skladu
897 *
898 * Example usage:
899 * $sklad = new Sklad_UI();
900 * $sklad->process_http_request();
901 *
902 * @package Sklad_UI
903 * @author Tomas Mudrunka
904 */
905 class Sklad_UI {
906 function __construct() {
907 $this->db = new Sklad_DB();
908 $this->html = new Sklad_HTML();
909 }
910
911 function render_items($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false) {
912 return $this->html->render_item_table($this->db->get_listing($class, $id, $limit, $offset, $where, $search, $history, false),$class);
913 }
914
915 function render_form_add($class) {
916 $columns = $this->db->get_columns($class);
917 $selectbox = $this->db->columns_get_selectbox($columns, $class);
918 return $this->html->render_insert_form($class, $columns, $selectbox);
919 }
920
921 function render_form_edit($class, $id, $multi_insert) {
922 $columns = $this->db->get_columns($class);
923 $selectbox = $this->db->columns_get_selectbox($columns, $class);
924 $current = $this->db->get_listing($class, $id, 1);
925 return $this->html->render_insert_form($class, $columns, $selectbox, $current, false, false, $multi_insert);
926 }
927
928 function render_single_record_details($class, $id, $barcode=true) {
929 $id_next = $id + 1;
930 $id_prev = $id - 1 > 0 ? $id - 1 : 0;
931 $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : '';
932 $html='';
933 $html.= $this->html->link('<<', "$class/$id_prev/");
934 $html.= '-';
935 $html.= $this->html->link('>>', "$class/$id_next/");
936 $html.= '&nbsp;&nbsp;&nbsp;';
937 $barcode && $html.='<span style="float:right;" class="floating_barcode">'.$this->html->render_barcode(BARCODE_PREFIX.strtoupper("$class/$id")).'</span>';
938 $html.= $this->html->link('edit', "$class/$id/edit/");
939 if($this->db->contains_history($class)) $html.= ' ][ '.$this->html->link('history', "$class/$id/history/");
940 return $html;
941 }
942
943 function render_listing_navigation($class, $id, $limit, $offset) {
944 $offset_next = $offset + $limit;
945 $offset_prev = $offset - $limit > 0 ? $offset - $limit : 0;
946 $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : '';
947 $moreget = isset($get[0]) ? '&' : '?';
948 $html='';
949 $html.= $this->html->link('<<', "$class/$id/$limit/$offset_prev/$get");
950 $html.= '-';
951 $html.= $this->html->link('[*]', "$class/$id/0/0/$get$moreget".'noimgs');
952 $html.= '-';
953 $html.= $this->html->link('>>', "$class/$id/$limit/$offset_next/$get");
954 $html.= '&nbsp;&nbsp;&nbsp;';
955 $html.= $this->html->link('new', "$class/new/$get");
956 return $html;
957 }
958
959 function render_listing_extensions($class, $id, $limit, $offset, $edit=false, $barcode=true) {
960 $html='';
961 if(is_numeric($id)) {
962 $html.=$this->render_single_record_details($class, $id, $barcode);
963 } else {
964 $html.=$this->render_listing_navigation($class, '*', $limit, $offset);
965 }
966 if($edit && $barcode) {
967 $html.= $this->render_form_edit($class, $id, false);
968 $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete";
969 $html.=$this->html->form($action,'POST',array(
970 array(false,'DELETE','submit'),
971 array('sure', false, 'checkbox', false, false, 'sure?')
972 ));
973 $action = $_SERVER['SCRIPT_NAME']."/$class/$id/image";
974 $html.=$this->html->form($action,'POST',array(
975 array('image', false, 'file', false, 'size="30"'),
976 array(false, 'IMAGE', 'submit')
977 ), "enctype='multipart/form-data'");
978 }
979 return $html;
980 }
981
982 function check_auth() {
983 new HTTP_Auth('WareHouse ['.BACKEND_AUTH.']', true, array($this->db->auth,'check_auth'));
984 }
985
986 function post_redirect_get($location, $message='', $error=false, $translate=true) {
987 $messaget = $translate ? T($message) : $message;
988 $url_args = $messaget != '' ? '?message='.urlencode($messaget) : '';
989 $location = $this->html->internal_url($location).$url_args;
990 header('Location: '.$location);
991 if($error) trigger_error($message);
992 $location=htmlspecialchars($location);
993 die(
994 "<meta http-equiv='refresh' content='0; url=$location'>".
995 $messaget."<br />Location: <a href='$location'>$location</a>"
996 );
997 }
998
999 function safe_include($dir,$name,$vars=array(),$ext='.inc.php') {
1000 if(preg_match('/[^a-zA-Z0-9-]/',$name)) $this->post_redirect_get('', 'SAFE INCLUDE: Securityfuck.', true);
1001 $filename="$dir/$name$ext";
1002 if(!is_file($filename)) $this->post_redirect_get('', 'SAFE INCLUDE: Fuckfound.', true);
1003 foreach($vars as $var => $val) $$var=$val;
1004 ob_start();
1005 include($filename);
1006 $out=ob_get_contents();
1007 ob_end_clean();
1008 return $out;
1009 }
1010
1011 function check_input_validity($field, $value='', $ruleset=0) {
1012 $rules = array(0 => array(
1013 'model_barcode' => '/./',
1014 'barcode_name' => '/./',
1015 'item_serial' => '/./',
1016 'vendor_id' => '/^[0-9]*$/'
1017 ));
1018 if(isset($rules[$ruleset][$field]) && !preg_match($rules[$ruleset][$field], trim($value))) return false;
1019 return true;
1020 }
1021
1022 function process_http_request_post($action=false, $class=false, $id=false, $force_redirect=false) {
1023 if($_SERVER['REQUEST_METHOD'] != 'POST') return;
1024 //echo('<pre>'); //DEBUG (maybe todo remove), HEADERS ALREADY SENT!!!!
1025
1026 //SephirPOST:
1027
1028 /* Tenhle foreach() prekopiruje promenne
1029 * z: $_POST['values'][$table][$column][$id];
1030 * do: $values[$table][$id][$column]
1031 */
1032 if(isset($_POST['values'])) {
1033 $values=array();
1034 foreach($_POST['values'] as $table => $columns) {
1035 foreach($columns as $column => $ids) {
1036 foreach($ids as $id => $val) {
1037 $values[$table][$id][$column] = trim($val);
1038 if(!$this->check_input_validity($column,$val)) {
1039 $message = "Spatny vstup: $column [$id] = \"$val\"; ". //XSS
1040 $this->html->link('GO BACK', 'javascript:history.back()', false, false);
1041 $this->post_redirect_get('', $message, false, false);
1042 }
1043 }
1044 }
1045 }
1046 //die(print_r($values));
1047 }
1048
1049 if($action) switch($action) {
1050 case 'new':
1051 $replace = false;
1052 case 'edit':
1053 if(!isset($replace)) $replace = true;
1054 $table = $class ? $class : 'item';
1055 //print_r($values); //debug
1056 $last = $this->db->insert_or_update_multitab($values, $replace);
1057 $last = $force_redirect ? $force_redirect."?last=$last" : "$table/$last/";
1058 $next = "$table/new/";
1059 $message = $force_redirect ? '' : 'Hotovo. Další záznam přidáte '.$this->html->link('zde', $next).'.';
1060 $this->post_redirect_get($last, $message);
1061 break;
1062 case 'delete':
1063 if(!isset($_POST['sure']) || !$_POST['sure']) $this->post_redirect_get("$class/$id/edit", 'Sure user expected :-)');
1064 $this->db->delete($class, $id) || $this->post_redirect_get("$class/$id/edit", "V tabulce $class jentak neco mazat nebudes chlapecku :-P");
1065 $this->post_redirect_get("$class", "Neco (pravdepodobne /$class/$id) bylo asi smazano. Fnuk :'-(");
1066 break;
1067 case 'image':
1068 $image_classes = array('model'); //TODO, use this more widely across the code
1069 if(!in_array($class, $image_classes)) $this->post_redirect_get("$class/$id/edit", "Nekdo nechce k DB Tride '$class' prirazovat obrazky!");
1070 $image_destination = DIR_IMAGES."/$class/$id.jpg";
1071 if($_FILES['image']['name'] == '') $this->post_redirect_get("$class/$id/edit", 'Everything has to be called somehow!', true);
1072 if(move_uploaded_file($_FILES['image']['tmp_name'], $image_destination)) {
1073 chmod ($image_destination, 0664);
1074 $this->post_redirect_get("$class/$id", 'Image has been upbloated successfully :)');
1075 } else $this->post_redirect_get("$class/$id/edit", 'File upload failed :(', true);
1076 break;
1077 default:
1078 $this->post_redirect_get('', 'Nothin\' to do here my cutie :-*');
1079 break;
1080 }
1081
1082 die('POSTed pyčo!');
1083 }
1084
1085 function process_http_request() {
1086 $listing_limit_classes = array('item','model');
1087
1088 $this->check_auth();
1089
1090 @ini_set('magic_quotes_gpc' , 'off');
1091 if(get_magic_quotes_gpc()) {
1092 die(trigger_error("Error: magic_quotes_gpc needs to be disabled! F00K!"));
1093 }
1094
1095 $PATH_INFO=@trim($_SERVER[PATH_INFO]);
1096 if($PATH_INFO == '' || $PATH_INFO == '/') $PATH_INFO = FRONTEND_PAGE_WELCOME;
1097 $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
1098 //Sephirot:
1099 if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]='';
1100 if($_SERVER['REQUEST_METHOD'] != 'POST' && $PATH_CHUNKS[1]!='barcodeimg' && $PATH_CHUNKS[1]!='api') { //TODO: tyhle podminky naznacujou, ze je v navrhu nejaka drobna nedomyslenost...
1101 $result = $this->db->safe_query_fetch("SELECT * FROM `lock`;");
1102 $headerhtml = !empty($result) ? T('There are locks:').' '.$this->html->render_item_table($result) : '';
1103 echo $this->html->header($PATH_INFO,$this->db->auth->get_user(),$headerhtml);
1104 }
1105 switch($PATH_CHUNKS[1]) { //TODO: Move some branches to plugins if possible
1106 case 'test': //test
1107 die('Tell me why you cry');
1108 break;
1109 case 'assistant': case 'api': //assistant|api
1110 $incdirs = array(
1111 'assistant' => DIR_ASSISTANTS,
1112 'api' => DIR_APIS
1113 );
1114 $PATH_CHUNKS[3] = isset($PATH_CHUNKS[3]) ? trim($PATH_CHUNKS[3]) : false;
1115 $assistant_vars['SUBPATH'] = array_slice($PATH_CHUNKS, 3);
1116 $assistant_vars['URL_INTERNAL'] = 'assistant/'.$PATH_CHUNKS[2];
1117 $assistant_vars['URL'] = $_SERVER['SCRIPT_NAME'].'/'.$assistant_vars['URL_INTERNAL'];
1118 $assistant_vars['ASSISTANT'] = $PATH_CHUNKS[2];
1119 echo $this->safe_include($incdirs[$PATH_CHUNKS[1]],$PATH_CHUNKS[2],$assistant_vars);
1120 break;
1121 case 'barcodeimg': //barcode
1122 Barcode::download_barcode(implode('/',array_slice($PATH_CHUNKS, 2)));
1123 break;
1124 default: //?
1125 $search = (isset($_GET['q']) && trim($_GET['q']) != '') ? trim($_GET['q']) : false;
1126 $class = (isset($PATH_CHUNKS[1]) && $PATH_CHUNKS[1] != '') ? $PATH_CHUNKS[1] : 'item';
1127 if(!isset($PATH_CHUNKS[2])) $PATH_CHUNKS[2]='';
1128 switch($PATH_CHUNKS[2]) {
1129 case 'new': //?/new
1130 $this->process_http_request_post($PATH_CHUNKS[2], $class);
1131 echo $this->render_form_add($class);
1132 break;
1133 default: //?/?
1134 $id = (isset($PATH_CHUNKS[2]) && is_numeric($PATH_CHUNKS[2]) ? (int) $PATH_CHUNKS[2] : false);
1135 if(!isset($PATH_CHUNKS[3])) $PATH_CHUNKS[3]='';
1136 $edit=false;
1137 switch($PATH_CHUNKS[3]) {
1138 case 'edit': //?/?/edit
1139 case 'image': //?/?/image
1140 case 'delete': //?/?/delete
1141 $this->process_http_request_post($PATH_CHUNKS[3], $class, $id);
1142 $edit=true;
1143 default: //?/?/?
1144 $history = $PATH_CHUNKS[3] == 'history' ? true : false;
1145 $limit = is_numeric($PATH_CHUNKS[3]) ? (int) $PATH_CHUNKS[3] : (in_array($class, $listing_limit_classes) ? FRONTEND_LISTING_LIMIT : 0);
1146 $offset = isset($PATH_CHUNKS[4]) ? (int) $PATH_CHUNKS[4] : 0;
1147 $where = @is_array($_GET['where']) ? $_GET['where'] : false;
1148 echo $this->render_listing_extensions($class, $id, $limit, $offset, $edit, false);
1149 echo $this->render_items($class, $id, $limit, $offset, $where, $search, $history);
1150 echo $this->render_listing_extensions($class, $id, $limit, $offset, $edit);
1151 //print_r(array("<pre>",$_SERVER));
1152 break;
1153 }
1154 break;
1155 }
1156 break;
1157 }
1158 }
1159 }
1160
1161 $sklad = new Sklad_UI();
1162 $sklad->process_http_request();
1163
1164 echo('<br style="clear:both;" /><hr />');
This page took 1.324294 seconds and 4 git commands to generate.