diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php index f8b476545..c2015ae7d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php @@ -723,6 +723,7 @@ class Light */ public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data) { + $response = array("status" => "fail"); if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) { $arrayField = array (); $arrayFileName = array (); @@ -773,6 +774,7 @@ class Light $sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP; $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension; G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName ); + $response = array("status" => "ok"); } } } @@ -780,4 +782,31 @@ class Light return $response; } + + /** + * claim case + * + * @param $userUid + * @param $Fields + * @param $type + * @throws \Exception + */ + public function claimCaseUser($userUid, $sAppUid) + { + $response = array("status" => "fail"); + $oCase = new \Cases(); + $iDelIndex = $oCase->getCurrentDelegation( $sAppUid, $userUid ); + + $oAppDelegation = new \AppDelegation(); + $aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex ); + + //if there are no user in the delegation row, this case is still in selfservice + if ($aDelegation['USR_UID'] == "") { + $oCase->setCatchUser( $sAppUid,$iDelIndex, $userUid ); + $response = array("status" => "ok"); + } else { + //G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' ); + } + return $response; + } } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Light.php b/workflow/engine/src/ProcessMaker/Services/Api/Light.php index 1e3f7687d..c3421e0c6 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Light.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Light.php @@ -794,10 +794,28 @@ class Light extends Api try { $userUid = $this->getUserId(); $oMobile = new \ProcessMaker\BusinessModel\Light(); - $filesUids = $oMobile->documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data); + $response = $oMobile->documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } - return $filesUids; + return $response; + } + + /** + * @url POST /case/:app_uid/claim + * + * @param $app_uid + * @return mixed + */ + public function claimCaseUser($app_uid) + { + try { + $userUid = $this->getUserId(); + $oMobile = new \ProcessMaker\BusinessModel\Light(); + $response = $oMobile->claimCaseUser($userUid, $app_uid); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $response; } }