diff --git a/workflow/engine/classes/class.wsBase.php b/workflow/engine/classes/class.wsBase.php index cc65076c0..9181d8db3 100755 --- a/workflow/engine/classes/class.wsBase.php +++ b/workflow/engine/classes/class.wsBase.php @@ -970,10 +970,10 @@ class wsBase $oCase = new Cases(); $oldFields = $oCase->loadCase( $caseId ); - if($gmail == 1){ - $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP; - }else { - $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP; + if($gmail == 1){ + $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP; + }else { + $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP; } $fileTemplate = $pathEmail . $sTemplate; G::mk_dir( $pathEmail, 0777, true ); @@ -2512,7 +2512,8 @@ class wsBase $oLight = new \ProcessMaker\BusinessModel\Light(); $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $delIndex); $notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice(); - $notificationMobile->routeCaseNotification($userId, $_SESSION["PROCESS"], $appdel['TAS_UID'], $appFields, $nextDelegations, $nextIndex); + $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"); } diff --git a/workflow/engine/classes/model/NotificationDevice.php b/workflow/engine/classes/model/NotificationDevice.php index 226cfa07b..34d0e24de 100644 --- a/workflow/engine/classes/model/NotificationDevice.php +++ b/workflow/engine/classes/model/NotificationDevice.php @@ -196,4 +196,22 @@ class NotificationDevice extends BaseNotificationDevice { return (( get_class ($oRow) == 'NotificationDevice' )&&(!is_null($oRow))); } + public function isExistNextNotification($app_uid, $del_index) + { + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(AppDelegationPeer::APP_UID); + $oCriteria->add(AppDelegationPeer::APP_UID, $app_uid); + $oCriteria->add(AppDelegationPeer::DEL_PREVIOUS, $del_index); + $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); + $oCriteria->setLimit(1); + //execute the query + $oDataset = AppDelegationPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + if ($oDataset->next()) { + return true; + } else { + return false; + } + } + } // NotificationDevice diff --git a/workflow/engine/methods/cases/cases_Derivate.php b/workflow/engine/methods/cases/cases_Derivate.php index 8c2bd6e15..6c8de7614 100755 --- a/workflow/engine/methods/cases/cases_Derivate.php +++ b/workflow/engine/methods/cases/cases_Derivate.php @@ -21,34 +21,34 @@ * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ -if (!isset($_SESSION['USER_LOGGED'])) { - G::SendTemporalMessage( 'ID_LOGIN_AGAIN', 'warning', 'labels' ); - die( ''); +if (!isset($_SESSION['USER_LOGGED'])) { + G::SendTemporalMessage( 'ID_LOGIN_AGAIN', 'warning', 'labels' ); + die( ''); } /* Permissions */ switch ($RBAC->userCanAccess( 'PM_CASES' )) { @@ -163,7 +163,8 @@ try { $oLight = new \ProcessMaker\BusinessModel\Light(); $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $appFields['DEL_INDEX']); $notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice(); - $notificationMobile->routeCaseNotification($_SESSION['USER_LOGGED'], $_SESSION['PROCESS'], $_SESSION['TASK'], $appFields, $_POST['form']['TASKS'], $nextIndex); + $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"); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php b/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php index a38bde7f9..fd885fd57 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php @@ -147,7 +147,8 @@ class NotificationDevice * @author Ronald Quenta * */ - public function routeCaseNotification($currentUserId, $processId, $currentTaskId, $appFields, $aTasks, $nextIndex) + public function routeCaseNotification($currentUserId, $processId, $currentTaskId, $appFields, $aTasks, + $nextIndex, $currentDelIndex) { try { $response = array(); @@ -166,7 +167,7 @@ class NotificationDevice $delIndex = null; foreach ($nextIndex as $nIndex) { - if($aTask['TAS_UID'] == $nIndex['TAS_UID']){ + if ($aTask['TAS_UID'] == $nIndex['TAS_UID']) { $delIndex = $nIndex['DEL_INDEX']; break; } @@ -184,10 +185,9 @@ class NotificationDevice ); if ($userIds) { - $oNoti = new \NotificationDevice(); $devices = array(); - if (is_array($userIds)){ + if (is_array($userIds)) { $devices = $oNoti->loadUsersArrayId($userIds); } else { $devices = $oNoti->loadByUsersId($userIds); @@ -210,13 +210,15 @@ class NotificationDevice break; } } - if (count($devicesAppleIds) > 0) { + $isExistNextNotifications = $oNoti->isExistNextNotification($appFields['APP_UID'], + $currentDelIndex); + if (count($devicesAppleIds) > 0 && $isExistNextNotifications) { $oNotification = new PushMessageIOS(); $oNotification->setSettingNotification(); $oNotification->setDevices($devicesAppleIds); $response['apple'] = $oNotification->send($message, $data); } - if (count($devicesAndroidIds) > 0) { + if (count($devicesAndroidIds) > 0 && $isExistNextNotifications) { $oNotification = new PushMessageAndroid(); $oNotification->setSettingNotification(); $oNotification->setDevices($devicesAndroidIds);