superedit-VIEWTABLE_AJAX.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. Lib::loadClass('ProcesHelper');
  3. Lib::loadClass('Request');
  4. function VIEWTABLE_AJAX($params = array()) {
  5. try {
  6. SE_Layout::menu();
  7. $zasobID = V::get('ZASOB_ID', 0, $_GET, 'int');
  8. if ($zasobID <= 0) throw new Exception("Wrong param ZASOB_ID");
  9. $zasobObj = ProcesHelper::getZasobTableInfo($zasobID);
  10. if (!$zasobObj) throw new Exception("Zasob TABELA ID={$zasobID} nie istnieje");
  11. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">zasobObj (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($zasobObj);echo'</pre>';
  12. $userAcl = User::getAcl();
  13. $userAcl->fetchGroups();
  14. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;display:none;">$userAcl (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($userAcl);echo'</pre>';
  15. if (!$userAcl->hasTableAcl($zasobObj->ID)) throw new Exception("Brak uprawnień do tabeli ID={$zasobObj->ID}");
  16. $acl = $userAcl->getTableAcl($zasobObj->ID);
  17. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">tblAcl (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($acl);echo'</pre>';
  18. $forceTblAclInit = ('1' == V::get('_force', '', $_GET));
  19. $acl->init($forceTblAclInit);
  20. Lib::loadClass('TableAjax');
  21. $forceFilterInit = array();
  22. $filterInit = new stdClass();
  23. $filterInit->currSortCol = 'ID';
  24. $filterInit->currSortFlip = 'desc';
  25. foreach ($_GET as $k => $v) {
  26. if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
  27. $filterInit->$k = $v;
  28. }
  29. else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
  30. $filterInit->$k = $v;
  31. }
  32. else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
  33. $fldName = substr($k, 3);
  34. $forceFilterInit[$fldName] = $v;
  35. }
  36. }
  37. $tbl = new TableAjax($acl);
  38. $syncUrl = Request::getPathUri() . 'index.php?_route=ViewTableAjax&namespace=' . $acl->getNamespace();
  39. $tbl->setSyncUrl($syncUrl);
  40. $tblLabel = array();
  41. if (!empty($zasobObj->DESC_PL)) $tblLabel []= $zasobObj->DESC_PL;
  42. if (!empty($zasobObj->OPIS)) $tblLabel []= $zasobObj->OPIS;
  43. $tblLabel = implode(" - ", $tblLabel);
  44. $tbl->setLabel($tblLabel);
  45. $tbl->setFilterInit($filterInit);
  46. if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
  47. $tbl->addRowFunction('edit');
  48. $tbl->addRowFunction('hist');
  49. $tbl->addRowFunction('files');
  50. $tbl->addRowFunction('cp');
  51. $tbl->addRowFunction('msgs');
  52. echo $tbl->render();
  53. } catch (Exception $e) {
  54. echo '<div class="container">';
  55. SE_Layout::alert('danger', "<strong>Wystąpiły błędy!</strong> " . $e->getMessage());
  56. echo '</div>';
  57. }
  58. }