CODE STYLE, workflow/engine/classes/model/
FILES: Event.php Process.php
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Event.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/om/BaseEvent.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'EVENT' table.
|
||||
*
|
||||
@@ -16,7 +16,6 @@ require_once 'classes/model/om/BaseEvent.php';
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/AppDelegation.php';
|
||||
@@ -24,22 +23,27 @@ require_once 'classes/model/AppEvent.php';
|
||||
require_once 'classes/model/Triggers.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
|
||||
class Event extends BaseEvent {
|
||||
class Event extends BaseEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $evn_description = '';
|
||||
|
||||
/**
|
||||
* Get the evn_description column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEvnDescription() {
|
||||
public function getEvnDescription ()
|
||||
{
|
||||
if ($this->getEvnUid() == "") {
|
||||
throw (new Exception( "Error in getEvnDescription, the getEvnUid() can't be blank" ));
|
||||
}
|
||||
@@ -69,7 +73,8 @@ class Event extends BaseEvent {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function load($sUID) {
|
||||
public function load ($sUID)
|
||||
{
|
||||
try {
|
||||
$oEvent = EventPeer::retrieveByPK( $sUID );
|
||||
if (! is_null( $oEvent )) {
|
||||
@@ -85,17 +90,16 @@ class Event extends BaseEvent {
|
||||
$aFields['EVN_ACTION_PARAMETERS'] = unserialize( $aFields['EVN_ACTION_PARAMETERS'] );
|
||||
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function create($aData) {
|
||||
function create ($aData)
|
||||
{
|
||||
if (! isset( $aData['EVN_UID'] ) || $aData['EVN_UID'] == '') {
|
||||
$aData['EVN_UID'] = G::generateUniqueID();
|
||||
}
|
||||
@@ -178,7 +182,8 @@ class Event extends BaseEvent {
|
||||
$aTrigger['PRO_UID'] = $aData['PRO_UID'];
|
||||
$aTrigger['TRI_TITLE'] = 'For event: ' . $aData['EVN_DESCRIPTION'];
|
||||
$aTrigger['TRI_DESCRIPTION'] = 'Autogenerated ' . $aTrigger['TRI_TITLE'];
|
||||
$aTrigger['TRI_WEBBOT'] = '// ' . $aTrigger['TRI_DESCRIPTION'];;
|
||||
$aTrigger['TRI_WEBBOT'] = '// ' . $aTrigger['TRI_DESCRIPTION'];
|
||||
;
|
||||
$oTrigger->create( $aTrigger );
|
||||
} else {
|
||||
$oTrigger = TriggersPeer::retrieveByPk( $aData['TRI_UID'] );
|
||||
@@ -189,7 +194,6 @@ class Event extends BaseEvent {
|
||||
$parameters = new StdClass();
|
||||
$parameters->hash = md5( $oTrigger->getTriWebbot() );
|
||||
|
||||
|
||||
if (isset( $aData['EVN_ACTION_PARAMETERS']->SUBJECT )) {
|
||||
$parameters->SUBJECT = $aData['EVN_ACTION_PARAMETERS']->SUBJECT;
|
||||
$parameters->TO = $aData['EVN_ACTION_PARAMETERS']->TO;
|
||||
@@ -216,74 +220,83 @@ class Event extends BaseEvent {
|
||||
}
|
||||
throw (new Exception( 'The row Event cannot be created!<br />' . $sMessage ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function update($aData) {
|
||||
function update ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection( EventPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oEvent = EventPeer::retrieveByPK( $aData['EVN_UID'] );
|
||||
if (! is_null( $oEvent )) {
|
||||
|
||||
//$oEvent->setProUid( $aData['PRO_UID'] );
|
||||
if(isset($aData['EVN_RELATED_TO']))
|
||||
{
|
||||
if (isset( $aData['EVN_RELATED_TO'] )) {
|
||||
$oEvent->setEvnRelatedTo( $aData['EVN_RELATED_TO'] );
|
||||
if ($aData['EVN_RELATED_TO'] == 'SINGLE') {
|
||||
if(isset($aData['TAS_UID']) && $aData['TAS_UID'] != '')
|
||||
if (isset( $aData['TAS_UID'] ) && $aData['TAS_UID'] != '') {
|
||||
$oEvent->setTasUid( $aData['TAS_UID'] );
|
||||
}
|
||||
$oEvent->setEvnTasUidTo( '' );
|
||||
$oEvent->setEvnTasUidFrom( '' );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$oEvent->setTasUid( '' );
|
||||
if(isset($aData['EVN_TAS_UID_TO']))
|
||||
if (isset( $aData['EVN_TAS_UID_TO'] )) {
|
||||
$oEvent->setEvnTasUidTo( $aData['EVN_TAS_UID_TO'] );
|
||||
if(isset($aData['EVN_TAS_UID_FROM']))
|
||||
}
|
||||
if (isset( $aData['EVN_TAS_UID_FROM'] )) {
|
||||
$oEvent->setEvnTasUidFrom( $aData['EVN_TAS_UID_FROM'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($aData['EVN_POSX']))
|
||||
if (isset( $aData['EVN_POSX'] )) {
|
||||
$oEvent->setEvnPosx( $aData['EVN_POSX'] );
|
||||
if(isset($aData['EVN_POSY']))
|
||||
}
|
||||
if (isset( $aData['EVN_POSY'] )) {
|
||||
$oEvent->setEvnPosy( $aData['EVN_POSY'] );
|
||||
|
||||
|
||||
}
|
||||
if (isset( $aData['EVN_TIME_UNIT'] )) {
|
||||
$oEvent->setEvnTimeUnit( $aData['EVN_TIME_UNIT'] );
|
||||
if ($aData['EVN_TIME_UNIT'] == 'HOURS') {
|
||||
$aData['EVN_TAS_ESTIMATED_DURATION'] = $aData['EVN_TAS_ESTIMATED_DURATION'] / 24;
|
||||
}
|
||||
}
|
||||
if(isset($aData['EVN_TAS_ESTIMATED_DURATION']))
|
||||
if (isset( $aData['EVN_TAS_ESTIMATED_DURATION'] )) {
|
||||
$oEvent->setEvnTasEstimatedDuration( $aData['EVN_TAS_ESTIMATED_DURATION'] );
|
||||
}
|
||||
|
||||
if(isset($aData['EVN_WHEN_OCCURS']))
|
||||
if (isset( $aData['EVN_WHEN_OCCURS'] )) {
|
||||
$oEvent->setEvnWhenOccurs( $aData['EVN_WHEN_OCCURS'] );
|
||||
}
|
||||
|
||||
if(isset($aData['EVN_STATUS']))
|
||||
if (isset( $aData['EVN_STATUS'] )) {
|
||||
$oEvent->setEvnStatus( $aData['EVN_STATUS'] );
|
||||
}
|
||||
|
||||
if(isset($aData['EVN_WHEN']))
|
||||
if (isset( $aData['EVN_WHEN'] )) {
|
||||
$oEvent->setEvnWhen( $aData['EVN_WHEN'] );
|
||||
}
|
||||
|
||||
if(isset($aData['TRI_UID']))
|
||||
if (isset( $aData['TRI_UID'] )) {
|
||||
$oEvent->setTriUid( $aData['TRI_UID'] );
|
||||
}
|
||||
|
||||
if(isset($aData['EVN_TYPE']))
|
||||
if (isset( $aData['EVN_TYPE'] )) {
|
||||
$oEvent->setEvnType( $aData['EVN_TYPE'] );
|
||||
}
|
||||
|
||||
if(isset($aData['EVN_CONDITIONS']))
|
||||
if (isset( $aData['EVN_CONDITIONS'] )) {
|
||||
$oEvent->setEvnConditions( $aData['EVN_CONDITIONS'] );
|
||||
}
|
||||
|
||||
if ( isset ($aData['EVN_ACTION'] ) )
|
||||
if (isset( $aData['EVN_ACTION'] )) {
|
||||
$oEvent->setEvnAction( $aData['EVN_ACTION'] );
|
||||
//if ( isset ($aData['ENV_MAX_ATTEMPTS'] )) $oEvent->setEvnMaxAttempts( 3 );
|
||||
}
|
||||
|
||||
if (isset( $aData['EVN_ACTION_PARAMETERS'] ) && $aData['EVN_ACTION_PARAMETERS'] != 0) {
|
||||
|
||||
@@ -319,18 +332,20 @@ class Event extends BaseEvent {
|
||||
|
||||
//$oParameters->TRI_UID = $sTrigger->getTriUid();
|
||||
|
||||
|
||||
$oEvent->setEvnActionParameters( serialize( $oParameters ) );
|
||||
}
|
||||
|
||||
if ($oEvent->validate()) {
|
||||
//start the transaction
|
||||
$oConnection->begin();
|
||||
if (array_key_exists('EVN_DESCRIPTION', $aData)) $oEvent->setEvnDescription($aData['EVN_DESCRIPTION']);
|
||||
if (array_key_exists( 'EVN_DESCRIPTION', $aData )) {
|
||||
$oEvent->setEvnDescription( $aData['EVN_DESCRIPTION'] );
|
||||
}
|
||||
$iResult = $oEvent->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oEvent->getValidationFailures();
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
@@ -338,18 +353,17 @@ class Event extends BaseEvent {
|
||||
}
|
||||
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($sUID) {
|
||||
function remove ($sUID)
|
||||
{
|
||||
$oConnection = Propel::getConnection( EventPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oEvent = EventPeer::retrieveByPK( $sUID );
|
||||
@@ -384,18 +398,17 @@ class Event extends BaseEvent {
|
||||
$iResult = $oEvent->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function calculateEventsExecutionDate() {
|
||||
function calculateEventsExecutionDate ()
|
||||
{
|
||||
$line1 = '';
|
||||
$line2 = '';
|
||||
$line1 = $this->calculateExecutionDateSingle();
|
||||
@@ -403,7 +416,8 @@ class Event extends BaseEvent {
|
||||
return $line1 . "<br>\n" . $line2;
|
||||
}
|
||||
|
||||
function calculateExecutionDateSingle() {
|
||||
function calculateExecutionDateSingle ()
|
||||
{
|
||||
try {
|
||||
$rowsCreated = 0;
|
||||
$rowsRejected = 0;
|
||||
@@ -433,6 +447,7 @@ class Event extends BaseEvent {
|
||||
//-- and APP_DELEGATION.DEL_DELEGATE_DATE > "2009-01-01 12:00:00"
|
||||
//ORDER BY APP_DELEGATION.DEL_DELEGATE_DATE
|
||||
|
||||
|
||||
//get info about the Event and the APP_DELEGATION to process
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( EventPeer::EVN_UID );
|
||||
@@ -452,14 +467,18 @@ class Event extends BaseEvent {
|
||||
$oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
|
||||
|
||||
$aConditions = array ();
|
||||
$aConditions[] = array(AppDelegationPeer::TAS_UID, EventPeer::TAS_UID);
|
||||
$aConditions[] = array (AppDelegationPeer::TAS_UID,EventPeer::TAS_UID
|
||||
);
|
||||
//$aConditions[] = array(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::IS_NULL ); //is null is supported by addJoinMC by the way.
|
||||
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||
|
||||
$aConditions = array ();
|
||||
$aConditions[] = array(AppDelegationPeer::APP_UID, AppEventPeer::APP_UID);
|
||||
$aConditions[] = array(AppDelegationPeer::DEL_INDEX, AppEventPeer::DEL_INDEX);
|
||||
$aConditions[] = array(EventPeer::EVN_UID, AppEventPeer::EVN_UID );
|
||||
$aConditions[] = array (AppDelegationPeer::APP_UID,AppEventPeer::APP_UID
|
||||
);
|
||||
$aConditions[] = array (AppDelegationPeer::DEL_INDEX,AppEventPeer::DEL_INDEX
|
||||
);
|
||||
$aConditions[] = array (EventPeer::EVN_UID,AppEventPeer::EVN_UID
|
||||
);
|
||||
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||
|
||||
$oCriteria->add( AppEventPeer::APP_UID, null, Criteria::ISNULL );
|
||||
@@ -471,10 +490,12 @@ class Event extends BaseEvent {
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$aRows = Array ();
|
||||
while($oDataset->next()) $aRows[]= $oDataset->getRow();
|
||||
while ($oDataset->next()) {
|
||||
$aRows[] = $oDataset->getRow();
|
||||
}
|
||||
|
||||
g::pr( $aRows );
|
||||
die;
|
||||
die();
|
||||
|
||||
$oDataset->next();
|
||||
|
||||
@@ -489,8 +510,7 @@ class Event extends BaseEvent {
|
||||
$calculatedDueDateA = $oDates->calculateDate( $sDueDate, $when, 'days', 1 );
|
||||
$sActionDate = date( 'Y-m-d H:i:s', $calculatedDueDateA['DUE_DATE_SECONDS'] );
|
||||
$validStartDate = ($sActionDate >= $aData['DEL_DELEGATE_DATE']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sDueDate = $aData['DEL_DELEGATE_DATE'];
|
||||
$calculatedDueDateA = $oDates->calculateDate( $sDueDate, $when, 'days', 1 );
|
||||
$sActionDate = date( 'Y-m-d H:i:s', $calculatedDueDateA['DUE_DATE_SECONDS'] );
|
||||
@@ -503,8 +523,7 @@ class Event extends BaseEvent {
|
||||
$rowsCreated ++;
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->create( $aData );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rowsRejected ++;
|
||||
$aData['APP_EVN_STATUS'] = 'INVALID';
|
||||
$oAppEvent = new AppEvent();
|
||||
@@ -513,14 +532,13 @@ class Event extends BaseEvent {
|
||||
$oDataset->next();
|
||||
}
|
||||
return "Created $rowsCreated SINGLE rows in APP_EVENT and rejected $rowsRejected rows ";
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw new Exception( $oError->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function calculateExecutionDateMultiple() {
|
||||
function calculateExecutionDateMultiple ()
|
||||
{
|
||||
try {
|
||||
$rowsCreated = 0;
|
||||
$rowsRejected = 0;
|
||||
@@ -560,22 +578,27 @@ class Event extends BaseEvent {
|
||||
$oCriteria->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
|
||||
$oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
|
||||
|
||||
|
||||
$aConditions = array ();
|
||||
$aConditions[] = array(AppDelegationPeer::TAS_UID, EventPeer::EVN_TAS_UID_FROM);
|
||||
$aConditions[] = array (AppDelegationPeer::TAS_UID,EventPeer::EVN_TAS_UID_FROM
|
||||
);
|
||||
//$aConditions[] = array(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::IS_NULL );
|
||||
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||
|
||||
$aConditions = array ();
|
||||
$aConditions[] = array(AppDelegationPeer::APP_UID, AppEventPeer::APP_UID);
|
||||
$aConditions[] = array(AppDelegationPeer::DEL_INDEX, AppEventPeer::DEL_INDEX);
|
||||
$aConditions[] = array(EventPeer::EVN_UID, AppEventPeer::EVN_UID );
|
||||
$aConditions[] = array (AppDelegationPeer::APP_UID,AppEventPeer::APP_UID
|
||||
);
|
||||
$aConditions[] = array (AppDelegationPeer::DEL_INDEX,AppEventPeer::DEL_INDEX
|
||||
);
|
||||
$aConditions[] = array (EventPeer::EVN_UID,AppEventPeer::EVN_UID
|
||||
);
|
||||
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||
|
||||
$oCriteria->addAlias( 'DEL2', 'APP_DELEGATION' );
|
||||
$aConditions = array ();
|
||||
$aConditions[] = array( AppDelegationPeer::APP_UID, 'DEL2.APP_UID' );
|
||||
$aConditions[] = array( EventPeer::EVN_TAS_UID_TO, 'DEL2.TAS_UID' );
|
||||
$aConditions[] = array (AppDelegationPeer::APP_UID,'DEL2.APP_UID'
|
||||
);
|
||||
$aConditions[] = array (EventPeer::EVN_TAS_UID_TO,'DEL2.TAS_UID'
|
||||
);
|
||||
$oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
|
||||
|
||||
$oCriteria->add( AppEventPeer::APP_UID, null, Criteria::ISNULL );
|
||||
@@ -598,8 +621,7 @@ class Event extends BaseEvent {
|
||||
$calculatedDueDateA = $oDates->calculateDate( $sDueDate, $when, 'days', 1 );
|
||||
$sActionDate = date( 'Y-m-d H:i:s', $calculatedDueDateA['DUE_DATE_SECONDS'] );
|
||||
$validStartDate = ($sActionDate >= $aData['DEL_DELEGATE_DATE']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sDueDate = $aData['DEL_DELEGATE_DATE'];
|
||||
$calculatedDueDateA = $oDates->calculateDate( $sDueDate, $when, 'days', 1 );
|
||||
$sActionDate = date( 'Y-m-d H:i:s', $calculatedDueDateA['DUE_DATE_SECONDS'] );
|
||||
@@ -611,8 +633,7 @@ class Event extends BaseEvent {
|
||||
$rowsCreated ++;
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->create( $aData );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rowsRejected ++;
|
||||
$aData['APP_EVN_STATUS'] = 'INVALID';
|
||||
$oAppEvent = new AppEvent();
|
||||
@@ -621,14 +642,13 @@ class Event extends BaseEvent {
|
||||
$oDataset->next();
|
||||
}
|
||||
return "Created $rowsCreated MULTIPLE rows in APP_EVENT and rejected $rowsRejected rows ";
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw new Exception( $oError->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function closeAppEvents($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID){
|
||||
function closeAppEvents ($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID)
|
||||
{
|
||||
|
||||
$aAppEvents = $this->getAppEvents( $APP_UID, $DEL_INDEX );
|
||||
if ($aAppEvents) {
|
||||
@@ -644,7 +664,8 @@ class Event extends BaseEvent {
|
||||
|
||||
}
|
||||
|
||||
function createAppEvents($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID){
|
||||
function createAppEvents ($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID)
|
||||
{
|
||||
$aRows = Array ();
|
||||
$aEventsRows = $this->getBy( $PRO_UID, $TAS_UID );
|
||||
if ($aEventsRows !== false) {
|
||||
@@ -707,7 +728,8 @@ class Event extends BaseEvent {
|
||||
}
|
||||
}
|
||||
|
||||
function verifyTaskbetween($PRO_UID, $taskFrom, $taskTo, $taskVerify) {
|
||||
function verifyTaskbetween ($PRO_UID, $taskFrom, $taskTo, $taskVerify)
|
||||
{
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( RoutePeer::ROU_NEXT_TASK );
|
||||
|
||||
@@ -734,7 +756,8 @@ class Event extends BaseEvent {
|
||||
}
|
||||
}
|
||||
|
||||
function getBy($PRO_UID, $taskUid){
|
||||
function getBy ($PRO_UID, $taskUid)
|
||||
{
|
||||
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( EventPeer::EVN_UID );
|
||||
@@ -787,14 +810,16 @@ class Event extends BaseEvent {
|
||||
$oDataset = EventPeer::doSelectRs( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
while($oDataset->next()) $aRows[]= $oDataset->getRow();
|
||||
while ($oDataset->next()) {
|
||||
$aRows[] = $oDataset->getRow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (count( $aRows ) > 0) ? $aRows : false;
|
||||
}
|
||||
|
||||
function getAppEvents($APP_UID, $DEL_INDEX){
|
||||
function getAppEvents ($APP_UID, $DEL_INDEX)
|
||||
{
|
||||
//for single task event
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( AppEventPeer::APP_UID );
|
||||
@@ -830,12 +855,15 @@ class Event extends BaseEvent {
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$aRows = Array ();
|
||||
while($oDataset->next()) $aRows[]= $oDataset->getRow();
|
||||
while ($oDataset->next()) {
|
||||
$aRows[] = $oDataset->getRow();
|
||||
}
|
||||
|
||||
return (count( $aRows ) > 0) ? $aRows : false;
|
||||
}
|
||||
|
||||
function toCalculateTime($aData, $iDate=null){
|
||||
function toCalculateTime ($aData, $iDate = null)
|
||||
{
|
||||
G::LoadClass( 'dates' );
|
||||
$oDates = new dates();
|
||||
|
||||
@@ -845,6 +873,7 @@ class Event extends BaseEvent {
|
||||
$when = $aData['EVN_WHEN']; //how many days
|
||||
$whenOccurs = $aData['EVN_WHEN_OCCURS']; //time on action (AFTER_TIME/TASK_STARTED)
|
||||
|
||||
|
||||
if ($whenOccurs == 'TASK_STARTED') {
|
||||
|
||||
$calculatedDueDateA = $oDates->calculateDate( $iDate, $when, 'days', 1 );
|
||||
@@ -858,12 +887,12 @@ class Event extends BaseEvent {
|
||||
return $sActionDate;
|
||||
}
|
||||
|
||||
function Exists ( $sUid ) {
|
||||
function Exists ($sUid)
|
||||
{
|
||||
try {
|
||||
$oObj = EventPeer::retrieveByPk( $sUid );
|
||||
return (is_object( $oObj ) && get_class( $oObj ) == 'Event');
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
@@ -893,7 +922,6 @@ class Event extends BaseEvent {
|
||||
$aRow = $oDataset->getRow();
|
||||
return $aRow;
|
||||
}
|
||||
}
|
||||
// Event
|
||||
|
||||
|
||||
} // Event
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Process.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -28,7 +29,6 @@ require_once 'classes/model/om/BaseProcess.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/ProcessCategory.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'PROCESS' table.
|
||||
*
|
||||
@@ -40,15 +40,18 @@ require_once 'classes/model/ProcessCategory.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Process extends BaseProcess {
|
||||
class Process extends BaseProcess
|
||||
{
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pro_title = '';
|
||||
|
||||
/**
|
||||
* Get the [Pro_title] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProTitle ()
|
||||
@@ -87,14 +90,17 @@ class Process extends BaseProcess {
|
||||
|
||||
} // set()
|
||||
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pro_description = '';
|
||||
|
||||
/**
|
||||
* Get the [Pro_description] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProDescription ()
|
||||
@@ -133,6 +139,7 @@ class Process extends BaseProcess {
|
||||
|
||||
} // set()
|
||||
|
||||
|
||||
/**
|
||||
* Creates the Process
|
||||
*
|
||||
@@ -143,7 +150,8 @@ class Process extends BaseProcess {
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($aData ) {
|
||||
function create ($aData)
|
||||
{
|
||||
if (! isset( $aData['USR_UID'] )) {
|
||||
throw (new PropelException( 'The process cannot be created. The USR_UID is empty.' ));
|
||||
}
|
||||
@@ -180,32 +188,32 @@ class Process extends BaseProcess {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
if (isset ( $aData['PRO_TITLE'] ) )
|
||||
if (isset( $aData['PRO_TITLE'] )) {
|
||||
$this->setProTitle( $aData['PRO_TITLE'] );
|
||||
else
|
||||
} else {
|
||||
$this->setProTitle( 'Default Process Title' );
|
||||
}
|
||||
|
||||
if (isset ( $aData['PRO_DESCRIPTION'] ) )
|
||||
if (isset( $aData['PRO_DESCRIPTION'] )) {
|
||||
$this->setProDescription( $aData['PRO_DESCRIPTION'] );
|
||||
else
|
||||
} else {
|
||||
$this->setProDescription( 'Default Process Description' );
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
|
||||
$this->memcachedDelete();
|
||||
|
||||
return $this->getProUid();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
}
|
||||
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
@@ -217,24 +225,21 @@ class Process extends BaseProcess {
|
||||
* @param string $sProUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function processExists ( $ProUid ) {
|
||||
function processExists ($ProUid)
|
||||
{
|
||||
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oPro = ProcessPeer::retrieveByPk( $ProUid );
|
||||
if (is_object( $oPro ) && get_class( $oPro ) == 'Process') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load the Process row specified in [pro_id] column value.
|
||||
*
|
||||
@@ -242,7 +247,8 @@ class Process extends BaseProcess {
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function load ( $ProUid , $getAllLang=false) {
|
||||
function load ($ProUid, $getAllLang = false)
|
||||
{
|
||||
|
||||
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
||||
try {
|
||||
@@ -264,7 +270,9 @@ class Process extends BaseProcess {
|
||||
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
|
||||
$c->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
$c->add( ContentPeer::CON_ID, $ProUid );
|
||||
if(!$getAllLang) $c->add(ContentPeer::CON_LANG, $lang );
|
||||
if (! $getAllLang) {
|
||||
$c->add( ContentPeer::CON_LANG, $lang );
|
||||
}
|
||||
$rs = ProcessPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
@@ -272,22 +280,25 @@ class Process extends BaseProcess {
|
||||
|
||||
while (is_array( $row )) {
|
||||
switch ($row['CON_CATEGORY']) {
|
||||
case 'PRO_TITLE' : $aFields['PRO_TITLE'] = $row['CON_VALUE'];
|
||||
case 'PRO_TITLE':
|
||||
$aFields['PRO_TITLE'] = $row['CON_VALUE'];
|
||||
$this->pro_title = $row['CON_VALUE'];
|
||||
if ( $row['CON_VALUE'] !== '' )
|
||||
if ($row['CON_VALUE'] !== '') {
|
||||
$this->setProTitle( $aFields['PRO_TITLE'] );
|
||||
}
|
||||
break;
|
||||
case 'PRO_DESCRIPTION' : $aFields['PRO_DESCRIPTION'] = $row['CON_VALUE'];
|
||||
case 'PRO_DESCRIPTION':
|
||||
$aFields['PRO_DESCRIPTION'] = $row['CON_VALUE'];
|
||||
$this->pro_description = $row['CON_VALUE'];
|
||||
if ( $row['CON_VALUE'] !== '' )
|
||||
if ($row['CON_VALUE'] !== '') {
|
||||
$this->setProDescription( $aFields['PRO_DESCRIPTION'] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
|
||||
|
||||
//If the prev script doesn't return anithing try to create the values based on EN
|
||||
if (! isset( $aFields['PRO_TITLE'] )) {
|
||||
$aFields['PRO_TITLE'] = $oPro->getProTitle();
|
||||
@@ -316,18 +327,16 @@ class Process extends BaseProcess {
|
||||
$aFields['PRO_DYNAFORMS'] = @unserialize( $aFields['PRO_DYNAFORMS'] );
|
||||
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw (new Exception( "The row '$ProUid' in table Process doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getAll() {
|
||||
function getAll ()
|
||||
{
|
||||
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
|
||||
@@ -369,27 +378,31 @@ class Process extends BaseProcess {
|
||||
}
|
||||
|
||||
G::loadClass( 'configuration' );
|
||||
$oConf = new Configurations;
|
||||
$oConf = new Configurations();
|
||||
$oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
|
||||
|
||||
foreach ($processes as $i => $process) {
|
||||
$processes[$i]['PRO_TITLE'] = $processes[$i]['PRO_DESCRIPTION'] = '';
|
||||
|
||||
if (isset($processesDetails[$process['PRO_UID']]['PRO_TITLE']))
|
||||
if (isset( $processesDetails[$process['PRO_UID']]['PRO_TITLE'] )) {
|
||||
$processes[$i]['PRO_TITLE'] = $processesDetails[$process['PRO_UID']]['PRO_TITLE'];
|
||||
}
|
||||
|
||||
if (isset($processesDetails[$process['PRO_UID']]))
|
||||
if (isset( $processesDetails[$process['PRO_UID']] )) {
|
||||
$processes[$i]['PRO_DESCRIPTION'] = $processesDetails[$process['PRO_UID']]['PRO_DESCRIPTION'];
|
||||
}
|
||||
}
|
||||
|
||||
return $processes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Prolication row
|
||||
*
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
*
|
||||
*/
|
||||
|
||||
public function update ($aData)
|
||||
{
|
||||
@@ -404,41 +417,42 @@ class Process extends BaseProcess {
|
||||
if (is_object( $oPro ) && get_class( $oPro ) == 'Process') {
|
||||
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oPro->validate()) {
|
||||
if ( isset ( $aData['PRO_TITLE'] ) )
|
||||
if (isset( $aData['PRO_TITLE'] )) {
|
||||
$oPro->setProTitle( $aData['PRO_TITLE'] );
|
||||
|
||||
if ( isset ( $aData['PRO_DESCRIPTION'] ) )
|
||||
}
|
||||
if (isset( $aData['PRO_DESCRIPTION'] )) {
|
||||
$oPro->setProDescription( $aData['PRO_DESCRIPTION'] );
|
||||
}
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
|
||||
$this->memcachedDelete();
|
||||
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$msg = '';
|
||||
foreach($oPro->getValidationFailures() as $objValidationFailure)
|
||||
foreach ($oPro->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
|
||||
throw (new Exception( 'The row cannot be updated!' . $msg ));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw (new Exception( "The row '" . $aData['PRO_UID'] . "' in table Process doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an Application row
|
||||
*
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
*
|
||||
*/
|
||||
|
||||
public function createRow ($aData)
|
||||
{
|
||||
@@ -487,26 +501,26 @@ class Process extends BaseProcess {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
if (isset ( $aData['PRO_TITLE'] ) && trim ($aData['PRO_TITLE']) != '' )
|
||||
if (isset( $aData['PRO_TITLE'] ) && trim( $aData['PRO_TITLE'] ) != '') {
|
||||
$this->setProTitle( $aData['PRO_TITLE'] );
|
||||
else
|
||||
} else {
|
||||
$this->setProTitle( 'Default Process Title' );
|
||||
|
||||
if (isset ( $aData['PRO_DESCRIPTION'] ) )
|
||||
}
|
||||
if (isset( $aData['PRO_DESCRIPTION'] )) {
|
||||
$this->setProDescription( $aData['PRO_DESCRIPTION'] );
|
||||
else
|
||||
} else {
|
||||
$this->setProDescription( 'Default Process Description' );
|
||||
|
||||
}
|
||||
$con->commit();
|
||||
|
||||
$this->memcachedDelete();
|
||||
|
||||
return $this->getProUid();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
|
||||
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
|
||||
}
|
||||
@@ -515,9 +529,11 @@ class Process extends BaseProcess {
|
||||
|
||||
/**
|
||||
* Remove the Prolication document registry
|
||||
*
|
||||
* @param array $aData or string $ProUid
|
||||
* @return string
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public function remove ($ProUid)
|
||||
{
|
||||
if (is_array( $ProUid )) {
|
||||
@@ -525,20 +541,17 @@ class Process extends BaseProcess {
|
||||
}
|
||||
try {
|
||||
$oPro = ProcessPeer::retrieveByPK( $ProUid );
|
||||
if (!is_null($oPro))
|
||||
{
|
||||
if (! is_null( $oPro )) {
|
||||
Content::removeContent( 'PRO_TITLE', '', $oPro->getProUid() );
|
||||
Content::removeContent( 'PRO_DESCRIPTION', '', $oPro->getProUid() );
|
||||
|
||||
$this->memcachedDelete();
|
||||
|
||||
return $oPro->delete();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw (new Exception( "The row '$ProUid' in table Process doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
@@ -565,7 +578,8 @@ class Process extends BaseProcess {
|
||||
}
|
||||
|
||||
//new functions
|
||||
function getAllProcessesCount(){
|
||||
function getAllProcessesCount ()
|
||||
{
|
||||
$c = $this->tmpCriteria;
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( 'COUNT(*)' );
|
||||
@@ -573,19 +587,20 @@ class Process extends BaseProcess {
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
if( is_array($aRow) )
|
||||
if (is_array( $aRow )) {
|
||||
return $aRow[0];
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function getAllProcesses($start, $limit, $category=NULL, $processName=NULL, $counters = true, $reviewSubProcess = false)
|
||||
function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false)
|
||||
{
|
||||
require_once PATH_RBAC . "model/RbacUsers.php";
|
||||
require_once "classes/model/ProcessCategory.php";
|
||||
require_once "classes/model/Users.php";
|
||||
|
||||
$user = new RbacUsers;
|
||||
$user = new RbacUsers();
|
||||
$aProcesses = Array ();
|
||||
$categories = Array ();
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
@@ -612,18 +627,21 @@ class Process extends BaseProcess {
|
||||
$oCriteria->add( ProcessPeer::PRO_SUBPROCESS, '1', Criteria::NOT_EQUAL );
|
||||
}
|
||||
|
||||
if( isset($category) )
|
||||
if (isset( $category )) {
|
||||
$oCriteria->add( ProcessPeer::PRO_CATEGORY, $category, Criteria::EQUAL );
|
||||
}
|
||||
|
||||
$oCriteria->addJoin( ProcessPeer::PRO_CREATE_USER, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
|
||||
$oCriteria->addJoin( ProcessPeer::PRO_CATEGORY, ProcessCategoryPeer::CATEGORY_UID, Criteria::LEFT_JOIN );
|
||||
|
||||
$this->tmpCriteria = clone $oCriteria;
|
||||
|
||||
if($start != '')
|
||||
if ($start != '') {
|
||||
$oCriteria->setOffset( $start );
|
||||
if($limit != '' && !isset($category) && !isset($processName))
|
||||
}
|
||||
if ($limit != '' && ! isset( $category ) && ! isset( $processName )) {
|
||||
$oCriteria->setLimit( $limit );
|
||||
}
|
||||
|
||||
//execute a query to obtain numbers, how many cases there are by process
|
||||
if ($counters) {
|
||||
@@ -658,7 +676,7 @@ class Process extends BaseProcess {
|
||||
}
|
||||
|
||||
G::loadClass( 'configuration' );
|
||||
$oConf = new Configurations;
|
||||
$oConf = new Configurations();
|
||||
$oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
|
||||
|
||||
foreach ($processes as $process) {
|
||||
@@ -694,9 +712,10 @@ class Process extends BaseProcess {
|
||||
$userOwner = str_replace( '@userName', $process['USR_USERNAME'], $userOwner );
|
||||
$userOwner = str_replace( '@firstName', $process['USR_FIRSTNAME'], $userOwner );
|
||||
$userOwner = str_replace( '@lastName', $process['USR_LASTNAME'], $userOwner );
|
||||
if ( $userOwner == " ( )" ) $userOwner = '-';
|
||||
if ($userOwner == " ( )") {
|
||||
$userOwner = '-';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$userOwner = $process['USR_FIRSTNAME'] . ' ' . $process['USR_LASTNAME'];
|
||||
}
|
||||
|
||||
@@ -734,7 +753,8 @@ class Process extends BaseProcess {
|
||||
return $aProcesses;
|
||||
}
|
||||
|
||||
function getCasesCountInAllProcesses(){
|
||||
function getCasesCountInAllProcesses ()
|
||||
{
|
||||
/*SELECT PRO_UID, APP_STATUS, COUNT( * )
|
||||
FROM APPLICATION
|
||||
GROUP BY PRO_UID, APP_STATUS*/
|
||||
@@ -763,7 +783,8 @@ class Process extends BaseProcess {
|
||||
return $aProcesses;
|
||||
}
|
||||
|
||||
function getAllProcessesByCategory(){
|
||||
function getAllProcessesByCategory ()
|
||||
{
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( ProcessPeer::PRO_CATEGORY );
|
||||
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
|
||||
@@ -834,9 +855,12 @@ class Process extends BaseProcess {
|
||||
$r = $memcache->delete( $memkeyTotal );
|
||||
}
|
||||
}
|
||||
} //Process
|
||||
}
|
||||
//Process
|
||||
|
||||
function ordProcessByProTitle($a, $b){
|
||||
|
||||
function ordProcessByProTitle ($a, $b)
|
||||
{
|
||||
|
||||
if ($a['PRO_TITLE'] > $b['PRO_TITLE']) {
|
||||
return 1;
|
||||
@@ -845,7 +869,5 @@ function ordProcessByProTitle($a, $b){
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user