change in response type endpoint paused and participated

This commit is contained in:
Ronald Quenta
2015-03-11 15:27:08 -04:00
parent 7016a8afa9
commit 563c3c5f4b
2 changed files with 45 additions and 11 deletions

View File

@@ -604,15 +604,17 @@ class Light
*/ */
public function getInformation($userUid, $type, $app_uid) public function getInformation($userUid, $type, $app_uid)
{ {
//$response = array();
switch ($type) { switch ($type) {
case 'paused': case 'paused':
case 'participated': case 'participated':
$oCase = new \Cases(); $oCase = new \Cases();
$iDelIndex = $oCase->getCurrentDelegationCase( $app_uid ); $iDelIndex = $oCase->getCurrentDelegationCase( $app_uid );
$aFields = $oCase->loadCase( $app_uid, $iDelIndex ); $aFields = $oCase->loadCase( $app_uid, $iDelIndex );
$this->getInfoResume($userUid, $aFields, $type); $response = $this->getInfoResume($userUid, $aFields, $type);
break; break;
} }
return $response;
} }
/** /**
@@ -662,9 +664,10 @@ class Light
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE']; $Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
} }
require_once(PATH_GULLIVER .'../thirdparty/smarty/libs/Smarty.class.php'); // require_once(PATH_GULLIVER .'../thirdparty/smarty/libs/Smarty.class.php');
$G_PUBLISH = new \Publisher(); // $G_PUBLISH = new \Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '' ); // $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '' );
$G_PUBLISH->RenderContent(); // $G_PUBLISH->RenderContent();
return $Fields;
} }
} }

View File

@@ -351,26 +351,27 @@ class Light extends Api
foreach ($d as $field => $value) { foreach ($d as $field => $value) {
if (array_key_exists($field, $structure)) { if (array_key_exists($field, $structure)) {
$newName = $structure[$field]; $newName = $structure[$field];
$newData[$newName] = $value; $newData[$newName] = is_null($value) ? "":$value;
} else { } else {
foreach ($structure as $name => $str) { foreach ($structure as $name => $str) {
if (is_array($str) && array_key_exists($field, $str)) { if (is_array($str) && array_key_exists($field, $str)) {
$newName = $str[$field]; $newName = $str[$field];
$newData[$name][$newName] = $value; $newData[$name][$newName] = is_null($value) ? "":$value;
} }
} }
} }
} }
if (count($newData) > 0)
$response[] = $newData; $response[] = $newData;
} else { } else {
if (array_key_exists($field, $structure)) { if (array_key_exists($field, $structure)) {
$newName = $structure[$field]; $newName = $structure[$field];
$response[$newName] = $d; $response[$newName] = is_null($d) ? "":$d;
} else { } else {
foreach ($structure as $name => $str) { foreach ($structure as $name => $str) {
if (is_array($str) && array_key_exists($field, $str)) { if (is_array($str) && array_key_exists($field, $str)) {
$newName = $str[$field]; $newName = $str[$field];
$response[$name][$newName] = $d; $response[$name][$newName] = is_null($d) ? "":$d;
} }
} }
} }
@@ -726,9 +727,39 @@ class Light extends Api
try { try {
$userUid = $this->getUserId(); $userUid = $this->getUserId();
$oMobile = new \ProcessMaker\BusinessModel\Light(); $oMobile = new \ProcessMaker\BusinessModel\Light();
$oMobile->getInformation($userUid, $type, $app_uid); $response = $oMobile->getInformation($userUid, $type, $app_uid);
$response = $this->parserGetInformation($response);
} catch (\Exception $e) { } catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
} }
return $response;
}
public function parserGetInformation ($data)
{
$structure = array(
'case' => array(
'PRO_TITLE' => 'processTitle',
'APP_TITLE' => 'caseTitle',
'APP_NUMBER' => 'caseNumber',
'APP_STATUS' => 'caseStatus',
'APP_UID' => 'caseId',
'CREATOR' => 'caseCreator',
'CREATE_DATE' => 'caseCreateDate',
'UPDATE_DATE' => 'caseUpdateData',
'DESCRIPTION' => 'caseDescription'
),
'task' => array(
'TAS_TITLE' => 'taskTitle',
'CURRENT_USER' => 'currentUser',
'DEL_DELEGATE_DATE' => 'delegateDate',
'DEL_INIT_DATE' => 'initDate',
'DEL_TASK_DUE_DATE' => 'dueDate',
'DEL_FINISH_DATE' => 'finishDate'
)
);
$response = $this->replaceFields($data, $structure);
return $response;
} }
} }