Commit | Line | Data |
---|---|---|
cdfce7c2 TM |
1 | <?php |
2 | /* | |
3 | * SkladovySystem - Storage management system compatible with LMS | |
78bf26a5 | 4 | * Copyright (C) 2011 Tomas Mudrunka |
cdfce7c2 TM |
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'); | |
5f093236 TM |
21 | set_include_path(DIR_LIB.PATH_SEPARATOR.get_include_path()); |
22 | ||
63747dad | 23 | require_once('Sklad_Auth.class/common.php'); |
cdfce7c2 | 24 | require_once('HTTP_Auth.class.php'); |
326a9fc9 | 25 | require_once('Locale.class.php'); |
81ab8aef | 26 | require_once('Barcode.class.php'); |
cdfce7c2 | 27 | |
0a027cc7 TM |
28 | /** |
29 | * Trida poskytuje vseobecne funkce pro generovani HTML kodu | |
30 | * | |
31 | * Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)! | |
32 | * | |
33 | * @package HTML | |
34 | * @author Tomas Mudrunka | |
35 | */ | |
36 | class HTML { | |
933b760a TM |
37 | function row($row,$type=false) { |
38 | $html = ''; | |
39 | if($type) $html.="<$type>"; | |
40 | $html.='<tr>'; | |
41 | $td = $type == 'thead' ? 'th' : 'td'; | |
0a027cc7 TM |
42 | foreach($row as $var) { |
43 | if(trim($var) == '') $var = ' '; | |
933b760a | 44 | $html.="<$td>$var</$td>"; |
0a027cc7 TM |
45 | } |
46 | $html.='</tr>'; | |
933b760a | 47 | if($type) $html.="</$type>"; |
0a027cc7 TM |
48 | return $html; |
49 | } | |
50 | ||
51 | function table(&$table, $params='border=1') { | |
52 | $html="<table $params>"; | |
53 | $header=true; | |
54 | foreach($table as $row) { | |
55 | if($header) { | |
933b760a | 56 | $html.=$this->row(array_keys($row),'thead'); |
0a027cc7 TM |
57 | $header=false; |
58 | } | |
59 | $html.=$this->row($row); | |
60 | } | |
61 | $html.='</table>'; | |
62 | return $html; | |
63 | } | |
64 | ||
81ab8aef | 65 | function link($title='n/a', $link='#void', $internal=true, $translate=true) { |
35916247 | 66 | if($internal && (!isset($link[0]) || $link[0] != '#')) $link = $this->internal_url($link); |
81ab8aef TM |
67 | if($translate) $title = T($title); |
68 | return "<a href='$link'>".$title."</a>"; | |
0a027cc7 TM |
69 | } |
70 | ||
81ab8aef TM |
71 | function img($src='#void', $title='img', $options='width=64') { |
72 | $options = $options ? " $options" : ''; | |
73 | return "<img src='$src' alt='$title' title='$title'$options; />"; | |
0a027cc7 TM |
74 | } |
75 | ||
35916247 TM |
76 | function input($name=false, $value=false, $type='text', $placeholder=false, $options=false, $prefix='') { |
77 | $html = T($prefix)."<input type='$type' "; | |
0a027cc7 | 78 | if($name) $html.= "name='$name' "; |
326a9fc9 TM |
79 | if(!is_bool($value)) { |
80 | if($type == 'submit') $value = T($value); | |
81 | $html.= "value='$value' "; | |
82 | } | |
0a027cc7 TM |
83 | if($options) $html.= "$options "; |
84 | if($placeholder) $html.= "placeholder='$placeholder' "; | |
85 | $html .= '/>'; | |
86 | return $html; | |
87 | } | |
88 | ||
35916247 TM |
89 | function form($action=false, $method=false, $inputs, $options=false) { |
90 | $action = $action ? " action='$action'" : ''; | |
91 | $method = $method ? " method='$method'" : ''; | |
92 | $options = $options ? " $options" : ''; | |
93 | $html = "<form$action$method$options>"; | |
94 | foreach($inputs as $input) $html .= call_user_func_array(array($this,'input'), $input); | |
95 | $html .= "</form>"; | |
96 | return $html; | |
97 | } | |
98 | ||
0a027cc7 TM |
99 | function select($name, $selectbox, $default=false) { |
100 | //echo('<pre>'); print_r($selectbox); | |
101 | $html = "<select name='$name'>"; | |
102 | ||
103 | if($default) { | |
104 | $value=$default; $title=$selectbox[$value]; | |
105 | $html .= "<option value='$value'>$value :: $title</option>"; | |
106 | unset($selectbox[$value]); | |
107 | } | |
108 | foreach($selectbox as $value => $title) { | |
109 | $html .= "<option value='$value'>$value :: $title</option>"; | |
110 | } | |
111 | $html .= "</select>"; | |
112 | return $html; | |
113 | } | |
35916247 TM |
114 | |
115 | function ul($items,$tag=ul,$head='',$class=false) { | |
116 | $class = $class ? " class='$class'" : ''; | |
117 | $html = "$head<$tag$class>"; | |
118 | foreach($items as $key => $value) { | |
119 | $html .= '<li>'; | |
120 | if(is_numeric($key)) { | |
121 | $html .= $value; | |
122 | } else { | |
123 | $html .= $this->link($key,$value); | |
124 | } | |
125 | $html .= '</li>'; | |
126 | } | |
127 | $html .= "</$tag>"; | |
128 | return $html; | |
129 | } | |
130 | ||
131 | function div($html, $options) { | |
132 | $options = $options ? " $options" : ''; | |
133 | return "<div$options>$html</div>"; | |
134 | } | |
ec106ddf TM |
135 | |
136 | function head($title=false,$charset='UTF-8',$more='') { | |
137 | $title = $title ? "\n<title>$title</title>" : ''; | |
138 | $html= '<head>'; | |
139 | $html.= '<meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" />'.$title.$more; | |
140 | $html.= '</head>'; | |
141 | return $html; | |
142 | } | |
0a027cc7 TM |
143 | } |
144 | ||
78bf26a5 TM |
145 | /** |
146 | * Trida poskytuje podpurne funkce pro generovani HTML kodu specificke pro sklad | |
147 | * | |
fc5c5b8b TM |
148 | * Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)! |
149 | * | |
78bf26a5 TM |
150 | * @package Sklad_HTML |
151 | * @author Tomas Mudrunka | |
152 | */ | |
35916247 | 153 | class Sklad_HTML extends HTML { //TODO: Split into few more methods |
e9f6461f | 154 | function header($title='', $user=array()) { |
cdfce7c2 TM |
155 | $home = URL_HOME; |
156 | $script = $_SERVER['SCRIPT_NAME']; | |
d9384cb5 | 157 | $search = htmlspecialchars(@trim($_GET['q'])); |
64f31c54 | 158 | $message = strip_tags(@trim($_GET['message']),'<a><b><u><i>'); |
ac2ed3a1 | 159 | $instance = INSTANCE_ID != '' ? '/'.INSTANCE_ID : ''; |
e9f6461f TM |
160 | $user_id = htmlspecialchars($user['id']); |
161 | $user_gid = htmlspecialchars($user['gid']); | |
162 | $user_name = htmlspecialchars($user['name']); | |
40eef626 | 163 | $time = date('r'); |
35916247 | 164 | //$title = T($title); //TODO |
ec106ddf TM |
165 | |
166 | $html = $this->head("SōkoMan$title"); | |
167 | $html .= <<<EOF | |
6d98215b | 168 | <h1 style="display: inline;"><a href="$script/">SōkoMan</a><small>$instance$title</small></h1> |
40eef626 TM |
169 | <div style="float:right; text-align:right;"> |
170 | Logged in as <b>$user_name</b> [UID: <b>$user_id</b>; GID: <b>$user_gid</b>]<br /> | |
171 | Page loaded at $time | |
172 | </div> | |
c9759229 TM |
173 | |
174 | <style type="text/css"> | |
ac2ed3a1 | 175 | * { font-family: arial; } |
933b760a TM |
176 | td,body { background-color: white; } |
177 | table { background-color: orange; border: orange; } | |
d0e7939c | 178 | a, a img { text-decoration:none; color: darkblue; border:none; } |
933b760a | 179 | li a, a:hover { text-decoration:underline; } |
ac2ed3a1 | 180 | |
7bcd6b42 | 181 | .menu li { |
c9759229 | 182 | float: left; |
7bcd6b42 TM |
183 | padding: 0.2em; |
184 | } | |
185 | ||
186 | .menu * li { | |
187 | float: none; | |
c9759229 TM |
188 | } |
189 | ||
190 | .menu * menu { | |
191 | position: absolute; | |
7bcd6b42 | 192 | padding: 0.2em; |
c9759229 TM |
193 | } |
194 | ||
195 | .menu, .menu * menu { | |
196 | list-style: none; | |
197 | } | |
198 | ||
199 | .menu * menu { | |
7bcd6b42 | 200 | border: 1px solid orange; |
c9759229 TM |
201 | display: none; |
202 | margin: 0; | |
203 | } | |
204 | ||
7bcd6b42 | 205 | .menu li:hover menu, .menu li:hover { |
c9759229 | 206 | display: block; |
7bcd6b42 | 207 | background-color: yellow; |
c9759229 | 208 | } |
7bcd6b42 | 209 | |
c9759229 TM |
210 | </style> |
211 | ||
cdfce7c2 | 212 | <div> |
35916247 TM |
213 | EOF; |
214 | ||
215 | $assistants=array(); | |
216 | foreach(scandir(DIR_ASSISTANTS) as $item) { | |
217 | if($item == '.' || $item == '..') continue; | |
218 | $item = preg_replace('/\.inc\.php$/','',$item); | |
219 | $assistants[$item] = "assistant/$item"; | |
220 | } | |
221 | ||
222 | $tables=array('item','model','category','producer','vendor','room','status'); | |
223 | ||
224 | foreach($tables as $table) { | |
225 | $listable[$table] = $table; | |
226 | $insertable[$table] = "$table/new"; | |
227 | } | |
228 | ||
229 | $html .= $this->ul(array( | |
35916247 | 230 | 'Home' => '', |
ec106ddf | 231 | 'Logout' => '?logout', |
35916247 | 232 | 0 => $this->ul($assistants,'menu',$this->link('Assistants','#')), |
ec106ddf TM |
233 | 1 => $this->ul($insertable,'menu',$this->link('New','#')), |
234 | 2 => $this->ul($listable,'menu',$this->link('List','#')) | |
35916247 TM |
235 | ),'menu', '', 'menu'); |
236 | ||
237 | $html .= '<div style="float: right;">'; | |
238 | ||
239 | $html .= $this->form("$script/assistant/go", 'GET', array( | |
81ab8aef | 240 | array('q','','text','smart id...', 'autofocus'), |
35916247 TM |
241 | array(false,'go','submit') |
242 | ), 'style="float: left;"'); | |
243 | ||
244 | $html .= $this->form('?', 'GET', array( | |
245 | array('q',$search,'text','regexp...'), | |
246 | array(false,'filter','submit') | |
247 | ), 'style="float: left;"'); | |
248 | ||
249 | $html .= '</div>'; | |
250 | ||
251 | $html .= <<<EOF | |
cdfce7c2 | 252 | </div> |
c9759229 | 253 | <hr style="clear: both;" /> |
d9384cb5 TM |
254 | <div style="background-color:#FFDDDD;"> |
255 | <font color="red">$message</font> | |
256 | </div> | |
cdfce7c2 | 257 | EOF; |
35916247 TM |
258 | |
259 | return $html; | |
cdfce7c2 TM |
260 | } |
261 | ||
d9384cb5 TM |
262 | function internal_url($link) { |
263 | return $_SERVER['SCRIPT_NAME'].'/'.$link; | |
264 | } | |
265 | ||
cdfce7c2 TM |
266 | function table_add_images(&$table) { |
267 | $image = array('model_id'); | |
268 | foreach($table as $id => $row) { | |
269 | foreach($image as $column) if(isset($table[$id][$column])) { | |
270 | $type = @array_shift(preg_split('/_/', $column)); | |
271 | $src=URL_IMAGES."/$type/".$table[$id][$column].'.jpg'; | |
272 | $table[$id][$type.'_image']=$this->img($src, $table[$id][$column]); | |
273 | } | |
274 | } | |
275 | } | |
276 | ||
81ab8aef TM |
277 | function render_barcode($barcode,$opts=false) { |
278 | return $this->link($this->img($this->internal_url("barcode/$barcode"),$barcode,$opts),"barcode/$barcode",true,false); | |
279 | } | |
280 | ||
281 | function table_add_barcodes(&$table) { | |
282 | $image = array('model_barcode', 'item_serial'); | |
283 | foreach($table as $id => $row) { | |
284 | foreach($image as $column) if(isset($table[$id][$column])) { | |
285 | $table[$id][$column]=$this->render_barcode($table[$id][$column]); | |
286 | } | |
287 | } | |
288 | } | |
289 | ||
cdfce7c2 TM |
290 | function table_collapse(&$table) { |
291 | $collapse = array( | |
292 | 'item_id' => 'item_id', | |
293 | 'model_id' => 'model_name', | |
294 | 'category_id' => 'category_name', | |
295 | 'producer_id' => 'producer_name', | |
296 | 'vendor_id' => 'vendor_name', | |
297 | 'room_id' => 'room_name', | |
298 | 'status_id' => 'status_name', | |
299 | ); | |
300 | foreach($table as $id => $row) { | |
301 | foreach($collapse as $link => $title) | |
fff6ce40 | 302 | if(isset($table[$id][$link]) && isset($row[$title])) { |
cdfce7c2 TM |
303 | $type = @array_shift(preg_split('/_/', $link)); |
304 | if($link != $title) unset($table[$id][$link]); | |
305 | $table[$id][$title]=$this->link($row[$title], $type.'/'.$row[$link].'/'); | |
306 | } | |
307 | } | |
308 | } | |
309 | ||
310 | function table_sort(&$table) { | |
311 | $precedence = array('item_id', 'model_image', 'model_name','model_descript','category_name','status_name','room_name'); | |
312 | $table_sorted = array(); | |
313 | foreach($table as $id => $row) { | |
314 | $table_sorted[$id] = array(); | |
315 | foreach($precedence as $column) if(isset($table[$id][$column])) { | |
326a9fc9 | 316 | $table_sorted[$id][T($column)]=$table[$id][$column]; |
cdfce7c2 TM |
317 | unset($table[$id][$column]); |
318 | } | |
326a9fc9 TM |
319 | //$table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]); |
320 | foreach($table[$id] as $key => $val) $table_sorted[$id][T($key)] = $val; //array_merge with T() translating | |
cdfce7c2 TM |
321 | } |
322 | $table = $table_sorted; | |
323 | } | |
324 | ||
fc5c5b8b | 325 | function render_item_table($table) { |
cdfce7c2 | 326 | $this->table_add_images($table); |
81ab8aef | 327 | $this->table_add_barcodes($table); |
cdfce7c2 TM |
328 | $this->table_collapse($table); |
329 | $this->table_sort($table); | |
fc5c5b8b | 330 | return $this->table($table); |
cdfce7c2 TM |
331 | } |
332 | ||
d0e7939c TM |
333 | function render_insert_inputs($class,$columns,$selectbox,$current,$hidecols,$update) { |
334 | $html = ''; | |
cdfce7c2 | 335 | foreach($columns as $column) { |
326a9fc9 | 336 | $html.=T($class).':<b>'.T($column['Field']).'</b>: '; |
7d20381f | 337 | $name="values[$class][".$column['Field'].'][]'; |
16261142 | 338 | $val = $update && isset($current[$column['Field']]) ? $current[$column['Field']] : false; |
cdfce7c2 | 339 | switch(true) { |
a084118b | 340 | case (preg_match('/auto_increment/', $column['Extra']) || in_array($column['Field'], $hidecols)): |
e9cb8cea | 341 | if(!$val) $val = ''; |
fc5c5b8b TM |
342 | $html.=$this->input($name, $val, 'hidden'); |
343 | $html.=$val.'(AUTO)'; | |
cdfce7c2 TM |
344 | break; |
345 | case isset($selectbox[$column['Field']]): | |
e9cb8cea | 346 | $html.=$this->select($name,$selectbox[$column['Field']],$val); |
cdfce7c2 TM |
347 | break; |
348 | default: | |
fc5c5b8b | 349 | $html.=$this->input($name, $val); |
cdfce7c2 TM |
350 | break; |
351 | } | |
fc5c5b8b | 352 | $html.='<br />'; |
cdfce7c2 | 353 | } |
d0e7939c TM |
354 | return $html; |
355 | } | |
cdfce7c2 | 356 | |
d0e7939c TM |
357 | function render_insert_form_multi($array) { |
358 | $html = ''; | |
359 | $head=false; | |
360 | ||
361 | foreach($array as $key => $args) { | |
362 | $parts=array('inputs'); | |
363 | if(!$head) { $head = true; | |
364 | $parts[]='head'; | |
365 | } | |
366 | if(!isset($array[$key+1])) { | |
367 | $parts[]='foot'; | |
5b0075fa TM |
368 | $hr = ''; |
369 | } else $hr = '<hr />'; | |
370 | //$args[] = false; | |
d0e7939c TM |
371 | $args[] = $parts; |
372 | $html .= call_user_func_array(array($this, 'render_insert_form'), $args); | |
5b0075fa | 373 | $html .= $hr; |
d0e7939c TM |
374 | } |
375 | return $html; | |
376 | } | |
377 | ||
378 | function render_insert_form($class, $columns, $selectbox=array(), $current=false, $hidecols=false, $action=false, $multi_insert=true, $parts=false) { | |
379 | $html = ''; | |
380 | //print_r($parts); | |
381 | //echo('<pre>'); print_r($selectbox); | |
382 | //echo('<pre>'); print_r($current); | |
383 | $update = false; | |
384 | if(is_array($current)) { | |
385 | $update = true; | |
386 | $current = array_shift($current); | |
387 | } | |
388 | ||
389 | if(!is_array($hidecols)) $hidecols = array(); | |
390 | $hidecols = array_merge($hidecols, array('item_author', 'item_valid_from', 'item_valid_till')); //TODO Autodetect | |
391 | ||
392 | if(!is_array($parts) || in_array('head', $parts)) { | |
393 | $action = $action ? " action='$action'" : false; | |
394 | $html.="<form$action method='POST'>"; //TODO: use $this->form() | |
5b0075fa | 395 | $html.='<span><div name="input_set" style="float:left; border:1px solid grey; padding: 1px; margin: 1px;">'; |
cdfce7c2 TM |
396 | } |
397 | ||
d0e7939c TM |
398 | if(!is_array($parts) || in_array('inputs', $parts)) |
399 | $html.=$this->render_insert_inputs($class,$columns,$selectbox,$current,$hidecols,$update); | |
400 | ||
401 | if(!is_array($parts) || in_array('foot', $parts)) { | |
5b0075fa | 402 | $html .= '</div></span><br style="clear:both" />'; |
d0e7939c TM |
403 | if($multi_insert) { //TODO, move to separate JS file |
404 | $html.=<<<EOF | |
d0e7939c TM |
405 | <script> |
406 | function duplicate_element(what, where) { | |
407 | var node = document.getElementsByName(what)[0]; | |
408 | node.parentNode.appendChild(node.cloneNode(true)); | |
409 | } | |
410 | </script> | |
411 | <a href='#' onClick="duplicate_element('input_set')">+</a> | |
412 | EOF; | |
413 | } | |
414 | ||
415 | $btn = is_array($current) ? 'UPDATE' : 'INSERT'; //TODO: $current may be set even when inserting... | |
416 | $html.=$this->input(false, $btn, 'submit'); | |
417 | $html.='</form>'; | |
418 | } | |
fc5c5b8b | 419 | return $html; |
cdfce7c2 TM |
420 | } |
421 | } | |
422 | ||
78bf26a5 TM |
423 | /** |
424 | * Trida poskytuje rozhrani k databazi skladu | |
425 | * | |
426 | * @package Sklad_DB | |
427 | * @author Tomas Mudrunka | |
428 | */ | |
cdfce7c2 TM |
429 | class Sklad_DB extends PDO { |
430 | function __construct() { | |
63747dad | 431 | $this->auth = new Sklad_Auth(); |
cdfce7c2 TM |
432 | |
433 | parent::__construct( | |
434 | DB_DSN, DB_USER, DB_PASS, | |
435 | array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") //Force UTF8 for MySQL | |
436 | ); | |
437 | } | |
438 | ||
439 | function escape($str) { | |
440 | return preg_replace('(^.|.$)', '', $this->quote($str)); //TODO HACK | |
441 | } | |
442 | ||
382324d3 TM |
443 | function quote_identifier($str) { |
444 | return '`'.$this->escape($str).'`'; //TODO HACK | |
445 | } | |
446 | ||
cb8a6861 | 447 | function build_query_select($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $order=false, $suffix_id='_id') { |
2bedfdac | 448 | //Configuration |
cdfce7c2 TM |
449 | $join = array( |
450 | 'item' => array('model', 'category', 'producer', 'vendor', 'room', 'status'), | |
451 | 'model' => array('category', 'producer') | |
9ea191cb | 452 | ); //TODO Autodetect using foreign keys? |
cdfce7c2 | 453 | $search_fields = array( |
df4079a6 | 454 | 'item' => array('item_id','item_serial','model_name','model_barcode','model_descript','producer_name','vendor_name') |
9ea191cb | 455 | ); //TODO Autodetect |
2bedfdac | 456 | |
d9d47bd3 TM |
457 | //Init |
458 | if(is_array($where)) foreach($where as $key => $value) $where[$key] = $key.' '.$value; //TODO: escape SQLi!!! | |
459 | ||
2bedfdac TM |
460 | //Escaping |
461 | $class = $this->escape($class); | |
462 | ||
463 | //SELECT | |
382324d3 | 464 | $sql="SELECT * FROM `$class`\n"; |
2bedfdac | 465 | //JOIN |
382324d3 | 466 | if(isset($join[$class])) foreach($join[$class] as $j) $sql .= "LEFT JOIN `$j` USING($j$suffix_id)\n"; |
2bedfdac | 467 | //WHERE/REGEXP |
cdfce7c2 TM |
468 | if($search) { |
469 | $search = $this->quote($search); | |
326a9fc9 | 470 | if(!isset($search_fields[$class])) die(trigger_error(T("Can't search in $class table yet :-("))); //TODO: post_redirect_get |
5895162b TM |
471 | $sql_search = ''; |
472 | foreach($search_fields[$class] as $column) $sql_search .= "OR $column REGEXP $search "; | |
473 | $where[] = "FALSE $sql_search"; | |
cb8a6861 TM |
474 | } elseif($id) $where[] = "$class$suffix_id = $id"; |
475 | if(!$history && $this->contains_history($class)) $where[] = $class.'_valid_till=0'; | |
476 | ||
5895162b | 477 | if($where) $sql .= 'WHERE ('.implode(') AND (', $where).")\n"; |
117817be TM |
478 | //ORDER |
479 | if(!$order) $order = $class.$suffix_id; | |
480 | if($this->contains_history($class)) $order .= ",${class}_valid_from DESC"; | |
481 | $sql .= "ORDER BY $order\n"; | |
2bedfdac | 482 | //LIMIT/OFFSET |
cdfce7c2 TM |
483 | if($limit) { |
484 | $limit = $this->escape((int)$limit); | |
485 | $offset = $this->escape((int)$offset); | |
486 | $sql .= "LIMIT $offset,$limit\n"; | |
487 | } | |
2bedfdac | 488 | |
cdfce7c2 TM |
489 | return $sql; |
490 | } | |
491 | ||
66b6f4d6 | 492 | function safe_query($sql, $fatal=true) { |
cdfce7c2 TM |
493 | $result = $this->query($sql); |
494 | if(!$result) { | |
2bedfdac | 495 | $error = $this->errorInfo(); |
66b6f4d6 TM |
496 | 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>"); |
497 | if($fatal) die(); | |
cdfce7c2 TM |
498 | } |
499 | return $result; | |
500 | } | |
501 | ||
326a9fc9 TM |
502 | function translate_query_results($result) { |
503 | $translate_cols = array('status_name', 'item_valid_till'); //TODO: Hardcoded | |
504 | foreach($result as $key => $row) { | |
505 | foreach($translate_cols as $col) if(isset($result[$key][$col])){ | |
506 | $result[$key][$col] = T($result[$key][$col]); | |
507 | } | |
508 | } | |
509 | return $result; | |
510 | } | |
511 | ||
512 | function safe_query_fetch($sql, $fatal=true, $fetch_flags = PDO::FETCH_ASSOC, $translate=true) { | |
513 | $result = $this->safe_query($sql, $fatal)->fetchAll($fetch_flags); | |
514 | if($translate) $result = $this->translate_query_results($result); | |
515 | return $result; | |
516 | } | |
517 | ||
518 | ||
cb8a6861 TM |
519 | function get_listing($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $indexed=array(), $suffix_id='_id') { |
520 | $sql = $this->build_query_select($class, $id, $limit, $offset, $where, $search, $history); | |
326a9fc9 | 521 | $result = $this->safe_query_fetch($sql); |
cdfce7c2 TM |
522 | if(!$result || !is_array($indexed)) return $result; |
523 | ||
524 | foreach($result as $key => $row) $indexed[$row[$class.$suffix_id]]=$row; | |
525 | return $indexed; | |
526 | } | |
527 | ||
d0e7939c | 528 | function get_columns($class,$disable_cols=array()) { //TODO: Not sure if compatible with non-MySQL DBs |
cdfce7c2 TM |
529 | $class = $this->escape($class); |
530 | $sql = "SHOW COLUMNS FROM $class;"; | |
d0e7939c TM |
531 | $columns = $this->safe_query_fetch($sql); |
532 | /*foreach($columns as $colk => $col) foreach($col as $key => $val) { | |
533 | if(in_array($col['Field'],$disable_cols)) $columns[$colk]['Extra']='auto_increment'; | |
534 | }*/ | |
535 | return $columns; | |
cdfce7c2 TM |
536 | } |
537 | ||
538 | function columns_get_selectbox($columns, $class=false, $suffix_id='_id', $suffix_name='_name') { | |
539 | $selectbox=array(); | |
540 | foreach($columns as $column) { | |
66b6f4d6 | 541 | 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)! |
cdfce7c2 TM |
542 | if($class && $column['Field'] == $class.$suffix_id) continue; |
543 | if(!preg_match('/'.$suffix_id.'$/', $column['Field'])) continue; | |
544 | $table=preg_replace('/'.$suffix_id.'$/','',$column['Field']); | |
66b6f4d6 | 545 | |
117817be | 546 | $history = $this->contains_history($table) ? " WHERE ${table}_valid_till=0" : ''; |
b4dcae05 | 547 | $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table$history;"; //TODO use build_query_select()!!! |
326a9fc9 | 548 | $result = $this->safe_query_fetch($sql, false); |
66b6f4d6 | 549 | if(!$result) continue; |
cdfce7c2 TM |
550 | foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name]; |
551 | } | |
552 | //echo('<pre>'); print_r($selectbox); | |
66b6f4d6 | 553 | return array_filter($selectbox, 'ksort'); |
9ea191cb TM |
554 | } |
555 | ||
d0e7939c | 556 | function map_unique($key, $value, $select, $table, $fatal=true) { //TODO: Guess $select and $table if not passed |
16261142 TM |
557 | $history = $this->contains_history($table) ? " AND ${table}_valid_till=0" : ''; |
558 | $value=$this->quote($value); | |
559 | $sql = "SELECT $select FROM $table WHERE $key=$value$history LIMIT 1;"; //TODO use build_query_select()!!! | |
326a9fc9 | 560 | $result = $this->safe_query_fetch($sql); |
d0e7939c | 561 | if(isset($result[0][$select])) return $result[0][$select]; else if($fatal) die(trigger_error(T('Record not found!'))); //TODO post_redirect_get... |
16261142 TM |
562 | } |
563 | ||
9ea191cb TM |
564 | function contains_history($table) { |
565 | $history_tables = array('item'); //TODO Autodetect | |
566 | return in_array($table, $history_tables); | |
cdfce7c2 TM |
567 | } |
568 | ||
569 | function build_query_insert($table, $values, $replace=true, $suffix_id='_id') { | |
b66fadbb TM |
570 | //Init |
571 | $history = $this->contains_history($table); | |
572 | ||
9ea191cb | 573 | //Escaping |
cdfce7c2 TM |
574 | $table = $this->escape($table); |
575 | ||
576 | //Get list of POSTed columns | |
aa3fd0a8 TM |
577 | $columns_array = array_map(array($this,'escape'), array_keys($values[0])); |
578 | $columns = implode(',',$columns_array); | |
cdfce7c2 | 579 | |
9fb856ba | 580 | //Build query |
b66fadbb | 581 | $sql = ''; |
b66fadbb TM |
582 | //echo('<pre>'); die(print_r($values)); |
583 | ||
584 | if($history) { | |
585 | $history_update=false; foreach($values as $row) if(is_numeric($row[$table.'_id'])) $history_update=true; | |
586 | if($history_update) { | |
587 | $sql .= "UPDATE $table"; | |
117817be TM |
588 | $sql .= " SET ${table}_valid_till=NOW()"; |
589 | $sql .= " WHERE ${table}_valid_till=0 AND ("; | |
b66fadbb TM |
590 | $or = ''; |
591 | foreach($values as $row) { | |
5b0075fa | 592 | $sql .= $or.' '.$table.'_id='.$this->quote($row[$table.'_id']); |
b66fadbb TM |
593 | $or = ' OR'; |
594 | } | |
595 | $sql .= " );\n\n"; | |
596 | $replace = false; | |
597 | } | |
598 | } | |
599 | ||
cdfce7c2 | 600 | //Insert into table (columns) |
aa3fd0a8 | 601 | $sql .= "INSERT INTO $table ($columns) VALUES "; |
cdfce7c2 TM |
602 | |
603 | //Values (a,b,c),(d,e,f) | |
604 | $comma=''; | |
605 | foreach($values as $row) { | |
9fb856ba TM |
606 | $row_quoted = array_map(array($this,'quote'), $row); //Check |
607 | if($history) { | |
b66fadbb TM |
608 | foreach($row as $column => $value) { |
609 | switch($column) { | |
610 | case $table.'_valid_from': | |
611 | $row_quoted[$column] = 'NOW()'; | |
612 | break; | |
613 | case $table.'_valid_till': | |
614 | $row_quoted[$column] = '0'; | |
615 | break; | |
9fb856ba | 616 | case $table.'_author': |
e9f6461f TM |
617 | $row_quoted[$column] = $this->auth->get_user_id(); |
618 | //die($this->auth->get_user_id().'=USER'); | |
b66fadbb | 619 | break; |
b66fadbb TM |
620 | } |
621 | } | |
622 | } | |
623 | $sql .= $comma.'('.implode(',',$row_quoted).')'; | |
cdfce7c2 TM |
624 | $comma = ','; |
625 | } | |
626 | ||
aa3fd0a8 TM |
627 | //On duplicate key |
628 | if($replace) { | |
629 | foreach($columns_array as $col) { | |
630 | if($col == $table.'_id' || $col == $table.'_valid_till') continue; | |
631 | $on_duplicate[] = "$col=VALUES($col)"; | |
632 | } | |
633 | $sql .= "\nON DUPLICATE KEY UPDATE ".implode(',', $on_duplicate); | |
634 | } | |
635 | ||
cdfce7c2 TM |
636 | //Terminate |
637 | $sql .= ';'; | |
638 | return $sql; | |
639 | } | |
640 | ||
b4dcae05 TM |
641 | function insert_or_update($table, $values, $replace=true) { |
642 | $sql = $this->build_query_insert($table, $values, $replace); | |
cdfce7c2 TM |
643 | $this->safe_query($sql); |
644 | return $this->lastInsertId(); | |
645 | } | |
646 | ||
b4dcae05 | 647 | function insert_or_update_multitab($values, $replace=true) { |
371a86f4 | 648 | $last=false; |
b4dcae05 | 649 | foreach($values as $table => $rows) $last = $this->insert_or_update($table, $rows, $replace); |
371a86f4 TM |
650 | return $last; |
651 | } | |
652 | ||
cdfce7c2 | 653 | function delete($table, $id, $suffix_id='_id') { |
64f31c54 | 654 | if($this->contains_history($table)) return false; |
cdfce7c2 TM |
655 | $key = $this->escape($table.$suffix_id); |
656 | $table = $this->escape($table); | |
657 | $id = $this->quote($id); | |
658 | return $this->safe_query("DELETE FROM $table WHERE $key = $id LIMIT 1;"); | |
659 | } | |
660 | } | |
661 | ||
0a027cc7 TM |
662 | /** |
663 | * Trida poskytuje high-level rozhrani k databazi skladu | |
664 | * | |
665 | * @package Sklad_DB_Abstract | |
666 | * @author Tomas Mudrunka | |
667 | */ | |
668 | class Sklad_DB_Abstract extends Sklad_DB { | |
669 | //TODO Code | |
670 | } | |
671 | ||
78bf26a5 TM |
672 | /** |
673 | * Trida implementuje uzivatelske rozhrani skladu | |
674 | * | |
675 | * Example usage: | |
676 | * $sklad = new Sklad_UI(); | |
677 | * $sklad->process_http_request(); | |
678 | * | |
679 | * @package Sklad_UI | |
680 | * @author Tomas Mudrunka | |
681 | */ | |
cdfce7c2 TM |
682 | class Sklad_UI { |
683 | function __construct() { | |
684 | $this->db = new Sklad_DB(); | |
685 | $this->html = new Sklad_HTML(); | |
686 | } | |
687 | ||
cb8a6861 TM |
688 | function render_items($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false) { |
689 | return $this->html->render_item_table($this->db->get_listing($class, $id, $limit, $offset, $where, $search, $history, false)); | |
cdfce7c2 TM |
690 | } |
691 | ||
a25f85f8 | 692 | function render_form_add($class) { |
cdfce7c2 TM |
693 | $columns = $this->db->get_columns($class); |
694 | $selectbox = $this->db->columns_get_selectbox($columns, $class); | |
a25f85f8 | 695 | return $this->html->render_insert_form($class, $columns, $selectbox); |
cdfce7c2 TM |
696 | } |
697 | ||
a25f85f8 | 698 | function render_form_edit($class, $id) { |
cdfce7c2 TM |
699 | $columns = $this->db->get_columns($class); |
700 | $selectbox = $this->db->columns_get_selectbox($columns, $class); | |
117817be | 701 | $current = $this->db->get_listing($class, $id, 1); |
a25f85f8 | 702 | return $this->html->render_insert_form($class, $columns, $selectbox, $current); |
cdfce7c2 TM |
703 | } |
704 | ||
a25f85f8 | 705 | function render_single_record_details($class, $id) { |
cdfce7c2 TM |
706 | $id_next = $id + 1; |
707 | $id_prev = $id - 1 > 0 ? $id - 1 : 0; | |
708 | $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : ''; | |
a25f85f8 TM |
709 | $html=''; |
710 | $html.= $this->html->link('<<', "$class/$id_prev/"); | |
711 | $html.= '-'; | |
712 | $html.= $this->html->link('>>', "$class/$id_next/"); | |
713 | $html.= '<br />'; | |
54694117 | 714 | $html.='<span style="float:right;">'.$this->html->render_barcode(BARCODE_PREFIX.strtoupper("$class/$id")).'</span>'; |
a25f85f8 | 715 | $html.= $this->html->link('edit', "$class/$id/edit/"); |
9fb856ba | 716 | if($this->db->contains_history($class)) $html.= ' ][ '.$this->html->link('history', "$class/$id/history/"); |
a25f85f8 | 717 | return $html; |
cdfce7c2 TM |
718 | } |
719 | ||
a25f85f8 | 720 | function render_listing_navigation($class, $id, $limit, $offset) { |
cdfce7c2 TM |
721 | $offset_next = $offset + $limit; |
722 | $offset_prev = $offset - $limit > 0 ? $offset - $limit : 0; | |
723 | $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : ''; | |
a25f85f8 TM |
724 | $html=''; |
725 | $html.= $this->html->link('<<', "$class/$id/$limit/$offset_prev/$get"); | |
726 | $html.= '-'; | |
727 | $html.= $this->html->link('>>', "$class/$id/$limit/$offset_next/$get"); | |
728 | $html.= '<br />'; | |
729 | $html.= $this->html->link('new', "$class/new/$get"); | |
730 | return $html; | |
cdfce7c2 TM |
731 | } |
732 | ||
a25f85f8 TM |
733 | function render_listing_extensions($class, $id, $limit, $offset, $edit=false) { |
734 | $html=''; | |
cdfce7c2 | 735 | if(is_numeric($id)) { |
a25f85f8 | 736 | $html.=$this->render_single_record_details($class, $id); |
cdfce7c2 | 737 | } else { |
a25f85f8 | 738 | $html.=$this->render_listing_navigation($class, '*', $limit, $offset); |
cdfce7c2 TM |
739 | } |
740 | if($edit) { | |
a25f85f8 | 741 | $html.= $this->render_form_edit($class, $id); |
cdfce7c2 | 742 | $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete"; |
35916247 TM |
743 | $html.=$this->html->form($action,'POST',array( |
744 | array(false,'DELETE','submit'), | |
745 | array('sure', false, 'checkbox', false, false, 'sure?') | |
746 | )); | |
cdfce7c2 | 747 | $action = $_SERVER['SCRIPT_NAME']."/$class/$id/image"; |
35916247 TM |
748 | $html.=$this->html->form($action,'POST',array( |
749 | array('image', false, 'file', false, 'size="30"'), | |
750 | array(false, 'IMAGE', 'submit') | |
751 | ), "enctype='multipart/form-data'"); | |
cdfce7c2 | 752 | } |
a25f85f8 | 753 | return $html; |
cdfce7c2 TM |
754 | } |
755 | ||
756 | function check_auth() { | |
63747dad | 757 | new HTTP_Auth('SkladovejSystem', true, array($this->db->auth,'check_auth')); |
cdfce7c2 TM |
758 | } |
759 | ||
64f31c54 | 760 | function post_redirect_get($location, $message='', $error=false) { |
326a9fc9 | 761 | $url_args = $message != '' ? '?message='.urlencode(T($message)) : ''; |
8acef003 | 762 | $location = $this->html->internal_url($location).$url_args; |
1f74892d | 763 | header('Location: '.$location); |
64f31c54 | 764 | if($error) trigger_error($message); |
7efdf72a TM |
765 | $location=htmlspecialchars($location); |
766 | die( | |
767 | "<meta http-equiv='refresh' content='0; url=$location'>". | |
326a9fc9 | 768 | T($message)."<br />Location: <a href='$location'>$location</a>" |
7efdf72a | 769 | ); |
cdfce7c2 TM |
770 | } |
771 | ||
623c65e2 | 772 | function safe_include($dir,$name,$vars=array(),$ext='.inc.php') { |
64f31c54 | 773 | if(preg_match('/[^a-zA-Z0-9-]/',$name)) $this->post_redirect_get('', 'SAFE INCLUDE: Securityfuck.', true); |
3e6c412e | 774 | $filename="$dir/$name$ext"; |
64f31c54 | 775 | if(!is_file($filename)) $this->post_redirect_get('', 'SAFE INCLUDE: Fuckfound.', true); |
623c65e2 | 776 | foreach($vars as $var => $val) $$var=$val; |
3e6c412e TM |
777 | ob_start(); |
778 | include($filename); | |
779 | $out=ob_get_contents(); | |
780 | ob_end_clean(); | |
781 | return $out; | |
782 | } | |
783 | ||
bda4a4be | 784 | function process_http_request_post($action=false, $class=false, $id=false, $force_redirect=false) { |
cdfce7c2 | 785 | if($_SERVER['REQUEST_METHOD'] != 'POST') return; |
1f74892d | 786 | //echo('<pre>'); //DEBUG (maybe todo remove), HEADERS ALREADY SENT!!!! |
cdfce7c2 TM |
787 | |
788 | //SephirPOST: | |
371a86f4 TM |
789 | |
790 | /* Tenhle foreach() prekopiruje promenne | |
7d20381f | 791 | * z: $_POST['values'][$table][$column][$id]; |
371a86f4 TM |
792 | * do: $values[$table][$id][$column] |
793 | */ | |
7d20381f TM |
794 | if(isset($_POST['values'])) { |
795 | $values=array(); | |
796 | foreach($_POST['values'] as $table => $columns) { | |
797 | foreach($columns as $column => $ids) { | |
798 | foreach($ids as $id => $val) $values[$table][$id][$column] = $val; | |
799 | } | |
cdfce7c2 | 800 | } |
7d20381f | 801 | //die(print_r($values)); |
cdfce7c2 TM |
802 | } |
803 | ||
804 | if($action) switch($action) { | |
805 | case 'new': | |
b4dcae05 | 806 | $replace = false; |
cdfce7c2 | 807 | case 'edit': |
b4dcae05 | 808 | if(!isset($replace)) $replace = true; |
64f31c54 | 809 | $table = $class ? $class : 'item'; |
cdfce7c2 | 810 | //print_r($values); //debug |
b4dcae05 | 811 | $last = $this->db->insert_or_update_multitab($values, $replace); |
bda4a4be | 812 | $last = $force_redirect ? $force_redirect."?last=$last" : "$table/$last/"; |
d9384cb5 | 813 | $next = "$table/new/"; |
bda4a4be TM |
814 | $message = $force_redirect ? '' : 'Hotovo. Další záznam přidáte '.$this->html->link('zde', $next).'.'; |
815 | $this->post_redirect_get($last, $message); | |
cdfce7c2 TM |
816 | break; |
817 | case 'delete': | |
64f31c54 TM |
818 | if(!isset($_POST['sure']) || !$_POST['sure']) $this->post_redirect_get("$class/$id/edit", 'Sure user expected :-)'); |
819 | $this->db->delete($class, $id) || $this->post_redirect_get("$class/$id/edit", "V tabulce $class jentak neco mazat nebudes chlapecku :-P"); | |
1f74892d | 820 | $this->post_redirect_get("$class", "Neco (pravdepodobne /$class/$id) bylo asi smazano. Fnuk :'-("); |
cdfce7c2 TM |
821 | break; |
822 | case 'image': | |
823 | $image_classes = array('model'); //TODO, use this more widely across the code | |
64f31c54 | 824 | if(!in_array($class, $image_classes)) $this->post_redirect_get("$class/$id/edit", "Nekdo nechce k DB Tride '$class' prirazovat obrazky!"); |
cdfce7c2 | 825 | $image_destination = DIR_IMAGES."/$class/$id.jpg"; |
326a9fc9 | 826 | if($_FILES['image']['name'] == '') $this->post_redirect_get("$class/$id/edit", 'Everything has to be called somehow!', true); |
cdfce7c2 | 827 | if(move_uploaded_file($_FILES['image']['tmp_name'], $image_destination)) { |
1f74892d | 828 | chmod ($image_destination, 0664); |
326a9fc9 TM |
829 | $this->post_redirect_get("$class/$id", 'Image has been upbloated successfully :)'); |
830 | } else $this->post_redirect_get("$class/$id/edit", 'File upload failed :(', true); | |
cdfce7c2 TM |
831 | break; |
832 | default: | |
326a9fc9 | 833 | $this->post_redirect_get('', 'Nothin\' to do here my cutie :-*'); |
cdfce7c2 TM |
834 | break; |
835 | } | |
836 | ||
837 | die('POSTed pyčo!'); | |
838 | } | |
839 | ||
840 | function process_http_request() { | |
841 | $this->check_auth(); | |
842 | ||
843 | @ini_set('magic_quotes_gpc' , 'off'); | |
844 | if(get_magic_quotes_gpc()) { | |
845 | die(trigger_error("Error: magic_quotes_gpc needs to be disabled! F00K!")); | |
846 | } | |
847 | ||
848 | $PATH_INFO=@trim($_SERVER[PATH_INFO]); | |
cdfce7c2 | 849 | $PATH_CHUNKS = preg_split('/\//', $PATH_INFO); |
81ab8aef | 850 | //Sephirot: |
cdfce7c2 | 851 | if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]=''; |
6d98215b | 852 | if($_SERVER['REQUEST_METHOD'] != 'POST' && $PATH_CHUNKS[1]!='barcode') //TODO: tyhle podminky naznacujou, ze je v navrhu nejaka drobna nedomyslenost... |
e9f6461f | 853 | echo $this->html->header($PATH_INFO,$this->db->auth->get_user()); |
81ab8aef | 854 | switch($PATH_CHUNKS[1]) { //TODO: Move some branches to plugins if possible |
cdfce7c2 TM |
855 | case 'test': //test |
856 | die('Tell me why you cry'); | |
857 | break; | |
3e6c412e | 858 | case 'assistant': //assistant |
de77377e TM |
859 | $PATH_CHUNKS[3] = isset($PATH_CHUNKS[3]) ? trim($PATH_CHUNKS[3]) : false; |
860 | $assistant_vars['SUBPATH'] = array_slice($PATH_CHUNKS, 3); | |
861 | $assistant_vars['URL_INTERNAL'] = 'assistant/'.$PATH_CHUNKS[2]; | |
862 | $assistant_vars['URL'] = $_SERVER['SCRIPT_NAME'].'/'.$assistant_vars['URL_INTERNAL']; | |
5ef6c52f | 863 | $assistant_vars['ASSISTANT'] = $PATH_CHUNKS[2]; |
623c65e2 | 864 | echo $this->safe_include(DIR_ASSISTANTS,$PATH_CHUNKS[2],$assistant_vars); |
3e6c412e | 865 | break; |
81ab8aef TM |
866 | case 'barcode': //barcode |
867 | Barcode::download_barcode(implode('/',array_slice($PATH_CHUNKS, 2))); | |
868 | break; | |
cdfce7c2 TM |
869 | default: //? |
870 | $search = (isset($_GET['q']) && trim($_GET['q']) != '') ? trim($_GET['q']) : false; | |
871 | $class = (isset($PATH_CHUNKS[1]) && $PATH_CHUNKS[1] != '') ? $PATH_CHUNKS[1] : 'item'; | |
872 | if(!isset($PATH_CHUNKS[2])) $PATH_CHUNKS[2]=''; | |
873 | switch($PATH_CHUNKS[2]) { | |
874 | case 'new': //?/new | |
875 | $this->process_http_request_post($PATH_CHUNKS[2], $class); | |
a25f85f8 | 876 | echo $this->render_form_add($class); |
cdfce7c2 TM |
877 | break; |
878 | default: //?/? | |
879 | $id = (isset($PATH_CHUNKS[2]) && is_numeric($PATH_CHUNKS[2]) ? (int) $PATH_CHUNKS[2] : false); | |
880 | if(!isset($PATH_CHUNKS[3])) $PATH_CHUNKS[3]=''; | |
881 | $edit=false; | |
882 | switch($PATH_CHUNKS[3]) { | |
883 | case 'edit': //?/?/edit | |
9fb856ba TM |
884 | case 'image': //?/?/image |
885 | case 'delete': //?/?/delete | |
cdfce7c2 TM |
886 | $this->process_http_request_post($PATH_CHUNKS[3], $class, $id); |
887 | $edit=true; | |
888 | default: //?/?/? | |
9fb856ba | 889 | $history = $PATH_CHUNKS[3] == 'history' ? true : false; |
cdfce7c2 TM |
890 | $limit = (int) (isset($PATH_CHUNKS[3]) ? $PATH_CHUNKS[3] : '0'); |
891 | $offset = (int) (isset($PATH_CHUNKS[4]) ? $PATH_CHUNKS[4] : '0'); | |
d9d47bd3 | 892 | $where = @is_array($_GET['where']) ? $_GET['where'] : false; |
cb8a6861 | 893 | echo $this->render_items($class, $id, $limit, $offset, $where, $search, $history); |
a25f85f8 | 894 | echo $this->render_listing_extensions($class, $id, $limit, $offset, $edit); |
cdfce7c2 TM |
895 | //print_r(array("<pre>",$_SERVER)); |
896 | break; | |
897 | } | |
898 | break; | |
899 | } | |
900 | break; | |
901 | } | |
902 | } | |
903 | } | |
904 | ||
905 | $sklad = new Sklad_UI(); | |
906 | $sklad->process_http_request(); | |
907 | ||
54694117 | 908 | echo('<br style="clear:both;" /><hr />'); |