PageRenderTime 28ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/workflow/engine/methods/cases/proxyReassignCasesList.php

https://bitbucket.org/ferOnti/processmaker
PHP | 97 lines | 80 code | 14 blank | 3 comment | 6 complexity | 6cb3728eb209c174e73f7fccc7ad046b MD5 | raw file
  1. <?php
  2. $callback = isset( $_POST['callback'] ) ? $_POST['callback'] : 'stcCallback1001';
  3. $dir = isset( $_POST['dir'] ) ? $_POST['dir'] : 'DESC';
  4. $sort = isset( $_POST['sort'] ) ? $_POST['sort'] : '';
  5. $start = isset( $_POST['start'] ) ? $_POST['start'] : '0';
  6. $limit = isset( $_POST['limit'] ) ? $_POST['limit'] : '25';
  7. $filter = isset( $_POST['filter'] ) ? $_POST['filter'] : '';
  8. $search = isset( $_POST['search'] ) ? $_POST['search'] : '';
  9. $process = isset( $_POST['process'] ) ? $_POST['process'] : '';
  10. $user = isset( $_POST['user'] ) ? $_POST['user'] : '';
  11. $status = isset( $_POST['status'] ) ? strtoupper( $_POST['status'] ) : '';
  12. $action = isset( $_GET['action'] ) ? $_GET['action'] : (isset( $_POST['action'] ) ? $_POST['action'] : 'todo');
  13. $type = isset( $_GET['type'] ) ? $_GET['type'] : (isset( $_POST['type'] ) ? $_POST['type'] : 'extjs');
  14. $user = isset( $_POST['user'] ) ? $_POST['user'] : '';
  15. $sentUids = explode( ',', $_POST['APP_UIDS'] );
  16. $allUidsRecords = array ();
  17. $allTasUids = array ();
  18. // getting all App Uids and task Uids
  19. foreach ($sentUids as $sentUid) {
  20. $aItem = explode( '|', $sentUid );
  21. $allUidsRecords[] = array ('APP_UID' => $aItem[0],'TAS_UID' => $aItem[1],'DEL_INDEX' => $aItem[2]);
  22. }
  23. $sReassignFromUser = isset( $_POST['user'] ) ? $_POST['user'] : '';
  24. $sProcessUid = isset( $_POST['process'] ) ? $_POST['process'] : '';
  25. G::LoadClass( 'tasks' );
  26. G::LoadClass( 'groups' );
  27. G::LoadClass( 'case' );
  28. G::LoadClass( 'users' );
  29. require_once ("classes/model/AppCacheView.php");
  30. $oTasks = new Tasks();
  31. $oGroups = new Groups();
  32. $oUser = new Users();
  33. $oCases = new Cases();
  34. $aCasesList = Array ();
  35. $vard = 0;
  36. foreach ($allUidsRecords as $aRecord) {
  37. $vard = $vard + 1;
  38. $APP_UID = $aRecord['APP_UID'];
  39. $delIndex = $aRecord['DEL_INDEX'];
  40. $aCase = $oCases->loadCaseByDelegation( $APP_UID, $delIndex );
  41. $aUsersInvolved = Array ();
  42. $aCaseGroups = $oTasks->getGroupsOfTask( $aCase['TAS_UID'], 1 );
  43. foreach ($aCaseGroups as $aCaseGroup) {
  44. $aCaseUsers = $oGroups->getUsersOfGroup( $aCaseGroup['GRP_UID'] );
  45. foreach ($aCaseUsers as $aCaseUser) {
  46. if ($aCaseUser['USR_UID'] != $sReassignFromUser) {
  47. $aCaseUserRecord = $oUser->load( $aCaseUser['USR_UID'] );
  48. $aUsersInvolved[] = array ('userUid' => $aCaseUser['USR_UID'],'userFullname' => $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']);
  49. // . ' (' . $aCaseUserRecord['USR_USERNAME']
  50. }
  51. }
  52. }
  53. $aCaseUsers = $oTasks->getUsersOfTask( $aCase['TAS_UID'], 1 );
  54. foreach ($aCaseUsers as $aCaseUser) {
  55. if ($aCaseUser['USR_UID'] != $sReassignFromUser) {
  56. $aCaseUserRecord = $oUser->load( $aCaseUser['USR_UID'] );
  57. $aUsersInvolved[] = array ('userUid' => $aCaseUser['USR_UID'],'userFullname' => $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']
  58. );
  59. }
  60. }
  61. $oTmp = $aUsersInvolved;
  62. $aCase['USERS'] = $oTmp;
  63. array_push( $aCasesList, $aCase );
  64. }
  65. $filedNames = Array ("APP_UID","APP_NUMBER","APP_UPDATE_DATE","DEL_PRIORITY","DEL_INDEX","TAS_UID","DEL_INIT_DATE","DEL_FINISH_DATE","USR_UID","APP_STATUS","DEL_TASK_DUE_DATE","APP_CURRENT_USER","APP_TITLE","APP_PRO_TITLE","APP_TAS_TITLE","APP_DEL_PREVIOUS_USER","USERS"
  66. );
  67. $aCasesList = array_merge( Array ($filedNames
  68. ), $aCasesList );
  69. $rows = array ();
  70. $i = $start;
  71. for ($j = 0; $j < $limit; $j ++) {
  72. $i ++;
  73. if (isset( $aCasesList[$i] )) {
  74. $rows[] = $aCasesList[$i];
  75. }
  76. }
  77. $totalCount = count( $aCasesList ) - 1;
  78. $result = array ();
  79. $result['totalCount'] = $totalCount;
  80. $index = $start;
  81. $result['data'] = $rows;
  82. //print the result in json format
  83. print G::json_encode( $result );