- Se crearon varias funciones para este caso. - La funcion getCaseNotes en la class.case.php con los parametros applicationID, type que es la forma que quiere que se devuelvan los datos, puede ser array, objetc, string por defecto esta en array, y userID que nos daria solo las notas de ese usuario, por defecto nos devuelve de todos los usuarios. - Se modifico la funcion getNotesList para poder traer las notas por un determinado usuario y por defecto recupera las notas de todos los usuarios. - en class.pmFunctions.php se creo la funcion PMFGetCaseNotes con los parametros applicationID, type que es la forma que quiere que se devuelvan los datos, puede ser array, objetc, string por defecto esta en array, y userID que nos daria solo las notas de ese usuario, por defecto nos devuelve de todos los usuarios. - En class.wsBase.php la funcion getCaseNotes con los parametros applicationID, userID que nos daria solo las notas de ese usuario, por defecto nos devuelve de todos los usuarios, esta funcion nos devuelve un array con los fieds en minuscula. - En soap2.php getCaseNotes donde se tienen los siguiente parametros: sessionId, se necesita iniciar una session para poder utilizarlo, applicationID, userID que nos daria solo las notas de ese usuario, por defecto nos devuelve de todos los usuarios. - Se adiciono la funcion para utilizarlo en SoapServer. - En wsResponse se creo un nuevo template para la respuesta del webservice wsGetCaseNotesResponse con los campos status_code, message, notes, timestamp. - En pmos2.wsdl se agregaron los datos necesarios para la salida correcta del webservice.
201 lines
7.7 KiB
PHP
201 lines
7.7 KiB
PHP
<?php
|
|
/**
|
|
* App controller
|
|
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
* @herits Controller
|
|
* @access public
|
|
*/
|
|
|
|
class AppProxy extends HttpProxyController
|
|
{
|
|
/**
|
|
* Get Notes List
|
|
* @param int $httpData->start
|
|
* @param int $httpData->limit
|
|
* @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION'])
|
|
* @return array containg the case notes
|
|
*/
|
|
function getNotesList($httpData)
|
|
{
|
|
require_once ( "classes/model/AppNotes.php" );
|
|
$appUid = null;
|
|
|
|
if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
|
|
$appUid = $httpData->appUid;
|
|
}
|
|
else {
|
|
if (isset($_SESSION['APPLICATION'])) {
|
|
$appUid = $_SESSION['APPLICATION'];
|
|
}
|
|
}
|
|
|
|
if (!isset($appUid)) {
|
|
throw new Exception('Can\'t resolve the Apllication ID for this request.');
|
|
}
|
|
|
|
$usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
|
|
$appNotes = new AppNotes();
|
|
$response = $appNotes->getNotesList($appUid, '', $httpData->start, $httpData->limit);
|
|
|
|
return $response['array'];
|
|
}
|
|
|
|
/**
|
|
* post Note Action
|
|
* @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
|
|
* @return array containg the case notes
|
|
*/
|
|
function postNote($httpData)
|
|
{
|
|
//extract(getExtJSParams());
|
|
if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
|
|
$appUid = $httpData->appUid;
|
|
}
|
|
else {
|
|
$appUid = $_SESSION['APPLICATION'];
|
|
}
|
|
|
|
if (!isset($appUid)) {
|
|
throw new Exception('Can\'t resolve the Apllication ID for this request.');
|
|
}
|
|
|
|
$usrUid = (isset($_SESSION['USER_LOGGED'])) ? $_SESSION['USER_LOGGED'] : "";
|
|
require_once ( "classes/model/AppNotes.php" );
|
|
|
|
$appNotes = new AppNotes();
|
|
$noteContent = addslashes($httpData->noteText);
|
|
|
|
$result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false);
|
|
|
|
// Disabling the controller response because we handle a special behavior
|
|
$this->setSendResponse(false);
|
|
|
|
//send the response to client
|
|
@ini_set('implicit_flush', 1);
|
|
ob_start();
|
|
echo G::json_encode($result);
|
|
@ob_flush();
|
|
@flush();
|
|
@ob_end_flush();
|
|
ob_implicit_flush(1);
|
|
|
|
//send notification in background
|
|
$noteRecipientsList = array();
|
|
G::LoadClass('case');
|
|
$oCase = new Cases();
|
|
|
|
$p = $oCase->getUsersParticipatedInCase($appUid);
|
|
foreach($p['array'] as $key => $userParticipated){
|
|
$noteRecipientsList[] = $key;
|
|
}
|
|
$noteRecipients = implode(",", $noteRecipientsList);
|
|
|
|
$appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
|
|
}
|
|
|
|
/**
|
|
* request to open the case summary
|
|
* @param string $httpData->appUid
|
|
* @param string $httpData->delIndex
|
|
* @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid
|
|
*/
|
|
function requestOpenSummary($httpData)
|
|
{
|
|
global $RBAC;
|
|
$this->success = true;
|
|
$this->dynUid = '';
|
|
|
|
switch ($RBAC->userCanAccess('PM_CASES')) {
|
|
case -2:
|
|
throw new Exception(G::LoadTranslation('ID_USER_HAVENT_RIGHTS_SYSTEM'));
|
|
break;
|
|
case -1:
|
|
throw new Exception(G::LoadTranslation('ID_USER_HAVENT_RIGHTS_PAGE'));
|
|
break;
|
|
}
|
|
|
|
G::LoadClass('case');
|
|
$case = new Cases();
|
|
|
|
if ($RBAC->userCanAccess('PM_ALLCASES') < 0 && $case->userParticipatedInCase($httpData->appUid, $_SESSION['USER_LOGGED']) == 0) {
|
|
throw new Exception(G::LoadTranslation('ID_NO_PERMISSION_NO_PARTICIPATED'));
|
|
}
|
|
|
|
$applicationFields = $case->loadCase($httpData->appUid, $httpData->delIndex);
|
|
$process = new Process();
|
|
$processData = $process->load($applicationFields['PRO_UID']);
|
|
|
|
if (isset($processData['PRO_DYNAFORMS']['PROCESS'])) {
|
|
$this->dynUid = $processData['PRO_DYNAFORMS']['PROCESS'];
|
|
}
|
|
|
|
$_SESSION['_applicationFields'] = $applicationFields;
|
|
$_SESSION['_processData'] = $processData;
|
|
$_SESSION['APPLICATION'] = $httpData->appUid;
|
|
$_SESSION['INDEX'] = $httpData->delIndex;
|
|
$_SESSION['PROCESS'] = $applicationFields['PRO_UID'];
|
|
$_SESSION['TASK'] = $applicationFields['TAS_UID'];
|
|
$_SESSION['STEP_POSITION'] = '';
|
|
}
|
|
|
|
/**
|
|
* get the case summary data
|
|
* @param string $httpData->appUid
|
|
* @param string $httpData->delIndex
|
|
* @return array containg the case summary data
|
|
*/
|
|
function getSummary($httpData)
|
|
{
|
|
$labels = array();
|
|
$form = new Form('cases/cases_Resume', PATH_XMLFORM, SYS_LANG);
|
|
G::LoadClass('case');
|
|
$case = new Cases();
|
|
|
|
foreach($form->fields as $fieldName => $field) {
|
|
$labels[$fieldName] = $field->label;
|
|
}
|
|
|
|
if (isset($_SESSION['_applicationFields']) && $_SESSION['_processData']) {
|
|
$applicationFields = $_SESSION['_applicationFields'];
|
|
unset($_SESSION['_applicationFields']);
|
|
$processData = $_SESSION['_processData'];
|
|
unset($_SESSION['_processData']);
|
|
}
|
|
else {
|
|
$applicationFields = $case->loadCase($httpData->appUid, $httpData->delIndex);
|
|
$process = new Process();
|
|
$processData = $process->load($applicationFields['PRO_UID']);
|
|
}
|
|
|
|
$data = array();
|
|
$task = new Task();
|
|
$taskData = $task->load($applicationFields['TAS_UID']);
|
|
$currentUser = $applicationFields['CURRENT_USER'] != '' ? $applicationFields['CURRENT_USER'] : '[' . G::LoadTranslation('ID_UNASSIGNED') . ']';
|
|
|
|
|
|
$data[] = array('label'=>$labels['PRO_TITLE'] , 'value' => $processData['PRO_TITLE'], 'section'=>$labels['TITLE1']);
|
|
$data[] = array('label'=>$labels['TITLE'] , 'value' => $applicationFields['TITLE'], 'section'=>$labels['TITLE1']);
|
|
$data[] = array('label'=>$labels['APP_NUMBER'] , 'value' => $applicationFields['APP_NUMBER'], 'section'=>$labels['TITLE1']);
|
|
$data[] = array('label'=>$labels['STATUS'] , 'value' => $applicationFields['STATUS'], 'section'=>$labels['TITLE1']);
|
|
$data[] = array('label'=>$labels['APP_UID'] , 'value' => $applicationFields['APP_UID'], 'section'=>$labels['TITLE1']);
|
|
$data[] = array('label'=>$labels['CREATOR'] , 'value' => $applicationFields['CREATOR'], 'section'=>$labels['TITLE1']);
|
|
$data[] = array('label'=>$labels['CREATE_DATE'] , 'value' => $applicationFields['CREATE_DATE'],'section'=>$labels['TITLE1']);
|
|
$data[] = array('label'=>$labels['UPDATE_DATE'] , 'value' => $applicationFields['UPDATE_DATE'],'section'=>$labels['TITLE1']);
|
|
|
|
// note added by krlos pacha carlos[at]colosa[dot]com
|
|
//getting this field if it doesn't exist. Related 7994 bug
|
|
$taskData['TAS_TITLE'] = (array_key_exists('TAS_TITLE', $taskData))?$taskData['TAS_TITLE']:Content::Load("TAS_TITLE", "", $applicationFields['TAS_UID'], SYS_LANG);
|
|
|
|
$data[] = array('label'=>$labels['TAS_TITLE'] , 'value' => $taskData['TAS_TITLE'], 'section'=>$labels['TITLE2']);
|
|
$data[] = array('label'=>$labels['CURRENT_USER'] , 'value' => $currentUser, 'section'=>$labels['TITLE2']);
|
|
$data[] = array('label'=>$labels['DEL_DELEGATE_DATE'] , 'value' => $applicationFields['DEL_DELEGATE_DATE'],'section'=>$labels['TITLE2']);
|
|
$data[] = array('label'=>$labels['DEL_INIT_DATE'] , 'value' => $applicationFields['DEL_INIT_DATE'], 'section'=>$labels['TITLE2']);
|
|
$data[] = array('label'=>$labels['DEL_TASK_DUE_DATE'] , 'value' => $applicationFields['DEL_TASK_DUE_DATE'],'section'=>$labels['TITLE2']);
|
|
$data[] = array('label'=>$labels['DEL_FINISH_DATE'] , 'value' => $applicationFields['DEL_FINISH_DATE'], 'section'=>$labels['TITLE2']);
|
|
//$data[] = array('label'=>$labels['DYN_UID'] , 'value' => $processData['PRO_DYNAFORMS']['PROCESS'];, 'section'=>$labels['DYN_UID']);
|
|
|
|
return $data;
|
|
}
|
|
|
|
}
|