@@ -1232,6 +1232,7 @@ class Derivation
|
||||
{
|
||||
$iAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
$delType = 'NORMAL';
|
||||
$sendNotificationsMobile = false;
|
||||
|
||||
if (is_numeric( $nextDel['DEL_PRIORITY'] )) {
|
||||
$nextDel['DEL_PRIORITY'] = (isset( $nextDel['DEL_PRIORITY'] ) ? ($nextDel['DEL_PRIORITY'] >= 1 && $nextDel['DEL_PRIORITY'] <= 5 ? $nextDel['DEL_PRIORITY'] : '3') : '3');
|
||||
@@ -1358,6 +1359,8 @@ class Derivation
|
||||
}
|
||||
}
|
||||
|
||||
$sendNotificationsMobile = $this->sendNotificationsMobile($aOldFields, $aSP, $aNewCase['INDEX']);
|
||||
|
||||
//If not is SYNCHRONOUS derivate one more time
|
||||
if ($aSP['SP_SYNCHRONOUS'] == 0) {
|
||||
$this->case->setDelInitDate( $currentDelegation['APP_UID'], $iNewDelIndex );
|
||||
@@ -1388,6 +1391,10 @@ class Derivation
|
||||
}
|
||||
}
|
||||
} //end switch
|
||||
|
||||
if($iNewDelIndex !== 0 && !$sendNotificationsMobile){
|
||||
$sendNotificationsMobile = $this->sendNotificationsMobile($appFields, $nextDel, $iNewDelIndex);
|
||||
}
|
||||
return $iNewDelIndex;
|
||||
}
|
||||
|
||||
@@ -1640,5 +1647,24 @@ class Derivation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $appFields
|
||||
* @param $nextDel
|
||||
* @param $iNewDelIndex
|
||||
* @return bool
|
||||
*/
|
||||
private function sendNotificationsMobile($appFields, $nextDel, $iNewDelIndex)
|
||||
{
|
||||
try {
|
||||
$notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
if ($notificationMobile->checkMobileNotifications()) {
|
||||
$notificationMobile->routeCaseNotificationDevice($appFields, $nextDel, $iNewDelIndex);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
\G::log(G::loadTranslation('ID_NOTIFICATION_ERROR') . '|' . $e->getMessage(), PATH_DATA, "mobile.log");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2518,20 +2518,6 @@ class wsBase
|
||||
|
||||
$oCase->sendNotifications( $appdel['TAS_UID'], $nextDelegations, $appFields['APP_DATA'], $caseId, $delIndex, $sFromName );
|
||||
|
||||
// Send notifications Mobile - Start
|
||||
try {
|
||||
$notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
if ($notificationMobile->checkMobileNotifications()) {
|
||||
$oLight = new \ProcessMaker\BusinessModel\Light();
|
||||
$nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $delIndex);
|
||||
$notificationMobile->routeCaseNotification($userId, $_SESSION["PROCESS"], $appdel['TAS_UID'],
|
||||
$appFields, $nextDelegations, $nextIndex, $delIndex);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
\G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log");
|
||||
}
|
||||
// Send notifications Mobile - End
|
||||
|
||||
//Save data - Start
|
||||
//$appFields = $oCase->loadCase($caseId);
|
||||
//$oCase->updateCase($caseId, $appFields);
|
||||
|
||||
@@ -197,21 +197,6 @@ try {
|
||||
G::SendTemporalMessage( G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%' );
|
||||
}
|
||||
// Send notifications - End
|
||||
|
||||
// Send notifications Mobile - Start
|
||||
try {
|
||||
$notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice();
|
||||
if ($notificationMobile->checkMobileNotifications()) {
|
||||
$oLight = new \ProcessMaker\BusinessModel\Light();
|
||||
$nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $appFields['DEL_INDEX']);
|
||||
$notificationMobile->routeCaseNotification($_SESSION['USER_LOGGED'], $_SESSION['PROCESS'], $_SESSION['TASK'],
|
||||
$appFields, $_POST['form']['TASKS'], $nextIndex, $appFields['DEL_INDEX']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
\G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log");
|
||||
}
|
||||
// Send notifications Mobile - End
|
||||
|
||||
// Events - Start
|
||||
$oEvent = new Event();
|
||||
|
||||
|
||||
@@ -154,112 +154,95 @@ class NotificationDevice
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Message each user id
|
||||
*
|
||||
* @param array $request_data
|
||||
* @author Ronald Quenta <ronald.quenta@processmaker.com>
|
||||
*
|
||||
* @param $appFields
|
||||
* @param $nextDel
|
||||
* @param $iNewDelIndex
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function routeCaseNotification($currentUserId, $processId, $currentTaskId, $appFields, $aTasks,
|
||||
$nextIndex, $currentDelIndex)
|
||||
public function routeCaseNotificationDevice($appFields, $nextDel, $iNewDelIndex)
|
||||
{
|
||||
try {
|
||||
$response = array();
|
||||
$typeList = 'todo';
|
||||
foreach ($aTasks as $aTask) {
|
||||
$arrayTaskUser = array();
|
||||
$delIndex = null;
|
||||
foreach ($nextIndex as $nIndex) {
|
||||
if ($aTask['TAS_UID'] == $nIndex['TAS_UID']) {
|
||||
$delIndex = $nIndex['DEL_INDEX'];
|
||||
break;
|
||||
$arrayTaskUser = array();
|
||||
switch ($nextDel["TAS_ASSIGN_TYPE"]) {
|
||||
case "SELF_SERVICE":
|
||||
$arrayTaskUser = $this->getTaskUserSelfService($nextDel["TAS_UID"], $appFields);
|
||||
$typeList = 'unassigned';
|
||||
break;
|
||||
default:
|
||||
if (isset($nextDel["USR_UID"]) && !empty($nextDel["USR_UID"])) {
|
||||
$arrayTaskUser = $nextDel["USR_UID"];
|
||||
}
|
||||
}
|
||||
switch ($aTask["TAS_ASSIGN_TYPE"]) {
|
||||
case "MULTIPLE_INSTANCE":
|
||||
case "MULTIPLE_INSTANCE_VALUE_BASED":
|
||||
$arrayTaskUser = $this->getTaskUserMultipleInstance($aTask["TAS_UID"], $appFields);
|
||||
$delIndex = 0;
|
||||
break;
|
||||
case "SELF_SERVICE":
|
||||
$arrayTaskUser = $this->getTaskUserSelfService($aTask["TAS_UID"], $appFields);
|
||||
$typeList = 'unassigned';
|
||||
break;
|
||||
default:
|
||||
if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
|
||||
$arrayTaskUser = $aTask["USR_UID"];
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
$userIds = $arrayTaskUser;
|
||||
//sub process
|
||||
$taskAssignType = (isset($nextDel["TAS_ASSIGN_TYPE"])) ? $nextDel["TAS_ASSIGN_TYPE"] : $nextDel["SP_TYPE"];
|
||||
$message = '#' . $appFields['APP_NUMBER'] . ' : ' . $appFields['APP_TITLE'];
|
||||
$data = array(
|
||||
'processId' => $appFields['PRO_UID'],
|
||||
'taskId' => $nextDel["TAS_UID"],
|
||||
'taskAssignType' => $taskAssignType,
|
||||
'caseId' => $appFields['APP_UID'],
|
||||
'caseTitle' => $appFields['APP_TITLE'],
|
||||
'delIndex' => $iNewDelIndex,
|
||||
'typeList' => $typeList
|
||||
);
|
||||
|
||||
if ($userIds) {
|
||||
$oNoti = new \NotificationDevice();
|
||||
if (is_array($userIds)) {
|
||||
$devices = $oNoti->loadUsersArrayId($userIds);
|
||||
} else {
|
||||
$devices = $oNoti->loadByUsersId($userIds);
|
||||
$lists = new \ProcessMaker\BusinessModel\Lists();
|
||||
$counter = $lists->getCounters($userIds);
|
||||
$light = new \ProcessMaker\Services\Api\Light();
|
||||
$result = $light->parserCountersCases($counter);
|
||||
$data['counters'] = $result;
|
||||
}
|
||||
|
||||
$userIds = $arrayTaskUser;
|
||||
$message = '#'. $appFields['APP_NUMBER'] . ' : '.$appFields['APP_TITLE'];
|
||||
$data = array(
|
||||
'processId' => $processId,
|
||||
'taskId' => $aTask["TAS_UID"],
|
||||
'taskAssignType' => $aTask["TAS_ASSIGN_TYPE"],
|
||||
'caseId' => $appFields['APP_UID'],
|
||||
'caseTitle' => $appFields['APP_TITLE'],
|
||||
'delIndex' => $delIndex,
|
||||
'typeList' => $typeList
|
||||
);
|
||||
|
||||
if ($userIds) {
|
||||
$oNoti = new \NotificationDevice();
|
||||
$devices = array();
|
||||
if (is_array($userIds)) {
|
||||
$devices = $oNoti->loadUsersArrayId($userIds);
|
||||
} else {
|
||||
$devices = $oNoti->loadByUsersId($userIds);
|
||||
$lists = new \ProcessMaker\BusinessModel\Lists();
|
||||
$counter = $lists->getCounters($userIds);
|
||||
$light = new \ProcessMaker\Services\Api\Light();
|
||||
$result = $light->parserCountersCases($counter);
|
||||
$data['counters'] = $result;
|
||||
}
|
||||
|
||||
$devicesAndroidIds = array();
|
||||
$devicesAppleIds = array();
|
||||
foreach ($devices as $dev) {
|
||||
switch ($dev['DEV_TYPE']) {
|
||||
case "apple":
|
||||
$devicesAppleIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
case "android":
|
||||
$devicesAndroidIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$isExistNextNotifications = $oNoti->isExistNextNotification($appFields['APP_UID'],
|
||||
$currentDelIndex);
|
||||
if (count($devicesAppleIds) > 0 && $isExistNextNotifications) {
|
||||
$arrayData = array();
|
||||
$arrayData['NOT_FROM'] = $currentUserId;
|
||||
$arrayData['DEV_TYPE'] = 'apple';
|
||||
$arrayData['DEV_UID'] = serialize($devicesAppleIds);
|
||||
$arrayData['NOT_MSG'] = $message;
|
||||
$arrayData['NOT_DATA'] = serialize($data);
|
||||
$arrayData['NOT_STATUS'] = "pending";
|
||||
$notQueue = new \NotificationQueue();
|
||||
$notQueue->create($arrayData);
|
||||
}
|
||||
if (count($devicesAndroidIds) > 0 && $isExistNextNotifications) {
|
||||
$arrayData = array();
|
||||
$arrayData['NOT_FROM'] = $currentUserId;
|
||||
$arrayData['DEV_TYPE'] = 'android';
|
||||
$arrayData['DEV_UID'] = serialize($devicesAndroidIds);
|
||||
$arrayData['NOT_MSG'] = $message;
|
||||
$arrayData['NOT_DATA'] = serialize($data);
|
||||
$arrayData['NOT_STATUS'] = "pending";
|
||||
$notQueue = new \NotificationQueue();
|
||||
$notQueue->create($arrayData);
|
||||
$devicesAndroidIds = array();
|
||||
$devicesAppleIds = array();
|
||||
foreach ($devices as $dev) {
|
||||
switch ($dev['DEV_TYPE']) {
|
||||
case "apple":
|
||||
$devicesAppleIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
case "android":
|
||||
$devicesAndroidIds[] = $dev['DEV_REG_ID'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count($devicesAppleIds) > 0) {
|
||||
$arrayData = array();
|
||||
$arrayData['NOT_FROM'] = $appFields['APP_CUR_USER'];
|
||||
$arrayData['DEV_TYPE'] = 'apple';
|
||||
$arrayData['DEV_UID'] = serialize($devicesAppleIds);
|
||||
$arrayData['NOT_MSG'] = $message;
|
||||
$arrayData['NOT_DATA'] = serialize($data);
|
||||
$arrayData['NOT_STATUS'] = "pending";
|
||||
$notQueue = new \NotificationQueue();
|
||||
$notQueue->create($arrayData);
|
||||
}
|
||||
if (count($devicesAndroidIds) > 0) {
|
||||
$arrayData = array();
|
||||
$arrayData['NOT_FROM'] = $appFields['APP_CUR_USER'];
|
||||
$arrayData['DEV_TYPE'] = 'android';
|
||||
$arrayData['DEV_UID'] = serialize($devicesAndroidIds);
|
||||
$arrayData['NOT_MSG'] = $message;
|
||||
$arrayData['NOT_DATA'] = serialize($data);
|
||||
$arrayData['NOT_STATUS'] = "pending";
|
||||
$notQueue = new \NotificationQueue();
|
||||
$notQueue->create($arrayData);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception($e->getMessage(), Api::STAT_APP_EXCEPTION);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -301,16 +284,4 @@ class NotificationDevice
|
||||
|
||||
return $arrayTaskUser;
|
||||
}
|
||||
public function getTaskUserMultipleInstance($tas_uid, $appFields)
|
||||
{
|
||||
$oDerivation = new \Derivation();
|
||||
$taskNextDel = \TaskPeer::retrieveByPK($tas_uid);
|
||||
$oDerivation->case = new \Cases();
|
||||
$arrayUsersOfTask = $oDerivation->getNextAssignedUser(array("APP_UID" => $appFields['APP_UID'], "NEXT_TASK" => $taskNextDel->toArray(\BasePeer::TYPE_FIELDNAME)));
|
||||
$arrayTaskUser = array();
|
||||
foreach ($arrayUsersOfTask as $arrayUser) {
|
||||
$arrayTaskUser[] = $arrayUser["USR_UID"];
|
||||
}
|
||||
return $arrayTaskUser;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user