superedit-VIEWTABLE_AJAX.php 2.5 KB

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