diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php
index 0cb222a62..099d3f501 100755
--- a/workflow/engine/bin/cron_single.php
+++ b/workflow/engine/bin/cron_single.php
@@ -1054,6 +1054,7 @@ function sendNotifications()
setExecutionMessage("Resending Notifications");
setExecutionResultMessage("PROCESSING");
$notQueue = new \NotificationQueue();
+ $notQueue->checkIfCasesOpenForResendingNotification();
$notificationsAndroid = $notQueue->loadStatusDeviceType('pending', 'android');
if ($notificationsAndroid) {
setExecutionMessage("|-- Send Android's Notifications");
diff --git a/workflow/engine/classes/model/NotificationQueue.php b/workflow/engine/classes/model/NotificationQueue.php
index ac78e2fe0..1207f3e51 100644
--- a/workflow/engine/classes/model/NotificationQueue.php
+++ b/workflow/engine/classes/model/NotificationQueue.php
@@ -27,6 +27,8 @@ class NotificationQueue extends BaseNotificationQueue
$this->setNotData($arrayData['NOT_DATA']);
$this->setNotStatus($arrayData['NOT_STATUS']);
$this->setNotSendDate('now');
+ $this->setAppUid($arrayData['APP_UID']);
+ $this->setDelIndex($arrayData['DEL_INDEX']);
if ($this->validate()) {
$cnn->begin();
@@ -62,6 +64,40 @@ class NotificationQueue extends BaseNotificationQueue
return $notifications;
}
+ /**
+ * This method changes the state of a notification when the case ended before running the cron.php
+ */
+ public function checkIfCasesOpenForResendingNotification()
+ {
+ $arrayCondition = array();
+ $criteria = new Criteria();
+ $criteria->clearSelectColumns();
+ $criteria->addSelectColumn(NotificationQueuePeer::APP_UID);
+ $criteria->addSelectColumn(NotificationQueuePeer::DEL_INDEX);
+ $criteria->addSelectColumn(NotificationQueuePeer::NOT_UID);
+ $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNOTNULL);
+ $arrayCondition[] = array(NotificationQueuePeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
+ $arrayCondition[] = array(NotificationQueuePeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX, Criteria::EQUAL);
+ $criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
+ $rs = NotificationQueuePeer::doSelectRS($criteria);
+ $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $notUID = array();
+ while ($rs->next()) {
+ $row = $rs->getRow();
+ if ($row['DEL_INDEX'] != 0 && $row['APP_UID'] != '') {
+ array_push($notUID, $row['NOT_UID']);
+ }
+ }
+
+ $criteriaSet = new Criteria("workflow");
+ $criteriaSet->add(NotificationQueuePeer::NOT_STATUS, 'sent');
+ $criteriaSet->add(NotificationQueuePeer::NOT_SEND_DATE, date('Y-m-d H:i:s'));
+ $criteriaWhere = new Criteria("workflow");
+ $criteriaWhere->add(NotificationQueuePeer::NOT_UID, $notUID, Criteria::IN);
+
+ \BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
+ }
+
public function loadStatusDeviceType($status, $devType)
{
try {
diff --git a/workflow/engine/classes/model/map/NotificationQueueMapBuilder.php b/workflow/engine/classes/model/map/NotificationQueueMapBuilder.php
index a69a47678..b8702b1c9 100644
--- a/workflow/engine/classes/model/map/NotificationQueueMapBuilder.php
+++ b/workflow/engine/classes/model/map/NotificationQueueMapBuilder.php
@@ -79,6 +79,10 @@ class NotificationQueueMapBuilder
$tMap->addColumn('NOT_SEND_DATE', 'NotSendDate', 'int', CreoleTypes::TIMESTAMP, true, null);
+ $tMap->addColumn('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32);
+
+ $tMap->addColumn('DEL_INDEX', 'DelIndex', 'int', CreoleTypes::INTEGER, true, null);
+
} // doBuild()
} // NotificationQueueMapBuilder
diff --git a/workflow/engine/classes/model/om/BaseNotificationQueue.php b/workflow/engine/classes/model/om/BaseNotificationQueue.php
index 7d69aafd1..8343c73ed 100644
--- a/workflow/engine/classes/model/om/BaseNotificationQueue.php
+++ b/workflow/engine/classes/model/om/BaseNotificationQueue.php
@@ -69,6 +69,18 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
*/
protected $not_send_date;
+ /**
+ * The value for the app_uid field.
+ * @var string
+ */
+ protected $app_uid = '';
+
+ /**
+ * The value for the del_index field.
+ * @var int
+ */
+ protected $del_index = 0;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -181,6 +193,28 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
}
}
+ /**
+ * Get the [app_uid] column value.
+ *
+ * @return string
+ */
+ public function getAppUid()
+ {
+
+ return $this->app_uid;
+ }
+
+ /**
+ * Get the [del_index] column value.
+ *
+ * @return int
+ */
+ public function getDelIndex()
+ {
+
+ return $this->del_index;
+ }
+
/**
* Set the value of [not_uid] column.
*
@@ -342,6 +376,50 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
} // setNotSendDate()
+ /**
+ * Set the value of [app_uid] column.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setAppUid($v)
+ {
+
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->app_uid !== $v || $v === '') {
+ $this->app_uid = $v;
+ $this->modifiedColumns[] = NotificationQueuePeer::APP_UID;
+ }
+
+ } // setAppUid()
+
+ /**
+ * Set the value of [del_index] column.
+ *
+ * @param int $v new value
+ * @return void
+ */
+ public function setDelIndex($v)
+ {
+
+ // Since the native PHP type for this column is integer,
+ // we will cast the input value to an int (if it is not).
+ if ($v !== null && !is_int($v) && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->del_index !== $v || $v === 0) {
+ $this->del_index = $v;
+ $this->modifiedColumns[] = NotificationQueuePeer::DEL_INDEX;
+ }
+
+ } // setDelIndex()
+
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
@@ -373,12 +451,16 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
$this->not_send_date = $rs->getTimestamp($startcol + 6, null);
+ $this->app_uid = $rs->getString($startcol + 7);
+
+ $this->del_index = $rs->getInt($startcol + 8);
+
$this->resetModified();
$this->setNew(false);
// FIXME - using NUM_COLUMNS may be clearer.
- return $startcol + 7; // 7 = NotificationQueuePeer::NUM_COLUMNS - NotificationQueuePeer::NUM_LAZY_LOAD_COLUMNS).
+ return $startcol + 9; // 9 = NotificationQueuePeer::NUM_COLUMNS - NotificationQueuePeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating NotificationQueue object", $e);
@@ -603,6 +685,12 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
case 6:
return $this->getNotSendDate();
break;
+ case 7:
+ return $this->getAppUid();
+ break;
+ case 8:
+ return $this->getDelIndex();
+ break;
default:
return null;
break;
@@ -630,6 +718,8 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
$keys[4] => $this->getNotData(),
$keys[5] => $this->getNotStatus(),
$keys[6] => $this->getNotSendDate(),
+ $keys[7] => $this->getAppUid(),
+ $keys[8] => $this->getDelIndex(),
);
return $result;
}
@@ -682,6 +772,12 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
case 6:
$this->setNotSendDate($value);
break;
+ case 7:
+ $this->setAppUid($value);
+ break;
+ case 8:
+ $this->setDelIndex($value);
+ break;
} // switch()
}
@@ -733,6 +829,14 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
$this->setNotSendDate($arr[$keys[6]]);
}
+ if (array_key_exists($keys[7], $arr)) {
+ $this->setAppUid($arr[$keys[7]]);
+ }
+
+ if (array_key_exists($keys[8], $arr)) {
+ $this->setDelIndex($arr[$keys[8]]);
+ }
+
}
/**
@@ -772,6 +876,14 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
$criteria->add(NotificationQueuePeer::NOT_SEND_DATE, $this->not_send_date);
}
+ if ($this->isColumnModified(NotificationQueuePeer::APP_UID)) {
+ $criteria->add(NotificationQueuePeer::APP_UID, $this->app_uid);
+ }
+
+ if ($this->isColumnModified(NotificationQueuePeer::DEL_INDEX)) {
+ $criteria->add(NotificationQueuePeer::DEL_INDEX, $this->del_index);
+ }
+
return $criteria;
}
@@ -838,6 +950,10 @@ abstract class BaseNotificationQueue extends BaseObject implements Persistent
$copyObj->setNotSendDate($this->not_send_date);
+ $copyObj->setAppUid($this->app_uid);
+
+ $copyObj->setDelIndex($this->del_index);
+
$copyObj->setNew(true);
diff --git a/workflow/engine/classes/model/om/BaseNotificationQueuePeer.php b/workflow/engine/classes/model/om/BaseNotificationQueuePeer.php
index 39cb5e935..d52f5b639 100644
--- a/workflow/engine/classes/model/om/BaseNotificationQueuePeer.php
+++ b/workflow/engine/classes/model/om/BaseNotificationQueuePeer.php
@@ -25,7 +25,7 @@ abstract class BaseNotificationQueuePeer
const CLASS_DEFAULT = 'classes.model.NotificationQueue';
/** The total number of columns. */
- const NUM_COLUMNS = 7;
+ const NUM_COLUMNS = 9;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -52,6 +52,12 @@ abstract class BaseNotificationQueuePeer
/** the column name for the NOT_SEND_DATE field */
const NOT_SEND_DATE = 'NOTIFICATION_QUEUE.NOT_SEND_DATE';
+ /** the column name for the APP_UID field */
+ const APP_UID = 'NOTIFICATION_QUEUE.APP_UID';
+
+ /** the column name for the DEL_INDEX field */
+ const DEL_INDEX = 'NOTIFICATION_QUEUE.DEL_INDEX';
+
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
@@ -63,10 +69,10 @@ abstract class BaseNotificationQueuePeer
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => array ('NotUid', 'DevType', 'DevUid', 'NotMsg', 'NotData', 'NotStatus', 'NotSendDate', ),
- BasePeer::TYPE_COLNAME => array (NotificationQueuePeer::NOT_UID, NotificationQueuePeer::DEV_TYPE, NotificationQueuePeer::DEV_UID, NotificationQueuePeer::NOT_MSG, NotificationQueuePeer::NOT_DATA, NotificationQueuePeer::NOT_STATUS, NotificationQueuePeer::NOT_SEND_DATE, ),
- BasePeer::TYPE_FIELDNAME => array ('NOT_UID', 'DEV_TYPE', 'DEV_UID', 'NOT_MSG', 'NOT_DATA', 'NOT_STATUS', 'NOT_SEND_DATE', ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ BasePeer::TYPE_PHPNAME => array ('NotUid', 'DevType', 'DevUid', 'NotMsg', 'NotData', 'NotStatus', 'NotSendDate', 'AppUid', 'DelIndex', ),
+ BasePeer::TYPE_COLNAME => array (NotificationQueuePeer::NOT_UID, NotificationQueuePeer::DEV_TYPE, NotificationQueuePeer::DEV_UID, NotificationQueuePeer::NOT_MSG, NotificationQueuePeer::NOT_DATA, NotificationQueuePeer::NOT_STATUS, NotificationQueuePeer::NOT_SEND_DATE, NotificationQueuePeer::APP_UID, NotificationQueuePeer::DEL_INDEX, ),
+ BasePeer::TYPE_FIELDNAME => array ('NOT_UID', 'DEV_TYPE', 'DEV_UID', 'NOT_MSG', 'NOT_DATA', 'NOT_STATUS', 'NOT_SEND_DATE', 'APP_UID', 'DEL_INDEX', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -76,10 +82,10 @@ abstract class BaseNotificationQueuePeer
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array ('NotUid' => 0, 'DevType' => 1, 'DevUid' => 2, 'NotMsg' => 3, 'NotData' => 4, 'NotStatus' => 5, 'NotSendDate' => 6, ),
- BasePeer::TYPE_COLNAME => array (NotificationQueuePeer::NOT_UID => 0, NotificationQueuePeer::DEV_TYPE => 1, NotificationQueuePeer::DEV_UID => 2, NotificationQueuePeer::NOT_MSG => 3, NotificationQueuePeer::NOT_DATA => 4, NotificationQueuePeer::NOT_STATUS => 5, NotificationQueuePeer::NOT_SEND_DATE => 6, ),
- BasePeer::TYPE_FIELDNAME => array ('NOT_UID' => 0, 'DEV_TYPE' => 1, 'DEV_UID' => 2, 'NOT_MSG' => 3, 'NOT_DATA' => 4, 'NOT_STATUS' => 5, 'NOT_SEND_DATE' => 6, ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ BasePeer::TYPE_PHPNAME => array ('NotUid' => 0, 'DevType' => 1, 'DevUid' => 2, 'NotMsg' => 3, 'NotData' => 4, 'NotStatus' => 5, 'NotSendDate' => 6, 'AppUid' => 7, 'DelIndex' => 8, ),
+ BasePeer::TYPE_COLNAME => array (NotificationQueuePeer::NOT_UID => 0, NotificationQueuePeer::DEV_TYPE => 1, NotificationQueuePeer::DEV_UID => 2, NotificationQueuePeer::NOT_MSG => 3, NotificationQueuePeer::NOT_DATA => 4, NotificationQueuePeer::NOT_STATUS => 5, NotificationQueuePeer::NOT_SEND_DATE => 6, NotificationQueuePeer::APP_UID => 7, NotificationQueuePeer::DEL_INDEX => 8, ),
+ BasePeer::TYPE_FIELDNAME => array ('NOT_UID' => 0, 'DEV_TYPE' => 1, 'DEV_UID' => 2, 'NOT_MSG' => 3, 'NOT_DATA' => 4, 'NOT_STATUS' => 5, 'NOT_SEND_DATE' => 6, 'APP_UID' => 7, 'DEL_INDEX' => 8, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
);
/**
@@ -194,6 +200,10 @@ abstract class BaseNotificationQueuePeer
$criteria->addSelectColumn(NotificationQueuePeer::NOT_SEND_DATE);
+ $criteria->addSelectColumn(NotificationQueuePeer::APP_UID);
+
+ $criteria->addSelectColumn(NotificationQueuePeer::DEL_INDEX);
+
}
const COUNT = 'COUNT(NOTIFICATION_QUEUE.NOT_UID)';
diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml
index d3bf953bb..f4565ef9e 100755
--- a/workflow/engine/config/schema.xml
+++ b/workflow/engine/config/schema.xml
@@ -5377,6 +5377,8 @@
+
+
diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql
index c346956bb..ec8070a01 100755
--- a/workflow/engine/data/mysql/schema.sql
+++ b/workflow/engine/data/mysql/schema.sql
@@ -2997,6 +2997,8 @@ CREATE TABLE `NOTIFICATION_QUEUE`
`NOT_DATA` MEDIUMTEXT NOT NULL,
`NOT_STATUS` VARCHAR(150) NOT NULL,
`NOT_SEND_DATE` DATETIME NOT NULL,
+ `APP_UID` VARCHAR(32) default '' NOT NULL,
+ `DEL_INDEX` INTEGER default 0 NOT NULL,
PRIMARY KEY (`NOT_UID`),
KEY `indexNotStatus`(`NOT_STATUS`)
)ENGINE=InnoDB ;
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php b/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php
index f8b23fecf..a73f8f819 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Light/NotificationDevice.php
@@ -226,6 +226,8 @@ class NotificationDevice
$arrayData['NOT_MSG'] = $message;
$arrayData['NOT_DATA'] = serialize($data);
$arrayData['NOT_STATUS'] = "pending";
+ $arrayData['APP_UID'] = $appFields['APP_UID'];
+ $arrayData['DEL_INDEX'] = $iNewDelIndex;
$notQueue = new \NotificationQueue();
$notQueue->create($arrayData);
}
@@ -237,6 +239,8 @@ class NotificationDevice
$arrayData['NOT_MSG'] = $message;
$arrayData['NOT_DATA'] = serialize($data);
$arrayData['NOT_STATUS'] = "pending";
+ $arrayData['APP_UID'] = $appFields['APP_UID'];
+ $arrayData['DEL_INDEX'] = $iNewDelIndex;
$notQueue = new \NotificationQueue();
$notQueue->create($arrayData);
}