Changeset 46 for trunk/Global.php
- Timestamp:
- Nov 10, 2019, 1:42:40 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Global.php
r37 r46 22 22 { 23 23 global $Config; 24 24 25 25 return $Config['BaseURL'].$URL; 26 26 } … … 184 184 return ((float)$Usec + (float)$Sec); 185 185 } 186 187 class Filter 188 { 189 var $Items = array(); 190 191 function GetOutput($Link) 192 { 193 $Output = ''; 194 foreach ($this->rItems as $Item) 195 { 196 if (($Item['Type'] == 'String') or ($Item['Type'] == 'Enumeration')) 197 { 198 if (!array_key_exists($Item['Name'], $_SESSION)) $_SESSION[$Item['Name']] = ''; 199 } else 200 if ($Item['Type'] == 'Integer') 201 { 202 if (!array_key_exists($Item['Name'].'od', $_SESSION)) $_SESSION[$Item['Name'].'od'] = ''; 203 if (!array_key_exists($Item['Name'].'do', $_SESSION)) $_SESSION[$Item['Name'].'do'] = ''; 204 } 205 } 206 207 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 208 { 209 foreach ($this->Items as $Item) 210 { 211 if ($Item['Type'] == 'String') 212 { 213 if (array_key_exists($Item['Name'], $_GET) ) $_SESSION[$Item['Name']] = $_GET[$Item['Name']]; 214 } else 215 if ($Item['Type'] == 'Enumeration') 216 { 217 if (array_key_exists($Item['Name'], $_GET) ) $_SESSION[$Item['Name']] = $_GET[$Item['Name']]; 218 if ($_SESSION[$Item['Name']] == '0') $_SESSION[$Item['Name']] = ''; 219 } else 220 if ($Item['Type'] == 'Integer') 221 { 222 if (array_key_exists($Item['Name'].'od', $_GET) ) $_SESSION[$Item['Name'].'od'] = $_GET[$Item['Name'].'od']; 223 if ($_SESSION[$Item['Name'].'od'] == '0') $_SESSION[$Item['Name'].'od'] = ''; 224 if (array_key_exists($Item['Name'].'do', $_GET) ) $_SESSION[$Item['Name'].'do'] = $_GET[$Item['Name'].'do']; 225 if ($_SESSION[$Item['Name'].'do'] == '0') $_SESSION[$Item['Name'].'do'] = ''; 226 } 227 } 228 } else { 229 $Output .= '<script type="text/javascript">function reloadlist(){ $(\'#meetlist\').load(document.URL + \' #meetlist\');}'. 230 ' var load_timer = 100; 231 var ltimer = null; 232 233 function checkOut(kc,obj){ 234 if(kc==13) $(obj).blur(); 235 } 236 function initLTimer(tm){ 237 if(ltimer) clearTimeout(ltimer); 238 ltimer = setTimeout("freloader()",tm); 239 } 240 function stopLTimer(){ 241 if(ltimer) clearTimeout(ltimer); 242 ltimer = null; 243 } 244 245 var cf = {}; 246 247 function setupc(key,val){ 248 //console.log(\'setup-control-\'+key+\' = \'+val); 249 '; 250 $Keys = array(); 251 foreach ($this->Items as $Item) 252 { 253 if ($Item['Type'] == 'Integer') 254 { 255 $Keys[] = 'key==\''.$Item['Name'].'od\''; 256 $Keys[] = 'key==\''.$Item['Name'].'do\''; 257 } 258 } 259 if (count($Keys) > 0) 260 { 261 $Output .= 'if ('.implode(' || ', $Keys).') { 262 var ccv = $(\'#\'+key).val(); 263 if(ccv!=val) $(\'#\'+key).val(val==0?\'\':val); 264 } 265 '; 266 } 267 268 $Keys = array(); 269 foreach ($this->Items as $Item) 270 { 271 if ($Item['Type'] == 'Enumeration') 272 { 273 $Keys[] = 'key==\''.$Item['Name'].'\''; 274 } 275 } 276 if (count($Keys) > 0) 277 { 278 $Output .= 'if('.implode(' || ', $Keys).') { 279 $(\'.c\'+key).removeClass(\'active\'); 280 $(\'#\'+key+val).addClass(\'active\'); 281 } 282 '; 283 } 284 $Output .= ' 285 } 286 287 function upf(key,val,lonreload){ 288 if(key!=\'first\') cf[\'first\']=0; else st(); 289 setupc(key,val); 290 cf[key]=val; 291 if(lonreload) initLTimer(1000); else initLTimer(100); 292 } 293 294 function freloader(){ 295 ltimer = null; 296 var qp = jQuery.param( cf ); 297 $(\'#list_content\').html(\'\'); $(\'#list_loading\').show(); 298 $.get(\''.$Link.'?lvm=seznam&\'+qp,function(data){$(\'#list_loading\').hide();$(\'#list_content\').html(data);}) 299 }'. 300 '</script> 301 <div class="table-filter">'; 302 foreach ($this->Items as $Item) 303 { 304 if ($Item['Type'] == 'String') 305 { 306 $Output .= '<div class="filter-num-box">'. 307 '<div class="label-box">'.$Item['Title'].'</div>'. 308 '<input value="'.$_SESSION[$Item['Name']].'" onkeyup="if(event.keyCode!=9) upf(\''.$Item['Name'].'\',$(this).val(),(event.keyCode==13?0:1)); '. 309 '" id="'.$Item['Name'].'" autocomplete="off" type="text"/>'. 310 '</div> '; 311 } else 312 if ($Item['Type'] == 'Enumeration') 313 { 314 $Output .= '<div class="btn-group ma3">'. 315 '<div class="label-box">'.$Item['Title'].'</div>'; 316 foreach ($Item['States'] as $EnumIndex => $EnumItem) 317 { 318 $Output .= '<button class="btn btn-filter c'.$Item['Name'].' btn-ico" onclick="upf(\''.$Item['Name'].'\','.$EnumIndex.')" id="'.$Item['Name'].$EnumIndex.'" data-toggle="tooltip" '. 319 'data-placement="top" title="'.$EnumItem.'"><span class="icon-'.$EnumIndex.'"></span></button>'; 320 } 321 $Output .= '</div>'; 322 } else 323 if ($Item['Type'] == 'Integer') 324 { 325 $Output .= '<div class="filter-num-box">'. 326 '<div class="label-box">'.$Item['Title'].'</div>'. 327 '<input value="'.$_SESSION[$Item['Name'].'od'].'" onkeyup="if(event.keyCode!=9) upf(\''.$Item['Name'].'od\',$(this).val(),(event.keyCode==13?0:1)); '. 328 '" id="'.$Item['Name'].'od" autocomplete="off" type="text"/>'. 329 '<div class="label-box">-</div>'. 330 '<input value="'.$_SESSION[$Item['Name'].'do'].'" onkeyup="'. 331 'if(event.keyCode!=9) upf(\''.$Item['Name'].'do\',$(this).val(),(event.keyCode==13?0:1));" '. 332 'id="'.$Item['Name'].'do" autocomplete="off" type="text"/>'. 333 '<div class="label-box">'.$Item['Units'].'</div>'. 334 '</div> '; 335 } 336 } 337 $Output .= '</div>'; 338 } 339 return $Output; 340 } 341 342 function GetWhere($Database) 343 { 344 $Where = ''; 345 foreach($this->Items as $Item) 346 { 347 if ($Item['Type'] == 'String') 348 { 349 if ($_SESSION[$Item['Name']] != '') 350 $Where .= ' AND ('.$Item['DbName'].' LIKE "%'.$Database->real_escape_string($_SESSION[$Item['Name']]).'%")'; 351 } else 352 if ($Item['Type'] == 'Enumeration') 353 { 354 if ($_SESSION[$Item['Name']] != '') 355 $Where .= ' AND ('.$Item['DbName'].' = '.$Database->real_escape_string($_SESSION[$Item['Name']]).')'; 356 } else 357 if ($Item['Type'] == 'Integer') 358 { 359 if ($_SESSION[$Item['Name'].'od'] != '') 360 $Where .= ' AND ('.$Item['DbName'].' >= '.$Database->real_escape_string($_SESSION[$Item['Name'].'od']).')'; 361 if ($_SESSION[$Item['Name'].'do'] != '') 362 $Where .= ' AND ('.$Item['DbName'].' <= '.$Database->real_escape_string($_SESSION[$Item['Name'].'do']).')'; 363 } 364 } 365 if (substr($Where, 0, 4) == ' AND') 366 $Where = substr($Where, 4); 367 if ($Where == '') $Where = '1'; 368 return $Where; 369 } 370 }
Note:
See TracChangeset
for help on using the changeset viewer.