superedit-PROCES_MENU.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. Lib::loadClass('TypespecialVariable');
  3. function PROCES_MENU() {
  4. $taskMsgs = array();
  5. $taskErrors = array();
  6. $task = V::get('_task', '', $_REQUEST);
  7. switch ($task) {
  8. case 'TYPESPECIAL': {
  9. $DBG = ('1' == V::get('DBG', '', $_REQUEST));
  10. header("Content-type: application/json");
  11. $fld = V::get('fld', '', $_GET);
  12. switch ($fld) {
  13. case '_user_id': {
  14. $typeSpecialUserId = TypespecialVariable::getInstance(-1, '__USER_ID');
  15. if (!$typeSpecialUserId) {
  16. $jsonData = new stdClass();
  17. $jsonData->message = "TypeSpecial '__USER_ID' not exists";
  18. echo json_encode($jsonData);
  19. exit;
  20. }
  21. $query = V::get('q', '', $_REQUEST);
  22. $rawRows = null;
  23. $jsonData = array();
  24. $queryParams = array();
  25. $rows = $typeSpecialUserId->getValuesWithExports($query, $queryParams);
  26. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
  27. foreach ($rows as $kID => $vItem) {
  28. $itemJson = new stdClass();
  29. $itemJson->id = $vItem->id;
  30. $itemJson->name = $vItem->param_out;
  31. if (!empty($vItem->exports)) {
  32. $itemJson->exports = $vItem->exports;
  33. }
  34. $jsonData[] = $itemJson;
  35. }
  36. echo json_encode($jsonData);
  37. break;
  38. }
  39. case 'ProcesMenu__Proces_filtr_id': {
  40. $typeSpecialProces = TypespecialVariable::getInstance(-1, '__PROCES');
  41. if (!$typeSpecialProces) {
  42. $jsonData = new stdClass();
  43. $jsonData->message = "TypeSpecial '__PROCES' not exists";
  44. echo json_encode($jsonData);
  45. exit;
  46. }
  47. $query = V::get('q', '', $_REQUEST);
  48. $rawRows = null;
  49. $jsonData = array();
  50. $queryParams = array();
  51. $rows = $typeSpecialProces->getValuesWithExports($query, $queryParams);
  52. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
  53. foreach ($rows as $kID => $vItem) {
  54. $itemJson = new stdClass();
  55. $itemJson->id = $vItem->id;
  56. $itemJson->name = $vItem->param_out;
  57. if (!empty($vItem->exports)) {
  58. $itemJson->exports = $vItem->exports;
  59. }
  60. $jsonData[] = $itemJson;
  61. }
  62. echo json_encode($jsonData);
  63. break;
  64. }
  65. case 'ProcesMenu__Zasob_filtr_id': {
  66. $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
  67. if (!$typeSpecialZasob) {
  68. $jsonData = new stdClass();
  69. $jsonData->message = "TypeSpecial '__ZASOB' not exists";
  70. echo json_encode($jsonData);
  71. exit;
  72. }
  73. $query = V::get('q', '', $_REQUEST);
  74. $rawRows = null;
  75. $jsonData = array();
  76. $queryParams = array();
  77. $rows = $typeSpecialZasob->getValuesWithExports($query, $queryParams);
  78. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
  79. foreach ($rows as $kID => $vItem) {
  80. $itemJson = new stdClass();
  81. $itemJson->id = $vItem->id;
  82. $itemJson->name = $vItem->param_out;
  83. if (!empty($vItem->exports)) {
  84. $itemJson->exports = $vItem->exports;
  85. }
  86. $jsonData[] = $itemJson;
  87. }
  88. echo json_encode($jsonData);
  89. break;
  90. }
  91. }
  92. exit;
  93. }
  94. case 'PROCES_FOR_TABLE': {
  95. $tblId = V::get('tblId', 0, $_REQUEST, 'int');
  96. $tableProcesInitIds = ACL::getTableProcesInitIds($tblId);
  97. $tableProcesIdsCSV = implode(",", $tableProcesInitIds);
  98. $url = Request::getPathUri() . "procesy5.php?task=CRM_PROCES&filtr_id={$tableProcesIdsCSV}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B";
  99. if (!headers_sent()) {
  100. header('HTTP/1.1 303 See Other');
  101. header('Location: '.$url);
  102. } else {
  103. ?>
  104. <script type="text/javascript">
  105. window.location.href='<?php echo $url; ?>';
  106. </script>
  107. <noscript>
  108. <meta http-equiv="refresh" content="0;url=<?php echo $url; ?>" />
  109. </noscript>
  110. <p><a href="<?php echo $url; ?>">dalej</a></p>
  111. <?php
  112. }
  113. exit;
  114. }
  115. case 'PROCES_FOR_USER': {
  116. // <a href="procesy5.php?task=CRM_PROCES echo "&filtr_id={$userProcesIdsCSV}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B"; ">Moje Procesy</a>
  117. $userAcl = User::getAcl();
  118. $usedProcesInitIds = $userAcl->getUserProcesInitIds();
  119. $userProcesIdsCSV = implode(",", $usedProcesInitIds);
  120. $url = Request::getPathUri() . "procesy5.php?task=CRM_PROCES&filtr_id={$userProcesIdsCSV}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B";
  121. if (!headers_sent()) {
  122. header('HTTP/1.1 303 See Other');
  123. header('Location: '.$url);
  124. } else {
  125. ?>
  126. <script type="text/javascript">
  127. window.location.href='<?php echo $url; ?>';
  128. </script>
  129. <noscript>
  130. <meta http-equiv="refresh" content="0;url=<?php echo $url; ?>" />
  131. </noscript>
  132. <p><a href="<?php echo $url; ?>">dalej</a></p>
  133. <?php
  134. }
  135. exit;
  136. }
  137. }
  138. }