| Conditions | 145 |
| Paths | 8 |
| Total Lines | 472 |
| Code Lines | 333 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 268 | public function administracao($url, $campos) |
||
| 269 | { |
||
| 270 | $criterio = new \CriteriaCompo(); |
||
| 271 | if (!empty($campos['precrit']['campo']) && !empty($campos['precrit']['valor'])) { |
||
| 272 | $precrit_hidden = ''; |
||
| 273 | $precrit_url = ''; |
||
| 274 | foreach ($campos['precrit']['campo'] as $k => $v) { |
||
| 275 | $hiddens[$v] = $campos['precrit']['valor'][$k]; |
||
| 276 | $criterio->add(new \Criteria($v, $campos['precrit']['valor'][$k], '=', $this->tabela)); |
||
| 277 | $precrit_hidden .= "<input type='hidden' name='" . $v . "' value='" . $campos['precrit']['valor'][$k] . "'>"; |
||
| 278 | $precrit_url .= '&' . $v . '=' . $campos['precrit']['valor'][$k]; |
||
| 279 | } |
||
| 280 | } else { |
||
| 281 | $precrit_hidden = ''; |
||
| 282 | $precrit_url = ''; |
||
| 283 | } |
||
| 284 | if (!empty($campos['checks']) && Request::hasVar('group_action', 'POST') && is_array(Request::getArray('checks', '', 'POST')) |
||
| 285 | && 'group_del_ok' === Request::getString('group_action', '', 'POST')) { |
||
| 286 | $chks = Request::getArray('checks', [], 'POST'); |
||
| 287 | $classe = get_class($this); |
||
| 288 | foreach ($chks as $k => $v) { |
||
| 289 | $nova = new $classe($k); |
||
| 290 | if (!empty($campos['group_del_function']) && is_array($campos['group_del_function'])) { |
||
| 291 | foreach ($campos['group_del_function'] as $k => $v) { |
||
| 292 | $nova->$v(); |
||
| 293 | } |
||
| 294 | } |
||
| 295 | $nova->delete(); |
||
| 296 | } |
||
| 297 | } |
||
| 298 | if (!empty($campos['checks']) && Request::hasVar('group_action', 'POST') |
||
| 299 | && 'group_del' === Request::getString('group_action', '', 'POST') |
||
| 300 | && is_array(Request::getArray('checks', '', 'POST'))) { |
||
| 301 | $chks = Request::getArray('checks', [], 'POST'); |
||
| 302 | foreach ($chks as $k => $v) { |
||
| 303 | $hiddens['checks[' . $k . ']'] = 1; |
||
| 304 | } |
||
| 305 | $hiddens['op'] = $campos['op']; |
||
| 306 | $hiddens['group_action'] = 'group_del_ok'; |
||
| 307 | |||
| 308 | return xoops_confirm($hiddens, $url, $campos['lang']['group_del_sure'], _SUBMIT) . '<br>'; |
||
| 309 | } |
||
| 310 | $busca_url = ''; |
||
| 311 | if (Request::hasVar('busca', 'GET')) { |
||
| 312 | foreach (Request::getArray('busca', [], 'GET') as $k => $v) { |
||
| 313 | if ('' !== $v && '-1' != $v && in_array($k, $campos['nome'])) { |
||
| 314 | if (is_numeric($v)) { |
||
| 315 | $criterio->add(new \Criteria($k, $v, '=', $this->tabela)); |
||
| 316 | } elseif (is_array($v)) { |
||
| 317 | if (!empty($v['dday']) || !empty($v['dmonth']) || !empty($v['dyear']) || !empty($v['aday']) |
||
| 318 | || !empty($v['amonth']) |
||
| 319 | || !empty($v['ayear'])) { |
||
| 320 | $dday = !empty($v['dday']) ? $v['dday'] : 1; |
||
| 321 | $dmonth = !empty($v['dmonth']) ? $v['dmonth'] : 1; |
||
| 322 | $dyear = !empty($v['dyear']) ? $v['dyear'] : 1; |
||
| 323 | $aday = !empty($v['aday']) ? $v['aday'] : 1; |
||
| 324 | $amonth = !empty($v['amonth']) ? $v['dmonth'] : 1; |
||
| 325 | $ayear = !empty($v['ayear']) ? $v['ayear'] : date('Y'); |
||
| 326 | $ddate = mktime(0, 0, 0, $v['dmonth'], $v['dday'], $v['dyear']); |
||
| 327 | $adate = mktime(0, 0, 0, $v['amonth'], $v['aday'], $v['ayear']); |
||
| 328 | $criterio->add(new \Criteria($k, $ddate, '>=', $this->tabela)); |
||
| 329 | $criterio->add(new \Criteria($k, $adate, '<=', $this->tabela)); |
||
| 330 | } |
||
| 331 | } else { |
||
| 332 | $criterio->add(new \Criteria($k, "%$v%", 'LIKE', $this->tabela)); |
||
| 333 | } |
||
| 334 | $busca_url .= (!is_array($v)) ? '&busca[' . $k . ']=' . $v : '&busca[' |
||
| 335 | . $k |
||
| 336 | . '][dday]=' |
||
| 337 | . $v['dday'] |
||
| 338 | . '&busca[' |
||
| 339 | . $k |
||
| 340 | . '][dmonth]=' |
||
| 341 | . $v['dmonth'] |
||
| 342 | . '&busca[' |
||
| 343 | . $k |
||
| 344 | . '][dyear]=' |
||
| 345 | . $v['dyear'] |
||
| 346 | . '&busca[' |
||
| 347 | . $k |
||
| 348 | . '][aday]=' |
||
| 349 | . $v['aday'] |
||
| 350 | . '&busca[' |
||
| 351 | . $k |
||
| 352 | . '][amonth]=' |
||
| 353 | . $v['amonth'] |
||
| 354 | . '&busca[' |
||
| 355 | . $k |
||
| 356 | . '][ayear]=' |
||
| 357 | . $v['ayear']; |
||
| 358 | } |
||
| 359 | } |
||
| 360 | } |
||
| 361 | $limit = (Request::hasVar('limit', 'GET') && Request::getInt('limit', 0, 'GET') <= 100) ? Request::getInt('limit', 0, 'GET') : 15; |
||
| 362 | $criterio->setLimit($limit); |
||
| 363 | $start = Request::getInt('start', 0, 'GET'); |
||
| 364 | $criterio->setStart($start); |
||
| 365 | $order = Request::getInt('order', 'DESC', 'GET'); |
||
| 366 | $criterio->setOrder($order); |
||
| 367 | $sort = (Request::hasVar('sort', 'GET') |
||
| 368 | && in_array(Request::getString('sort', '', 'GET'), $campos['nome'])) ? $_GET['sort'] : (empty($campos['sort']) ? $campos['nome'][1] : $campos['sort']); |
||
| 369 | $criterio->setSort($sort); |
||
| 370 | $form = !empty($campos['form']) ? 1 : 0; |
||
| 371 | $checks = !empty($campos['checks']) ? 1 : 0; |
||
| 372 | $op = !empty($campos['op']) ? $campos['op'] : ''; |
||
| 373 | $norder = ('ASC' === $order) ? 'DESC' : 'ASC'; |
||
| 374 | $colunas = count($campos['rotulo']); |
||
| 375 | $colunas = !empty($campos['checks']) ? $colunas + 1 : $colunas; |
||
| 376 | $colunas = !empty($campos['botoes']) ? $colunas + 1 : $colunas; |
||
| 377 | $url_colunas = $url . '?op=' . $op . '&limit=' . $limit . '&start=' . $start . $busca_url . $precrit_url; |
||
| 378 | $url_full_pg = $url . '?op=' . $op . '&limit=' . $limit . '&sort=' . $sort . '&order=' . $order . $busca_url . $precrit_url; |
||
| 379 | $contar = $this->contar($criterio); |
||
| 380 | $ret = '<style type="text/css"> |
||
| 381 | .hd {background-color: #c2cdd6; padding: 5px; font-weight: bold;} |
||
| 382 | tr.bx td {background-color: #DFDFDF; padding: 5px; font-weight: bold; color: #000000;} |
||
| 383 | tr.hd td {background-image:url("../assets/images/bg.gif"); padding: 5px; font-weight: bold; border:1px solid #C0C0C0; color: #000000;} |
||
| 384 | tr.hd td.hds {background-image:url("../assets/images/bgs.gif"); padding: 5px; font-weight: bolder; border:1px solid #C0C0C0; border-top: 1px solid #000000; color: #000000;} |
||
| 385 | tr.hd td a{color: #1D5F9F;} |
||
| 386 | .fundo1 {background-color: #DFDFDF; padding: 4px;} |
||
| 387 | tr.fundo1 td {background-color: #DFDFDF; padding: 4px; border:1px solid #C0C0C0;} |
||
| 388 | .fundo2 {background-color: #E0E8EF; padding: 4px;} |
||
| 389 | tr.fundo2 td {background-color: #E0E8EF; padding: 4px; border:1px solid #C0C0C0;} |
||
| 390 | .neutro {background-color: #FFFFFF; padding: 4px;} |
||
| 391 | tr.neutro td {background-color: #FFFFFF; padding: 4px; border:1px solid #9FD4FF;} |
||
| 392 | </style> |
||
| 393 | <script language="javascript" type="text/javascript"> |
||
| 394 | function exibe_esconde(tipo) { |
||
| 395 | var coisinha = document.getElementById(tipo); |
||
| 396 | if (coisinha.style.display == "") { |
||
| 397 | coisinha.style.display = "none"; |
||
| 398 | } else { |
||
| 399 | coisinha.style.display = ""; |
||
| 400 | } |
||
| 401 | } |
||
| 402 | |||
| 403 | function esconde_menus() { |
||
| 404 | var els = document.getElementsByTagName("TD"); |
||
| 405 | var elsLen = els.length; |
||
| 406 | var pattern = new RegExp("(^|\\s)bg5(\\s|$)"); |
||
| 407 | for (i = 0, j = 0; i < elsLen; i++) { |
||
| 408 | if (pattern.test(els[i].className) && els[i].colSpan != 3 && els[i].colSpan != 4) { |
||
| 409 | if (els[i].style.display=="") { |
||
| 410 | els[i].style.display="none"; |
||
| 411 | } else { |
||
| 412 | els[i].style.display=""; |
||
| 413 | } |
||
| 414 | } |
||
| 415 | } |
||
| 416 | } |
||
| 417 | |||
| 418 | function changecheck() { |
||
| 419 | var f = document.getElementById("update_form"); |
||
| 420 | var inputs = document.getElementsByTagName("input"); |
||
| 421 | for (var t = 0;t < inputs.length;t++) { |
||
| 422 | if (inputs[t].type == "checkbox" && inputs[t].id != "checkAll") { |
||
| 423 | inputs[t].checked = !inputs[t].checked; |
||
| 424 | inputs[t].onclick(); |
||
| 425 | } |
||
| 426 | } |
||
| 427 | |||
| 428 | return true; |
||
| 429 | }' . ($checks ? ' |
||
| 430 | |||
| 431 | function verificaChecks() { |
||
| 432 | var grp_sel = document.getElementById("group_action"); |
||
| 433 | if(grp_sel.options[grp_sel.selectedIndex].value == 0) return true; |
||
| 434 | var inputs = document.getElementsByTagName("input"); |
||
| 435 | for (var t = 0;t < inputs.length;t++) { |
||
| 436 | if(inputs[t].type == "checkbox" && inputs[t].checked === true) return true; |
||
| 437 | } |
||
| 438 | alert("' . $campos['lang']['group_erro_sel'] . '"); |
||
| 439 | |||
| 440 | return false; |
||
| 441 | } |
||
| 442 | |||
| 443 | function marcaCheck(linha, ckbx, classe) { |
||
| 444 | var tr = document.getElementById(linha); |
||
| 445 | var valor = document.getElementById(ckbx).checked; |
||
| 446 | //alert(tr.onmouseout); |
||
| 447 | if (valor === true) { |
||
| 448 | tr.className = "neutro"; |
||
| 449 | tr.onmouseout = function(){}; |
||
| 450 | |||
| 451 | return true; |
||
| 452 | } else { |
||
| 453 | tr.className = classe; |
||
| 454 | tr.onmouseout = function(){this.className=classe}; |
||
| 455 | |||
| 456 | return true; |
||
| 457 | } |
||
| 458 | } |
||
| 459 | </script>' : '</script>'); |
||
| 460 | |||
| 461 | $ret .= !empty($campos['noadminmenu']) ? ' |
||
| 462 | <script language="javascript" type="text/javascript"> |
||
| 463 | if (window.addEventListener) window.addEventListener("load", esconde_menus, false) else if (window.attachEvent) window.attachEvent("onload", esconde_menus) |
||
| 464 | </script>' : ''; |
||
| 465 | |||
| 466 | global $pathIcon16; |
||
| 467 | |||
| 468 | $ret .= ' |
||
| 469 | <table width="100%" border="0" cellspacing="0" class="outer"> |
||
| 470 | <tr><td style="padding:5px; font-size:16px; border: 1px solid #C0C0C0; border-bottom:0px;"><div style="font-size:12px; text-align:right; float:right;">' . (empty($campos['nofilters']) ? '<a href="javascript:void(0);" onclick="exibe_esconde(\'busca\');">' |
||
| 471 | . $campos['lang']['filtros'] |
||
| 472 | . '</a>' |
||
| 473 | // .' - <a href="javascript:void(0);" onclick="esconde_menus();">' |
||
| 474 | // . $campos['lang']['showhidemenu'] |
||
| 475 | // . '</a>' |
||
| 476 | . '' : '') . '</div><b>' . $campos['lang']['titulo'] . '</b></td></tr> |
||
| 477 | <tr><td class="outer" style="background-color: #F3F2F2;"><div style="text-align: center;">'; |
||
| 478 | $ret .= "<form action='" |
||
| 479 | . $url |
||
| 480 | . "' method='GET' name='form_npag'>" |
||
| 481 | . $precrit_hidden |
||
| 482 | . '<b>' |
||
| 483 | . $campos['lang']['exibir'] |
||
| 484 | . " <input type='text' name='limit' value='" |
||
| 485 | . $limit |
||
| 486 | . "' size='4' maxlength='3' style='text-align:center'> " |
||
| 487 | . $campos['lang']['por_pagina'] |
||
| 488 | . '</b>'; |
||
| 489 | if (Request::hasVar('busca', 'GET')) { |
||
| 490 | foreach (Request::getArray('busca', [], 'GET') as $k => $v) { |
||
| 491 | if ('' !== $v && '-1' != $v && !is_array($v)) { |
||
| 492 | $ret .= "<input type='hidden' name='busca[" . $k . "]' value='" . $v . "'>"; |
||
| 493 | } elseif (is_array($v)) { |
||
| 494 | $ret .= "<input type='hidden' name='busca[" . $k . "][dday]' value='" . $v['dday'] . "'>"; |
||
| 495 | $ret .= "<input type='hidden' name='busca[" . $k . "][dmonth]' value='" . $v['dmonth'] . "'>"; |
||
| 496 | $ret .= "<input type='hidden' name='busca[" . $k . "][dyear]' value='" . $v['dyear'] . "'>"; |
||
| 497 | $ret .= "<input type='hidden' name='busca[" . $k . "][aday]' value='" . $v['aday'] . "'>"; |
||
| 498 | $ret .= "<input type='hidden' name='busca[" . $k . "][amonth]' value='" . $v['amonth'] . "'>"; |
||
| 499 | $ret .= "<input type='hidden' name='busca[" . $k . "][ayear]' value='" . $v['ayear'] . "'>"; |
||
| 500 | } |
||
| 501 | } |
||
| 502 | } |
||
| 503 | $ret .= "<input type='hidden' name='op' value='" . $op . "'><input type='hidden' name='sort' value='" . $sort . "'><input type='hidden' name='order' value='" . $order . "'>"; |
||
| 504 | $ret .= " <input type='image' src='../assets/images/envia.gif' style='border:0; background-color:transparent' align='absmiddle'></form>"; |
||
| 505 | $ret .= "<table width='100%' border='0' cellspacing='0'>"; |
||
| 506 | $ret .= "<tbody><tr><td colspan='" . $colunas . "' align='right'>" . sprintf($campos['lang']['exibindo'], $start + 1, ((($start + $limit) < $contar) ? $start + $limit : $contar), $contar) . '</td></tr></tbody>'; |
||
| 507 | $ret .= "<tbody><tr class='hd'>"; |
||
| 508 | $ret .= $checks ? "<td align='center'><input type='checkbox' name='checkAll' id='checkAll' onclick='changecheck();'></td>" : ''; |
||
| 509 | foreach ($campos['rotulo'] as $k => $v) { |
||
| 510 | $ret .= "<td nowrap='nowrap' align='center' " . (($sort == $campos['nome'][$k] |
||
| 511 | && empty($campos['nosort'][$k])) ? "class='hds'" : '') . '>' . (empty($campos['nosort'][$k]) ? "<A HREF='" |
||
| 512 | . $url_colunas |
||
| 513 | . '&sort=' |
||
| 514 | . $campos['nome'][$k] |
||
| 515 | . '&order=' |
||
| 516 | . $norder |
||
| 517 | . "'>" |
||
| 518 | . $v |
||
| 519 | . ' ' |
||
| 520 | . (($sort |
||
| 521 | == $campos['nome'][$k]) ? '<img src=' |
||
| 522 | . $pathIcon16 |
||
| 523 | . '/' |
||
| 524 | . $order |
||
| 525 | . ".png align='absmiddle'>" : '') |
||
| 526 | . '</a></td>' : $v . '</td>'); |
||
| 527 | } |
||
| 528 | $ret .= !empty($campos['botoes']) ? "<td align='center'>" . $campos['lang']['acao'] . '</td>' : ''; |
||
| 529 | $ret .= '</tr></tbody>'; |
||
| 530 | if (empty($campos['nofilters'])) { |
||
| 531 | $ret .= "<form action='" . $url . "' method='GET' name='form_busca'><tbody><tr id='busca' " . (Request::hasVar('busca', 'GET') ? '' : "style='display:none'") . " class='neutro'>"; |
||
| 532 | $ret .= $checks ? '<td> </td>' : ''; |
||
| 533 | foreach ($campos['rotulo'] as $k => $v) { |
||
| 534 | $ret .= "<td align='center' nowrap='nowrap'>"; |
||
| 535 | switch ($campos['tipo'][$k]) { |
||
| 536 | case 'none': |
||
| 537 | break; |
||
| 538 | case 'date': |
||
| 539 | $ret .= "<input type='text' name='busca[" |
||
| 540 | . $campos['nome'][$k] |
||
| 541 | . "][dday]' size='2' maxlength='2' value=" |
||
| 542 | . (Request::hasVar('busca', 'GET')[$campos['nome'][$k]]['dday'] ? Request::getArray('busca', [], 'GET')[$campos['nome'][$k]]['dday'] : '') |
||
| 543 | . "> <input type='text' name='busca[" |
||
| 544 | . $campos['nome'][$k] |
||
| 545 | . "][dmonth]' size='2' maxlength='2' value=" |
||
| 546 | . (Request::hasVar('busca', 'GET')[$campos['nome'][$k]]['dmonth'] ? Request::getArray('busca', [], 'GET')[$campos['nome'][$k]]['dmonth'] : '') |
||
| 547 | . "> <input type='text' name='busca[" |
||
| 548 | . $campos['nome'][$k] |
||
| 549 | . "][dyear]' size='2' maxlength='4' value=" |
||
| 550 | . (Request::hasVar('busca', 'GET')[$campos['nome'][$k]]['dyear'] ? Request::getArray('busca', [], 'GET')[$campos['nome'][$k]]['dyear'] : '') |
||
| 551 | . '><br>'; |
||
| 552 | $ret .= "<input type='text' name='busca[" |
||
| 553 | . $campos['nome'][$k] |
||
| 554 | . "][aday]' size='2' maxlength='2' value=" |
||
| 555 | . (Request::hasVar('busca', 'GET')[$campos['nome'][$k]]['aday'] ? Request::getArray('busca', [], 'GET')[$campos['nome'][$k]]['aday'] : '') |
||
| 556 | . "> <input type='text' name='busca[" |
||
| 557 | . $campos['nome'][$k] |
||
| 558 | . "][amonth]' size='2' maxlength='2' value=" |
||
| 559 | . (Request::hasVar('busca', 'GET')[$campos['nome'][$k]]['amonth'] ? Request::getArray('busca', [], 'GET')[$campos['nome'][$k]]['amonth'] : '') |
||
| 560 | . "> <input type='text' name='busca[" |
||
| 561 | . $campos['nome'][$k] |
||
| 562 | . "][ayear]' size='2' maxlength='4' value=" |
||
| 563 | . (Request::hasVar('busca', 'GET')[$campos['nome'][$k]]['ayear'] ? Request::getArray('busca', [], 'GET')[$campos['nome'][$k]]['ayear'] : '') |
||
| 564 | . '>'; |
||
| 565 | break; |
||
| 566 | case 'select': |
||
| 567 | $ret .= "<select name='busca[" . $campos['nome'][$k] . "]'><option value='-1'>" . _SELECT . '</option>'; |
||
| 568 | foreach ($campos['options'][$k] as $x => $y) { |
||
| 569 | $ret .= "<option value='" . $x . "'"; |
||
| 570 | $ret .= (isset(Request::getArray('busca', [], 'GET') [$campos['nome'][$k]]) |
||
| 571 | && Request::getArray('busca', [], 'GET') [$campos['nome'][$k]] == $x) ? ' selected' : ''; |
||
| 572 | $ret .= '>' . $y . '</option>'; |
||
| 573 | } |
||
| 574 | $ret .= '</select>'; |
||
| 575 | break; |
||
| 576 | case 'simnao': |
||
| 577 | $ret .= "<select name='busca[" . $campos['nome'][$k] . "]'><option value='-1'>" . _SELECT . '</option>'; |
||
| 578 | $ret .= "<option value='1'"; |
||
| 579 | $ret .= (isset(Request::getArray('busca', [], 'GET') [$campos['nome'][$k]]) |
||
| 580 | && 1 == Request::getArray('busca', [], 'GET') [$campos['nome'][$k]]) ? ' selected' : ''; |
||
| 581 | $ret .= '>' . _YES . '</option>'; |
||
| 582 | $ret .= "<option value='0'"; |
||
| 583 | $ret .= (isset(Request::getArray('busca', [], 'GET') [$campos['nome'][$k]]) |
||
| 584 | && 0 == Request::getArray('busca', [], 'GET') [$campos['nome'][$k]]) ? ' selected' : ''; |
||
| 585 | $ret .= '>' . _NO . '</option>'; |
||
| 586 | $ret .= '</select>'; |
||
| 587 | break; |
||
| 588 | case 'text': |
||
| 589 | default: |
||
| 590 | $ret .= "<input type='text' name='busca[" |
||
| 591 | . $campos['nome'][$k] |
||
| 592 | . "]' value='" |
||
| 593 | . (isset(Request::getArray('busca', [], 'GET') [$campos['nome'][$k]]) ? Request::getArray('busca', [], 'GET') [$campos['nome'][$k]] : '') |
||
| 594 | . "' size='" |
||
| 595 | . (isset($campos['tamanho'][$k]) ? $campos['tamanho'][$k] : 20) |
||
| 596 | . "'>"; |
||
| 597 | } |
||
| 598 | if (empty($campos['botoes']) && $k == count($campos['rotulo'])) { |
||
| 599 | $ret .= " <input type='image' src='../assets/images/envia.gif' style='border:0; background-color:transparent' align='absmiddle'>"; |
||
| 600 | } |
||
| 601 | $ret .= '</td>'; |
||
| 602 | } |
||
| 603 | $ret .= !empty($campos['botoes']) ? "<td align='center'><input type='image' src='../assets/images/envia.gif' style='border:0; background-color:transparent'></td>" : ''; |
||
| 604 | $ret .= '</tr></tbody>'; |
||
| 605 | $ret .= $precrit_hidden . "<input type='hidden' name='op' value='" . $op . "'><input type='hidden' name='sort' value='" . $sort . "'><input type='hidden' name='order' value='" . $order . "'><input type='hidden' name='limit' value='" . $limit . "'></form>"; |
||
| 606 | } |
||
| 607 | $registros = empty($campos['join']) ? $this->pegaTudo($criterio) : $this->pegaTudo($criterio, true, $campos['join']); |
||
| 608 | if (!$registros || 0 == count($registros)) { |
||
| 609 | $ret .= "<tbody><tr><td colspan='" . $colunas . "'><h2>" . $campos['lang']['semresult'] . '</h2></td></tr></tbody>'; |
||
| 610 | $ret .= "<tbody><tr class='bx'><td colspan='" . $colunas . "' align='left'>" . $this->paginar($url_full_pg, $criterio, $precrit_url) . '</td></tr></tbody>'; |
||
| 611 | } else { |
||
| 612 | $ret .= ($form || $checks) ? "<form action='" . $url . "' method='POST' name='update_form' id='update_form' " . ($checks ? "onsubmit='return verificaChecks()'" : '') . '>' : ''; |
||
| 613 | foreach ($registros as $reg) { |
||
| 614 | $eod = (!isset($eod) || 'fundo1' === $eod) ? 'fundo2' : 'fundo1'; |
||
| 615 | $ret .= "<tbody><tr id='tr_reg_" . $reg->getVar($reg->id) . "' class='" . $eod . "' onmouseover='this.className=\"neutro\";' onmouseout='this.className=\"" . $eod . "\"'>"; |
||
| 616 | $ret .= $checks ? "<td align='center'><input type='checkbox' name='checks[" |
||
| 617 | . $reg->getVar($reg->id) |
||
| 618 | . "]' id='checks[" |
||
| 619 | . $reg->getVar($reg->id) |
||
| 620 | . "]' value='1' onclick='marcaCheck(\"tr_reg_" |
||
| 621 | . $reg->getVar($reg->id) |
||
| 622 | . '", "checks[' |
||
| 623 | . $reg->getVar($reg->id) |
||
| 624 | . ']", "' |
||
| 625 | . $eod |
||
| 626 | . "\");'></td>" : ''; |
||
| 627 | foreach ($campos['rotulo'] as $l => $f) { |
||
| 628 | $ret .= '<td>'; |
||
| 629 | switch ($campos['tipo'][$l]) { |
||
| 630 | case 'none': |
||
| 631 | $ret .= empty($campos['show'][$l]) ? $reg->getVar($campos['nome'][$l]) : eval('return ' . $campos['show'][$l] . ';'); |
||
| 632 | break; |
||
| 633 | case 'date': |
||
| 634 | $ret .= (!empty($campos['show'][$l]) ? eval('return ' . $campos['show'][$l] . ';') : ((0 != $reg->getVar($campos['nome'][$l]) |
||
| 635 | && '' !== $reg->getVar($campos['nome'][$l])) ? date(_SHORTDATESTRING, $reg->getVar($campos['nome'][$l])) : '')); |
||
| 636 | break; |
||
| 637 | case 'select': |
||
| 638 | if ($form && empty($campos['show'][$l])) { |
||
| 639 | $ret .= "<select name='campos[" . $reg->getVar($reg->id) . '][' . $campos['nome'][$l] . "]'>"; |
||
| 640 | foreach ($campos['options'][$l] as $x => $y) { |
||
| 641 | $ret .= "<option value='" . $x . "'"; |
||
| 642 | $ret .= ($reg->getVar($campos['nome'][$l]) == $x) ? ' selected' : ''; |
||
| 643 | $ret .= '>' . $y . '</option>'; |
||
| 644 | } |
||
| 645 | $ret .= '</select>'; |
||
| 646 | } elseif (!empty($campos['show'][$l])) { |
||
| 647 | $ret .= eval('return ' . $campos['show'][$l] . ';'); |
||
| 648 | } else { |
||
| 649 | $ret .= isset($campos['options'][$l][$reg->getVar($campos['nome'][$l])]) ? $campos['options'][$l][$reg->getVar($campos['nome'][$l])] : $reg->getVar($campos['nome'][$l]); |
||
| 650 | } |
||
| 651 | break; |
||
| 652 | case 'simnao': |
||
| 653 | if ($form && empty($campos['show'][$l])) { |
||
| 654 | $ret .= "<select name='campos[" . $reg->getVar($reg->id) . '][' . $campos['nome'][$l] . "]'>"; |
||
| 655 | $ret .= "<option value='1'"; |
||
| 656 | $ret .= (1 == $reg->getVar($campos['nome'][$l])) ? ' selected' : ''; |
||
| 657 | $ret .= '>' . _YES . '</option>'; |
||
| 658 | $ret .= "<option value='0'"; |
||
| 659 | $ret .= (0 == $reg->getVar($campos['nome'][$l])) ? ' selected' : ''; |
||
| 660 | $ret .= '>' . _NO . '</option>'; |
||
| 661 | $ret .= '</select>'; |
||
| 662 | } elseif (!empty($campos['show'][$l])) { |
||
| 663 | $ret .= eval('return ' . $campos['show'][$l] . ';'); |
||
| 664 | } else { |
||
| 665 | $ret .= (1 == $reg->getVar($campos['nome'][$l])) ? _YES : ((0 == $reg->getVar($campos['nome'][$l])) ? _NO : $reg->getVar($campos['nome'][$l])); |
||
| 666 | } |
||
| 667 | break; |
||
| 668 | case 'text': |
||
| 669 | default: |
||
| 670 | |||
| 671 | // $bong = $campos['nome'][$l]; |
||
| 672 | // $bong2 = $reg->getVar($campos['nome'][$l]); |
||
| 673 | // echo $bong . '---- 1 <br><br>'; |
||
| 674 | // echo $bong2 .'---- 2<br><br>'; |
||
| 675 | // echo 'show: ' . $campos['show'][$l] . '---- 3<br><br><br>'; |
||
| 676 | |||
| 677 | $ret .= ($form && empty($campos['show'][$l])) ? ("<input type='text' name='campos[" |
||
| 678 | . $reg->getVar($reg->id) |
||
| 679 | . '][' |
||
| 680 | . $campos['nome'][$l] |
||
| 681 | . "]' value='" |
||
| 682 | . $reg->getVar($campos['nome'][$l]) |
||
| 683 | . "' size='" |
||
| 684 | . (isset($campos['tamanho'][$l]) ? $campos['tamanho'][$l] : 20) |
||
| 685 | . "'>") |
||
| 686 | |||
| 687 | : (!empty($campos['show'][$l]) ? eval('return ' . $campos['show'][$l] . ';') : $reg->getVar($campos['nome'][$l])); |
||
| 688 | } |
||
| 689 | |||
| 690 | $ret .= '</td>'; |
||
| 691 | } |
||
| 692 | //$ret.= "<td nowrap='nowrap'><a href='".$url."?op=".$op."_editar&".$reg->id."=".$reg->getVar($reg->id)."'><img src='../assets/images/editar.gif'></a> <a href='".$url."?op=".$op."_deletar&".$reg->id."=".$reg->getVar($reg->id)."'><img src='../assets/images/deletar.gif'></a> ".((!empty($campos['print'])) ? "<a href='".$url."?op=".$op."_imprime&".$reg->id."=".$reg->getVar($reg->id)."' target='_blank'><img src='../assets/images/imprime.gif'></a>" : ''); |
||
| 693 | if (!empty($campos['botoes'])) { |
||
| 694 | $ret .= "<td nowrap='nowrap'>"; |
||
| 695 | if (is_array($campos['botoes'])) { |
||
| 696 | foreach ($campos['botoes'] as $b) { |
||
| 697 | $ret .= "<a href='" . $b['link'] . '&' . $reg->id . '=' . $reg->getVar($reg->id) . "' title='" . $b['texto'] . "'><img src='" . $b['imagem'] . "' alt='" . $b['texto'] . "'></a> "; |
||
| 698 | } |
||
| 699 | } |
||
| 700 | $ret .= '</td>'; |
||
| 701 | } |
||
| 702 | $ret .= '</tr></tbody>'; |
||
| 703 | } |
||
| 704 | if ($form || $checks) { |
||
| 705 | $ret .= "<tbody><tr><td colspan='" . $colunas . "'>"; |
||
| 706 | $ret .= $precrit_hidden . "<input type='hidden' name='sort' value='" . $sort . "'><input type='hidden' name='order' value='" . $order . "'><input type='hidden' name='limit' value='" . $limit . "'><input type='hidden' name='start' value='" . $start . "'>"; |
||
| 707 | if (Request::hasVar('busca', 'GET')) { |
||
| 708 | foreach (Request::getArray('busca', [], 'GET') as $k => $v) { |
||
| 709 | if ('' !== $v && '-1' != $v && !is_array($v)) { |
||
| 710 | $ret .= "<input type='hidden' name='busca[" . $k . "]' value='" . $v . "'>"; |
||
| 711 | } elseif (is_array($v)) { |
||
| 712 | $ret .= "<input type='hidden' name='busca[" . $k . "][dday]' value='" . $v['dday'] . "'>"; |
||
| 713 | $ret .= "<input type='hidden' name='busca[" . $k . "][dmonth]' value='" . $v['dmonth'] . "'>"; |
||
| 714 | $ret .= "<input type='hidden' name='busca[" . $k . "][dyear]' value='" . $v['dyear'] . "'>"; |
||
| 715 | $ret .= "<input type='hidden' name='busca[" . $k . "][aday]' value='" . $v['aday'] . "'>"; |
||
| 716 | $ret .= "<input type='hidden' name='busca[" . $k . "][amonth]' value='" . $v['amonth'] . "'>"; |
||
| 717 | $ret .= "<input type='hidden' name='busca[" . $k . "][ayear]' value='" . $v['ayear'] . "'>"; |
||
| 718 | } |
||
| 719 | } |
||
| 720 | } |
||
| 721 | $ret .= "<input type='hidden' name='op' value='" . $op . "'> <br>"; |
||
| 722 | if ($checks) { |
||
| 723 | $ret .= $campos['lang']['group_action'] . " <select name='group_action' id='group_action'><option value='0'>" . _SELECT . '</option>'; |
||
| 724 | $ret .= !empty($campos['group_del']) ? "<option value='group_del'>" . $campos['lang']['group_del'] . '</option>' : ''; |
||
| 725 | if (!empty($campos['group_action'])) { |
||
| 726 | foreach ($campos['group_action'] as $grp) { |
||
| 727 | $ret .= "<option value='" . $grp['valor'] . "'>" . $grp['texto'] . '</option>'; |
||
| 728 | } |
||
| 729 | } |
||
| 730 | $ret .= '</select> '; |
||
| 731 | } |
||
| 732 | $ret .= "<input type='submit' value='" . _SUBMIT . "'><br> </td></tr></tbody></form>"; |
||
| 733 | } |
||
| 734 | $ret .= !empty($campos['soma']) ? "<tbody><tr class='bx'><td colspan='" . $colunas . "' align='right'>Total: R$ " . number_format($this->soma($criterio, $campos['soma']), 2, ',', '.') . '</td></tr></tbody>' : ''; |
||
| 735 | $ret .= "<tbody><tr class='bx'><td colspan='" . $colunas . "' align='left'>" . $this->paginar($url_full_pg, $criterio, $precrit_url) . '</td></tr></tbody>'; |
||
| 736 | } |
||
| 737 | $ret .= '</table></div></td></tr></table><br>'; |
||
| 738 | |||
| 739 | return $ret; |
||
| 740 | } |
||
| 850 |