initial commit from rev. 632
This commit is contained in:
1123
workflow/engine/classes/model/AdditionalTables.php
Normal file
1123
workflow/engine/classes/model/AdditionalTables.php
Normal file
File diff suppressed because it is too large
Load Diff
23
workflow/engine/classes/model/AdditionalTablesPeer.php
Normal file
23
workflow/engine/classes/model/AdditionalTablesPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAdditionalTablesPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AdditionalTables.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'ADDITIONAL_TABLES' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AdditionalTablesPeer extends BaseAdditionalTablesPeer {
|
||||
|
||||
} // AdditionalTablesPeer
|
||||
1188
workflow/engine/classes/model/AppCacheView.php
Normal file
1188
workflow/engine/classes/model/AppCacheView.php
Normal file
File diff suppressed because it is too large
Load Diff
23
workflow/engine/classes/model/AppCacheViewPeer.php
Normal file
23
workflow/engine/classes/model/AppCacheViewPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppCacheViewPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppCacheView.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_CACHE_VIEW' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppCacheViewPeer extends BaseAppCacheViewPeer {
|
||||
|
||||
} // AppCacheViewPeer
|
||||
118
workflow/engine/classes/model/AppDelay.php
Normal file
118
workflow/engine/classes/model/AppDelay.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseAppDelay.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_DELAY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppDelay extends BaseAppDelay {
|
||||
/**
|
||||
* Create the application delay registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME);
|
||||
try {
|
||||
if ( isset ( $aData['APP_DELAY_UID'] ) && $aData['APP_DELAY_UID']== '' )
|
||||
unset ( $aData['APP_DELAY_UID'] );
|
||||
if ( !isset ( $aData['APP_DELAY_UID'] ) )
|
||||
$aData['APP_DELAY_UID'] = G::generateUniqueID();
|
||||
$oAppDelay = new AppDelay();
|
||||
$oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oAppDelay->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oAppDelay->save();
|
||||
$oConnection->commit();
|
||||
return $aData['APP_DELAY_UID'];
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oAppDelay->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application delay registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppDelay = AppDelayPeer::retrieveByPK($aData['APP_DELAY_UID']);
|
||||
if (!is_null($oAppDelay))
|
||||
{
|
||||
$oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oAppDelay->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oAppDelay->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oAppDelay->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function isPaused($appUid, $delIndex){
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(AppDelayPeer::APP_UID, $appUid);
|
||||
$oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex);
|
||||
$oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
|
||||
$oCriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, null);
|
||||
$oCriteria->add(
|
||||
$oCriteria->getNewCriterion(
|
||||
AppDelayPeer::APP_DISABLE_ACTION_USER,
|
||||
null,
|
||||
Criteria::ISNULL
|
||||
)->addOr(
|
||||
$oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0)
|
||||
)
|
||||
);
|
||||
$oDataset = AppDelayPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
if( $aRow )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
} // AppDelay
|
||||
23
workflow/engine/classes/model/AppDelayPeer.php
Normal file
23
workflow/engine/classes/model/AppDelayPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppDelayPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppDelay.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_DELAY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppDelayPeer extends BaseAppDelayPeer {
|
||||
|
||||
} // AppDelayPeer
|
||||
415
workflow/engine/classes/model/AppDelegation.php
Normal file
415
workflow/engine/classes/model/AppDelegation.php
Normal file
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
/**
|
||||
* AppDelegation.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseAppDelegation.php';
|
||||
require_once ( "classes/model/HolidayPeer.php" );
|
||||
require_once ( "classes/model/TaskPeer.php" );
|
||||
G::LoadClass("dates");
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_DELEGATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppDelegation extends BaseAppDelegation {
|
||||
|
||||
/**
|
||||
* create an application delegation
|
||||
* @param $sProUid process Uid
|
||||
* @param $sAppUid Application Uid
|
||||
* @param $sTasUid Task Uid
|
||||
* @param $sUsrUid User Uid
|
||||
* @param $iPriority delegation priority
|
||||
* @param $isSubprocess is a subprocess inside a process?
|
||||
* @return delegation index of the application delegation.
|
||||
*/
|
||||
function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess=false, $sPrevious=-1 ) {
|
||||
|
||||
if (!isset($sProUid) || strlen($sProUid) == 0 ) {
|
||||
throw ( new Exception ( 'Column "PRO_UID" cannot be null.' ) );
|
||||
}
|
||||
|
||||
if (!isset($sAppUid) || strlen($sAppUid ) == 0 ) {
|
||||
throw ( new Exception ( 'Column "APP_UID" cannot be null.' ) );
|
||||
}
|
||||
|
||||
if (!isset($sTasUid) || strlen($sTasUid ) == 0 ) {
|
||||
throw ( new Exception ( 'Column "TAS_UID" cannot be null.' ) );
|
||||
}
|
||||
|
||||
if (!isset($sUsrUid) /*|| strlen($sUsrUid ) == 0*/ ) {
|
||||
throw ( new Exception ( 'Column "USR_UID" cannot be null.' ) );
|
||||
}
|
||||
if (!isset($sAppThread) || strlen($sAppThread ) == 0 ) {
|
||||
throw ( new Exception ( 'Column "APP_THREAD" cannot be null.' ) );
|
||||
}
|
||||
//get max DEL_INDEX SELECT MAX(DEL_INDEX) AS M FROM APP_DELEGATION WHERE APP_UID="'.$Fields['APP_UID'].'"'
|
||||
$c = new Criteria ();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn ( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
|
||||
$c->add ( AppDelegationPeer::APP_UID, $sAppUid );
|
||||
$rs = AppDelegationPeer::doSelectRS ( $c );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$delIndex = $row[0] + 1;
|
||||
|
||||
$this->setAppUid ( $sAppUid );
|
||||
$this->setProUid ( $sProUid );
|
||||
$this->setTasUid ( $sTasUid );
|
||||
$this->setDelIndex ( $delIndex );
|
||||
$this->setDelPrevious ( $sPrevious == -1 ? 0 : $sPrevious );
|
||||
$this->setUsrUid ( $sUsrUid );
|
||||
$this->setDelType ( 'NORMAL' );
|
||||
$this->setDelPriority ( ($iPriority != '' ? $iPriority : '3') );
|
||||
$this->setDelThread ( $sAppThread );
|
||||
$this->setDelThreadStatus ( 'OPEN' );
|
||||
$this->setDelDelegateDate ( 'now' );
|
||||
//The function return an array now. By JHL
|
||||
$delTaskDueDate=$this->calculateDueDate();
|
||||
$this->setDelTaskDueDate ( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
|
||||
$this->setDelData ( '' ); //$delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
|
||||
|
||||
// this condition assures that an internal delegation like a subprocess dont have an initial date setted
|
||||
if ( $delIndex == 1 && !$isSubprocess ) //the first delegation, init date this should be now for draft applications, in other cases, should be null.
|
||||
$this->setDelInitDate ('now' );
|
||||
|
||||
if ($this->validate() ) {
|
||||
try {
|
||||
$res = $this->save();
|
||||
}
|
||||
catch ( PropelException $e ) {
|
||||
throw ( $e );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $this->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
throw ( new Exception ( 'Failed Data validation saving APP_DELEGATION row: ' . $msg ) );
|
||||
}
|
||||
|
||||
return $this->getDelIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Application Delegation row specified in [app_id] column value.
|
||||
*
|
||||
* @param string $AppUid the uid of the application
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $AppUid, $sDelIndex ) {
|
||||
$con = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppDel = AppDelegationPeer::retrieveByPk( $AppUid, $sDelIndex );
|
||||
if ( get_class ($oAppDel) == 'AppDelegation' ) {
|
||||
$aFields = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application row
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oApp = AppDelegationPeer::retrieveByPK( $aData['APP_UID'], $aData['DEL_INDEX'] );
|
||||
if ( get_class ($oApp) == 'AppDelegation' ) {
|
||||
$oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oApp->validate()) {
|
||||
$res = $oApp->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "This AppDelegation row doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($sApplicationUID, $iDelegationIndex) {
|
||||
$oConnection = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oConnection->begin();
|
||||
$oApp = AppDelegationPeer::retrieveByPK( $sApplicationUID, $iDelegationIndex );
|
||||
if ( get_class ($oApp) == 'AppDelegation' ) {
|
||||
$result = $oApp->delete();
|
||||
}
|
||||
$oConnection->commit();
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e) {
|
||||
$oConnection->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
// TasTypeDay = 1 => working days
|
||||
// TasTypeDay = 2 => calendar days
|
||||
function calculateDueDate()
|
||||
{
|
||||
//Get Task properties
|
||||
$task = TaskPeer::retrieveByPK( $this->getTasUid() );
|
||||
|
||||
//use the dates class to calculate dates
|
||||
$dates = new dates();
|
||||
$iDueDate = $dates->calculateDate( $this->getDelDelegateDate(),
|
||||
$task->getTasDuration(),
|
||||
$task->getTasTimeUnit(), //hours or days, ( we only accept this two types or maybe weeks
|
||||
$task->getTasTypeDay(), //working or calendar days
|
||||
$this->getUsrUid(),
|
||||
$task->getProUid(),
|
||||
$this->getTasUid() );
|
||||
return $iDueDate;
|
||||
}
|
||||
|
||||
function getDiffDate ( $date1, $date2 ) {
|
||||
return ( $date1 - $date2 )/(24*60*60); //days
|
||||
return ( $date1 - $date2 ) / 3600;
|
||||
}
|
||||
function calculateDuration() {
|
||||
try {
|
||||
//patch rows with initdate = null and finish_date
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(AppDelegationPeer::APP_UID );
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
|
||||
$c->add(AppDelegationPeer::DEL_FINISH_DATE, NULL, Criteria::ISNOTNULL);
|
||||
//$c->add(AppDelegationPeer::DEL_INDEX, 1);
|
||||
|
||||
$rs = AppDelegationPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
|
||||
while (is_array($row)) {
|
||||
$oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX'] );
|
||||
if ( isset ($row['DEL_FINISH_DATE']) )
|
||||
$oAppDel->setDelInitDate($row['DEL_FINISH_DATE']);
|
||||
else
|
||||
$oAppDel->setDelInitDate($row['DEL_INIT_DATE']);
|
||||
$oAppDel->save();
|
||||
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
//walk in all rows with DEL_STARTED = 0 or DEL_FINISHED = 0
|
||||
|
||||
$c = new Criteria('workflow');
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(AppDelegationPeer::APP_UID );
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_STARTED);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
|
||||
$c->addSelectColumn(TaskPeer::TAS_DURATION);
|
||||
$c->addSelectColumn(TaskPeer::TAS_TIMEUNIT);
|
||||
$c->addSelectColumn(TaskPeer::TAS_TYPE_DAY);
|
||||
|
||||
$c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
|
||||
//$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
|
||||
//$c->add(AppDelegationPeer::APP_UID, '7694483844a37bfeb0931b1063501289');
|
||||
//$c->add(AppDelegationPeer::DEL_STARTED, 0);
|
||||
|
||||
$cton1 = $c->getNewCriterion(AppDelegationPeer::DEL_STARTED, 0);
|
||||
$cton2 = $c->getNewCriterion(AppDelegationPeer::DEL_FINISHED, 0);
|
||||
$cton1->addOR($cton2);
|
||||
$c->add($cton1);
|
||||
|
||||
$rs = AppDelegationPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$i =0;
|
||||
//print "<table colspacing='2' border='1'>";
|
||||
//print "<tr><td>iDelegateDate </td><td>iInitDate </td><td>iDueDate </td><td>iFinishDate </td><td>isStarted </td><td>isFinished </td><td>isDelayed </td><td>queueDuration </td><td>delDuration </td><td>delayDuration</td></tr>";
|
||||
$now = strtotime ( 'now' );
|
||||
while ( is_array($row) ) {
|
||||
$fTaskDuration = $row['TAS_DURATION'];
|
||||
$iDelegateDate = strtotime ( $row['DEL_DELEGATE_DATE'] );
|
||||
$iInitDate = strtotime ( $row['DEL_INIT_DATE'] );
|
||||
$iDueDate = strtotime ( $row['DEL_TASK_DUE_DATE'] );
|
||||
$iFinishDate = strtotime ( $row['DEL_FINISH_DATE'] );
|
||||
$isStarted = intval ( $row['DEL_STARTED'] );
|
||||
$isFinished = intval ( $row['DEL_FINISHED'] );
|
||||
$isDelayed = intval ( $row['DEL_DELAYED'] );
|
||||
$queueDuration = $this->getDiffDate ($iInitDate, $iDelegateDate);
|
||||
$delDuration = 0;
|
||||
$delayDuration = 0;
|
||||
$overduePercentage = 0.0;
|
||||
//get the object,
|
||||
$oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX'] );
|
||||
//if the task is not started
|
||||
if ( $isStarted == 0 ) {
|
||||
if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
|
||||
$oAppDel->setDelStarted(1);
|
||||
$queueDuration = $this->getDiffDate ($iInitDate, $iDelegateDate );
|
||||
$oAppDel->setDelQueueDuration( $queueDuration);
|
||||
}
|
||||
else {//the task was not started
|
||||
$queueDuration = $this->getDiffDate ( $now, $iDelegateDate );
|
||||
$oAppDel->setDelQueueDuration( $queueDuration);
|
||||
|
||||
//we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
|
||||
$delayDuration = $this->getDiffDate ($now, $iDueDate );
|
||||
$oAppDel->setDelDelayDuration( $delayDuration);
|
||||
if ( $fTaskDuration != 0) {
|
||||
$overduePercentage = $delayDuration / $fTaskDuration;
|
||||
$oAppDel->setAppOverduePercentage( $overduePercentage);
|
||||
if ( $iDueDate < $now ) {
|
||||
$oAppDel->setDelDelayed(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if the task was not finished
|
||||
if ( $isFinished == 0 ) {
|
||||
if ( $row['DEL_FINISH_DATE'] != NULL && $row['DEL_FINISH_DATE'] != '') {
|
||||
$oAppDel->setAppOverduePercentage($overduePercentage);
|
||||
$oAppDel->setDelFinished(1);
|
||||
|
||||
$delDuration = $this->getDiffDate ($iFinishDate, $iInitDate );
|
||||
$oAppDel->setDelDuration( $delDuration);
|
||||
//calculate due date if correspond
|
||||
if ( $iDueDate < $iFinishDate ) {
|
||||
$oAppDel->setDelDelayed(1);
|
||||
$delayDuration = $this->getDiffDate ($iFinishDate, $iDueDate );
|
||||
}
|
||||
else {
|
||||
$oAppDel->setDelDelayed(0);
|
||||
$delayDuration = 0;
|
||||
}
|
||||
}
|
||||
else { //the task was not completed
|
||||
if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
|
||||
$delDuration = $this->getDiffDate ($now, $iInitDate );
|
||||
}
|
||||
else
|
||||
$delDuration = $this->getDiffDate ($now, $iDelegateDate);
|
||||
$oAppDel->setDelDuration( $delDuration);
|
||||
|
||||
//we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
|
||||
$delayDuration = $this->getDiffDate ($now, $iDueDate );
|
||||
$oAppDel->setDelDelayDuration( $delayDuration);
|
||||
if ( $fTaskDuration != 0) {
|
||||
$overduePercentage = $delayDuration / $fTaskDuration;
|
||||
$oAppDel->setAppOverduePercentage($overduePercentage );
|
||||
if ( $iDueDate < $now ) {
|
||||
$oAppDel->setDelDelayed(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//and finally save the record
|
||||
$RES = $oAppDel->save();
|
||||
//print "<tr><td>$iDelegateDate </td><td>$iInitDate </td><td>$iDueDate </td><td>$iFinishDate </td><td>$isStarted </td><td>$isFinished </td><td>$isDelayed</td><td>$queueDuration </td><td>$delDuration </td>" .
|
||||
// "<td>$delayDuration</td><td>$overduePercentage</td><td>" . $row['DEL_INDEX'] . " $RES </td></tr>";
|
||||
|
||||
//UPDATE APP_DELEGATION SET DEL_DELAYED = 0
|
||||
//where
|
||||
// APP_OVERDUE_PERCENTAGE < 0
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
|
||||
}
|
||||
}
|
||||
catch ( Exception $oError) {
|
||||
//krumo ( $oError->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
function getLastDeleration($APP_UID){
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn(AppDelegationPeer::APP_UID );
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_STARTED);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
|
||||
$c->addSelectColumn(AppDelegationPeer::USR_UID);
|
||||
|
||||
$c->add(AppDelegationPeer::APP_UID, $APP_UID);
|
||||
$c->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$rs = AppDelegationPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
return $rs->getRow();
|
||||
}
|
||||
} // AppDelegation
|
||||
46
workflow/engine/classes/model/AppDelegationPeer.php
Normal file
46
workflow/engine/classes/model/AppDelegationPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* AppDelegationPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppDelegationPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppDelegation.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_DELEGATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppDelegationPeer extends BaseAppDelegationPeer {
|
||||
|
||||
} // AppDelegationPeer
|
||||
574
workflow/engine/classes/model/AppDocument.php
Normal file
574
workflow/engine/classes/model/AppDocument.php
Normal file
@@ -0,0 +1,574 @@
|
||||
<?php
|
||||
/**
|
||||
* AppDocument.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseAppDocument.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/InputDocument.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_DOCUMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppDocument extends BaseAppDocument {
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $app_doc_title = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $app_doc_comment = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $app_doc_filename = '';
|
||||
|
||||
/*
|
||||
* Load the application document registry
|
||||
* @param string $sAppDocUid
|
||||
* @param integer $iVersion (Document version)
|
||||
* @return variant
|
||||
*/
|
||||
public function load($sAppDocUid,$iVersion=NULL)
|
||||
{
|
||||
try {
|
||||
if($iVersion==NULL) $iVersion=$this->getLastAppDocVersion($sAppDocUid);
|
||||
$oAppDocument = AppDocumentPeer::retrieveByPK($sAppDocUid,$iVersion);
|
||||
if (!is_null($oAppDocument))
|
||||
{
|
||||
$aFields = $oAppDocument->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
//optimized for speed
|
||||
$aContentFields = $oAppDocument->getContentFields();
|
||||
$aFields['APP_DOC_TITLE'] = $aContentFields['APP_DOC_TITLE'];
|
||||
$aFields['APP_DOC_COMMENT'] = $aContentFields['APP_DOC_COMMENT'];
|
||||
$aFields['APP_DOC_FILENAME'] = $aContentFields['APP_DOC_FILENAME'];
|
||||
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('Error loading Document '.$sAppDocUid.'/'.$iVersion.'. This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
public function getLastIndex( $sAppUid )
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->add( AppDocumentPeer::APP_UID , $sAppUid );
|
||||
//$oCriteria->addAscendingOrderByColumn ( AppDocumentPeer::APP_DOC_INDEX );
|
||||
$oCriteria->addDescendingOrderByColumn( AppDocumentPeer::APP_DOC_INDEX );
|
||||
$lastAppDoc = AppDocumentPeer::doSelectOne($oCriteria);
|
||||
if (!is_null($lastAppDoc))
|
||||
{
|
||||
return $lastAppDoc->getAppDocIndex();
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get last Document Version based on Doc UID
|
||||
* @param s $sAppDocUid
|
||||
* @return integer
|
||||
**/
|
||||
public function getLastDocVersion( $sDocUid ,$appUID)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->add(AppDocumentPeer::DOC_UID, $sDocUid );
|
||||
$oCriteria->add(AppDocumentPeer::APP_UID, $appUID);
|
||||
$oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION );
|
||||
$lastAppDocVersion = AppDocumentPeer::doSelectOne($oCriteria);
|
||||
if (!is_null($lastAppDocVersion))
|
||||
{
|
||||
return $lastAppDocVersion->getDocVersion();
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get last Document Version based on APPDoc UID
|
||||
* @param s $sAppDocUid
|
||||
* @return integer
|
||||
**/
|
||||
public function getLastAppDocVersion( $sAppDocUid ,$appUID=0)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $sAppDocUid );
|
||||
if($appUID!=0) $oCriteria->add(AppDocumentPeer::APP_UID, $appUID);
|
||||
$oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION );
|
||||
$lastAppDocVersion = AppDocumentPeer::doSelectOne($oCriteria);
|
||||
if (!is_null($lastAppDocVersion))
|
||||
{
|
||||
return $lastAppDocVersion->getDocVersion();
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(AppDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppDocument = new AppDocument();
|
||||
|
||||
if(!isset($aData['APP_DOC_UID'])){
|
||||
$sUID = G::generateUniqueID();
|
||||
$docVersion = 1;
|
||||
}else{
|
||||
$sUID = $aData['APP_DOC_UID'];
|
||||
$docVersion = $this->getLastAppDocVersion($aData['APP_DOC_UID'],$oAppDocument->getAppUid());
|
||||
$oAppDocument->load($aData['APP_DOC_UID'], $docVersion);
|
||||
switch( $oAppDocument->getAppDocType() ){
|
||||
case "OUTPUT"://Output versioning
|
||||
$o = new OutputDocument();
|
||||
$oOutputDocument = $o->load($oAppDocument->getDocUid());
|
||||
|
||||
if( !$oOutputDocument['OUT_DOC_VERSIONING'] ){
|
||||
throw(new Exception('The Output document has not versioning enabled!'));
|
||||
}
|
||||
break;
|
||||
case "INPUT":// Input versioning
|
||||
$o = new InputDocument();
|
||||
$oInputDocument = $o->load($oAppDocument->getDocUid());
|
||||
if( !$oInputDocument['INP_DOC_VERSIONING'] ){
|
||||
throw(new Exception('This Input document does not have the versioning enabled, for this reason this operation cannot be completed'));
|
||||
}
|
||||
break;
|
||||
default://Not a valid type
|
||||
throw(new Exception('The document is not of a valid Type'));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$docVersion++;
|
||||
}
|
||||
|
||||
$oAppDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$oAppDocument->setDocVersion($docVersion);
|
||||
|
||||
$oAppDocument->setAppDocUid( $sUID );
|
||||
$oAppDocument->setAppDocIndex($this->getLastIndex( $oAppDocument->getAppUid() )+1);
|
||||
if ($oAppDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['APP_DOC_TITLE'])) {
|
||||
$oAppDocument->setAppDocTitle($aData['APP_DOC_TITLE']);
|
||||
}
|
||||
if (isset($aData['APP_DOC_COMMENT'])) {
|
||||
$oAppDocument->setAppDocComment($aData['APP_DOC_COMMENT']);
|
||||
}
|
||||
if (isset($aData['APP_DOC_FILENAME'])) {
|
||||
$oAppDocument->setAppDocFilename($aData['APP_DOC_FILENAME']);
|
||||
}
|
||||
$iResult = $oAppDocument->save();
|
||||
$oConnection->commit();
|
||||
$this->fromArray($oAppDocument->toArray( BasePeer::TYPE_FIELDNAME ), BasePeer::TYPE_FIELDNAME);
|
||||
return $sUID;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oAppDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(AppDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppDocument = AppDocumentPeer::retrieveByPK($aData['APP_DOC_UID'],$aData['DOC_VERSION']);
|
||||
if (!is_null($oAppDocument))
|
||||
{
|
||||
$oAppDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oAppDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['APP_DOC_TITLE']))
|
||||
{
|
||||
$oAppDocument->setAppDocTitle($aData['APP_DOC_TITLE']);
|
||||
}
|
||||
if (isset($aData['APP_DOC_COMMENT']))
|
||||
{
|
||||
$oAppDocument->setAppDocComment($aData['APP_DOC_COMMENT']);
|
||||
}
|
||||
if (isset($aData['APP_DOC_FILENAME']))
|
||||
{
|
||||
$oAppDocument->setAppDocFilename($aData['APP_DOC_FILENAME']);
|
||||
}
|
||||
$iResult = $oAppDocument->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oAppDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry by changing status only
|
||||
* Modified by Hugo Loza hugo@colosa.com
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sAppDocUid,$iVersion=1)
|
||||
{
|
||||
$oConnection = Propel::getConnection(AppDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppDocument = AppDocumentPeer::retrieveByPK($sAppDocUid,$iVersion);
|
||||
if (!is_null($oAppDocument)){
|
||||
$arrayDocumentsToDelete=array();
|
||||
if($oAppDocument->getAppDocType()=="INPUT"){
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $sAppDocUid);
|
||||
$oDataset = AppDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$arrayDocumentsToDelete[]=array('sAppDocUid'=>$aRow['APP_DOC_UID'],'iVersion'=>$aRow['DOC_VERSION']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
}else{
|
||||
$arrayDocumentsToDelete[]=array('sAppDocUid'=>$sAppDocUid,'iVersion'=>$iVersion);
|
||||
}
|
||||
|
||||
foreach($arrayDocumentsToDelete as $key => $docToDelete){
|
||||
$aFields = array('APP_DOC_UID' => $docToDelete['sAppDocUid'],
|
||||
'DOC_VERSION' => $docToDelete['iVersion'],
|
||||
'APP_DOC_STATUS' => 'DELETED');
|
||||
|
||||
|
||||
$oAppDocument->update($aFields);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [app_doc_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getAppDocTitle()
|
||||
{
|
||||
if ($this->app_doc_title == '') {
|
||||
try {
|
||||
$this->app_doc_title = Content::load('APP_DOC_TITLE', $this->getDocVersion(), $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
if($this->app_doc_title=="") $this->app_doc_title = Content::load('APP_DOC_TITLE', '', $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en')); //For backward compatibility
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->app_doc_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [app_doc_title] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppDocTitle($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->app_doc_title !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->app_doc_title = $sValue;
|
||||
$iResult = Content::addContent('APP_DOC_TITLE', $this->getDocVersion(), $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->app_doc_title);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->app_doc_title = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [app_doc_comment] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getAppDocComment()
|
||||
{
|
||||
if ($this->app_doc_comment == '') {
|
||||
try {
|
||||
$this->app_doc_comment = Content::load('APP_DOC_COMMENT', $this->getDocVersion(), $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
if($this->app_doc_comment=="") $this->app_doc_comment = Content::load('APP_DOC_COMMENT', '', $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en')); //For backward compatibility
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->app_doc_comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [app_doc_comment] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppDocComment($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->app_doc_comment !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->app_doc_comment = $sValue;
|
||||
$iResult = Content::addContent('APP_DOC_COMMENT', $this->getDocVersion(), $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->app_doc_comment);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->app_doc_comment = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [app_doc_filename] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getAppDocFilename()
|
||||
{
|
||||
if ($this->app_doc_filename == '') {
|
||||
try {
|
||||
$this->app_doc_filename = Content::load('APP_DOC_FILENAME', $this->getDocVersion(), $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
if($this->app_doc_filename=="") $this->app_doc_filename = Content::load('APP_DOC_FILENAME', '', $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en')); //For backward compatibility
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->app_doc_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [app_doc_filename] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppDocFilename($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->app_doc_filename !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->app_doc_filename = $sValue;
|
||||
$iResult = Content::addContent('APP_DOC_FILENAME', $this->getDocVersion(), $this->getAppDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->app_doc_filename);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->app_doc_filename = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isEmptyInContent ( $content, $field, $lang ) {
|
||||
if ( isset ( $content[$field][ $lang ] ) ) {
|
||||
if ( trim( $content[$field][ $lang ] ) != '' )
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateInsertContent ( $content, $field, $value ) {
|
||||
if ( isset ( $content[$field][ 'en' ] ) ) {
|
||||
//update
|
||||
$con = ContentPeer::retrieveByPK ( $field, $this->getDocVersion(), $this->getAppDocUid(), 'en' );
|
||||
$con->setConValue ( $value );
|
||||
if ($con->validate ()) {
|
||||
$res = $con->save ();
|
||||
}
|
||||
}
|
||||
else {//insert
|
||||
$con = new Content ( );
|
||||
$con->setConCategory ( $field );
|
||||
$con->setConParent ($this->getDocVersion() );
|
||||
$con->setConId ( $this->getAppDocUid() );
|
||||
$con->setConLang ( 'en' );
|
||||
$con->setConValue ( $value );
|
||||
if ($con->validate ()) {
|
||||
$res = $con->save ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function normalizeContent( $content, $field , $lang ) {
|
||||
$value = '';
|
||||
//if the lang row is not empty, update in 'en' row and continue
|
||||
if ( !$this->isEmptyInContent ( $content, $field , $lang ) ) {
|
||||
//update/insert only if this lang is != 'en', with this always we will have an en row with last value
|
||||
$value = $content [ $field ][ $lang ];
|
||||
if ( $lang != 'en' ) {
|
||||
$this->updateInsertContent ( $content, $field , $value );
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if the lang row is empty, and 'en' row is not empty return 'en' value
|
||||
if ( !$this->isEmptyInContent ( $content, $field , 'en' ) ) {
|
||||
$value = $content [ $field ][ 'en' ];
|
||||
}
|
||||
|
||||
//if the lang row is empty, and 'en' row is empty get value for 'other' row and update in 'en' row and continue
|
||||
if ( $this->isEmptyInContent ( $content, $field , 'en' ) ) {
|
||||
if ( isset($content[$field]) && is_array ($content[$field] ) ) {
|
||||
foreach ( $content [ $field ] as $lan => $val ) {
|
||||
if ( trim ( $val ) != '' ) {
|
||||
$value = $val;
|
||||
if ( $lan != 'en' ) {
|
||||
$this->updateInsertContent ( $content, $field , $value );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->updateInsertContent ( $content, $field , '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [app_description] , [app_title] column values.
|
||||
* @return array of string
|
||||
*/
|
||||
public function getContentFields()
|
||||
{
|
||||
if ( $this->getAppDocUid() == '' ) {
|
||||
throw ( new Exception( "Error in getContentFields, the APP_DOC_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
|
||||
$c->addSelectColumn( ContentPeer::CON_PARENT );
|
||||
$c->addSelectColumn( ContentPeer::CON_LANG );
|
||||
$c->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
$c->add( ContentPeer::CON_ID, $this->getAppDocUid() );
|
||||
$c->add( ContentPeer::CON_PARENT, $this->getDocVersion() );
|
||||
$c->addAscendingOrderByColumn('CON_CATEGORY');
|
||||
$c->addAscendingOrderByColumn('CON_LANG');
|
||||
$rs = ContentPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$content = array();
|
||||
while ($row = $rs->getRow()) {
|
||||
$conCategory = $row['CON_CATEGORY'];
|
||||
$conLang = $row['CON_LANG'];
|
||||
if ( !isset( $content[$conCategory] ) ) $content[$conCategory] = array();
|
||||
if ( !isset( $content[$conCategory][$conLang] ) ) $content[$conCategory][$conLang] = array();
|
||||
$content[$conCategory][$conLang] = $row['CON_VALUE'];
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
|
||||
$res['APP_DOC_TITLE'] = $this->normalizeContent( $content, 'APP_DOC_TITLE', $lang );
|
||||
$res['APP_DOC_COMMENT'] = $this->normalizeContent( $content, 'APP_DOC_COMMENT', $lang );
|
||||
$res['APP_DOC_FILENAME'] = $this->normalizeContent( $content, 'APP_DOC_FILENAME', $lang );
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
} // AppDocument
|
||||
46
workflow/engine/classes/model/AppDocumentPeer.php
Normal file
46
workflow/engine/classes/model/AppDocumentPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* AppDocumentPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppDocumentPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppDocument.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_DOCUMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppDocumentPeer extends BaseAppDocumentPeer {
|
||||
|
||||
} // AppDocumentPeer
|
||||
307
workflow/engine/classes/model/AppEvent.php
Normal file
307
workflow/engine/classes/model/AppEvent.php
Normal file
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseAppEvent.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_EVENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppEvent extends BaseAppEvent {
|
||||
public function load($sApplicationUID, $iDelegation) {
|
||||
try {
|
||||
$oAppEvent = AppEventPeer::retrieveByPK($sApplicationUID, $iDelegation);
|
||||
if (!is_null($oAppEvent)) {
|
||||
$aFields = $oAppEvent->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function create($aData) {
|
||||
$oConnection = Propel::getConnection(AppEventPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oAppEvent->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oAppEvent->save();
|
||||
$oConnection->commit();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oAppEvent->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />' . $sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function update($aData) {
|
||||
$oConnection = Propel::getConnection(AppEventPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppEvent = AppEventPeer::retrieveByPK($aData['APP_UID'], $aData['DEL_INDEX']);
|
||||
if (!is_null($oAppEvent)) {
|
||||
$oAppEvent->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oAppEvent->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oAppEvent->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oAppEvent->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($sApplicationUID, $iDelegation, $sEvnUid) {
|
||||
$oConnection = Propel::getConnection(AppEventPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oAppEvent = AppEventPeer::retrieveByPK($sApplicationUID, $iDelegation, $sEvnUid);
|
||||
if (!is_null($oAppEvent)) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oAppEvent->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function getAppEventsCriteria($sProcessUid, $sStatus = '', $EVN_ACTION='') {
|
||||
try {
|
||||
require_once 'classes/model/Event.php';
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_UID);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
|
||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN_OCCURS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
|
||||
$oCriteria->addAsColumn('EVN_DESCRIPTION', 'C1.CON_VALUE');
|
||||
$oCriteria->addAsColumn('TAS_TITLE', 'C2.CON_VALUE');
|
||||
$oCriteria->addAsColumn('APP_TITLE', 'C3.CON_VALUE');
|
||||
$oCriteria->addAlias('C1', 'CONTENT');
|
||||
$oCriteria->addAlias('C2', 'CONTENT');
|
||||
$oCriteria->addAlias('C3', 'CONTENT');
|
||||
$oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::LEFT_JOIN);
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
$aConditions = array();
|
||||
$aConditions[] = array(EventPeer::EVN_UID, 'C1.CON_ID');
|
||||
$aConditions[] = array('C1.CON_CATEGORY', $del . 'EVN_DESCRIPTION' . $del);
|
||||
$aConditions[] = array('C1.CON_LANG', $del . SYS_LANG . $del);
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
$aConditions = array();
|
||||
$aConditions[] = array(AppEventPeer::APP_UID, AppDelegationPeer::APP_UID);
|
||||
$aConditions[] = array(AppEventPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX);
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
$aConditions = array();
|
||||
$aConditions[] = array(AppDelegationPeer::TAS_UID, 'C2.CON_ID');
|
||||
$aConditions[] = array('C2.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
|
||||
$aConditions[] = array('C2.CON_LANG', $del . SYS_LANG . $del);
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
$aConditions = array();
|
||||
$aConditions[] = array(AppDelegationPeer::APP_UID, 'C3.CON_ID');
|
||||
$aConditions[] = array('C3.CON_CATEGORY', $del . 'APP_TITLE' . $del);
|
||||
$aConditions[] = array('C3.CON_LANG', $del . SYS_LANG . $del);
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(AppEventPeer::EVN_UID, '', Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(EventPeer::PRO_UID, $sProcessUid);
|
||||
|
||||
if($EVN_ACTION != ''){
|
||||
$oCriteria->add(EventPeer::EVN_ACTION, $EVN_ACTION);
|
||||
}
|
||||
|
||||
switch ($sStatus) {
|
||||
case '':
|
||||
//Nothing
|
||||
break;
|
||||
case 'PENDING':
|
||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
|
||||
break;
|
||||
case 'COMPLETED':
|
||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'CLOSE');
|
||||
break;
|
||||
}
|
||||
$oCriteria->addDescendingOrderByColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
||||
return $oCriteria;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function executeEvents($sNow, $debug=false) {
|
||||
|
||||
require_once 'classes/model/Configuration.php';
|
||||
require_once 'classes/model/Triggers.php';
|
||||
G::LoadClass('case');
|
||||
|
||||
$debug = 1;
|
||||
$oCase = new Cases();
|
||||
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_UID);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
|
||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
|
||||
$oCriteria->addSelectColumn(EventPeer::TRI_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
|
||||
|
||||
$oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::JOIN);
|
||||
|
||||
$aConditions = array();
|
||||
array_push($aConditions, Array(AppEventPeer::APP_UID, AppDelegationPeer::APP_UID));
|
||||
array_push($aConditions, Array(AppEventPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX));
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
|
||||
$oCriteria->addJoin(ApplicationPeer::APP_UID, AppEventPeer::APP_UID);
|
||||
|
||||
$oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); //by me
|
||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
|
||||
$oCriteria->add(AppEventPeer::APP_EVN_ACTION_DATE, $sNow, Criteria::LESS_EQUAL);
|
||||
|
||||
$oDataset = AppEventPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$c = 0;
|
||||
while ($oDataset->next()){
|
||||
|
||||
$c++;
|
||||
$aRow = $oDataset->getRow();
|
||||
$oTrigger = new Triggers();
|
||||
$aFields = $oCase->loadCase($aRow['APP_UID']);
|
||||
$oAppEvent = AppEventPeer::retrieveByPK($aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID']);
|
||||
|
||||
//g::pr($aRow); //die;
|
||||
|
||||
if($debug){
|
||||
require_once 'classes/model/Application.php';
|
||||
$oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
|
||||
$oEv = EventPeer::retrieveByPk($aRow['EVN_UID']);
|
||||
|
||||
println("\nOK+ event \"".$oEv->getEvnDescription()."\" with ID {$aRow['EVN_UID']} was found");
|
||||
println(" - PROCESS................".$aRow['PRO_UID']);
|
||||
println(" - APPLICATION............".$aRow['APP_UID']." CASE #".$oApp->getAppNumber());
|
||||
println(" - ACTION DATE............".$aRow['APP_EVN_ACTION_DATE']);
|
||||
println(" - ATTEMPTS...............".$aRow['APP_EVN_ATTEMPTS']);
|
||||
println(" - INTERVAL WITH TASKS....".$aRow['EVN_RELATED_TO']);
|
||||
}
|
||||
|
||||
if ($aRow['TRI_UID'] == '') {
|
||||
//a rare case when the tri_uid is not set.
|
||||
if($debug) println(" (!) Any trigger was set................................SKIPPED and will be CLOSED");
|
||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||
$oAppEvent->save();
|
||||
continue;
|
||||
}
|
||||
|
||||
$oTrigger = TriggersPeer::retrieveByPk($aRow['TRI_UID']);
|
||||
if( !is_object($oTrigger) ){
|
||||
//the trigger record doesn't exist..
|
||||
if($debug) println(" (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED");
|
||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||
$oAppEvent->save();
|
||||
continue;
|
||||
}
|
||||
|
||||
$oPMScript = new PMScript();
|
||||
|
||||
$oPMScript->setFields($aFields['APP_DATA']);
|
||||
$oPMScript->setScript($oTrigger->getTriWebbot());
|
||||
|
||||
$oPMScript->execute();
|
||||
|
||||
$oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
|
||||
|
||||
if( sizeof($_SESSION['TRIGGER_DEBUG']['ERRORS']) == 0 ){
|
||||
if($debug) println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
|
||||
//g::pr($aFields);
|
||||
$aFields['APP_DATA'] = $oPMScript->aFields;
|
||||
$oCase->updateCase($aRow['APP_UID'], $aFields);
|
||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||
} else {
|
||||
if($debug) {
|
||||
println(" - The trigger {$aRow['TRI_UID']} throw some errors!");
|
||||
print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']);
|
||||
}
|
||||
if ( $oAppEvent->getAppEvnAttempts() > 0 ){
|
||||
$oAppEvent->setAppEvnAttempts($oAppEvent->getAppEvnAttempts() - 1);
|
||||
} else {
|
||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||
}
|
||||
}
|
||||
$oAppEvent->save();
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
die($oError->getMessage());
|
||||
return $oError->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
function close($APP_UID, $DEL_INDEX){
|
||||
$aRow = $this->load($APP_UID, $DEL_INDEX);
|
||||
$aRow['APP_EVN_STATUS'] = 'CLOSE';
|
||||
$this->update($aRow);
|
||||
}
|
||||
|
||||
} // AppEvent
|
||||
23
workflow/engine/classes/model/AppEventPeer.php
Normal file
23
workflow/engine/classes/model/AppEventPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppEventPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppEvent.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_EVENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppEventPeer extends BaseAppEventPeer {
|
||||
|
||||
} // AppEventPeer
|
||||
424
workflow/engine/classes/model/AppFolder.php
Normal file
424
workflow/engine/classes/model/AppFolder.php
Normal file
@@ -0,0 +1,424 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseAppFolder.php';
|
||||
require_once 'classes/model/Application.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_FOLDER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
/**
|
||||
* @author hugo loza
|
||||
*
|
||||
*/
|
||||
class AppFolder extends BaseAppFolder {
|
||||
/**
|
||||
* @param string $folderName
|
||||
* @param strin(32) $folderParent
|
||||
* @return Ambigous <>|number
|
||||
*/
|
||||
function createFolder($folderName, $folderParent = "/") {
|
||||
//Try to Load the folder (Foldername+FolderParent)
|
||||
$oCriteria = new Criteria ( 'workflow' );
|
||||
$oCriteria->add ( AppFolderPeer::FOLDER_NAME, $folderName );
|
||||
$oCriteria->add ( AppFolderPeer::FOLDER_PARENT_UID, $folderParent );
|
||||
$oDataset = AppFolderPeer::doSelectRS ( $oCriteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
if ($aRow = $oDataset->getRow ()) { //Folder exist, then return the ID
|
||||
return ($aRow ['FOLDER_UID']);
|
||||
} else { //Folder doesn't exist. Create and return the ID
|
||||
|
||||
|
||||
$folderUID = G::GenerateUniqueID ();
|
||||
$tr = new AppFolder ( );
|
||||
$tr->setFolderUid ( $folderUID );
|
||||
$tr->setFolderParentUid ( $folderParent );
|
||||
$tr->setFolderName ( $folderName );
|
||||
$tr->setFolderCreateDate ( 'now' );
|
||||
$tr->setFolderUpdateDate ( 'now' );
|
||||
if ($tr->validate ()) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save ();
|
||||
return $folderUID;
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $tr->getValidationFailures ();
|
||||
foreach ( $validationFailuresArray as $objValidationFailure ) {
|
||||
$msg .= $objValidationFailure->getMessage () . "<br/>";
|
||||
}
|
||||
krumo ( $msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string $folderPath
|
||||
* @param strin(32) $sessionID
|
||||
* @return string Last Folder ID generated
|
||||
*/
|
||||
function createFromPath($folderPath, $sessionID = "") {
|
||||
if ($sessionID == "")
|
||||
$sessionID = $_SESSION ['APPLICATION'];
|
||||
//Get current Application Fields
|
||||
$oApplication = new Application ( );
|
||||
|
||||
$appFields = $oApplication->Load ( $sessionID );
|
||||
|
||||
$folderPathParsed = G::replaceDataField ( $folderPath, $appFields );
|
||||
$folderPathParsed = G::replaceDataField ( $folderPath, unserialize ( $appFields ['APP_DATA'] ) );
|
||||
|
||||
$folderPathParsedArray = explode ( "/", $folderPathParsed );
|
||||
|
||||
$folderRoot = "/"; //Always starting from Root
|
||||
foreach ( $folderPathParsedArray as $folderName ) {
|
||||
if (trim ( $folderName ) != "") {
|
||||
$folderRoot = $this->createFolder ( $folderName, $folderRoot );
|
||||
}
|
||||
}
|
||||
return $folderRoot != "/" ? $folderRoot : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileTags
|
||||
* @param string(32) $sessionID Application ID
|
||||
* @return string
|
||||
*/
|
||||
function parseTags($fileTags, $sessionID = "") {
|
||||
|
||||
if ($sessionID == "")
|
||||
$sessionID = $_SESSION ['APPLICATION'];
|
||||
//Get current Application Fields
|
||||
$oApplication = new Application ( );
|
||||
|
||||
$appFields = $oApplication->Load ( $sessionID );
|
||||
|
||||
$fileTagsParsed = G::replaceDataField ( $fileTags, $appFields );
|
||||
$fileTagsParsed = G::replaceDataField ( $fileTags, unserialize ( $appFields ['APP_DATA'] ) );
|
||||
|
||||
return $fileTagsParsed;
|
||||
}
|
||||
/**
|
||||
* @param string(32) $folderID
|
||||
* @return multitype:
|
||||
*/
|
||||
function getFolderList($folderID) {
|
||||
$Criteria = new Criteria ( 'workflow' );
|
||||
$Criteria->clearSelectColumns ()->clearOrderByColumns ();
|
||||
|
||||
$Criteria->addSelectColumn ( AppFolderPeer::FOLDER_UID );
|
||||
$Criteria->addSelectColumn ( AppFolderPeer::FOLDER_PARENT_UID );
|
||||
$Criteria->addSelectColumn ( AppFolderPeer::FOLDER_NAME );
|
||||
$Criteria->addSelectColumn ( AppFolderPeer::FOLDER_CREATE_DATE );
|
||||
$Criteria->addSelectColumn ( AppFolderPeer::FOLDER_UPDATE_DATE );
|
||||
|
||||
$Criteria->add ( appFolderPeer::FOLDER_PARENT_UID, $folderID, CRITERIA::EQUAL );
|
||||
|
||||
$Criteria->addAscendingOrderByColumn ( AppFolderPeer::FOLDER_NAME );
|
||||
|
||||
$rs = appFolderPeer::doSelectRS ( $Criteria );
|
||||
$rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next ();
|
||||
$folderResult = array ();
|
||||
while ( is_array ( $row = $rs->getRow () ) ) {
|
||||
$folderResult [] = $row;
|
||||
$rs->next ();
|
||||
}
|
||||
return ($folderResult);
|
||||
}
|
||||
/**
|
||||
* @param string(32) $folderUid
|
||||
* @return array <multitype:, mixed>
|
||||
*/
|
||||
function load($folderUid) {
|
||||
$tr = AppFolderPeer::retrieveByPK ( $folderUid );
|
||||
if ((is_object ( $tr ) && get_class ( $tr ) == 'AppFolder')) {
|
||||
$fields ['FOLDER_UID'] = $tr->getFolderUid ();
|
||||
$fields ['FOLDER_PARENT_UID'] = $tr->getFolderParentUid ();
|
||||
$fields ['FOLDER_NAME'] = $tr->getFolderName ();
|
||||
$fields ['FOLDER_CREATE_DATE'] = $tr->getFolderCreateDate ();
|
||||
$fields ['FOLDER_UPDATE_DATE'] = $tr->getFolderUpdateDate ();
|
||||
} elseif ($folderUid == "/") {
|
||||
$fields ['FOLDER_UID'] = "/";
|
||||
$fields ['FOLDER_PARENT_UID'] = "";
|
||||
$fields ['FOLDER_NAME'] = "/";
|
||||
$fields ['FOLDER_CREATE_DATE'] = "";
|
||||
$fields ['FOLDER_UPDATE_DATE'] = "";
|
||||
} else {
|
||||
$fields = array ();
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
function getFolderStructure($folderId) {
|
||||
|
||||
$folderObj = $this->load ( $folderId );
|
||||
$folderArray [$folderObj ['FOLDER_UID']] = array ("NAME" => $folderObj ['FOLDER_NAME'], "PARENT" => $folderObj ['FOLDER_PARENT_UID'] );
|
||||
$folderArray ['PATH_ARRAY'] [] = $folderObj ['FOLDER_NAME'];
|
||||
|
||||
while ( $folderObj ['FOLDER_PARENT_UID'] != "" ) {
|
||||
$folderObj = $this->load ( $folderObj ['FOLDER_PARENT_UID'] );
|
||||
$folderArray [$folderObj ['FOLDER_UID']] = array ("NAME" => $folderObj ['FOLDER_NAME'], "PARENT" => $folderObj ['FOLDER_PARENT_UID'] );
|
||||
$folderArray ['PATH_ARRAY'] [] = $folderObj ['FOLDER_NAME'];
|
||||
}
|
||||
|
||||
$folderArray ['PATH'] = str_replace ( "//", "/", implode ( "/", array_reverse ( $folderArray ['PATH_ARRAY'] ) ) );
|
||||
return $folderArray;
|
||||
}
|
||||
|
||||
function getFolderContent($folderID, $docIdFilter = array(), $keyword = NULL, $searchType = NULL) {
|
||||
require_once ("classes/model/AppDocument.php");
|
||||
require_once ("classes/model/InputDocument.php");
|
||||
require_once ("classes/model/OutputDocument.php");
|
||||
require_once ("classes/model/Users.php");
|
||||
|
||||
G::LoadClass ( 'case' );
|
||||
$oCase = new Cases ( );
|
||||
G::LoadClass ( 'process' );
|
||||
$oProcess = new Process ( );
|
||||
|
||||
$oAppDocument = new AppDocument ( );
|
||||
$oCriteria = new Criteria ( );
|
||||
if ((is_array ( $docIdFilter )) && (count ( $docIdFilter ) > 0)) { //Search by App Doc UID no matter what Folder it is
|
||||
$oCriteria->add ( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN );
|
||||
} elseif ($folderID != NULL) {
|
||||
$oCriteria->add ( AppDocumentPeer::FOLDER_UID, $folderID );
|
||||
} elseif ($searchType == "TAG") {
|
||||
$oCriteria->add ( AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE );
|
||||
}
|
||||
|
||||
$oCase->verifyTable ();
|
||||
|
||||
$oCriteria->addAscendingOrderByColumn ( AppDocumentPeer::APP_DOC_INDEX );
|
||||
|
||||
$rs = AppDocumentPeer::doSelectRS ( $oCriteria );
|
||||
$rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next ();
|
||||
$filesResult = array ();
|
||||
while ( is_array ( $row = $rs->getRow () ) ) {
|
||||
//**** start get Doc Info
|
||||
$oApp = new Application ( );
|
||||
if (($oApp->exists ( $row ['APP_UID'] )) || ($row ['APP_UID'] == "00000000000000000000000000000000")) {
|
||||
|
||||
$completeInfo = $this->getCompleteDocumentInfo ( $row ['APP_UID'], $row ['APP_DOC_UID'], $row ['DOC_VERSION'], $row ['DOC_UID'], $row ['USR_UID'] );
|
||||
|
||||
$oAppDocument = new AppDocument ( );
|
||||
$lastVersion = $oAppDocument->getLastAppDocVersion ( $row ['APP_DOC_UID'], $row ['APP_UID'] );
|
||||
|
||||
if ($completeInfo ['APP_DOC_STATUS'] != "DELETED") {
|
||||
if ((in_array ( $row ['APP_DOC_UID'], $completeInfo ['INPUT_DOCUMENTS'] )) || (in_array ( $row ['APP_DOC_UID'], $completeInfo ['OUTPUT_DOCUMENTS'] )) || (in_array ( $completeInfo ['USR_UID'], array ($_SESSION ['USER_LOGGED'], '-1' ) ))) {
|
||||
if (count ( $docIdFilter ) > 0) {
|
||||
if (in_array ( $row ['APP_DOC_UID'], $docIdFilter )) {
|
||||
$filesResult [] = $completeInfo;
|
||||
}
|
||||
} elseif ($lastVersion == $row ['DOC_VERSION']) { //Only Last Document version
|
||||
if ($searchType == "ALL") {// If search in name of docs is active then filter
|
||||
if ((stripos ( $completeInfo ['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos ( $completeInfo ['APP_DOC_TAGS'], $keyword ) !== false)) {
|
||||
$filesResult [] = $completeInfo;
|
||||
}
|
||||
} else {//No search filter active
|
||||
$filesResult [] = $completeInfo;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$rs->next ();
|
||||
}
|
||||
return ($filesResult);
|
||||
}
|
||||
function getCompleteDocumentInfo($appUid, $appDocUid, $docVersion, $docUid, $usrId) {
|
||||
require_once ("classes/model/AppDocument.php");
|
||||
require_once ("classes/model/InputDocument.php");
|
||||
require_once ("classes/model/OutputDocument.php");
|
||||
require_once ("classes/model/Users.php");
|
||||
//**** start get Doc Info
|
||||
$oApp = new Application ( );
|
||||
$oAppDocument = new AppDocument ( );
|
||||
G::LoadClass ( 'case' );
|
||||
$oCase = new Cases ( );
|
||||
G::LoadClass ( 'process' );
|
||||
$oProcess = new Process ( );
|
||||
if (($oApp->exists ( $appUid )) || ($appUid == "00000000000000000000000000000000")) {
|
||||
if ($appUid == "00000000000000000000000000000000") { //External Files
|
||||
$row1 = $oAppDocument->load ( $appDocUid, $docVersion );
|
||||
$row2 = array ('PRO_TITLE' => G::LoadTranslation ( 'ID_NOT_PROCESS_RELATED' ) );
|
||||
$row3 = array ('APP_TITLE' => G::LoadTranslation ( 'ID_NOT_PROCESS_RELATED' ) );
|
||||
} else {
|
||||
$row1 = $oAppDocument->load ( $appDocUid, $docVersion );
|
||||
$row2 = $oCase->loadCase ( $appUid );
|
||||
$row3 = $oProcess->Load ( $row2 ['PRO_UID'] );
|
||||
}
|
||||
$lastVersion = $oAppDocument->getLastAppDocVersion ( $appDocUid, $appUid );
|
||||
|
||||
switch ($row1 ['APP_DOC_TYPE']) {
|
||||
case "OUTPUT" :
|
||||
$oOutputDocument = new OutputDocument ( );
|
||||
$row4 = $oOutputDocument->load ( $docUid );
|
||||
$versioningEnabled = false; //$row4['OUT_DOC_VERSIONING']; //Only enabled for Input or Attached documents. Need to study the best way for Output docs.
|
||||
switch ($row4 ['OUT_DOC_GENERATE']) {
|
||||
case "PDF" :
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand ();
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = ".pdf";
|
||||
$downloadLabel1 = "";
|
||||
break;
|
||||
case "DOC" :
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand ();
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = ".doc";
|
||||
$downloadLabel1 = "";
|
||||
break;
|
||||
case "BOTH" :
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand ();
|
||||
$downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand ();
|
||||
$downloadLabel = ".pdf";
|
||||
$downloadLabel1 = ".doc";
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case "INPUT" :
|
||||
$oInputDocument = new InputDocument ( );
|
||||
if ($docUid != - 1) {
|
||||
if ($oInputDocument->InputExists ( $docUid )) {
|
||||
$row4 = $oInputDocument->load ( $docUid );
|
||||
$versioningEnabled = $row4 ['INP_DOC_VERSIONING'];
|
||||
} else {
|
||||
$row4 = array ();
|
||||
$versioningEnabled = false;
|
||||
}
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = G::LoadTranslation ( 'ID_DOWNLOAD' );
|
||||
$downloadLabel1 = "";
|
||||
} else {
|
||||
$row4 = array ();
|
||||
$versioningEnabled = false;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = G::LoadTranslation ( 'ID_DOWNLOAD' );
|
||||
$downloadLabel1 = "";
|
||||
}
|
||||
break;
|
||||
default :
|
||||
$row4 = array ();
|
||||
$versioningEnabled = false;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = G::LoadTranslation ( 'ID_DOWNLOAD' );
|
||||
$downloadLabel1 = "";
|
||||
break;
|
||||
|
||||
}
|
||||
$oUser = new Users ( );
|
||||
if ($usrId != "-1") {
|
||||
$row5 = $oUser->load ( $usrId );
|
||||
} else {
|
||||
$row5 ['USR_USERNAME'] = "***";
|
||||
}
|
||||
|
||||
//Labels/Links
|
||||
$row6 = array ();
|
||||
$row6 ['DELETE_LABEL'] = G::LoadTranslation('ID_DELETE');
|
||||
$row6 ['DOWNLOAD_LABEL'] = $downloadLabel;
|
||||
$row6 ['DOWNLOAD_LINK'] = $downloadLink;
|
||||
$row6 ['DOWNLOAD_LABEL1'] = $downloadLabel1;
|
||||
$row6 ['DOWNLOAD_LINK1'] = $downloadLink1;
|
||||
//if(($docVersion>1)&&($row1['APP_DOC_TYPE']!="OUTPUT")){
|
||||
if (($docVersion > 1)) {
|
||||
$row6 ['VERSIONHISTORY_LABEL'] = G::LoadTranslation ( 'ID_VERSION_HISTORY' );
|
||||
}
|
||||
if ($versioningEnabled) {
|
||||
$row6 ['NEWVERSION_LABEL'] = G::LoadTranslation ( 'ID_NEW_VERSION' );
|
||||
}
|
||||
$row6 ['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion;
|
||||
|
||||
if ($appUid == "00000000000000000000000000000000") { //External Files
|
||||
$row1 ['APP_DOC_TYPE'] = G::LoadTranslation ( 'ID_EXTERNAL_FILE' );
|
||||
}
|
||||
//**** End get docinfo
|
||||
|
||||
|
||||
$infoMerged = array_merge ( $row1, $row2, $row3, $row4, $row5, $row6 );
|
||||
//krumo($infoMerged);
|
||||
//****************************************************************************************************
|
||||
$sUserUID = $_SESSION ['USER_LOGGED'];
|
||||
$aObjectPermissions = array ();
|
||||
if (isset ( $infoMerged ['PRO_UID'] )) {
|
||||
$aObjectPermissions = $oCase->getAllObjects ( $infoMerged ['PRO_UID'], $infoMerged ['APP_UID'], '', $sUserUID );
|
||||
}
|
||||
|
||||
if (! is_array ( $aObjectPermissions )) {
|
||||
$aObjectPermissions = array ('DYNAFORMS' => array (- 1 ), 'INPUT_DOCUMENTS' => array (- 1 ), 'OUTPUT_DOCUMENTS' => array (- 1 ) );
|
||||
}
|
||||
if (! isset ( $aObjectPermissions ['DYNAFORMS'] )) {
|
||||
$aObjectPermissions ['DYNAFORMS'] = array (- 1 );
|
||||
} else {
|
||||
if (! is_array ( $aObjectPermissions ['DYNAFORMS'] )) {
|
||||
$aObjectPermissions ['DYNAFORMS'] = array (- 1 );
|
||||
}
|
||||
}
|
||||
if (! isset ( $aObjectPermissions ['INPUT_DOCUMENTS'] )) {
|
||||
$aObjectPermissions ['INPUT_DOCUMENTS'] = array (- 1 );
|
||||
} else {
|
||||
if (! is_array ( $aObjectPermissions ['INPUT_DOCUMENTS'] )) {
|
||||
$aObjectPermissions ['INPUT_DOCUMENTS'] = array (- 1 );
|
||||
}
|
||||
}
|
||||
if (! isset ( $aObjectPermissions ['OUTPUT_DOCUMENTS'] )) {
|
||||
$aObjectPermissions ['OUTPUT_DOCUMENTS'] = array (- 1 );
|
||||
} else {
|
||||
if (! is_array ( $aObjectPermissions ['OUTPUT_DOCUMENTS'] )) {
|
||||
$aObjectPermissions ['OUTPUT_DOCUMENTS'] = array (- 1 );
|
||||
}
|
||||
}
|
||||
//****************************************************************************************************
|
||||
|
||||
|
||||
return array_merge ( $infoMerged, $aObjectPermissions );
|
||||
}
|
||||
}
|
||||
function getFolderChilds($folderID, $folderArray) {
|
||||
$folderList = $this->getFolderList ( $folderID );
|
||||
$foldersList = array ();
|
||||
foreach ( $folderList as $key => $folderObj ) {
|
||||
$foldersList [$folderObj ['FOLDER_UID']] = $folderObj ['FOLDER_NAME'];
|
||||
$foldersList = array_merge ( $foldersList, $this->getFolderChilds ( $folderObj ['FOLDER_UID'], $folderArray ) );
|
||||
}
|
||||
return (array_merge ( $folderArray, $foldersList ));
|
||||
}
|
||||
|
||||
function getFolderTags($rootFolder) {
|
||||
$folderArray [$rootFolder] = $rootFolder;
|
||||
$foldersToProcess = $this->getFolderChilds ( $rootFolder, $folderArray );
|
||||
$tagsInfo = array ();
|
||||
|
||||
foreach ( $foldersToProcess as $folderkey => $foldername ) {
|
||||
$filesList = $this->getFolderContent ( $folderkey );
|
||||
|
||||
foreach ( $filesList as $key => $fileInfo ) {
|
||||
$fileTags = explode ( ",", $fileInfo ['APP_DOC_TAGS'] );
|
||||
foreach ( $fileTags as $key1 => $tag ) {
|
||||
if (! (isset ( $tagsInfo [$tag] )))
|
||||
$tagsInfo [$tag] = 0;
|
||||
$tagsInfo [$tag] ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tagsInfo;
|
||||
|
||||
}
|
||||
function remove ($FolderUid, $rootfolder ) {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add ( AppFolderPeer::FOLDER_UID, $FolderUid );
|
||||
AppFolderPeer::doDelete($oCriteria);
|
||||
}
|
||||
} // AppFolder
|
||||
23
workflow/engine/classes/model/AppFolderPeer.php
Normal file
23
workflow/engine/classes/model/AppFolderPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppFolderPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppFolder.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_FOLDER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppFolderPeer extends BaseAppFolderPeer {
|
||||
|
||||
} // AppFolderPeer
|
||||
199
workflow/engine/classes/model/AppHistory.php
Normal file
199
workflow/engine/classes/model/AppHistory.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseAppHistory.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_HISTORY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppHistory extends BaseAppHistory {
|
||||
|
||||
function insertHistory($aData){
|
||||
|
||||
$this->setAppUid($aData['APP_UID']);
|
||||
$this->setDelIndex($aData['DEL_INDEX']);
|
||||
$this->setProUid($aData['PRO_UID']);
|
||||
$this->setTasUid($aData['TAS_UID']);
|
||||
$this->setDynUid($aData['CURRENT_DYNAFORM']);
|
||||
$this->setUsrUid($aData['USER_UID']);
|
||||
$this->setAppStatus($aData['APP_STATUS']);
|
||||
$this->setHistoryDate($aData['APP_UPDATE_DATE']);
|
||||
$this->setHistoryData($aData['APP_DATA']);
|
||||
|
||||
|
||||
if ($this->validate() ) {
|
||||
$res = $this->save();
|
||||
}
|
||||
else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $this->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
krumo($msg);
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getDynaformHistory($PRO_UID,$TAS_UID,$APP_UID,$DYN_UID=""){
|
||||
G::LoadClass('case');
|
||||
$oCase = new Cases();
|
||||
|
||||
$oCase->verifyTable();
|
||||
|
||||
$aObjectPermissions = $oCase->getAllObjects($PRO_UID, $APP_UID, $TAS_UID, $_SESSION['USER_LOGGED']);
|
||||
|
||||
if (!is_array($aObjectPermissions)) {
|
||||
$aObjectPermissions = array('DYNAFORMS' => array(-1), 'INPUT_DOCUMENTS' => array(-1), 'OUTPUT_DOCUMENTS' => array(-1));
|
||||
}
|
||||
if (!isset($aObjectPermissions['DYNAFORMS'])) {
|
||||
$aObjectPermissions['DYNAFORMS'] = array(-1);
|
||||
}
|
||||
else {
|
||||
if (!is_array($aObjectPermissions['DYNAFORMS'])) {
|
||||
$aObjectPermissions['DYNAFORMS'] = array(-1);
|
||||
}
|
||||
}
|
||||
if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) {
|
||||
$aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
|
||||
}
|
||||
else {
|
||||
if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) {
|
||||
$aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
|
||||
}
|
||||
}
|
||||
if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
|
||||
$aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
|
||||
}
|
||||
else {
|
||||
if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
|
||||
$aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn(AppHistoryPeer::APP_UID);
|
||||
$c->addSelectColumn(AppHistoryPeer::DEL_INDEX);
|
||||
$c->addSelectColumn(AppHistoryPeer::PRO_UID);
|
||||
$c->addSelectColumn(AppHistoryPeer::TAS_UID);
|
||||
$c->addSelectColumn(AppHistoryPeer::DYN_UID);
|
||||
$c->addSelectColumn(AppHistoryPeer::USR_UID);
|
||||
$c->addSelectColumn(AppHistoryPeer::APP_STATUS);
|
||||
$c->addSelectColumn(AppHistoryPeer::HISTORY_DATE);
|
||||
$c->addSelectColumn(AppHistoryPeer::HISTORY_DATA);
|
||||
$c->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$c->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
|
||||
$c->addJoin(AppHistoryPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
|
||||
|
||||
//WHERE
|
||||
$c->add(AppHistoryPeer::DYN_UID, $aObjectPermissions['DYNAFORMS'], Criteria::IN);
|
||||
$c->add(AppHistoryPeer::PRO_UID, $PRO_UID);
|
||||
$c->add(AppHistoryPeer::TAS_UID, $TAS_UID);
|
||||
$c->add(AppHistoryPeer::APP_UID, $APP_UID);
|
||||
if((isset($DYN_UID))&&($DYN_UID!="")){
|
||||
$c->add(AppHistoryPeer::DYN_UID, $DYN_UID);
|
||||
}
|
||||
|
||||
//ORDER BY
|
||||
$c->clearOrderByColumns();
|
||||
$c->addDescendingOrderByColumn(AppHistoryPeer::HISTORY_DATE);
|
||||
|
||||
|
||||
//Execute
|
||||
$oDataset = AppHistoryPeer::doSelectRS($c);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
$aDynHistory = array();
|
||||
$aDynHistory[] = array(
|
||||
'DYN_TITLE' => 'char'
|
||||
);
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
|
||||
$o = new Dynaform();
|
||||
$o->setDynUid($aRow['DYN_UID']);
|
||||
$aRow['DYN_TITLE'] = $o->getDynTitle();
|
||||
$changedValues=unserialize($aRow['HISTORY_DATA']);
|
||||
$html="<table border='0' cellpadding='0' cellspacing='0'>";
|
||||
$sw_add=false;
|
||||
foreach($changedValues as $key =>$value){
|
||||
if(($value!=NULL)&&(!is_array($value))){
|
||||
$sw_add=true;
|
||||
$html.="<tr>";
|
||||
$html.="<td><b>$key:</b> </td>";
|
||||
$html.="<td>$value</td>";
|
||||
$html.="</tr>";
|
||||
}
|
||||
if(is_array($value)){
|
||||
$html.="<tr>";
|
||||
$html.="<td><b>$key (grid):</b> </td>";
|
||||
$html.="<td>";
|
||||
$html.="<table>";
|
||||
foreach($value as $key1 =>$value1){
|
||||
$html.="<tr>";
|
||||
$html.="<td><b>$key1</b></td>";
|
||||
$html.="<td>";
|
||||
if(is_array($value1)){
|
||||
$sw_add=true;
|
||||
$html.="<table>";
|
||||
foreach($value1 as $key2 =>$value2){
|
||||
$html.="<tr>";
|
||||
$html.="<td><b>$key2</b></td>";
|
||||
$html.="<td>$value2</td>";
|
||||
$html.="</tr>";
|
||||
}
|
||||
$html.="</table>";
|
||||
}
|
||||
$html.="</td>";
|
||||
$html.="</tr>";
|
||||
|
||||
}
|
||||
$html.="</table>";
|
||||
$html.="</td>";
|
||||
$html.="</tr>";
|
||||
$html.="</td>";
|
||||
}
|
||||
}
|
||||
$html.="</table>";
|
||||
|
||||
$aRow['FIELDS'] = $html;
|
||||
|
||||
if($sw_add){
|
||||
$aDynHistory[] = $aRow;
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
global $_DBArray;
|
||||
$_DBArray['DynaformsHistory'] = $aDynHistory;
|
||||
$_SESSION['_DBArray'] = $_DBArray;
|
||||
G::LoadClass('ArrayPeer');
|
||||
$oCriteria = new Criteria('dbarray');
|
||||
$oCriteria->setDBArrayTable('DynaformsHistory');
|
||||
$oCriteria->addDescendingOrderByColumn(AppHistoryPeer::HISTORY_DATE);
|
||||
return $oCriteria;
|
||||
|
||||
}
|
||||
|
||||
} // AppHistory
|
||||
23
workflow/engine/classes/model/AppHistoryPeer.php
Normal file
23
workflow/engine/classes/model/AppHistoryPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppHistoryPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppHistory.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_HISTORY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppHistoryPeer extends BaseAppHistoryPeer {
|
||||
|
||||
} // AppHistoryPeer
|
||||
120
workflow/engine/classes/model/AppMessage.php
Normal file
120
workflow/engine/classes/model/AppMessage.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* AppMessage.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseAppMessage.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_MESSAGE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppMessage extends BaseAppMessage {
|
||||
|
||||
private $data_spool;
|
||||
private $status_spool;
|
||||
private $error_spool;
|
||||
|
||||
public function getSpoolStatus() {
|
||||
return $this->status_spool;
|
||||
}
|
||||
|
||||
public function getSpoolError() {
|
||||
return $this->error_spool;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AppMessgae quick Save method
|
||||
* @Param Array(msg_uid, app_uid, del_index, app_msg_type, app_msg_subject, app_msg_from, app_msg_to,
|
||||
* app_msg_body, app_msg_cc, app_msg_bcc, app_msg_attach, app_msg_template, app_msg_status )
|
||||
*
|
||||
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmai.com>
|
||||
* @Date Aug 31th, 2009
|
||||
*/
|
||||
public function quickSave2($data_spool) {
|
||||
$this->data_spool = $data_spool;
|
||||
|
||||
$sUID = G::generateUniqueID();
|
||||
$spool = new AppMessage();
|
||||
|
||||
$spool->setAppMsgUid($sUID);
|
||||
$spool->setMsgUid($data_spool['msg_uid']);
|
||||
$spool->setAppUid($data_spool['app_uid']);
|
||||
$spool->setDelIndex($data_spool['del_index']);
|
||||
$spool->setAppMsgType($data_spool['app_msg_type']);
|
||||
$spool->setAppMsgSubject($data_spool['app_msg_subject']);
|
||||
$spool->setAppMsgFrom($data_spool['app_msg_from']);
|
||||
$spool->setAppMsgTo($data_spool['app_msg_to']);
|
||||
$spool->setAppMsgBody($data_spool['app_msg_body']);
|
||||
$spool->setAppMsgDate(date('Y-m-d H:i:s'));
|
||||
$spool->setAppMsgCc($data_spool['app_msg_cc']);
|
||||
$spool->setAppMsgBcc($data_spool['app_msg_bcc']);
|
||||
$spool->setappMsgAttach($data_spool['app_msg_attach']);
|
||||
$spool->setAppMsgTemplate($data_spool['app_msg_template']);
|
||||
$spool->setAppMsgStatus($data_spool['app_msg_status']);
|
||||
|
||||
if( !$spool->validate() ) {
|
||||
$this->error_spool = $spool->getValidationFailures();
|
||||
$this->status_spool = 'error';
|
||||
|
||||
$error_msg = "AppMessage::quickSave(): Validation error: \n";
|
||||
foreach($errors as $key=>$value) {
|
||||
$error_msg .= $value->getMessage($key) . "\n";
|
||||
}
|
||||
throw new Exception($error_msg);
|
||||
} else {
|
||||
//echo "Saving - validation ok\n";
|
||||
$this->error_spool = '';
|
||||
$this->status = 'success';
|
||||
$spool->save();
|
||||
}
|
||||
return $sUID;
|
||||
}
|
||||
|
||||
|
||||
public function quickSave($aData){
|
||||
if(isset($aData['app_msg_uid'])) {
|
||||
$o = EmployeePeer::retrieveByPk($aData['app_msg_uid']);
|
||||
}
|
||||
if (isset($o) && get_class($o) == 'AppMessage') {
|
||||
$o->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$o->setAppMsgDate(date('Y-m-d H:i:s'));
|
||||
$o->save();
|
||||
return $o->getAppMsgUid();
|
||||
} else {
|
||||
$this->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setAppMsgDate(date('Y-m-d H:i:s'));
|
||||
$this->save();
|
||||
return $this->getAppMsgUid();
|
||||
}
|
||||
}
|
||||
|
||||
} // AppMessage
|
||||
46
workflow/engine/classes/model/AppMessagePeer.php
Normal file
46
workflow/engine/classes/model/AppMessagePeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* AppMessagePeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppMessagePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppMessage.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_MESSAGE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppMessagePeer extends BaseAppMessagePeer {
|
||||
|
||||
} // AppMessagePeer
|
||||
42
workflow/engine/classes/model/AppOwner.php
Normal file
42
workflow/engine/classes/model/AppOwner.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* AppOwner.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseAppOwner.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_OWNER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppOwner extends BaseAppOwner {
|
||||
|
||||
} // AppOwner
|
||||
46
workflow/engine/classes/model/AppOwnerPeer.php
Normal file
46
workflow/engine/classes/model/AppOwnerPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* AppOwnerPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppOwnerPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppOwner.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_OWNER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppOwnerPeer extends BaseAppOwnerPeer {
|
||||
|
||||
} // AppOwnerPeer
|
||||
19
workflow/engine/classes/model/AppSpool.php
Normal file
19
workflow/engine/classes/model/AppSpool.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseAppSpool.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_SPOOL' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppSpool extends BaseAppSpool {
|
||||
|
||||
} // AppSpool
|
||||
23
workflow/engine/classes/model/AppSpoolPeer.php
Normal file
23
workflow/engine/classes/model/AppSpoolPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppSpoolPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppSpool.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_SPOOL' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppSpoolPeer extends BaseAppSpoolPeer {
|
||||
|
||||
} // AppSpoolPeer
|
||||
121
workflow/engine/classes/model/AppThread.php
Normal file
121
workflow/engine/classes/model/AppThread.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* AppThread.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseAppThread.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_THREAD' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppThread extends BaseAppThread {
|
||||
|
||||
function createAppThread ( $sAppUid, $iDelIndex, $iParent ) {
|
||||
if (!isset($sAppUid) || strlen($sAppUid ) == 0 ) {
|
||||
throw ( new Exception ( 'Column "APP_UID" cannot be null.' ) );
|
||||
}
|
||||
|
||||
if (!isset($iDelIndex) || strlen($iDelIndex ) == 0 ) {
|
||||
throw ( new Exception ( 'Column "DEL_INDEX" cannot be null.' ) );
|
||||
}
|
||||
|
||||
if (!isset($iParent) || strlen($iDelIndex ) == 0 ) {
|
||||
throw ( new Exception ( 'Column "APP_THREAD_INDEX" cannot be null.' ) );
|
||||
}
|
||||
|
||||
$c = new Criteria ();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn ( 'MAX(' . AppThreadPeer::APP_THREAD_INDEX . ') ' );
|
||||
$c->add ( AppThreadPeer::APP_UID, $sAppUid );
|
||||
$rs = AppThreadPeer::doSelectRS ( $c );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$iAppThreadIndex = $row[0] + 1;
|
||||
|
||||
$this->setAppUid ( $sAppUid );
|
||||
$this->setAppThreadIndex ( $iAppThreadIndex );
|
||||
$this->setAppThreadParent ( $iParent );
|
||||
$this->setAppThreadStatus ( 'OPEN' );
|
||||
$this->setDelIndex ( $iDelIndex );
|
||||
|
||||
if ($this->validate() ) {
|
||||
try {
|
||||
$res = $this->save();
|
||||
}
|
||||
catch ( PropelException $e ) {
|
||||
throw ( $e );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $this->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage();
|
||||
}
|
||||
throw ( new Exception ( 'Failed Data validation. ' . $msg ) );
|
||||
}
|
||||
return $iAppThreadIndex;
|
||||
}
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$con = Propel::getConnection( AppThreadPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oApp = AppThreadPeer::retrieveByPK( $aData['APP_UID'], $aData['APP_THREAD_INDEX'] );
|
||||
if ( get_class ($oApp) == 'AppThread' ) {
|
||||
$oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oApp->validate()) {
|
||||
$res = $oApp->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The AppThread row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "This AppThread row doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
} // AppThread
|
||||
46
workflow/engine/classes/model/AppThreadPeer.php
Normal file
46
workflow/engine/classes/model/AppThreadPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* AppThreadPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppThreadPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppThread.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_THREAD' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppThreadPeer extends BaseAppThreadPeer {
|
||||
|
||||
} // AppThreadPeer
|
||||
533
workflow/engine/classes/model/Application.php
Normal file
533
workflow/engine/classes/model/Application.php
Normal file
@@ -0,0 +1,533 @@
|
||||
<?php
|
||||
/**
|
||||
* Application.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseApplication.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APPLICATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Application extends BaseApplication {
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $app_title = '';
|
||||
protected $app_description = '';
|
||||
//protected $app_proc_code = '';
|
||||
|
||||
/**
|
||||
* Get the [app_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getAppTitle()
|
||||
{
|
||||
if ( $this->getAppUid() == '' ) {
|
||||
throw ( new Exception( "Error in getAppTitle, the APP_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->app_title = Content::load ( 'APP_TITLE', '', $this->getAppUid(), $lang );
|
||||
return $this->app_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [app_title] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppTitle($v)
|
||||
{
|
||||
if ( $this->getAppUid() == '' ) {
|
||||
throw ( new Exception( "Error in setAppTitle, the APP_UID can't be blank") );
|
||||
}
|
||||
// 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_title !== $v || $v === '') {
|
||||
$this->app_title = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'APP_TITLE', '', $this->getAppUid(), $lang, $this->app_title );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
/**
|
||||
* Get the [app_description] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getAppDescription()
|
||||
{
|
||||
if ( $this->getAppUid() == '' ) {
|
||||
throw ( new Exception( "Error in getAppDescription, the APP_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->app_description = Content::load ( 'APP_DESCRIPTION', '', $this->getAppUid(), $lang );
|
||||
return $this->app_description;
|
||||
}
|
||||
|
||||
public function isEmptyInContent ( $content, $field, $lang ) {
|
||||
if ( isset ( $content[$field][ $lang ] ) ) {
|
||||
if ( trim( $content[$field][ $lang ] ) != '' )
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateInsertContent ( $content, $field, $value ) {
|
||||
if ( isset ( $content[$field][ 'en' ] ) ) {
|
||||
//update
|
||||
$con = ContentPeer::retrieveByPK ( $field, '', $this->getAppUid(), 'en' );
|
||||
$con->setConValue ( $value );
|
||||
if ($con->validate ()) {
|
||||
$res = $con->save ();
|
||||
}
|
||||
}
|
||||
else {//insert
|
||||
$con = new Content ( );
|
||||
$con->setConCategory ( $field );
|
||||
$con->setConParent ( '' );
|
||||
$con->setConId ( $this->getAppUid());
|
||||
$con->setConLang ( 'en' );
|
||||
$con->setConValue ( $value );
|
||||
if ($con->validate ()) {
|
||||
$res = $con->save ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function normalizeContent( $content, $field , $lang ) {
|
||||
$value = '';
|
||||
//if the lang row is not empty, update in 'en' row and continue
|
||||
if ( !$this->isEmptyInContent ( $content, $field , $lang ) ) {
|
||||
//update/insert only if this lang is != 'en', with this always we will have an en row with last value
|
||||
$value = $content [ $field ][ $lang ];
|
||||
if ( $lang != 'en' ) {
|
||||
$this->updateInsertContent ( $content, $field , $value );
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if the lang row is empty, and 'en' row is not empty return 'en' value
|
||||
if ( !$this->isEmptyInContent ( $content, $field , 'en' ) ) {
|
||||
$value = $content [ $field ][ 'en' ];
|
||||
}
|
||||
|
||||
//if the lang row is empty, and 'en' row is empty get value for 'other' row and update in 'en' row and continue
|
||||
if ( $this->isEmptyInContent ( $content, $field , 'en' ) ) {
|
||||
if ( isset($content[$field]) && is_array ($content[$field] ) ) {
|
||||
foreach ( $content [ $field ] as $lan => $val ) {
|
||||
if ( trim ( $val ) != '' ) {
|
||||
$value = $val;
|
||||
if ( $lan != 'en' ) {
|
||||
$this->updateInsertContent ( $content, $field , $value );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->updateInsertContent ( $content, $field , '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [app_description] , [app_title] column values.
|
||||
* @return array of string
|
||||
*/
|
||||
public function getContentFields()
|
||||
{
|
||||
if ( $this->getAppUid() == '' ) {
|
||||
throw ( new Exception( "Error in getContentFields, the APP_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
|
||||
$c->addSelectColumn( ContentPeer::CON_LANG );
|
||||
$c->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
$c->add( ContentPeer::CON_ID, $this->getAppUid() );
|
||||
//$c->add( ContentPeer::CON_LANG, $lang );
|
||||
$c->addAscendingOrderByColumn('CON_CATEGORY');
|
||||
$c->addAscendingOrderByColumn('CON_LANG');
|
||||
$rs = ContentPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$content = array();
|
||||
while ($row = $rs->getRow()) {
|
||||
$conCategory = $row['CON_CATEGORY'];
|
||||
$conLang = $row['CON_LANG'];
|
||||
if ( !isset( $content[$conCategory] ) ) $content[$conCategory] = array();
|
||||
if ( !isset( $content[$conCategory][$conLang] ) ) $content[$conCategory][$conLang] = array();
|
||||
$content[$conCategory][$conLang] = $row['CON_VALUE'];
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
|
||||
$appTitle = $this->normalizeContent( $content, 'APP_TITLE', $lang );
|
||||
$appDescription = $this->normalizeContent( $content, 'APP_DESCRIPTION', $lang );
|
||||
|
||||
$res['APP_TITLE'] = $appTitle;
|
||||
$res['APP_DESCRIPTION'] = $appDescription;
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [app_description] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppDescription($v)
|
||||
{
|
||||
if ( $this->getAppUid() == '' ) {
|
||||
throw ( new Exception( "Error in setAppTitle, the APP_UID can't be blank") );
|
||||
}
|
||||
// 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_description !== $v || $v === '') {
|
||||
$this->app_description = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'APP_DESCRIPTION', '', $this->getAppUid(), $lang, $this->app_description );
|
||||
}
|
||||
} // set()
|
||||
|
||||
|
||||
/**
|
||||
* Get the [app_proc_code] column value.
|
||||
* @return string
|
||||
*/
|
||||
/*public function getAppProcCode ()
|
||||
{
|
||||
if ( $this->getAppUid() == '' ) {
|
||||
throw ( new Exception( "Error in getAppProcCode, the APP_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->app_proc_code = Content::load ( 'APP_PROC_CODE', '', $this->getAppUid(), $lang );
|
||||
return $this->app_proc_code;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Set the [app_proc_code] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
/*public function setAppProcCode ($v)
|
||||
{
|
||||
if ( $this->getAppUid() == '' ) {
|
||||
throw ( new Exception( "Error in setAppProcCode , the APP_UID can't be blank") );
|
||||
}
|
||||
// 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_proc_code !== $v || $v === '') {
|
||||
$this->app_proc_code = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'APP_PROC_CODE', '', $this->getAppUid(), $lang, $this->app_proc_code );
|
||||
}
|
||||
}*/ // set()
|
||||
|
||||
|
||||
/**
|
||||
* Load the Application row specified in [app_id] column value.
|
||||
*
|
||||
* @param string $AppUid the uid of the application
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $AppUid ) {
|
||||
$con = Propel::getConnection(ApplicationPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oApplication = ApplicationPeer::retrieveByPk( $AppUid );
|
||||
if ( get_class ($oApplication) == 'Application' ) {
|
||||
$aFields = $oApplication->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
|
||||
|
||||
//this is the new function to optimize content queries
|
||||
$aContentFields = $oApplication->getContentFields();
|
||||
|
||||
$aFields['APP_TITLE'] = $aContentFields['APP_TITLE'];
|
||||
$aFields['APP_DESCRIPTION'] = $aContentFields['APP_DESCRIPTION'];
|
||||
|
||||
$this->app_title = $aFields['APP_TITLE'];
|
||||
$this->app_description = $aFields['APP_DESCRIPTION'];
|
||||
|
||||
//$aFields['APP_PROC_CODE'] = $oApplication->getAppProcCode();
|
||||
//$this->setAppProcCode ( $oApplication->getAppProcCode() );
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The Application row '$AppUid' doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Application
|
||||
*
|
||||
* @param
|
||||
* $sProUid the process id
|
||||
* $sUsrUid the userid
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($sProUid, $sUsrUid ) {
|
||||
$con = Propel::getConnection( 'workflow' );
|
||||
try {
|
||||
//fill the default values for new application row
|
||||
$this->setAppUid ( G::generateUniqueID() );
|
||||
$this->setAppParent ( '' );
|
||||
$this->setAppStatus ( 'DRAFT' );
|
||||
$this->setProUid ( $sProUid );
|
||||
$this->setAppProcStatus('' );
|
||||
$this->setAppProcCode ( '' );
|
||||
$this->setAppParallel ( 'N' );
|
||||
$this->setAppInitUser ( $sUsrUid );
|
||||
$this->setAppCurUser ( $sUsrUid );
|
||||
$this->setAppCreateDate( 'now' );
|
||||
$this->setAppInitDate ( 'now' );
|
||||
$this->setAppFinishDate( '19020101' ); //to do: what is the empty date for propel???/
|
||||
$this->setAppUpdateDate( 'now' );
|
||||
|
||||
$pin = G::generateCode( 4, 'ALPHANUMERIC');
|
||||
$this->setAppData ( serialize ( array('PIN'=>$pin) ) );
|
||||
$this->setAppPin ( md5($pin) );
|
||||
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( 'MAX(' . ApplicationPeer::APP_NUMBER . ')' ); //the appnumber is based in all processes active, not only in the specified process guid
|
||||
|
||||
$result = ApplicationPeer::doSelectRS( $c );
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
|
||||
$maxNumber = $row[0] + 1;
|
||||
$this->setAppNumber ( $maxNumber );
|
||||
|
||||
if ( $this->validate() ) {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
$con->commit();
|
||||
|
||||
//to do: ID_CASE in translation $this->setAppTitle ( G::LoadTranslation ( 'ID_CASE') . $maxNumber );
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
Content::insertContent( 'APP_TITLE', '', $this->getAppUid(), $lang, '#' . $maxNumber );
|
||||
Content::insertContent( 'APP_DESCRIPTION', '', $this->getAppUid(), $lang, '' );
|
||||
//Content::insertContent( 'APP_PROC_CODE', '', $this->getAppUid(), $lang, '' );
|
||||
|
||||
$con->commit();
|
||||
return $this->getAppUid();
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The APPLICATION row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application row
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$con = Propel::getConnection( ApplicationPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oApp = ApplicationPeer::retrieveByPK( $aData['APP_UID'] );
|
||||
if ( get_class ($oApp) == 'Application' ) {
|
||||
$oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oApp->validate()) {
|
||||
if ( isset ( $aData['APP_TITLE'] ) )
|
||||
$oApp->setAppTitle( $aData['APP_TITLE'] );
|
||||
if ( isset ( $aData['APP_DESCRIPTION'] ) )
|
||||
$oApp->setAppDescription( $aData['APP_DESCRIPTION'] );
|
||||
//if ( isset ( $aData['APP_PROC_CODE'] ) )
|
||||
//$oApp->setAppProcCode( $aData['APP_PROC_CODE'] );
|
||||
$res = $oApp->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
throw ( new PropelException ( 'The row cannot be updated!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "The row '" . $aData['APP_UID'] . "' in table APPLICATION doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
* @param array $aData or string $appUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($appUid)
|
||||
{
|
||||
if ( is_array ( $appUid ) ) {
|
||||
$appUid = ( isset ( $appUid['APP_UID'] ) ? $appUid['APP_UID'] : '' );
|
||||
}
|
||||
try {
|
||||
$oApp = ApplicationPeer::retrieveByPK( $appUid );
|
||||
if (!is_null($oApp))
|
||||
{
|
||||
Content::removeContent('APP_TITLE', '', $oApp->getAppUid());
|
||||
Content::removeContent('APP_DESCRIPTION', '', $oApp->getAppUid());
|
||||
//Content::removeContent('APP_PROC_CODE', '', $oApp->getAppUid());
|
||||
return $oApp->delete();
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$appUid' in table Application doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function exists( $sAppUid )
|
||||
{
|
||||
$oApplicaton = ApplicationPeer::retrieveByPK( $sAppUid );
|
||||
return (!is_null($oApplicaton));
|
||||
}
|
||||
function createApplication ($aData ) {
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( 'MAX(' . ApplicationPeer::APP_NUMBER . ')' );
|
||||
$c->add( ApplicationPeer::PRO_UID, $aData['PRO_UID'] );
|
||||
$result = ApplicationPeer::doSelectRS( $c );
|
||||
$result->next();
|
||||
$row = $result->getRow();
|
||||
$maxNumber = $row[0] + 1;
|
||||
$this->setAppUid ( G::generateUniqueID() );
|
||||
|
||||
$this->setAppNumber ( $maxNumber );
|
||||
$this->setAppParent (isset($aData['APP_PARENT']) ? $aData['APP_PARENT'] : 0 );
|
||||
$this->setAppStatus (isset($aData['APP_STATUS']) ? $aData['APP_STATUS'] : 'DRAFT' );
|
||||
$this->setProUid ( $aData['PRO_UID'] );
|
||||
$this->setAppProcStatus(isset($aData['APP_PROC_STATUS'])? $aData['APP_PROC_STATUS'] : '' );
|
||||
$this->setAppProcCode (isset($aData['APP_PROC_CODE']) ? $aData['APP_PROC_CODE'] : '' );
|
||||
$this->setAppParallel (isset($aData['APP_PARALLEL']) ? $aData['APP_PARALLEL'] : 'N' );
|
||||
$this->setAppInitUser ( $aData['USR_UID'] );
|
||||
$this->setAppCurUser ( $aData['USR_UID'] );
|
||||
$this->setAppCreateDate(isset($aData['APP_CREATE_DATE'])? $aData['APP_CREATE_DATE'] : 'now' );
|
||||
$this->setAppInitDate (isset($aData['APP_INIT_DATE']) ? $aData['APP_INIT_DATE'] : 'now' );
|
||||
//$this->setAppFinishDate(isset($aData['APP_FINISH_DATE'])? $aData['APP_FINISH_DATE'] : '' );
|
||||
$this->setAppUpdateDate(isset($aData['APP_UPDATE_DATE'])? $aData['APP_UPDATE_DATE'] : 'now' );
|
||||
//$this->setAppData ( serialize ( array() ) );
|
||||
|
||||
/** Start Comment : Sets the $this->Fields['APP_DATA']
|
||||
Merge between stored APP_DATA with new APP_DATA. **/
|
||||
if (!$this->getAppData())
|
||||
{
|
||||
// if (!$this->is_new)
|
||||
// {
|
||||
// $this->load($fields['APP_UID']);
|
||||
// }
|
||||
}
|
||||
$this->Fields['APP_DATA']=isset($this->Fields['APP_DATA'])?$this->Fields['APP_DATA']:array();
|
||||
if (isset($fields['APP_DATA']) && is_array($fields['APP_DATA']))
|
||||
{
|
||||
foreach($fields['APP_DATA'] as $k=>$v)
|
||||
{
|
||||
$this->Fields['APP_DATA'][$k]=$v;
|
||||
}
|
||||
}
|
||||
/** End Comment **/
|
||||
|
||||
/** Begin Comment : Replace APP_DATA in APP_TITLE (before to serialize)
|
||||
$pro = new process( $this->_dbc );
|
||||
$pro->load((isset($fields['PRO_UID']) ? $fields['PRO_UID'] : $this->Fields['PRO_UID']));
|
||||
$fields['APP_TITLE'] = G::replaceDataField( $pro->Fields['PRO_TITLE'], $this->Fields['APP_DATA']);
|
||||
/** End Comment **/
|
||||
|
||||
// parent::save();
|
||||
// $this->Fields['APP_DATA'] = unserialize($this->Fields['APP_DATA']);
|
||||
// /** Start Comment: Save in the table CONTENT */
|
||||
// $this->content->saveContent('APP_TITLE',$fields);
|
||||
// /** End Comment */
|
||||
if ($this->validate() ) {
|
||||
$res = $this->save();
|
||||
$this->setAppTitle ('');
|
||||
$this->setAppDescription ('');
|
||||
$this->setAppProcCode ('');
|
||||
}
|
||||
else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $this->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
|
||||
return $this->getAppUid();
|
||||
}
|
||||
} // Application
|
||||
46
workflow/engine/classes/model/ApplicationPeer.php
Normal file
46
workflow/engine/classes/model/ApplicationPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* ApplicationPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseApplicationPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Application.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APPLICATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ApplicationPeer extends BaseApplicationPeer {
|
||||
|
||||
} // ApplicationPeer
|
||||
19
workflow/engine/classes/model/CalendarAssignments.php
Executable file
19
workflow/engine/classes/model/CalendarAssignments.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseCalendarAssignments.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CALENDAR_ASSIGNMENTS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarAssignments extends BaseCalendarAssignments {
|
||||
|
||||
} // CalendarAssignments
|
||||
23
workflow/engine/classes/model/CalendarAssignmentsPeer.php
Executable file
23
workflow/engine/classes/model/CalendarAssignmentsPeer.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseCalendarAssignmentsPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/CalendarAssignments.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CALENDAR_ASSIGNMENTS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarAssignmentsPeer extends BaseCalendarAssignmentsPeer {
|
||||
|
||||
} // CalendarAssignmentsPeer
|
||||
107
workflow/engine/classes/model/CalendarBusinessHours.php
Executable file
107
workflow/engine/classes/model/CalendarBusinessHours.php
Executable file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseCalendarBusinessHours.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CALENDAR_BUSINESS_HOURS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarBusinessHours extends BaseCalendarBusinessHours {
|
||||
function getCalendarBusinessHours($CalendarUid){
|
||||
$Criteria = new Criteria('workflow');
|
||||
$Criteria->clearSelectColumns ( );
|
||||
|
||||
$Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_UID );
|
||||
$Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_DAY );
|
||||
$Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START );
|
||||
$Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_END );
|
||||
|
||||
|
||||
|
||||
$Criteria->add ( CalendarBusinessHoursPeer::CALENDAR_UID, $CalendarUid , CRITERIA::EQUAL );
|
||||
$Criteria->addDescendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_DAY );
|
||||
$Criteria->addAscendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START );
|
||||
//$Criteria->addDescendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START );
|
||||
|
||||
$rs = CalendarBusinessHoursPeer::doSelectRS($Criteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
|
||||
$fields=array();
|
||||
$count=0;
|
||||
|
||||
while (is_array($row)) {
|
||||
$count++;
|
||||
$fields[$count] = $row;
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
function deleteAllCalendarBusinessHours($CalendarUid){
|
||||
$toDelete=$this->getCalendarBusinessHours($CalendarUid);
|
||||
foreach($toDelete as $key => $businessHoursInfo){
|
||||
$CalendarUid = $businessHoursInfo['CALENDAR_UID'];
|
||||
$CalendarBusinessDay = $businessHoursInfo['CALENDAR_BUSINESS_DAY'];
|
||||
$CalendarBusinessStart = $businessHoursInfo['CALENDAR_BUSINESS_START'];
|
||||
$CalendarBusinessEnd = $businessHoursInfo['CALENDAR_BUSINESS_END'];
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarBusinessHoursPeer::retrieveByPK ( $CalendarUid,$CalendarBusinessDay, $CalendarBusinessStart,$CalendarBusinessEnd );
|
||||
if ( ( is_object ( $tr ) && get_class ($tr) == 'CalendarBusinessHours' ) ) {
|
||||
$tr->delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function saveCalendarBusinessHours($aData){
|
||||
$CalendarUid = $aData['CALENDAR_UID'];
|
||||
$CalendarBusinessDay = $aData['CALENDAR_BUSINESS_DAY'];
|
||||
$CalendarBusinessStart = $aData['CALENDAR_BUSINESS_START'];
|
||||
$CalendarBusinessEnd = $aData['CALENDAR_BUSINESS_END'];
|
||||
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarBusinessHoursPeer::retrieveByPK ( $CalendarUid,$CalendarBusinessDay, $CalendarBusinessStart,$CalendarBusinessEnd );
|
||||
if ( ! ( is_object ( $tr ) && get_class ($tr) == 'CalendarBusinessHours' ) ) {
|
||||
$tr = new CalendarBusinessHours();
|
||||
}
|
||||
|
||||
$tr->setCalendarUid( $CalendarUid );
|
||||
$tr->setCalendarBusinessDay( $CalendarBusinessDay );
|
||||
$tr->setCalendarBusinessStart( $CalendarBusinessStart );
|
||||
$tr->setCalendarBusinessEnd( $CalendarBusinessEnd );
|
||||
|
||||
|
||||
if ($tr->validate() ) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save();
|
||||
}
|
||||
else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = $CalendarBusinessDay.'<hr/>';
|
||||
$validationFailuresArray = $tr->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
G::SendTemporalMessage($msg);
|
||||
}
|
||||
|
||||
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
|
||||
|
||||
//to do: uniform coderror structures for all classes
|
||||
|
||||
//if ( $res['codError'] < 0 ) {
|
||||
// G::SendMessageText ( $res['message'] , 'error' );
|
||||
//}
|
||||
}
|
||||
|
||||
} // CalendarBusinessHours
|
||||
23
workflow/engine/classes/model/CalendarBusinessHoursPeer.php
Executable file
23
workflow/engine/classes/model/CalendarBusinessHoursPeer.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseCalendarBusinessHoursPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/CalendarBusinessHours.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CALENDAR_BUSINESS_HOURS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarBusinessHoursPeer extends BaseCalendarBusinessHoursPeer {
|
||||
|
||||
} // CalendarBusinessHoursPeer
|
||||
328
workflow/engine/classes/model/CalendarDefinition.php
Executable file
328
workflow/engine/classes/model/CalendarDefinition.php
Executable file
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseCalendarDefinition.php';
|
||||
require_once 'classes/model/CalendarBusinessHours.php';
|
||||
require_once 'classes/model/CalendarHolidays.php';
|
||||
require_once 'classes/model/CalendarAssignments.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CALENDAR_DEFINITION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarDefinition extends BaseCalendarDefinition {
|
||||
public $calendarLog = '';
|
||||
function getCalendarList($onlyActive = false, $arrayMode = false) {
|
||||
$Criteria = new Criteria ( 'workflow' );
|
||||
$Criteria->clearSelectColumns ();
|
||||
|
||||
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID );
|
||||
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_NAME );
|
||||
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
|
||||
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
|
||||
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
|
||||
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_STATUS );
|
||||
// Note: This list doesn't show deleted items (STATUS = DELETED)
|
||||
if ($onlyActive) { // Show only active. Used on assignment lists
|
||||
$Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL );
|
||||
} else { // Show Active and Inactive calendars. USed in main list
|
||||
$Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE", "INACTIVE" ), CRITERIA::IN );
|
||||
}
|
||||
if(class_exists('pmLicenseManager')){
|
||||
$pmLicenseManagerO =& pmLicenseManager::getSingleton();
|
||||
$expireIn=$pmLicenseManagerO->getExpireIn();
|
||||
if($expireIn>0){
|
||||
$Criteria->add ( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL );
|
||||
}else{
|
||||
$Criteria->add ( calendarDefinitionPeer::CALENDAR_UID, "00000000000000000000000000000001", CRITERIA::EQUAL );
|
||||
}
|
||||
}else{
|
||||
$Criteria->add ( calendarDefinitionPeer::CALENDAR_UID, "00000000000000000000000000000001", CRITERIA::EQUAL );
|
||||
|
||||
}
|
||||
if (! $arrayMode) {
|
||||
return $Criteria;
|
||||
} else {
|
||||
$oDataset = calendarDefinitionPeer::doSelectRS ( $Criteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$calendarA = array (0 => 'dummy' );
|
||||
$calendarCount = 0;
|
||||
while ( is_array ( $aRow = $oDataset->getRow () ) ) {
|
||||
$calendarCount ++;
|
||||
$calendarA [$calendarCount] = $aRow;
|
||||
$oDataset->next ();
|
||||
}
|
||||
$return ['criteria'] = $Criteria;
|
||||
$return ['array'] = $calendarA;
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
function getCalendarInfo($CalendarUid) {
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
|
||||
|
||||
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) {
|
||||
$fields ['CALENDAR_UID'] = $tr->getCalendarUid ();
|
||||
$fields ['CALENDAR_NAME'] = $tr->getCalendarName ();
|
||||
$fields ['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate ();
|
||||
$fields ['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate ();
|
||||
$fields ['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription ();
|
||||
$fields ['CALENDAR_STATUS'] = $tr->getCalendarStatus ();
|
||||
$fields ['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays ();
|
||||
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", $tr->getCalendarWorkDays () );
|
||||
} else {
|
||||
$fields ['CALENDAR_UID'] = "00000000000000000000000000000001";
|
||||
$fields ['CALENDAR_NAME'] = "Default";
|
||||
$fields ['CALENDAR_CREATE_DATE'] = date ( "Y-m-d" );
|
||||
$fields ['CALENDAR_UPDATE_DATE'] = date ( "Y-m-d" );
|
||||
$fields ['CALENDAR_DESCRIPTION'] = "Default";
|
||||
$fields ['CALENDAR_STATUS'] = "ACTIVE";
|
||||
$fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
|
||||
$fields ['CALENDAR_WORK_DAYS'] = explode ( "|", "1|2|3|4|5" );
|
||||
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7;
|
||||
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00";
|
||||
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_END'] = "17:00";
|
||||
$fields ['HOLIDAY'] = array ();
|
||||
$this->saveCalendarInfo ( $fields );
|
||||
$fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
|
||||
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" );
|
||||
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
|
||||
}
|
||||
$CalendarBusinessHoursObj = new CalendarBusinessHours ( );
|
||||
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours ( $CalendarUid );
|
||||
$fields ['BUSINESS_DAY'] = $CalendarBusinessHours;
|
||||
|
||||
$CalendarHolidaysObj = new CalendarHolidays ( );
|
||||
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays ( $CalendarUid );
|
||||
$fields ['HOLIDAY'] = $CalendarHolidays;
|
||||
|
||||
return $fields;
|
||||
|
||||
}
|
||||
function saveCalendarInfo($aData) {
|
||||
$CalendarUid = $aData ['CALENDAR_UID'];
|
||||
$CalendarName = $aData ['CALENDAR_NAME'];
|
||||
$CalendarDescription = $aData ['CALENDAR_DESCRIPTION'];
|
||||
$CalendarStatus = isset ( $aData ['CALENDAR_STATUS'] ) ? $aData ['CALENDAR_STATUS'] : "INACTIVE";
|
||||
$defaultCalendars [] = '00000000000000000000000000000001';
|
||||
if (in_array ( $aData ['CALENDAR_UID'], $defaultCalendars )) {
|
||||
$CalendarStatus = 'ACTIVE';
|
||||
$CalendarName = 'Default';
|
||||
}
|
||||
$CalendarWorkDays = isset ( $aData ['CALENDAR_WORK_DAYS'] ) ? implode ( "|", $aData ['CALENDAR_WORK_DAYS'] ) : "";
|
||||
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
|
||||
if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) {
|
||||
$tr = new CalendarDefinition ( );
|
||||
$tr->setCalendarCreateDate ( 'now' );
|
||||
}
|
||||
$tr->setCalendarUid ( $CalendarUid );
|
||||
$tr->setCalendarName ( $CalendarName );
|
||||
|
||||
$tr->setCalendarUpdateDate ( 'now' );
|
||||
$tr->setCalendarDescription ( $CalendarDescription );
|
||||
$tr->setCalendarStatus ( $CalendarStatus );
|
||||
$tr->setCalendarWorkDays ( $CalendarWorkDays );
|
||||
|
||||
if ($tr->validate ()) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save ();
|
||||
//Calendar Business Hours Save code.
|
||||
//First Delete all current records
|
||||
$CalendarBusinessHoursObj = new CalendarBusinessHours ( );
|
||||
$CalendarBusinessHoursObj->deleteAllCalendarBusinessHours ( $CalendarUid );
|
||||
//Save all the sent records
|
||||
foreach ( $aData ['BUSINESS_DAY'] as $key => $objData ) {
|
||||
$objData ['CALENDAR_UID'] = $CalendarUid;
|
||||
$CalendarBusinessHoursObj->saveCalendarBusinessHours ( $objData );
|
||||
}
|
||||
|
||||
//Holiday Save code.
|
||||
//First Delete all current records
|
||||
$CalendarHolidayObj = new CalendarHolidays ( );
|
||||
$CalendarHolidayObj->deleteAllCalendarHolidays ( $CalendarUid );
|
||||
//Save all the sent records
|
||||
foreach ( $aData ['HOLIDAY'] as $key => $objData ) {
|
||||
if (($objData ['CALENDAR_HOLIDAY_NAME'] != "") && ($objData ['CALENDAR_HOLIDAY_START'] != "") && ($objData ['CALENDAR_HOLIDAY_END'] != "")) {
|
||||
$objData ['CALENDAR_UID'] = $CalendarUid;
|
||||
$CalendarHolidayObj->saveCalendarHolidays ( $objData );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $tr->getValidationFailures ();
|
||||
foreach ( $validationFailuresArray as $objValidationFailure ) {
|
||||
$msg .= $objValidationFailure->getMessage () . "<br/>";
|
||||
}
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
|
||||
|
||||
|
||||
//to do: uniform coderror structures for all classes
|
||||
|
||||
|
||||
//if ( $res['codError'] < 0 ) {
|
||||
// G::SendMessageText ( $res['message'] , 'error' );
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
function deleteCalendar($CalendarUid) {
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
|
||||
|
||||
if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) {
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
$defaultCalendars [] = '00000000000000000000000000000001';
|
||||
if (in_array ( $tr->getCalendarUid(), $defaultCalendars )) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tr->setCalendarStatus ( 'DELETED' );
|
||||
$tr->setCalendarUpdateDate ( 'now' );
|
||||
if ($tr->validate ()) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save ();
|
||||
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $tr->getValidationFailures ();
|
||||
foreach ( $validationFailuresArray as $objValidationFailure ) {
|
||||
$msg .= $objValidationFailure->getMessage () . "<br/>";
|
||||
}
|
||||
G::SendMessage ( "ERROR", $msg );
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
|
||||
|
||||
|
||||
//to do: uniform coderror structures for all classes
|
||||
|
||||
|
||||
//if ( $res['codError'] < 0 ) {
|
||||
// G::SendMessageText ( $res['message'] , 'error' );
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
function getCalendarFor($userUid, $proUid, $tasUid) {
|
||||
$Criteria = new Criteria ( 'workflow' );
|
||||
|
||||
//Default Calendar
|
||||
$calendarUid = "00000000000000000000000000000001";
|
||||
$calendarOwner = "DEFAULT";
|
||||
|
||||
//Try to load a User Calendar if exist
|
||||
$objectID = $userUid;
|
||||
$Criteria->clearSelectColumns ();
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::CALENDAR_UID );
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_UID );
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_TYPE );
|
||||
$Criteria->add ( CalendarAssignmentsPeer::OBJECT_UID, $objectID, CRITERIA::EQUAL );
|
||||
if (CalendarAssignmentsPeer::doCount ( $Criteria ) > 0) {
|
||||
$oDataset = CalendarAssignmentsPeer::doSelectRS ( $Criteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$aRow = $oDataset->getRow ();
|
||||
$calendarUid = $aRow ['CALENDAR_UID'];
|
||||
$calendarOwner = "USER";
|
||||
}
|
||||
|
||||
//Try to load a Process Calendar if exist
|
||||
$objectID = $proUid;
|
||||
$Criteria->clearSelectColumns ();
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::CALENDAR_UID );
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_UID );
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_TYPE );
|
||||
$Criteria->add ( CalendarAssignmentsPeer::OBJECT_UID, $objectID, CRITERIA::EQUAL );
|
||||
if (CalendarAssignmentsPeer::doCount ( $Criteria ) > 0) {
|
||||
$oDataset = CalendarAssignmentsPeer::doSelectRS ( $Criteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$aRow = $oDataset->getRow ();
|
||||
$calendarUid = $aRow ['CALENDAR_UID'];
|
||||
$calendarOwner = "PROCESS";
|
||||
}
|
||||
|
||||
//Try to load a Task Calendar if exist
|
||||
$objectID = $tasUid;
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::CALENDAR_UID );
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_UID );
|
||||
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_TYPE );
|
||||
$Criteria->add ( CalendarAssignmentsPeer::OBJECT_UID, $objectID, CRITERIA::EQUAL );
|
||||
$Criteria->clearSelectColumns ();
|
||||
if (CalendarAssignmentsPeer::doCount ( $Criteria ) > 0) {
|
||||
$oDataset = CalendarAssignmentsPeer::doSelectRS ( $Criteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$aRow = $oDataset->getRow ();
|
||||
$calendarUid = $aRow ['CALENDAR_UID'];
|
||||
$calendarOwner = "TASK";
|
||||
}
|
||||
|
||||
if(class_exists('pmLicenseManager')){
|
||||
$pmLicenseManagerO =& pmLicenseManager::getSingleton();
|
||||
$expireIn=$pmLicenseManagerO->getExpireIn();
|
||||
if($expireIn>0){
|
||||
$calendarUid=$calendarUid;
|
||||
}else{
|
||||
$calendarUid = "00000000000000000000000000000001";
|
||||
}
|
||||
}else{
|
||||
$calendarUid = "00000000000000000000000000000001";
|
||||
}
|
||||
|
||||
//print "<h1>$calendarUid</h1>";
|
||||
$calendarDefinition = $this->getCalendarInfo ( $calendarUid );
|
||||
$calendarDefinition ['CALENDAR_APPLIED'] = $calendarOwner;
|
||||
$this->addCalendarLog ( "--=== Calendar Applied: " . $calendarDefinition ['CALENDAR_NAME'] . " -> $calendarOwner" );
|
||||
return $calendarDefinition;
|
||||
}
|
||||
|
||||
function assignCalendarTo($objectUid, $calendarUid, $objectType) {
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarAssignmentsPeer::retrieveByPK ( $objectUid );
|
||||
if ($calendarUid != "") {
|
||||
if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) {
|
||||
$tr = new CalendarAssignments ( );
|
||||
|
||||
}
|
||||
$tr->setObjectUid ( $objectUid );
|
||||
$tr->setCalendarUid ( $calendarUid );
|
||||
$tr->setObjectType ( $objectType );
|
||||
|
||||
if ($tr->validate ()) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save ();
|
||||
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $tr->getValidationFailures ();
|
||||
foreach ( $validationFailuresArray as $objValidationFailure ) {
|
||||
$msg .= $objValidationFailure->getMessage () . "<br/>";
|
||||
}
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
} else { //Delete record
|
||||
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) {
|
||||
$tr->delete ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // CalendarDefinition
|
||||
23
workflow/engine/classes/model/CalendarDefinitionPeer.php
Executable file
23
workflow/engine/classes/model/CalendarDefinitionPeer.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseCalendarDefinitionPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/CalendarDefinition.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CALENDAR_DEFINITION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarDefinitionPeer extends BaseCalendarDefinitionPeer {
|
||||
|
||||
} // CalendarDefinitionPeer
|
||||
111
workflow/engine/classes/model/CalendarHolidays.php
Executable file
111
workflow/engine/classes/model/CalendarHolidays.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseCalendarHolidays.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CALENDAR_HOLIDAYS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarHolidays extends BaseCalendarHolidays {
|
||||
function getCalendarHolidays($CalendarUid){
|
||||
$Criteria = new Criteria('workflow');
|
||||
$Criteria->clearSelectColumns ( );
|
||||
|
||||
$Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_UID );
|
||||
$Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_NAME );
|
||||
$Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_START );
|
||||
$Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_END );
|
||||
|
||||
|
||||
|
||||
$Criteria->add ( CalendarHolidaysPeer::CALENDAR_UID, $CalendarUid , CRITERIA::EQUAL );
|
||||
|
||||
$rs = CalendarHolidaysPeer::doSelectRS($Criteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$fields=array();
|
||||
|
||||
$count=0;
|
||||
|
||||
while (is_array($row)) {
|
||||
$count++;
|
||||
$a=explode(" ",$row['CALENDAR_HOLIDAY_START']);
|
||||
$row['CALENDAR_HOLIDAY_START']=$a[0];
|
||||
$a=explode(" ",$row['CALENDAR_HOLIDAY_END']);
|
||||
$row['CALENDAR_HOLIDAY_END']=$a[0];
|
||||
$fields[$count] = $row;
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
function deleteAllCalendarHolidays($CalendarUid){
|
||||
$toDelete=$this->getCalendarHolidays($CalendarUid);
|
||||
foreach($toDelete as $key => $holidayInfo){
|
||||
print_r($holidayInfo);
|
||||
$CalendarUid = $holidayInfo['CALENDAR_UID'];
|
||||
$CalendarHolidayName = $holidayInfo['CALENDAR_HOLIDAY_NAME'];
|
||||
$CalendarHolidayStart = $holidayInfo['CALENDAR_HOLIDAY_START'];
|
||||
$CalendarHolidayEnd = $holidayInfo['CALENDAR_HOLIDAY_END'];
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
|
||||
$tr = CalendarHolidaysPeer::retrieveByPK ( $CalendarUid,$CalendarHolidayName );
|
||||
if ( ( is_object ( $tr ) && get_class ($tr) == 'CalendarHolidays' ) ) {
|
||||
$tr->delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function saveCalendarHolidays($aData){
|
||||
|
||||
$CalendarUid = $aData['CALENDAR_UID'];
|
||||
$CalendarHolidayName = $aData['CALENDAR_HOLIDAY_NAME'];
|
||||
$CalendarHolidayStart = $aData['CALENDAR_HOLIDAY_START'];
|
||||
$CalendarHolidayEnd = $aData['CALENDAR_HOLIDAY_END'];
|
||||
|
||||
//if exists the row in the database propel will update it, otherwise will insert.
|
||||
$tr = CalendarHolidaysPeer::retrieveByPK ( $CalendarUid,$CalendarHolidayName);
|
||||
if ( ! ( is_object ( $tr ) && get_class ($tr) == 'CalendarHolidays' ) ) {
|
||||
$tr = new CalendarHolidays();
|
||||
}
|
||||
|
||||
$tr->setCalendarUid( $CalendarUid );
|
||||
$tr->setCalendarHolidayName( $CalendarHolidayName );
|
||||
$tr->setCalendarHolidayStart( $CalendarHolidayStart );
|
||||
$tr->setCalendarHolidayEnd( $CalendarHolidayEnd );
|
||||
|
||||
|
||||
if ($tr->validate() ) {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save();
|
||||
}
|
||||
else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $tr->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
|
||||
|
||||
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
|
||||
|
||||
//to do: uniform coderror structures for all classes
|
||||
|
||||
//if ( $res['codError'] < 0 ) {
|
||||
// G::SendMessageText ( $res['message'] , 'error' );
|
||||
//}
|
||||
}
|
||||
|
||||
} // CalendarHolidays
|
||||
23
workflow/engine/classes/model/CalendarHolidaysPeer.php
Executable file
23
workflow/engine/classes/model/CalendarHolidaysPeer.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseCalendarHolidaysPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/CalendarHolidays.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CALENDAR_HOLIDAYS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CalendarHolidaysPeer extends BaseCalendarHolidaysPeer {
|
||||
|
||||
} // CalendarHolidaysPeer
|
||||
873
workflow/engine/classes/model/CaseScheduler.php
Normal file
873
workflow/engine/classes/model/CaseScheduler.php
Normal file
@@ -0,0 +1,873 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseCaseScheduler.php';
|
||||
|
||||
require_once 'classes/model/Process.php';
|
||||
require_once 'classes/model/Task.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CASE_SCHEDULER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CaseScheduler extends BaseCaseScheduler {
|
||||
|
||||
/*
|
||||
private $SchTimeNextRun = null;
|
||||
private $SchLastRunTime = null;
|
||||
|
||||
public function getSchTimeNextRun() {
|
||||
if($this->SchTimeNextRun === null)
|
||||
$this->SchTimeNextRun = time();
|
||||
return $this->SchTimeNextRun;
|
||||
}
|
||||
public function setSchTimeNextRun($value) {
|
||||
$this->SchTimeNextRun = $value;
|
||||
}
|
||||
public function getSchLastRunTime(){
|
||||
if($this->SchTimeNextRun === null)
|
||||
$this->SchTimeNextRun = time();
|
||||
return $this->SchLastRunTime;
|
||||
}
|
||||
public function setSchLastRunTime($value){
|
||||
$this->SchLastRunTime = $value;
|
||||
}
|
||||
*/
|
||||
|
||||
public function load($SchUid) {
|
||||
try {
|
||||
$oRow = CaseSchedulerPeer::retrieveByPK ( $SchUid );
|
||||
if (! is_null ( $oRow )) {
|
||||
$aFields = $oRow->toArray ( BasePeer::TYPE_FIELDNAME );
|
||||
$this->fromArray ( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$this->setNew ( false );
|
||||
return $aFields;
|
||||
} else {
|
||||
throw (new Exception ( "The row '" . $SchUid . "' in table CASE_SCHEDULER doesn't exist!" ));
|
||||
}
|
||||
} catch ( Exception $oError ) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function create($aData) {
|
||||
$con = Propel::getConnection ( CaseSchedulerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$this->fromArray ( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate ()) {
|
||||
$result = $this->save ();
|
||||
} else {
|
||||
$e = new Exception ( "Failed Validation in class " . get_class ( $this ) . "." );
|
||||
$e->aValidationFailures = $this->getValidationFailures ();
|
||||
throw ($e);
|
||||
}
|
||||
$con->commit ();
|
||||
return $result;
|
||||
} catch ( Exception $e ) {
|
||||
$con->rollback ();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($fields) {
|
||||
$con = Propel::getConnection ( CaseSchedulerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin ();
|
||||
$this->load ( $fields ['SCH_UID'] );
|
||||
$this->fromArray ( $fields, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate ()) {
|
||||
$result = $this->save ();
|
||||
$con->commit ();
|
||||
return $result;
|
||||
} else {
|
||||
$con->rollback ();
|
||||
throw (new Exception ( "Failed Validation in class " . get_class ( $this ) . "." ));
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
$con->rollback ();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($SchUid) {
|
||||
$con = Propel::getConnection ( CaseSchedulerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oCaseScheduler = CaseSchedulerPeer::retrieveByPK($SchUid);
|
||||
if(!is_null($oCaseScheduler)) {
|
||||
$iResult = $oCaseScheduler->delete();
|
||||
$con->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
/*
|
||||
$con->begin();
|
||||
$this->setSchUid ( $SchUid );
|
||||
$result = $this->delete();
|
||||
$con->commit();
|
||||
return $result;
|
||||
*/
|
||||
} catch ( Exception $e ) {
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* change Status of any Process
|
||||
* @param string $sSchedulerUid
|
||||
* @return boolean
|
||||
*/
|
||||
function changeStatus($sSchedulerUid = '') {
|
||||
$Fields = $this->Load ( $sSchedulerUid );
|
||||
$Fields ['SCH_LAST_STATE'] = $Fields ['SCH_STATE'];
|
||||
if ($Fields ['SCH_STATE'] == 'ACTIVE') {
|
||||
$Fields ['SCH_STATE'] = 'INACTIVE';
|
||||
} else {
|
||||
$Fields ['SCH_STATE'] = 'ACTIVE';
|
||||
}
|
||||
$this->Update ( $Fields );
|
||||
}
|
||||
|
||||
// SELECT A.SCH_UID, A.SCH_NAME, A.PRO_UID, B.CON_VALUE AS PROCESS,
|
||||
// A.TAS_UID, B.CON_VALUE AS TASK, A.SCH_TIME_NEXT_RUN, A.SCH_LAST_RUN_TIME, A.SCH_STATE, A.SCH_LAST_STATE,
|
||||
// A.USR_UID, A.SCH_OPTION
|
||||
// SCH_START_TIME, SCH_START_DATE, SCH_DAYS_PERFORM_TASK, SCH_EVERY_DAYS, SCH_WEEK_DAYS
|
||||
// SCH_START_DAY, SCH_MONTHS, SCH_END_DATE, SCH_REPEAT_EVERY, SCH_REPEAT_UNTIL, SCH_REPEAT_STOP_IF_RUNNING
|
||||
// FROM CASE_SCHEDULER A LEFT JOIN CONTENT B ON A.PRO_UID= B.CON_ID AND B.CON_CATEGORY='PRO_TITLE' AND B.CON_LANG='en'
|
||||
// LEFT JOIN CONTENT C ON A.TAS_UID= C.CON_ID AND C.CON_CATEGORY='TAS_TITLE' AND C.CON_LANG='en'
|
||||
//
|
||||
function getAllCriteria() {
|
||||
$c = new Criteria ( 'workflow' );
|
||||
$c->clearSelectColumns ();
|
||||
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_UID );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_NAME );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_DEL_USER_NAME );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_DEL_USER_PASS );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_DEL_USER_UID );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::PRO_UID );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::TAS_UID );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_TIME_NEXT_RUN );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_LAST_RUN_TIME );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_STATE );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_LAST_STATE );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::USR_UID );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_OPTION );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_START_TIME );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_START_DATE );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_DAYS_PERFORM_TASK );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_EVERY_DAYS );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_WEEK_DAYS );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_START_DAY );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_MONTHS );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_END_DATE );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_REPEAT_EVERY );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_REPEAT_UNTIL );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::SCH_REPEAT_STOP_IF_RUNNING );
|
||||
$c->addSelectColumn ( CaseSchedulerPeer::CASE_SH_PLUGIN_UID );
|
||||
|
||||
return $c;
|
||||
|
||||
}
|
||||
|
||||
function getAll() {
|
||||
$oCriteria = $this->getAllCriteria ();
|
||||
$oDataset = CaseSchedulerPeer::doSelectRS ( $oCriteria );
|
||||
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$aRows = Array ();
|
||||
while ( $aRow = $oDataset->getRow () ) {
|
||||
$aRows [] = $aRow;
|
||||
$oDataset->next ();
|
||||
}
|
||||
foreach ( $aRows as $k => $aRow ) {
|
||||
$oProcess = new Process ();
|
||||
$aProcessRow = $oProcess->load ( $aRow ['PRO_UID'] );
|
||||
|
||||
$oTask = new Task ();
|
||||
$aTaskRow = $oTask->load ( $aRow ['TAS_UID'] );
|
||||
|
||||
$aRows [$k] = array_merge ( $aRow, $aProcessRow, $aTaskRow );
|
||||
}
|
||||
|
||||
return $aRows;
|
||||
}
|
||||
/**
|
||||
* function getAllByProcess
|
||||
* @author gustavo cruz
|
||||
* @desc Get All Scheduled Tasks for some process.
|
||||
* @param $pro_uid process uid
|
||||
* @return $aRows a result set array
|
||||
*/
|
||||
function getAllByProcess($pro_uid) {
|
||||
|
||||
$oCriteria = $this->getAllCriteria ();
|
||||
$oCriteria->add ( CaseSchedulerPeer::PRO_UID, $pro_uid );
|
||||
$oDataset = CaseSchedulerPeer::doSelectRS ( $oCriteria );
|
||||
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$aRows = Array ();
|
||||
while ( $aRow = $oDataset->getRow () ) {
|
||||
$aRows [] = $aRow;
|
||||
$oDataset->next ();
|
||||
}
|
||||
foreach ( $aRows as $k => $aRow ) {
|
||||
$oProcess = new Process ();
|
||||
$aProcessRow = $oProcess->load ( $aRow ['PRO_UID'] );
|
||||
$oTask = new Task ();
|
||||
$aTaskRow = $oTask->load ( $aRow ['TAS_UID'] );
|
||||
$aRows [$k] = array_merge ( $aRow, $aProcessRow, $aTaskRow );
|
||||
}
|
||||
return $aRows;
|
||||
}
|
||||
|
||||
function getProcessDescription() {
|
||||
$c = new Criteria ( 'workflow' );
|
||||
$c->clearSelectColumns ();
|
||||
$c->addSelectColumn ( ProcessPeer::PRO_UID );
|
||||
|
||||
$oDataset = ProcessPeer::doSelectRS ( $c );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$aRows = Array ();
|
||||
while ( $aRow = $oDataset->getRow () ) {
|
||||
$aRows [] = $aRow;
|
||||
$oDataset->next ();
|
||||
}
|
||||
|
||||
foreach ( $aRows as $k => $aRow ) {
|
||||
$oProcess = new Process ();
|
||||
$aProcessRow = $oProcess->load ( $aRow ['PRO_UID'] );
|
||||
|
||||
$aRows [$k] = array_merge ( $aRow, array (
|
||||
'PRO_TITLE' => $aProcessRow ['PRO_TITLE']
|
||||
) );
|
||||
}
|
||||
return $aRows;
|
||||
|
||||
}
|
||||
|
||||
function getTaskDescription() {
|
||||
$c = new Criteria ( 'workflow' );
|
||||
$c->clearSelectColumns ();
|
||||
$c->addSelectColumn ( TaskPeer::TAS_UID );
|
||||
|
||||
$oDataset = TaskPeer::doSelectRS ( $c );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
$aRows = Array ();
|
||||
while ( $aRow = $oDataset->getRow () ) {
|
||||
$aRows [] = $aRow;
|
||||
$oDataset->next ();
|
||||
}
|
||||
foreach ( $aRows as $k => $aRow ) {
|
||||
|
||||
$oTask = new Task ();
|
||||
$aTaskRow = $oTask->load ( $aRow ['TAS_UID'] );
|
||||
|
||||
$aRows [$k] = array_merge ( $aRow, array (
|
||||
'TAS_TITLE' => $aTaskRow ['TAS_TITLE']
|
||||
), array (
|
||||
'PRO_UID' => $aTaskRow ['PRO_UID']
|
||||
) );
|
||||
}
|
||||
|
||||
// g::pr($aRows); die;
|
||||
|
||||
|
||||
return $aRows;
|
||||
|
||||
}
|
||||
|
||||
function caseSchedulerCron($date) {
|
||||
|
||||
G::LoadClass ( 'dates' );
|
||||
require_once ('classes/model/LogCasesScheduler.php');
|
||||
|
||||
$oDates = new dates ();
|
||||
|
||||
$nTime = strtotime ( $date );
|
||||
|
||||
$dCurrentDate = date ( 'Y-m-d', $nTime ) . ' 00:00:00';
|
||||
$dNextDay = date ( 'Y-m-d', strtotime ( "$dCurrentDate" ) ) . ' 23:59:59';
|
||||
|
||||
$oCriteria = $this->getAllCriteria ();
|
||||
$oCriteria->addAnd ( CaseSchedulerPeer::SCH_STATE, 'INACTIVE', Criteria::NOT_EQUAL );
|
||||
$oCriteria->addAnd ( CaseSchedulerPeer::SCH_STATE, 'PROCESSED', Criteria::NOT_EQUAL );
|
||||
$oCriteria->add ( CaseSchedulerPeer::SCH_TIME_NEXT_RUN, $dCurrentDate, Criteria::GREATER_EQUAL );
|
||||
$oCriteria->addAnd ( CaseSchedulerPeer::SCH_TIME_NEXT_RUN, $dNextDay, Criteria::LESS_EQUAL );
|
||||
$oCriteria->add ( CaseSchedulerPeer::SCH_END_DATE, null, Criteria::EQUAL );
|
||||
$oCriteria->addOr ( CaseSchedulerPeer::SCH_END_DATE, $dCurrentDate, Criteria::GREATER_EQUAL );
|
||||
$oDataset = CaseSchedulerPeer::doSelectRS ( $oCriteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next ();
|
||||
|
||||
$sValue = '';
|
||||
$sActualTime = '';
|
||||
$sDaysPerformTask = '';
|
||||
$sWeeks = '';
|
||||
$sStartDay = '';
|
||||
$sMonths = '';
|
||||
while ( $aRow = $oDataset->getRow () ) {
|
||||
$sSchedulerUid = $aRow ['SCH_UID'];
|
||||
$sOption = $aRow ['SCH_OPTION'];
|
||||
switch ($sOption) {
|
||||
case '1' :
|
||||
$sDaysPerformTask = $aRow ['SCH_DAYS_PERFORM_TASK'];
|
||||
$aDaysPerformTask = explode ( '|', $sDaysPerformTask );
|
||||
$sValue = $aDaysPerformTask [0];
|
||||
if ($sValue != 1)
|
||||
$sDaysPerformTask = $aDaysPerformTask [1];
|
||||
break;
|
||||
case '2' :
|
||||
$sDaysPerformTask = $aRow ['SCH_EVERY_DAYS'];
|
||||
$sWeeks = $aRow ['SCH_WEEK_DAYS'];
|
||||
break;
|
||||
case '3' :
|
||||
$sStartDay = $aRow ['SCH_START_DAY'];
|
||||
$sMonths = $aRow ['SCH_MONTHS'];
|
||||
$aStartDay = explode ( '|', $sStartDay );
|
||||
$sValue = $aStartDay [0];
|
||||
break;
|
||||
case '4' :
|
||||
$aRow ['SCH_STATE'] = 'PROCESSED';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$sActualTime = $aRow ['SCH_TIME_NEXT_RUN'];
|
||||
|
||||
$sActualDataHour = date ( 'H', strtotime ( $aRow ['SCH_TIME_NEXT_RUN'] ) );
|
||||
$sActualDataMinutes = date ( 'i', strtotime ( $aRow ['SCH_TIME_NEXT_RUN'] ) );
|
||||
$dActualSysHour = date ( 'H', $nTime );
|
||||
$dActualSysMinutes = date ( 'i', $nTime );
|
||||
|
||||
$sActualDataTime = strtotime ( $aRow ['SCH_TIME_NEXT_RUN'] );
|
||||
$sActualSysTime = strtotime ( $nTime );
|
||||
|
||||
// note added consider the posibility to encapsulate some in functionality in a class method or some funtions
|
||||
if ($sActualDataHour < $dActualSysHour) {
|
||||
$_PORT = (SERVER_PORT != '80') ? ':' . SERVER_PORT : '';
|
||||
|
||||
$defaultEndpoint = 'http://' . SERVER_NAME . $_PORT . '/sys' . SYS_SYS . '/en/green/services/wsdl2';
|
||||
println(" - Connecting webservice: $defaultEndpoint");
|
||||
|
||||
$user = $aRow ["SCH_DEL_USER_NAME"];
|
||||
$pass = $aRow ["SCH_DEL_USER_PASS"];
|
||||
$processId = $aRow ["PRO_UID"];
|
||||
$taskId = $aRow ["TAS_UID"];
|
||||
|
||||
$client = new SoapClient ( $defaultEndpoint );
|
||||
$params = array (
|
||||
'userid' => $user,
|
||||
'password' => 'md5:' . $pass
|
||||
);
|
||||
$result = $client->__SoapCall ( 'login', array (
|
||||
$params
|
||||
) );
|
||||
|
||||
eprint(" - Logging as user $user.............");
|
||||
if ($result->status_code == 0) {
|
||||
eprintln("OK+", 'green');
|
||||
$sessionId = $result->message;
|
||||
$newCaseLog = new LogCasesScheduler ();
|
||||
$newRouteLog = new LogCasesScheduler ();
|
||||
$variables = Array ();
|
||||
$params = array (
|
||||
'sessionId' => $sessionId,
|
||||
'processId' => $processId,
|
||||
'taskId' => $taskId,
|
||||
'variables' => $variables
|
||||
);
|
||||
|
||||
$paramsLog = array (
|
||||
'PRO_UID' => $processId,
|
||||
'TAS_UID' => $taskId,
|
||||
'SCH_UID' => $sSchedulerUid,
|
||||
'USR_NAME' => $user,
|
||||
'RESULT' => '',
|
||||
'EXEC_DATE' => date ( 'Y-m-d' ),
|
||||
'EXEC_HOUR' => date ( 'H:i:s' ),
|
||||
'WS_CREATE_CASE_STATUS' => '',
|
||||
'WS_ROUTE_CASE_STATUS' => ''
|
||||
);
|
||||
|
||||
$sw_transfer_control_plugin=false;//This SW will be true only if a plugin is allowed to continue the action
|
||||
//If this Job was was registered to be performed by a plugin
|
||||
if((isset($aRow['CASE_SH_PLUGIN_UID']))&&($aRow['CASE_SH_PLUGIN_UID']!="")){
|
||||
//Check if the plugin is active
|
||||
$pluginParts=explode("--",$aRow['CASE_SH_PLUGIN_UID']);
|
||||
if(count($pluginParts)==2){
|
||||
//***************** Plugins **************************
|
||||
G::LoadClass('plugin');
|
||||
//here we are loading all plugins registered
|
||||
//the singleton has a list of enabled plugins
|
||||
|
||||
$sSerializedFile = PATH_DATA_SITE . 'plugin.singleton';
|
||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||
if ( file_exists ($sSerializedFile) )
|
||||
$oPluginRegistry->unSerializeInstance( file_get_contents ( $sSerializedFile ) );
|
||||
|
||||
|
||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||
$activePluginsForCaseScheduler=$oPluginRegistry->getCaseSchedulerPlugins();
|
||||
foreach($activePluginsForCaseScheduler as $key => $caseSchedulerPlugin){
|
||||
if((isset($caseSchedulerPlugin->sNamespace))&&($caseSchedulerPlugin->sNamespace==$pluginParts[0])&&(isset($caseSchedulerPlugin->sActionId))&&($caseSchedulerPlugin->sActionId==$pluginParts[1])){
|
||||
$sw_transfer_control_plugin=true;
|
||||
$caseSchedulerSelected=$caseSchedulerPlugin;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//If there is a trigger that is registered to do this then transfer control
|
||||
|
||||
|
||||
if((isset($caseSchedulerSelected))&&(is_object($caseSchedulerSelected))){
|
||||
eprintln(" - Transfering control to a Plugin: ".$caseSchedulerSelected->sNamespace."/".$caseSchedulerSelected->sActionId,'green');
|
||||
|
||||
$oData['OBJ_SOAP'] = $client;
|
||||
$oData['SCH_UID'] = $aRow['SCH_UID'];
|
||||
$oData['params'] = $params;
|
||||
$oData['sessionId'] = $sessionId;
|
||||
$oData['userId'] = $user;
|
||||
$paramsLogResultFromPlugin=$oPluginRegistry->executeMethod( $caseSchedulerSelected->sNamespace, $caseSchedulerSelected->sActionExecute, $oData );
|
||||
$paramsLog['WS_CREATE_CASE_STATUS']=$paramsLogResultFromPlugin['WS_CREATE_CASE_STATUS'];
|
||||
$paramsLog['WS_ROUTE_CASE_STATUS']=$paramsLogResultFromPlugin['WS_ROUTE_CASE_STATUS'];
|
||||
|
||||
$paramsLogResult=$paramsLogResultFromPlugin['paramsLogResult'];
|
||||
$paramsRouteLogResult=$paramsLogResultFromPlugin['paramsRouteLogResult'];
|
||||
}else{
|
||||
|
||||
eprint(" - Creating the new case.............");
|
||||
$result = $client->__SoapCall ( 'NewCase', array (
|
||||
$params
|
||||
) );
|
||||
if ($result->status_code == 0) {
|
||||
eprintln("OK+ CASE #{$result->caseNumber} was created!", 'green');
|
||||
|
||||
$caseId = $result->caseId;
|
||||
$caseNumber = $result->caseNumber;
|
||||
$paramsLog ['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags ( $result->message );
|
||||
$paramsLogResult = 'SUCCESS';
|
||||
|
||||
$params = array (
|
||||
'sessionId' => $sessionId,
|
||||
'caseId' => $caseId,
|
||||
'delIndex' => "1"
|
||||
);
|
||||
eprint(" - Routing the case #$caseNumber..............");
|
||||
$result = $client->__SoapCall ( 'RouteCase', array (
|
||||
$params
|
||||
) );
|
||||
if ($result->status_code == 0) {
|
||||
$paramsLog ['WS_ROUTE_CASE_STATUS'] = strip_tags ( $result->message );
|
||||
$retMsg = explode("Debug", $paramsLog ['WS_ROUTE_CASE_STATUS']);
|
||||
$retMsg = $retMsg[0];
|
||||
eprintln("OK+ $retMsg", 'green');
|
||||
$paramsRouteLogResult = 'SUCCESS';
|
||||
} else {
|
||||
$paramsLog ['WS_ROUTE_CASE_STATUS'] = strip_tags ( $result->message );
|
||||
eprintln("FAILED-> {$paramsLog ['WS_ROUTE_CASE_STATUS']}", 'red');
|
||||
$paramsRouteLogResult = 'FAILED';
|
||||
}
|
||||
} else {
|
||||
$paramsLog ['WS_CREATE_CASE_STATUS'] = strip_tags ( $result->message );
|
||||
$paramsLogResult = 'FAILED';
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprintln($result->message, 'red');
|
||||
// invalid user or bad password
|
||||
}
|
||||
if ($paramsLogResult == 'SUCCESS' && $paramsRouteLogResult == 'SUCCESS') {
|
||||
$paramsLog ['RESULT'] = 'SUCCESS';
|
||||
} else {
|
||||
$paramsLog ['RESULT'] = 'FAILED';
|
||||
}
|
||||
|
||||
$newCaseLog->saveLogParameters ( $paramsLog );
|
||||
$newCaseLog->save ();
|
||||
|
||||
if ($sOption != '4') {
|
||||
$nSchLastRunTime = $sActualTime;
|
||||
|
||||
$dEstimatedDate = $this->updateNextRun ( $sOption, $sValue, $sActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths );
|
||||
|
||||
if ($aRow ['SCH_END_DATE'] != '') {
|
||||
if (date ( "Y-m-d", strtotime ( $dEstimatedDate ) ) > date ( "Y-m-d", strtotime ( $aRow ['SCH_END_DATE'] ) )) {
|
||||
$Fields = $this->Load ( $sSchedulerUid );
|
||||
$Fields ['SCH_LAST_STATE'] = $aRow ['SCH_STATE'];
|
||||
$Fields ['SCH_STATE'] = 'PROCESSED';
|
||||
$this->Update ( $Fields );
|
||||
}
|
||||
}
|
||||
|
||||
$nSchTimeNextRun = $dEstimatedDate;
|
||||
$this->updateDate ( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime );
|
||||
} else {
|
||||
$Fields = $this->Load ( $sSchedulerUid );
|
||||
$Fields ['SCH_LAST_STATE'] = $aRow ['SCH_STATE'];
|
||||
$Fields ['SCH_LAST_RUN_TIME'] = $Fields ['SCH_TIME_NEXT_RUN'];
|
||||
$Fields ['SCH_STATE'] = 'PROCESSED';
|
||||
$this->Update ( $Fields );
|
||||
}
|
||||
} else if ($sActualDataHour == $dActualSysHour && $sActualDataMinutes <= $dActualSysMinutes) {
|
||||
|
||||
$_PORT = ($_SERVER ['SERVER_PORT'] != '80') ? ':' . $_SERVER ['SERVER_PORT'] : '';
|
||||
|
||||
//$defaultEndpoint = 'http://' . $_SERVER ['SERVER_NAME'] . ':' . $_PORT . '/sys' . SYS_SYS . '/en/green/services/wsdl2';
|
||||
$defaultEndpoint = 'http://' . SERVER_NAME . $_PORT . '/sys' . SYS_SYS . '/en/green/services/wsdl2';
|
||||
println(" - Connecting webservice: $defaultEndpoint");
|
||||
$user = $aRow ["SCH_DEL_USER_NAME"];
|
||||
$pass = $aRow ["SCH_DEL_USER_PASS"];
|
||||
$processId = $aRow ["PRO_UID"];
|
||||
$taskId = $aRow ["TAS_UID"];
|
||||
|
||||
$client = new SoapClient ( $defaultEndpoint );
|
||||
$params = array (
|
||||
'userid' => $user,
|
||||
'password' => 'md5:' . $pass
|
||||
);
|
||||
$result = $client->__SoapCall ( 'login', array (
|
||||
$params
|
||||
) );
|
||||
|
||||
eprint(" - Logging as user $user.............");
|
||||
if ($result->status_code == 0) {
|
||||
eprintln("OK+", 'green');
|
||||
|
||||
$sessionId = $result->message;
|
||||
$newCaseLog = new LogCasesScheduler ();
|
||||
$newRouteLog = new LogCasesScheduler ();
|
||||
$variables = Array ();
|
||||
$params = array (
|
||||
'sessionId' => $sessionId,
|
||||
'processId' => $processId,
|
||||
'taskId' => $taskId,
|
||||
'variables' => $variables
|
||||
);
|
||||
|
||||
$paramsLog = array (
|
||||
'PRO_UID' => $processId,
|
||||
'TAS_UID' => $taskId,
|
||||
'SCH_UID' => $sSchedulerUid,
|
||||
'USR_NAME' => $user,
|
||||
'RESULT' => '',
|
||||
'EXEC_DATE' => date ( 'Y-m-d' ),
|
||||
'EXEC_HOUR' => date ( 'H:i:s' ),
|
||||
'WS_CREATE_CASE_STATUS' => '',
|
||||
'WS_ROUTE_CASE_STATUS' => ''
|
||||
);
|
||||
|
||||
$result = $client->__SoapCall ( 'NewCase', array (
|
||||
$params
|
||||
) );
|
||||
|
||||
eprint(" - Creating the new case.............");
|
||||
if ($result->status_code == 0) {
|
||||
eprintln("OK+ CASE #{$result->caseNumber} was created!", 'green');
|
||||
$caseId = $result->caseId;
|
||||
$caseNumber = $result->caseNumber;
|
||||
$paramsLog ['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags ( $result->message );
|
||||
$paramsLogResult = 'SUCCESS';
|
||||
|
||||
$params = array (
|
||||
'sessionId' => $sessionId,
|
||||
'caseId' => $caseId,
|
||||
'delIndex' => "1"
|
||||
);
|
||||
$result = $client->__SoapCall ( 'RouteCase', array (
|
||||
$params
|
||||
) );
|
||||
eprint(" - Routing the case #$caseNumber..............");
|
||||
if ($result->status_code == 0) {
|
||||
$paramsLog ['WS_ROUTE_CASE_STATUS'] = strip_tags ( $result->message );
|
||||
$retMsg = explode("Debug", $paramsLog ['WS_ROUTE_CASE_STATUS']);
|
||||
$retMsg = $retMsg[0];
|
||||
eprintln("OK+ $retMsg", 'green');
|
||||
$paramsRouteLogResult = 'SUCCESS';
|
||||
} else {
|
||||
eprintln("FAILED-> {$paramsLog ['WS_ROUTE_CASE_STATUS']}", 'red');
|
||||
$paramsLog ['WS_ROUTE_CASE_STATUS'] = strip_tags ( $result->message );
|
||||
$paramsRouteLogResult = 'FAILED';
|
||||
}
|
||||
|
||||
} else {
|
||||
$paramsLog ['WS_CREATE_CASE_STATUS'] = strip_tags ( $result->message );
|
||||
eprintln("FAILED->{$paramsLog ['WS_CREATE_CASE_STATUS']}", 'red');
|
||||
$paramsLogResult = 'FAILED';
|
||||
|
||||
}
|
||||
} else {
|
||||
// invalid user or bad password
|
||||
eprintln($result->message, 'red');
|
||||
}
|
||||
if ($paramsLogResult == 'SUCCESS' && $paramsRouteLogResult == 'SUCCESS') {
|
||||
$paramsLog ['RESULT'] = 'SUCCESS';
|
||||
} else {
|
||||
$paramsLog ['RESULT'] = 'FAILED';
|
||||
}
|
||||
|
||||
$newCaseLog->saveLogParameters ( $paramsLog );
|
||||
$newCaseLog->save ();
|
||||
|
||||
if ($sOption != '4') {
|
||||
$nSchLastRunTime = $sActualTime;
|
||||
|
||||
$dEstimatedDate = $this->updateNextRun ( $sOption, $sValue, $sActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths );
|
||||
|
||||
if ($aRow ['SCH_END_DATE'] != '') {
|
||||
if (date ( "Y-m-d", strtotime ( $dEstimatedDate ) ) > date ( "Y-m-d", strtotime ( $aRow ['SCH_END_DATE'] ) )) {
|
||||
$Fields = $this->Load ( $sSchedulerUid );
|
||||
$Fields ['SCH_LAST_STATE'] = $aRow ['SCH_STATE'];
|
||||
$Fields ['SCH_STATE'] = 'PROCESSED';
|
||||
$this->Update ( $Fields );
|
||||
|
||||
}
|
||||
}
|
||||
$nSchTimeNextRun = $dEstimatedDate;
|
||||
|
||||
$this->updateDate ( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime );
|
||||
} else {
|
||||
$Fields = $this->Load ( $sSchedulerUid );
|
||||
$Fields ['SCH_LAST_STATE'] = $aRow ['SCH_STATE'];
|
||||
$Fields ['SCH_LAST_RUN_TIME'] = $Fields ['SCH_TIME_NEXT_RUN'];
|
||||
$Fields ['SCH_STATE'] = 'PROCESSED';
|
||||
$this->Update ( $Fields );
|
||||
}
|
||||
}
|
||||
|
||||
$oDataset->next ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateDate($sSchedulerUid = '', $sSchTimeNextRun = '', $sSchLastRunTime = '') {
|
||||
$Fields = $this->Load ( $sSchedulerUid );
|
||||
$Fields ['SCH_TIME_NEXT_RUN'] = strtotime ( $sSchTimeNextRun );
|
||||
$Fields ['SCH_LAST_RUN_TIME'] = strtotime ( $sSchLastRunTime );
|
||||
$this->Update ( $Fields );
|
||||
}
|
||||
|
||||
function updateNextRun($sOption, $sValue = '', $sActualTime = '', $sDaysPerformTask = '', $sWeeks = '', $sStartDay = '', $sMonths = '', $currentDate = '') {
|
||||
$nActualDate = $currentDate . " " . $sActualTime; // date("Y-m-d H:i:s", $sActualTime);
|
||||
// date("Y-m-d H:i:s", $sActualTime);
|
||||
$dEstimatedDate = '';
|
||||
switch ($sOption) {
|
||||
case '1' :
|
||||
switch ($sValue) {
|
||||
case '1' :
|
||||
$dEstimatedDate = date ( 'Y-m-d H:i:s', strtotime ( "$nActualDate +1 day" ) );
|
||||
break;
|
||||
case '2' :
|
||||
$nDayOfTheWeek = date ( 'w', strtotime ( $sActualTime ) );
|
||||
$nDayOfTheWeek = ($nDayOfTheWeek == 0) ? 7 : $nDayOfTheWeek;
|
||||
if ($nDayOfTheWeek >= 5)
|
||||
$dEstimatedDate = date ( 'Y-m-d H:i:s', strtotime ( "$nActualDate +3 day" ) );
|
||||
else
|
||||
$dEstimatedDate = date ( 'Y-m-d H:i:s', strtotime ( "$nActualDate +1 day" ) );
|
||||
break;
|
||||
case '3' :
|
||||
$dEstimatedDate = date ( 'Y-m-d H:i:s', strtotime ( "$nActualDate + " . $sDaysPerformTask . " day" ) );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '2' :
|
||||
if (strlen ( $sWeeks ) > 0) {
|
||||
|
||||
//die($sActualTime);
|
||||
$nDayOfTheWeek = date ( 'w', strtotime ( $sActualTime ) );
|
||||
// $nDayOfTheWeek = 1;
|
||||
// echo "*".$nDayOfTheWeek."*";
|
||||
$aWeeks = explode ( '|', $sWeeks );
|
||||
$nFirstDay = $aWeeks [0];
|
||||
|
||||
$aDaysWeek = array (
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday',
|
||||
'Sunday'
|
||||
);
|
||||
$nFirstDay = $nFirstDay - 1;
|
||||
// echo "¨¨".$nFirstDay."¨¨";
|
||||
$nDayOfTheWeek = ($nDayOfTheWeek == 0) ? 7 : $nDayOfTheWeek;
|
||||
// echo $nDayOfTheWeek;
|
||||
|
||||
|
||||
$nSW = 0;
|
||||
$nNextDay = 0;
|
||||
foreach ( $aWeeks as $value ) {
|
||||
if ($value > $nDayOfTheWeek) {
|
||||
$nNextDay = $value - 1;
|
||||
$nSW = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//die;
|
||||
if ($nSW == 1) {
|
||||
$dEstimatedDate = date ( 'Y-m-d', strtotime ( "$nActualDate next " . $aDaysWeek [$nNextDay] ) ) . ' ' . date ( 'H:i:s', strtotime ( $sActualTime ) );
|
||||
//print_r($dEstimatedDate);
|
||||
// die("03");
|
||||
} else {
|
||||
$nEveryDays = $sDaysPerformTask;
|
||||
// $nEveryDays = '1';
|
||||
if ($nFirstDay >= $nDayOfTheWeek || $nEveryDays == 1)
|
||||
$sTypeOperation = "next";
|
||||
else
|
||||
$sTypeOperation = "last";
|
||||
if ($nEveryDays == 1) {
|
||||
// echo "**** $nActualDate *" . $sTypeOperation . "* *" . $aDaysWeek[$nFirstDay] . '*****' . date('H:i:s', strtotime($sActualTime)). "**";
|
||||
$dEstimatedDate = date ( 'Y-m-d', strtotime ( "$nActualDate " . $sTypeOperation . " " . $aDaysWeek [$nFirstDay] ) ) . ' ' . date ( 'H:i:s', strtotime ( $sActualTime ) );
|
||||
// echo "(date)*".$dEstimatedDate."*";
|
||||
// die("01");
|
||||
} else {
|
||||
$nEveryDays = 1;
|
||||
// $nActualDate = date('Y-m-d').' '.$sActualTime;
|
||||
$nDataTmp = date ( 'Y-m-d', strtotime ( "$nActualDate + " . $nEveryDays . " Week" ) );
|
||||
// echo "$nActualDate + " . $nEveryDays . " Week ";
|
||||
// echo "++";
|
||||
// echo strtotime( "+".$nEveryDays . " week"), "\n";
|
||||
// echo strtotime("$nActualDate +" . $nEveryDays . " Week ");
|
||||
// echo "++";
|
||||
// echo $nDataTmp;
|
||||
// echo "--";
|
||||
// echo $sTypeOperation;
|
||||
// echo $nFirstDay;
|
||||
// print_r ($aDaysWeek);
|
||||
// $sTypeOperation = "next";
|
||||
$dEstimatedDate = date ( 'Y-m-d', strtotime ( "$nDataTmp " . $sTypeOperation . " " . $aDaysWeek [$nFirstDay] ) ) . ' ' . date ( 'H:i:s', strtotime ( $sActualTime ) );
|
||||
|
||||
// echo (strtotime ("$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay]));
|
||||
// echo "$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay];
|
||||
|
||||
|
||||
// echo $dEstimatedDate;
|
||||
// echo "--";
|
||||
// echo date('Y-m-d', strtotime ("$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay])) . ' ' . date('H:i:s', strtotime($sActualTime));
|
||||
// die("02");
|
||||
}
|
||||
// die("03");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '3' :
|
||||
if (strlen ( $sMonths ) > 0) { // Must have at least one selected month
|
||||
// Calculamos para la siguiente ejecucion, acorde a lo seleccionado
|
||||
$aStartDay = explode ( '|', $sStartDay );
|
||||
$nYear = date ( "Y", strtotime ( $sActualTime ) );
|
||||
$nCurrentMonth = date ( "m", strtotime ( $sActualTime ) );
|
||||
$nCurrentDay = date ( "d", strtotime ( $sActualTime ) );
|
||||
$aMonths = explode ( '|', $sMonths );
|
||||
|
||||
$nSW = 0;
|
||||
$nNextMonth = 0;
|
||||
foreach ( $aMonths as $value ) {
|
||||
if ($value > $nCurrentMonth) {
|
||||
$nNextMonth = $value - 1;
|
||||
$nSW = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($nSW == 1) { // Mes encontrado
|
||||
$nExecNextMonth = $nNextMonth;
|
||||
} else {
|
||||
$nExecNextMonth = $aMonths [0] - 1;
|
||||
$nYear ++;
|
||||
}
|
||||
switch ($sValue) {
|
||||
case '1' :
|
||||
$nExecNextMonth ++;
|
||||
$nCurrentDay = $aStartDay [1];
|
||||
$dEstimatedDate = date ( 'Y-m-d', strtotime ( "$nYear-$nExecNextMonth-$nCurrentDay" ) ) . ' ' . date ( 'H:i:s', strtotime ( $sActualTime ) );
|
||||
break;
|
||||
case '2' :
|
||||
$aMontsShort = array (
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec'
|
||||
);
|
||||
$aWeeksShort = array (
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday',
|
||||
'Sunday'
|
||||
);
|
||||
$sNumDayWeek = $aStartDay [1];
|
||||
$sDayWeek = ($aStartDay [2] == 7 ? 0 : $aStartDay [2]);
|
||||
switch ($sNumDayWeek) {
|
||||
case '1' :
|
||||
$sDaysWeekOpt = "+0";
|
||||
break;
|
||||
case '2' :
|
||||
$sDaysWeekOpt = "+1";
|
||||
break;
|
||||
case '3' :
|
||||
$sDaysWeekOpt = "+2";
|
||||
break;
|
||||
case '4' :
|
||||
$sDaysWeekOpt = "+3";
|
||||
break;
|
||||
case '5' :
|
||||
$sDaysWeekOpt = "-1";
|
||||
$nExecNextMonth ++;
|
||||
if ($nExecNextMonth >= 12) {
|
||||
$nExecNextMonth = 0;
|
||||
$nYear ++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$dEstimatedDate = date ( 'Y-m-d', strtotime ( $sDaysWeekOpt . ' week ' . $aWeeksShort [$sDayWeek - 1] . ' ' . $aMontsShort [$nExecNextMonth] . ' ' . $nYear ) ) . ' ' . date ( 'H:i:s', strtotime ( $sActualTime ) );
|
||||
// krumo($nExecNextMonth, $sDayWeek);
|
||||
// krumo($sDaysWeekOpt . ' week ' . $aWeeksShort[$sDayWeek-1] . ' ' . $aMontsShort[$nExecNextMonth] . ' ' . $nYear);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $dEstimatedDate;
|
||||
|
||||
}
|
||||
|
||||
function Exists( $sUid ) {
|
||||
try {
|
||||
$oObj = CaseSchedulerPeer::retrieveByPk( $sUid );
|
||||
return (get_class($oObj) == 'CaseScheduler');
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
} // CaseScheduler
|
||||
23
workflow/engine/classes/model/CaseSchedulerPeer.php
Executable file
23
workflow/engine/classes/model/CaseSchedulerPeer.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseCaseSchedulerPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/CaseScheduler.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CASE_SCHEDULER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CaseSchedulerPeer extends BaseCaseSchedulerPeer {
|
||||
|
||||
} // CaseSchedulerPeer
|
||||
121
workflow/engine/classes/model/CaseTracker.php
Normal file
121
workflow/engine/classes/model/CaseTracker.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseCaseTracker.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CASE_TRACKER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CaseTracker extends BaseCaseTracker {
|
||||
public function load($sProcessUID) {
|
||||
try {
|
||||
$oRow = CaseTrackerPeer::retrieveByPK($sProcessUID);
|
||||
if (!is_null($oRow)) {
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception("The row '$sProcessUID' in table CASE_TRACKER doesn't exist!"));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function create($aData) {
|
||||
$oConnection = Propel::getConnection(CaseTrackerPeer::DATABASE_NAME);
|
||||
try {
|
||||
if (!isset($aData['CT_MAP_TYPE'])) {
|
||||
$aData['CT_MAP_TYPE'] = 'PROCESSMAP';
|
||||
}
|
||||
$oCaseTracker = new CaseTracker();
|
||||
$oCaseTracker->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oCaseTracker->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oCaseTracker->save();
|
||||
$oConnection->commit();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oCaseTracker->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($aData) {
|
||||
$oConnection = Propel::getConnection(CaseTrackerPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oCaseTracker = CaseTrackerPeer::retrieveByPK($aData['PRO_UID']);
|
||||
if (!is_null($oCaseTracker))
|
||||
{
|
||||
$oCaseTracker->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oCaseTracker->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oCaseTracker->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oCaseTracker->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($sProcessUID) {
|
||||
$oConnection = Propel::getConnection(CaseTrackerPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oConnection->begin();
|
||||
$this->setProUid($sProcessUID);
|
||||
$iResult = $this->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function caseTrackerExists ( $sUid ) {
|
||||
try {
|
||||
$oObj = CaseTrackerPeer::retrieveByPk($sUid);
|
||||
return (get_class($oObj) == 'CaseTracker');
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
} // CaseTracker
|
||||
169
workflow/engine/classes/model/CaseTrackerObject.php
Normal file
169
workflow/engine/classes/model/CaseTrackerObject.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseCaseTrackerObject.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CASE_TRACKER_OBJECT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CaseTrackerObject extends BaseCaseTrackerObject {
|
||||
public function load($Uid) {
|
||||
try {
|
||||
$oRow = CaseTrackerObjectPeer::retrieveByPK( $Uid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$Uid' in table CaseTrackerObject doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function create($aData) {
|
||||
$oConnection = Propel::getConnection(CaseTrackerObjectPeer::DATABASE_NAME);
|
||||
try {
|
||||
if (!isset($aData['CTO_UID'])) {
|
||||
$aData['CTO_UID'] = G::generateUniqueID();
|
||||
}
|
||||
$oCaseTrackerObject = new CaseTrackerObject();
|
||||
$oCaseTrackerObject->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oCaseTrackerObject->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oCaseTrackerObject->save();
|
||||
$oConnection->commit();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oCaseTrackerObject->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(CaseTrackerObjectPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oCaseTrackerObject = CaseTrackerObjectPeer::retrieveByPK($aData['CTO_UID']);
|
||||
if (!is_null($oCaseTrackerObject))
|
||||
{
|
||||
$oCaseTrackerObject->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oCaseTrackerObject->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oCaseTrackerObject->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oCaseTrackerObject->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($sCTOUID) {
|
||||
$oConnection = Propel::getConnection(CaseTrackerObjectPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oCaseTobj = CaseTrackerObjectPeer::retrieveByPK($sCTOUID);
|
||||
if (get_class($oCaseTobj) == 'CaseTrackerObject')
|
||||
{
|
||||
$oConnection->begin();
|
||||
$iResult = $oCaseTobj->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '" . $sCTOUID . "' in table CaseTrackerObject doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {var_dump($oError);die;
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function reorderPositions($sProcessUID, $iPosition) {
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
|
||||
$oCriteria->add(CaseTrackerObjectPeer::CTO_POSITION, $iPosition, '>');
|
||||
$oDataset = CaseTrackerObjectPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$this->update(array('CTO_UID' => $aRow['CTO_UID'],
|
||||
'PRO_UID' => $aRow['PRO_UID'],
|
||||
'CTO_TYPE_OBJ' => $aRow['CTO_TYPE_OBJ'],
|
||||
'CTO_UID_OBJ' => $aRow['CTO_UID_OBJ'],
|
||||
'CTO_CONDITION' => $aRow['CTO_CONDITION'],
|
||||
'CTO_POSITION' => $aRow['CTO_POSITION'] - 1));
|
||||
$oDataset->next();
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
throw $Exception;
|
||||
}
|
||||
}
|
||||
|
||||
function caseTrackerObjectExists ( $Uid ) {
|
||||
try {
|
||||
$oObj = CaseTrackerObjectPeer::retrieveByPk( $Uid );
|
||||
if ( get_class ($oObj) == 'CaseTrackerObject' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function removeByObject($sType, $sObjUid) {
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(CaseTrackerObjectPeer::CTO_TYPE_OBJ, $sType);
|
||||
$oCriteria->add(CaseTrackerObjectPeer::CTO_UID_OBJ, $sObjUid);
|
||||
CaseTrackerObjectPeer::doDelete($oCriteria);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
} // CaseTrackerObject
|
||||
23
workflow/engine/classes/model/CaseTrackerObjectPeer.php
Normal file
23
workflow/engine/classes/model/CaseTrackerObjectPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseCaseTrackerObjectPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/CaseTrackerObject.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CASE_TRACKER_OBJECT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CaseTrackerObjectPeer extends BaseCaseTrackerObjectPeer {
|
||||
|
||||
} // CaseTrackerObjectPeer
|
||||
23
workflow/engine/classes/model/CaseTrackerPeer.php
Normal file
23
workflow/engine/classes/model/CaseTrackerPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseCaseTrackerPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/CaseTracker.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CASE_TRACKER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class CaseTrackerPeer extends BaseCaseTrackerPeer {
|
||||
|
||||
} // CaseTrackerPeer
|
||||
145
workflow/engine/classes/model/Configuration.php
Normal file
145
workflow/engine/classes/model/Configuration.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseConfiguration.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CONFIGURATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Configuration extends BaseConfiguration {
|
||||
public function create($aData)
|
||||
{
|
||||
$con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->setCfgUid($aData['CFG_UID']);
|
||||
$this->setObjUid($aData['OBJ_UID']);
|
||||
$this->setCfgValue(isset($aData['CFG_VALUE'])?$aData['CFG_VALUE']:'');
|
||||
$this->setProUid($aData['PRO_UID']);
|
||||
$this->setUsrUid($aData['USR_UID']);
|
||||
$this->setAppUid($aData['APP_UID']);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
public function load($CfgUid, $ObjUid='', $ProUid='', $UsrUid='', $AppUid='')
|
||||
{
|
||||
try {
|
||||
$oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid' in table Configuration doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
public function update($fields)
|
||||
{
|
||||
$con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->load($fields['CFG_UID'], $fields['OBJ_UID'], $fields['PRO_UID'], $fields['USR_UID'], $fields['APP_UID']);
|
||||
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$contentResult=0;
|
||||
$result=$this->save();
|
||||
$result=($result==0)?($contentResult>0?1:0):$result;
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
public function remove($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid)
|
||||
{
|
||||
$con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->setCfgUid($CfgUid);
|
||||
$this->setObjUid($ObjUid);
|
||||
$this->setProUid($ProUid);
|
||||
$this->setUsrUid($UsrUid);
|
||||
$this->setAppUid($AppUid);
|
||||
$result=$this->delete();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
public function exists($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid)
|
||||
{
|
||||
$oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid );
|
||||
return ( get_class ($oRow) == 'Configuration' );
|
||||
}
|
||||
} // Configuration
|
||||
46
workflow/engine/classes/model/ConfigurationPeer.php
Normal file
46
workflow/engine/classes/model/ConfigurationPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* ConfigurationPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseConfigurationPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Configuration.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CONFIGURATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ConfigurationPeer extends BaseConfigurationPeer {
|
||||
|
||||
} // ConfigurationPeer
|
||||
299
workflow/engine/classes/model/Content.php
Normal file
299
workflow/engine/classes/model/Content.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
/**
|
||||
* Content.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseContent.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'CONTENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Content extends BaseContent {
|
||||
|
||||
/*
|
||||
* Load the content row specified by the parameters:
|
||||
* @param string $sUID
|
||||
* @return variant
|
||||
*/
|
||||
function load($ConCategory, $ConParent, $ConId, $ConLang) {
|
||||
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
if (is_null ( $content )) {
|
||||
//we dont find any value for this field and language in CONTENT table
|
||||
$ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
} else {
|
||||
//krumo($content);
|
||||
$ConValue = $content->getConValue ();
|
||||
if ($ConValue == "") { //try to find a valid translation
|
||||
$ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
}
|
||||
}
|
||||
return $ConValue;
|
||||
}
|
||||
/*
|
||||
* Find a valid Lang for current Content. The most recent
|
||||
* @param string $ConCategory
|
||||
* @param string $ConParent
|
||||
* @param string $ConId
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
function getDefaultContentLang($ConCategory, $ConParent, $ConId, $destConLang) {
|
||||
$Criteria = new Criteria ( 'workflow' );
|
||||
$Criteria->clearSelectColumns ()->clearOrderByColumns ();
|
||||
|
||||
$Criteria->addSelectColumn ( ContentPeer::CON_CATEGORY );
|
||||
$Criteria->addSelectColumn ( ContentPeer::CON_PARENT );
|
||||
$Criteria->addSelectColumn ( ContentPeer::CON_ID );
|
||||
$Criteria->addSelectColumn ( ContentPeer::CON_LANG );
|
||||
$Criteria->addSelectColumn ( ContentPeer::CON_VALUE );
|
||||
|
||||
$Criteria->add ( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL );
|
||||
$Criteria->add ( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL );
|
||||
$Criteria->add ( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL );
|
||||
|
||||
$Criteria->add ( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL );
|
||||
|
||||
$rs = ContentPeer::doSelectRS ( $Criteria );
|
||||
$rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next ();
|
||||
|
||||
if (is_array ( $row = $rs->getRow () )) {
|
||||
$defaultLang = $row ['CON_LANG'];
|
||||
|
||||
} else {
|
||||
$defaultLang = "";
|
||||
}
|
||||
return ($defaultLang);
|
||||
}
|
||||
/*
|
||||
* Load the content row and the Save automatically the row for the destination language
|
||||
* @param string $ConCategory
|
||||
* @param string $ConParent
|
||||
* @param string $ConId
|
||||
* @param string $destConLang
|
||||
* @return string
|
||||
* if the row doesn't exists, it will be created automatically, even the default 'en' language
|
||||
*/
|
||||
function autoLoadSave($ConCategory, $ConParent, $ConId, $destConLang) {
|
||||
//search in 'en' language, the default language
|
||||
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, 'en' );
|
||||
|
||||
if ((is_null ( $content )) || ($content->getConValue () == "")) {
|
||||
$differentLang = Content::getDefaultContentLang ( $ConCategory, $ConParent, $ConId, $destConLang );
|
||||
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $differentLang );
|
||||
}
|
||||
|
||||
//to do: review if the $destConLang is a valid language/
|
||||
if (is_null ( $content ))
|
||||
$ConValue = ''; //we dont find any value for this field and language in CONTENT table
|
||||
else
|
||||
$ConValue = $content->getConValue ();
|
||||
|
||||
try {
|
||||
$con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $destConLang );
|
||||
if (is_null ( $con )) {
|
||||
$con = new Content ( );
|
||||
}
|
||||
$con->setConCategory ( $ConCategory );
|
||||
$con->setConParent ( $ConParent );
|
||||
$con->setConId ( $ConId );
|
||||
$con->setConLang ( $destConLang );
|
||||
$con->setConValue ( $ConValue );
|
||||
if ($con->validate ()) {
|
||||
$res = $con->save ();
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
throw ($e);
|
||||
}
|
||||
|
||||
return $ConValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a content row
|
||||
* @param string $ConCategory
|
||||
* @param string $ConParent
|
||||
* @param string $ConId
|
||||
* @param string $ConLang
|
||||
* @param string $ConValue
|
||||
* @return variant
|
||||
*/
|
||||
function addContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
|
||||
try {
|
||||
$con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
|
||||
if (is_null ( $con )) {
|
||||
$con = new Content ( );
|
||||
} else {
|
||||
if ($con->getConParent () == $ConParent && $con->getConCategory () == $ConCategory && $con->getConValue () == $ConValue && $con->getConLang () == $ConLang && $con->getConId () == $ConId)
|
||||
return true;
|
||||
}
|
||||
$con->setConCategory ( $ConCategory );
|
||||
if ($con->getConParent () != $ConParent)
|
||||
$con->setConParent ( $ConParent );
|
||||
$con->setConId ( $ConId );
|
||||
$con->setConLang ( $ConLang );
|
||||
$con->setConValue ( $ConValue );
|
||||
if ($con->validate ()) {
|
||||
$res = $con->save ();
|
||||
return $res;
|
||||
} else {
|
||||
$e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
|
||||
throw ($e);
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a content row
|
||||
* @param string $ConCategory
|
||||
* @param string $ConParent
|
||||
* @param string $ConId
|
||||
* @param string $ConLang
|
||||
* @param string $ConValue
|
||||
* @return variant
|
||||
*/
|
||||
function insertContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
|
||||
try {
|
||||
$con = new Content ( );
|
||||
$con->setConCategory ( $ConCategory );
|
||||
$con->setConParent ( $ConParent );
|
||||
$con->setConId ( $ConId );
|
||||
$con->setConLang ( $ConLang );
|
||||
$con->setConValue ( $ConValue );
|
||||
if ($con->validate ()) {
|
||||
$res = $con->save ();
|
||||
return $res;
|
||||
} else {
|
||||
$e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
|
||||
throw ($e);
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* remove a content row
|
||||
* @param string $ConCategory
|
||||
* @param string $ConParent
|
||||
* @param string $ConId
|
||||
* @param string $ConLang
|
||||
* @param string $ConValue
|
||||
* @return variant
|
||||
*/
|
||||
function removeContent($ConCategory, $ConParent, $ConId) {
|
||||
try {
|
||||
$c = new Criteria ( );
|
||||
$c->add ( ContentPeer::CON_CATEGORY, $ConCategory );
|
||||
$c->add ( ContentPeer::CON_PARENT, $ConParent );
|
||||
$c->add ( ContentPeer::CON_ID, $ConId );
|
||||
$result = ContentPeer::doSelectRS ( $c );
|
||||
$result->next ();
|
||||
$row = $result->getRow ();
|
||||
while ( is_array ( $row ) ) {
|
||||
ContentPeer::doDelete ( array ($ConCategory, $ConParent, $ConId, $row [3] ) );
|
||||
$result->next ();
|
||||
$row = $result->getRow ();
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
throw ($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Reasons if the record already exists
|
||||
*
|
||||
* @param string $ConCategory
|
||||
* @param string $ConParent
|
||||
* @param string $ConId
|
||||
* @param string $ConLang
|
||||
* @param string $ConValue
|
||||
* @return boolean true or false
|
||||
*/
|
||||
function Exists ($ConCategory, $ConParent, $ConId, $ConLang)
|
||||
{
|
||||
try {
|
||||
$oPro = ContentPeer::retrieveByPk($ConCategory, $ConParent, $ConId, $ConLang);
|
||||
if ( get_class ($oPro) == 'Content' ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateContent($langId)
|
||||
{
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(ContentPeer::CON_CATEGORY);
|
||||
$oCriteria->addSelectColumn(ContentPeer::CON_ID);
|
||||
$oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
|
||||
$oCriteria->add(ContentPeer::CON_LANG, 'en');
|
||||
$oCriteria->add(ContentPeer::CON_VALUE, '', Criteria::NOT_EQUAL );
|
||||
$oDataset = ContentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$oContent = new Content();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oContent->load($aRow['CON_CATEGORY'], '', $aRow['CON_ID'], $langId);
|
||||
$oDataset->next();
|
||||
}
|
||||
}
|
||||
|
||||
function removeLanguageContent($lanId) {
|
||||
try {
|
||||
$c = new Criteria ( );
|
||||
$c->addSelectColumn(ContentPeer::CON_CATEGORY);
|
||||
$c->addSelectColumn(ContentPeer::CON_PARENT);
|
||||
$c->addSelectColumn(ContentPeer::CON_ID);
|
||||
$c->addSelectColumn(ContentPeer::CON_LANG);
|
||||
|
||||
$c->add ( ContentPeer::CON_LANG, $lanId );
|
||||
$result = ContentPeer::doSelectRS ( $c );
|
||||
$result->next ();
|
||||
$row = $result->getRow ();
|
||||
while ( is_array ( $row ) ) {
|
||||
ContentPeer::doDelete ( array ($row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId ) );
|
||||
$result->next ();
|
||||
$row = $result->getRow ();
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
} // Content
|
||||
46
workflow/engine/classes/model/ContentPeer.php
Normal file
46
workflow/engine/classes/model/ContentPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* ContentPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseContentPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Content.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'CONTENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ContentPeer extends BaseContentPeer {
|
||||
|
||||
} // ContentPeer
|
||||
195
workflow/engine/classes/model/DbSource.php
Normal file
195
workflow/engine/classes/model/DbSource.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* DbSource.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/om/BaseDbSource.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'DB_SOURCE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DbSource extends BaseDbSource
|
||||
{
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $db_source_description = '';
|
||||
|
||||
/**
|
||||
* Get the rep_tab_title column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getDBSourceDescription() {
|
||||
if ( $this->getDbsUid() == "" ) {
|
||||
throw ( new Exception( "Error in getDBSourceDescription, the getDbsUid() can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->db_source_description = Content::load ( 'DBS_DESCRIPTION', '', $this->getDbsUid(), $lang );
|
||||
return $this->db_source_description;
|
||||
}
|
||||
|
||||
function getCriteriaDBSList($sProcessUID)
|
||||
{
|
||||
$sDelimiter = DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::DBS_UID);
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::DBS_TYPE);
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::DBS_SERVER);
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::DBS_DATABASE_NAME);
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::DBS_USERNAME);
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::DBS_PASSWORD);
|
||||
$oCriteria->addSelectColumn(DbSourcePeer::DBS_PORT);
|
||||
$oCriteria->addAsColumn('DBS_DESCRIPTION', 'C.CON_VALUE');
|
||||
$oCriteria->addAlias('C', 'CONTENT');
|
||||
$aConditions = array();
|
||||
$aConditions[] = array(DbSourcePeer::DBS_UID, 'C.CON_ID');
|
||||
$aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'DBS_DESCRIPTION' . $sDelimiter);
|
||||
$aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID);
|
||||
return $oCriteria;
|
||||
}
|
||||
|
||||
public function load($Uid)
|
||||
{
|
||||
try {
|
||||
$oRow = DbSourcePeer::retrieveByPK($Uid);
|
||||
if (!is_null($oRow)) {
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['DBS_DESCRIPTION'] = $this->getDBSourceDescription();
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
} else {
|
||||
throw(new Exception( "The row '$Uid' in table DbSource doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function Exists ( $Uid ) {
|
||||
try {
|
||||
$oPro = DbSourcePeer::retrieveByPk( $Uid );
|
||||
if ( get_class ($oPro) == 'DbSource' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($fields)
|
||||
{
|
||||
if( $fields['DBS_ENCODE'] == '0'){
|
||||
unset($fields['DBS_ENCODE']);
|
||||
}
|
||||
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
|
||||
try {
|
||||
$con->begin();
|
||||
$this->load($fields['DBS_UID']);
|
||||
$this->fromArray($fields, BasePeer::TYPE_FIELDNAME);
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw (new Exception("Failed Validation in class " . get_class($this) . "."));
|
||||
}
|
||||
}
|
||||
catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($DbsUid)
|
||||
{
|
||||
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
|
||||
try {
|
||||
$con->begin();
|
||||
$this->setDbsUid($DbsUid);
|
||||
// note added by gustavo cruz gustavo-at-colosa-dot-com
|
||||
// we assure that the _delete attribute must be set to false
|
||||
// if a record exists in the database with that uid.
|
||||
if ($this->Exists($DbsUid)){
|
||||
$this->setDeleted(false);
|
||||
}
|
||||
$result = $this->delete();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function create($aData)
|
||||
{
|
||||
if( $aData['DBS_ENCODE'] == '0'){
|
||||
unset($aData['DBS_ENCODE']);
|
||||
}
|
||||
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
|
||||
try {
|
||||
if ( isset ( $aData['DBS_UID'] ) && $aData['DBS_UID']== '' )
|
||||
unset ( $aData['DBS_UID'] );
|
||||
if ( !isset ( $aData['DBS_UID'] ) )
|
||||
$aData['DBS_UID'] = G::generateUniqueID();
|
||||
$this->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
} else {
|
||||
$e = new Exception("Failed Validation in class " . get_class($this) . ".");
|
||||
$e->aValidationFailures = $this->getValidationFailures();
|
||||
throw ($e);
|
||||
}
|
||||
$con->commit();
|
||||
return $this->getDbsUid();
|
||||
}
|
||||
catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
} // DbSource
|
||||
23
workflow/engine/classes/model/DbSourcePeer.php
Normal file
23
workflow/engine/classes/model/DbSourcePeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseDbSourcePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/DbSource.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'DB_SOURCE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DbSourcePeer extends BaseDbSourcePeer {
|
||||
|
||||
} // DbSourcePeer
|
||||
558
workflow/engine/classes/model/Department.php
Normal file
558
workflow/engine/classes/model/Department.php
Normal file
@@ -0,0 +1,558 @@
|
||||
<?php
|
||||
/**
|
||||
* Department.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseDepartment.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'DEPARTMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Department extends BaseDepartment {
|
||||
|
||||
|
||||
protected $depo_title = '';
|
||||
/**
|
||||
* Create the Department
|
||||
*
|
||||
* @param array $aData
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($aData ) {
|
||||
$con = Propel::getConnection( DepartmentPeer::DATABASE_NAME );
|
||||
try {
|
||||
if ( isset ( $aData['DEP_UID'] ) )
|
||||
$this->setDepUid ( $aData['DEP_UID'] );
|
||||
else
|
||||
$this->setDepUid ( G::generateUniqueID() );
|
||||
|
||||
if ( isset ( $aData['DEP_PARENT'] ) )
|
||||
$this->setDepParent ( $aData['DEP_PARENT'] );
|
||||
else
|
||||
$this->setDepParent ( '' );
|
||||
|
||||
if ( isset ( $aData['DEP_MANAGER'] ) )
|
||||
$this->setDepManager ( $aData['DEP_MANAGER'] );
|
||||
else
|
||||
$this->setDepManager ( '' );
|
||||
|
||||
if ( isset ( $aData['DEP_LOCATION'] ) )
|
||||
$this->setDepLocation ( $aData['DEP_LOCATION'] );
|
||||
else
|
||||
$this->setDepLocation ( '' );
|
||||
|
||||
if ( isset ( $aData['DEP_STATUS'] ) )
|
||||
$this->setDepStatus ( $aData['DEP_STATUS'] );
|
||||
else
|
||||
$this->setDepStatus ( 'ACTIVE' );
|
||||
|
||||
if ( isset ( $aData['DEP_REF_CODE'] ) )
|
||||
$this->setDepRefCode ( $aData['DEP_REF_CODE'] );
|
||||
else
|
||||
$this->setDepRefCode ( '' );
|
||||
|
||||
if ( isset ( $aData['DEP_LDAP_DN'] ) )
|
||||
$this->setDepLdapDn ( $aData['DEP_LDAP_DN'] );
|
||||
else
|
||||
$this->setDepLdapDn ( '' );
|
||||
|
||||
if ( isset ( $aData['DEP_TITLE'] ) )
|
||||
$this->setDepTitle ( $aData['DEP_TITLE'] );
|
||||
else
|
||||
$this->setDepTitle ( '' );
|
||||
|
||||
if ( $this->validate() ) {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
$con->commit();
|
||||
return $this->getDepUid();
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new Exception ( " The Department row cannot be created $msg " ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [depo_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getDepTitle()
|
||||
{
|
||||
if ( $this->getDepUid() == '' ) {
|
||||
throw ( new Exception( "Error in getDepTitle, the DEP_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->depo_title = Content::load ( 'DEPO_TITLE', '', $this->getDepUid(), $lang );
|
||||
return $this->depo_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [depo_title] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDepTitle($v)
|
||||
{
|
||||
if ( $this->getDepUid() == '' ) {
|
||||
throw ( new Exception( "Error in setGrpTitle, the GRP_UID can't be blank") );
|
||||
}
|
||||
// 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->depo_title !== $v || $v === '') {
|
||||
$this->depo_title = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'DEPO_TITLE', '', $this->getDepUid(), $lang, $this->depo_title );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
|
||||
/**
|
||||
* Load the Process row specified in [depo_id] column value.
|
||||
*
|
||||
* @param string $ProUid the uid of the Prolication
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $DepUid ) {
|
||||
$con = Propel::getConnection(DepartmentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oDept = DepartmentPeer::retrieveByPk( $DepUid );
|
||||
if ( get_class ($oDept) == 'Department' ) {
|
||||
$aFields = $oDept->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$aFields['DEPO_TITLE'] = $oDept->getDepTitle();
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$DepUid' in table Department doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Dep row
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$con = Propel::getConnection( DepartmentPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oPro = DepartmentPeer::retrieveByPK( $aData['DEP_UID'] );
|
||||
if ( get_class ($oPro) == 'Department' ) {
|
||||
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oPro->validate()) {
|
||||
if ( isset ( $aData['DEPO_TITLE'] ) )
|
||||
$oPro->setDepTitle( $aData['DEPO_TITLE'] );
|
||||
if ( isset ( $aData['DEP_STATUS'] ) )
|
||||
$oPro->setDepStatus( $aData['DEP_STATUS'] );
|
||||
if ( isset ( $aData['DEP_PARENT'] ) )
|
||||
$oPro->setDepParent( $aData['DEP_PARENT'] );
|
||||
if ( isset ( $aData['DEP_MANAGER'] ) )
|
||||
$oPro->setDepManager( $aData['DEP_MANAGER'] );
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The Department row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "The row '" . $aData['DEP_UID'] . "' in table Department doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the row
|
||||
* @param array $aData or string $ProUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($ProUid)
|
||||
{
|
||||
if ( is_array ( $ProUid ) ) {
|
||||
$ProUid = ( isset ( $ProUid['DEP_UID'] ) ? $ProUid['DEP_UID'] : '' );
|
||||
}
|
||||
try {
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->add(UsersPeer::DEP_UID, $ProUid, Criteria::EQUAL);
|
||||
$oDataset = UsersPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$oDataset->next();
|
||||
$aFields = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
|
||||
$aFields['USR_UID'] = $aRow['USR_UID'];
|
||||
$aFields['DEP_UID'] = '';
|
||||
$oDepto = UsersPeer::retrieveByPk($aFields['USR_UID']);
|
||||
if (get_class($oDepto) == 'UsersPeer') {
|
||||
return true;
|
||||
} else {
|
||||
$oDepto = new Users();
|
||||
$oDepto->update($aFields);
|
||||
}
|
||||
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$oPro = DepartmentPeer::retrieveByPK( $ProUid );
|
||||
if (!is_null($oPro))
|
||||
{
|
||||
Content::removeContent('DEPO_TITLE', '', $oPro->getDepUid());
|
||||
Content::removeContent('DEPO_DESCRIPTION', '', $oPro->getDepUid());
|
||||
return $oPro->delete();
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the Department row specified in [depo_id] column value.
|
||||
*
|
||||
* @param string $ProUid the uid of the Prolication
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function existsDepartment( $DepUid ) {
|
||||
$con = Propel::getConnection(DepartmentPeer::DATABASE_NAME);
|
||||
$oPro = DepartmentPeer::retrieveByPk( $DepUid );
|
||||
if ( get_class ($oPro) == 'Department' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function existsUserInDepartment( $depId, $userId ) {
|
||||
$con = Propel::getConnection(DepartmentPeer::DATABASE_NAME);
|
||||
$oUser = UsersPeer::retrieveByPk( $userId );
|
||||
if ( get_class ($oUser) == 'Users' ) {
|
||||
if ( $oUser->getDepUid() == $depId )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateDepartmentManager ($depId) {
|
||||
$managerId = '';
|
||||
$depParent = '';
|
||||
$oDept = DepartmentPeer::retrieveByPk( $depId );
|
||||
if ( get_class ($oDept) == 'Department' ) {
|
||||
$managerId = $oDept->getDepManager( );
|
||||
$depParent = $oDept->getDepParent( );
|
||||
}
|
||||
|
||||
// update the reportsTo field to all users in that department
|
||||
$conn = Propel::getConnection(UsersPeer::DATABASE_NAME);
|
||||
$selectCriteria = new Criteria('workflow');
|
||||
$selectCriteria->add(UsersPeer::DEP_UID, $depId );
|
||||
$selectCriteria->add(UsersPeer::USR_UID, $managerId , Criteria::NOT_EQUAL);
|
||||
|
||||
// Create a Criteria object includes the value you want to set
|
||||
$updateCriteria = new Criteria('workflow');
|
||||
$updateCriteria->add(UsersPeer::USR_REPORTS_TO, $managerId );
|
||||
BasePeer::doUpdate($selectCriteria, $updateCriteria, $conn);
|
||||
|
||||
// update manager's manager, getting the manager of PARENT DEPARTMENT in order to enable scalating
|
||||
$oUser = UsersPeer::retrieveByPk( $managerId );
|
||||
if ( get_class ($oUser) == 'Users' ) {
|
||||
$oDept = DepartmentPeer::retrieveByPk( $depParent );
|
||||
$oUser->setUsrReportsTo( '' ); //by default no manager
|
||||
if ( get_class ($oDept) == 'Department' ) {
|
||||
$managerParentId = $oDept->getDepManager( );
|
||||
if ( trim($managerParentId) != '' ) {
|
||||
$oUser->setUsrReportsTo( $managerParentId );
|
||||
}
|
||||
}
|
||||
$oUser->save();
|
||||
}
|
||||
|
||||
// get children departments to update the reportsTo of these children
|
||||
$childrenCriteria = new Criteria('workflow');
|
||||
$childrenCriteria->add(DepartmentPeer::DEP_PARENT, $depId );
|
||||
$oDataset = DepartmentPeer::doSelectRS($childrenCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$oDataset->next();
|
||||
while ( $aRow = $oDataset->getRow() ) {
|
||||
$oUser = UsersPeer::retrieveByPk($aRow['DEP_MANAGER']);
|
||||
if (get_class($oUser) == 'Users') {
|
||||
$oUser->setUsrReportsTo ( $managerId );
|
||||
$oUser->save();
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//add an user to a department and sync all about manager info
|
||||
function addUserToDepartment( $depId, $userId, $manager, $updateManager = false ) {
|
||||
try {
|
||||
//update the field in user table
|
||||
$oUser = UsersPeer::retrieveByPk( $userId );
|
||||
if ( get_class ($oUser) == 'Users' ) {
|
||||
$oUser->setDepUid( $depId );
|
||||
$oUser->save();
|
||||
}
|
||||
|
||||
//if the user is a manager update Department Table
|
||||
if ( $manager ) {
|
||||
$oDept = DepartmentPeer::retrieveByPk( $depId );
|
||||
if ( get_class ($oDept) == 'Department' ) {
|
||||
$oDept->setDepManager( $userId );
|
||||
$oDept->save();
|
||||
}
|
||||
}
|
||||
|
||||
//now update the reportsto to all
|
||||
if ( $updateManager ) {
|
||||
$this->updateDepartmentManager ($depId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch ( Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
// select departments
|
||||
// this function is used to draw the hierachy tree view
|
||||
function getDepartments( $DepParent ) {
|
||||
try {
|
||||
$result = array();
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->add(DepartmentPeer::DEP_PARENT, $DepParent, Criteria::EQUAL);
|
||||
$con = Propel::getConnection(DepartmentPeer::DATABASE_NAME);
|
||||
$objects = DepartmentPeer::doSelect($criteria, $con);
|
||||
foreach( $objects as $oDepartment ) {
|
||||
$node = array();
|
||||
$node['DEP_UID'] = $oDepartment->getDepUid();
|
||||
$node['DEP_PARENT'] = $oDepartment->getDepParent();
|
||||
$node['DEP_TITLE'] = $oDepartment->getDepTitle();
|
||||
$node['DEP_LAST'] = 0;
|
||||
|
||||
$criteriaCount = new Criteria('workflow');
|
||||
$criteriaCount->clearSelectColumns();
|
||||
$criteriaCount->addSelectColumn( 'COUNT(*)' );
|
||||
$criteriaCount->add(DepartmentPeer::DEP_PARENT, $oDepartment->getDepUid(), Criteria::EQUAL);
|
||||
$rs = DepartmentPeer::doSelectRS($criteriaCount);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$node['HAS_CHILDREN'] = $row[0];
|
||||
$result[] = $node;
|
||||
}
|
||||
if ( count($result) >= 1 )
|
||||
$result[ count($result) -1 ]['DEP_LAST'] = 1;
|
||||
return $result;
|
||||
}
|
||||
catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
function getUsersFromDepartment( $sDepUid, $sManagerUid ) {
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_REPORTS_TO);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(UsersPeer::DEP_UID, $sDepUid);
|
||||
|
||||
$rs = UsersPeer::doSelectRS($oCriteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$oUser = new Users();
|
||||
$aUsers[] = array('USR_UID' =>'char', 'USR_USERNAME' =>'char','USR_FULLNAME' =>'char', 'USR_REPORTS_TO'=>'char','USR_MANAGER' =>'char');
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
while( is_array($row) ) {
|
||||
$usrFields = $oUser->LoadDetails( $row['USR_UID'] );
|
||||
$row['USR_USERNAME'] = $usrFields['USR_USERNAME'];
|
||||
$row['USR_FULLNAME'] = $usrFields['USR_FULLNAME'];
|
||||
$row['USR_MANAGER'] = $row['USR_UID'] == $sManagerUid ? G::loadTranslation("ID_YES") : G::loadTranslation("ID_NO");
|
||||
$row['DEP_UID'] = $sDepUid;
|
||||
if ( $row['USR_REPORTS_TO'] != '' ) {
|
||||
try {
|
||||
$managerFields = $oUser->LoadDetails( $row['USR_REPORTS_TO'] );
|
||||
$row['USR_REPORTS_NAME'] = $managerFields['USR_FULLNAME'];
|
||||
}
|
||||
catch (exception $e) {
|
||||
$row['USR_REPORTS_NAME'] = '.';
|
||||
}
|
||||
}
|
||||
else
|
||||
$row['USR_REPORTS_NAME'] = '.';
|
||||
$aUsers[] = $row;
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
|
||||
G::LoadClass('ArrayPeer');
|
||||
global $_DBArray;
|
||||
$_DBArray['DepartmentUserList'] = $aUsers ;
|
||||
$_SESSION['_DBArray'] = $_DBArray;
|
||||
$oCriteriaT = new Criteria('dbarray');
|
||||
$oCriteriaT->setDBArrayTable('DepartmentUserList');
|
||||
|
||||
return $oCriteriaT;
|
||||
}
|
||||
catch (exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove a user from Departments
|
||||
* @param string $DepUid, $UsrUid
|
||||
* @return array
|
||||
*/
|
||||
function removeUserFromDepartment($DepUid, $UsrUid) {
|
||||
$aFields = array ('USR_UID'=> $UsrUid,'DEP_UID'=> '', 'USR_REPORTS_TO' => '');
|
||||
try {
|
||||
$oUser = UsersPeer::retrieveByPk( $UsrUid );
|
||||
if ( get_class($oUser) == 'Users' ) {
|
||||
//$oDepto = new Users();
|
||||
$oUser->setDepUid ( '');
|
||||
$oUser->setUsrReportsTo ( '');
|
||||
$oUser->save();
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the available users list criteria object
|
||||
* @param string $sGroupUID
|
||||
* @return object
|
||||
*/
|
||||
function getAvailableUsersCriteria($sGroupUID = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$oCriteria->add(UsersPeer::DEP_UID, "", Criteria::EQUAL);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
return $oCriteria;
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the cant Users In Department
|
||||
* @param string $sDepUID
|
||||
* @return object
|
||||
*/
|
||||
function cantUsersInDepartment ( $sDepUID ) {
|
||||
try {
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn('COUNT(*)');
|
||||
$c->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
||||
$c->add(UsersPeer::DEP_UID, $sDepUID);
|
||||
|
||||
$rs = UsersPeer::doSelectRS($c);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$count = $row[0];
|
||||
return $count;
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
function loadByGroupname ( $Groupname ) {
|
||||
$c = new Criteria('workflow');
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
|
||||
$c->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
|
||||
$c->add(ContentPeer::CON_CATEGORY, 'DEPO_TITLE');
|
||||
$c->add(ContentPeer::CON_VALUE, $Groupname);
|
||||
$c->add(ContentPeer::CON_LANG, SYS_LANG );
|
||||
return $c;
|
||||
}
|
||||
|
||||
} // Department
|
||||
46
workflow/engine/classes/model/DepartmentPeer.php
Normal file
46
workflow/engine/classes/model/DepartmentPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* DepartmentPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseDepartmentPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Department.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'DEPARTMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DepartmentPeer extends BaseDepartmentPeer {
|
||||
|
||||
} // DepartmentPeer
|
||||
19
workflow/engine/classes/model/DimTimeComplete.php
Normal file
19
workflow/engine/classes/model/DimTimeComplete.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseDimTimeComplete.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'DIM_TIME_COMPLETE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DimTimeComplete extends BaseDimTimeComplete {
|
||||
|
||||
} // DimTimeComplete
|
||||
23
workflow/engine/classes/model/DimTimeCompletePeer.php
Normal file
23
workflow/engine/classes/model/DimTimeCompletePeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseDimTimeCompletePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/DimTimeComplete.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'DIM_TIME_COMPLETE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DimTimeCompletePeer extends BaseDimTimeCompletePeer {
|
||||
|
||||
} // DimTimeCompletePeer
|
||||
19
workflow/engine/classes/model/DimTimeDelegate.php
Normal file
19
workflow/engine/classes/model/DimTimeDelegate.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseDimTimeDelegate.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'DIM_TIME_DELEGATE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DimTimeDelegate extends BaseDimTimeDelegate {
|
||||
|
||||
} // DimTimeDelegate
|
||||
23
workflow/engine/classes/model/DimTimeDelegatePeer.php
Normal file
23
workflow/engine/classes/model/DimTimeDelegatePeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseDimTimeDelegatePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/DimTimeDelegate.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'DIM_TIME_DELEGATE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DimTimeDelegatePeer extends BaseDimTimeDelegatePeer {
|
||||
|
||||
} // DimTimeDelegatePeer
|
||||
469
workflow/engine/classes/model/Dynaform.php
Normal file
469
workflow/engine/classes/model/Dynaform.php
Normal file
@@ -0,0 +1,469 @@
|
||||
<?php
|
||||
/**
|
||||
* Dynaform.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseDynaform.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once('classes/model/AdditionalTables.php');
|
||||
G::LoadClass('dynaFormField');
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'DYNAFORM' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Dynaform extends BaseDynaform {
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $dyn_title = '';
|
||||
|
||||
/**
|
||||
* Get the [Dyn_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getDynTitle()
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in getDynTitle, the DYN_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->dyn_title = Content::load ( 'DYN_TITLE', '', $this->getDynUid(), $lang );
|
||||
return $this->dyn_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [Dyn_title] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDynTitle($v)
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in setDynTitle, the DYN_UID can't be blank") );
|
||||
}
|
||||
// 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->dyn_title !== $v || $v === '') {
|
||||
$this->dyn_title = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'DYN_TITLE', '', $this->getDynUid(), $lang, $this->dyn_title );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $dyn_description = '';
|
||||
|
||||
/**
|
||||
* Get the [Dyn_description] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getDynDescription()
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in getDynDescription, the DYN_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->dyn_description = Content::load ( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang );
|
||||
return $this->dyn_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [Dyn_description] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDynDescription($v)
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in setDynDescription, the DYN_UID can't be blank") );
|
||||
}
|
||||
// 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->dyn_description !== $v || $v === '') {
|
||||
$this->dyn_description = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang, $this->dyn_description );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
/**
|
||||
* Creates the Dynaform
|
||||
*
|
||||
* @param array $aData Fields with :
|
||||
* $aData['DYN_UID'] the dynaform id
|
||||
* $aData['USR_UID'] the userid
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($aData ) {
|
||||
if ( !isset ( $aData['PRO_UID'] ) ) {
|
||||
throw ( new PropelException ( 'The dynaform cannot be created. The PRO_UID is empty.' ) );
|
||||
}
|
||||
$con = Propel::getConnection( DynaformPeer::DATABASE_NAME );
|
||||
try {
|
||||
if ( isset ( $aData['DYN_UID'] ) && $aData['DYN_UID']== '' )
|
||||
unset ( $aData['DYN_UID'] );
|
||||
if ( !isset ( $aData['DYN_UID'] ) )
|
||||
$dynUid = ( G::generateUniqueID() );
|
||||
else
|
||||
$dynUid = $aData['DYN_UID'];
|
||||
$this->setDynUid ( $dynUid );
|
||||
$this->setProUid ( $aData['PRO_UID'] );
|
||||
$this->setDynType ( isset($aData['DYN_TYPE'])?$aData['DYN_TYPE']:'xmlform' );
|
||||
$this->setDynFilename ( $aData['PRO_UID'] . PATH_SEP . $dynUid );
|
||||
|
||||
if ( $this->validate() ) {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
if (isset ( $aData['DYN_TITLE'] ) )
|
||||
$this->setDynTitle ( $aData['DYN_TITLE'] );
|
||||
else
|
||||
$this->setDynTitle ( 'Default Dynaform Title' );
|
||||
|
||||
if (isset ( $aData['DYN_DESCRIPTION'] ) )
|
||||
$this->setDynDescription ( $aData['DYN_DESCRIPTION'] );
|
||||
else
|
||||
$this->setDynDescription ( 'Default Dynaform Description' );
|
||||
|
||||
$con->commit();
|
||||
$sXml = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="edit">'."\n";
|
||||
$sXml .= '</dynaForm>';
|
||||
G::verifyPath(PATH_DYNAFORM . $this->getProUid(), true);
|
||||
$oFile = fopen(PATH_DYNAFORM . $this->getProUid() . '/' . $this->getDynUid() . '.xml', 'w');
|
||||
fwrite($oFile, $sXml);
|
||||
fclose($oFile);
|
||||
return $this->getDynUid();
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a Dynaform based on a PMTable
|
||||
*
|
||||
* @name createFromPMTable
|
||||
* @author gustavo cruz gustavo[at]colosa[dot]com
|
||||
* @param array $aData Fields with :
|
||||
* $aData['DYN_UID'] the dynaform id
|
||||
* $aData['USR_UID'] the userid
|
||||
* string $pmTableUid uid of the PMTable
|
||||
*
|
||||
*/
|
||||
|
||||
function createFromPMTable ( $aData, $pmTableUid ) {
|
||||
$this->create($aData);
|
||||
$aData['DYN_UID']=$this->getDynUid();
|
||||
//krumo(BasePeer::getFieldnames('Content'));
|
||||
$fields = array();
|
||||
//$oCriteria = new Criteria('workflow');
|
||||
$pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
|
||||
$addTabName = $pmTable->getAddTabName();
|
||||
$keys = '';
|
||||
if (isset($aData['FIELDS'])){
|
||||
foreach ($aData['FIELDS'] as $iRow => $row) {
|
||||
if ($keys!='')
|
||||
$keys = $keys.'|'.$row['PRO_VARIABLE'];
|
||||
else
|
||||
$keys = $row['PRO_VARIABLE'];
|
||||
}
|
||||
} else {
|
||||
$keys = ' ';
|
||||
}
|
||||
|
||||
// $addTabKeys = $pmTable->getAddTabDynavars();
|
||||
// $addTabKeys = unserialize($addTabKeys);
|
||||
// $keys = '';
|
||||
// foreach ( $addTabKeys as $addTabKey ){
|
||||
// if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
|
||||
// $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
|
||||
// } else {
|
||||
// $keys = $addTabKey['CASE_VARIABLE'];
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
$sql = 'DESC '.$addTabName;
|
||||
$dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||
$sth = $dbh->createStatement();
|
||||
$res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$file = $aData['PRO_UID'].'/'.$aData['DYN_UID'];
|
||||
$dbc = new DBConnection( PATH_DYNAFORM . $file . '.xml' ,'','','','myxml' );
|
||||
$ses = new DBSession($dbc);
|
||||
$fieldXML = new DynaFormField( $dbc );
|
||||
|
||||
$pmConnectionName = $addTabName.'_CONNECTION';
|
||||
|
||||
if ($aData['DYN_TYPE']=='xmlform'){
|
||||
$labels = array();
|
||||
$options = array();
|
||||
$attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS'=>$keys);
|
||||
$fieldXML->Save($attributes, $labels, $options);
|
||||
}
|
||||
while ($res->next()){
|
||||
if(strtoupper($res->get('Null'))=='NO'){
|
||||
$required = '1';
|
||||
} else {
|
||||
$required = '0';
|
||||
}
|
||||
$fieldName = $res->get('Field');
|
||||
$defaultValue = $res->get('Default');
|
||||
$labels = array ( SYS_LANG => $fieldName );
|
||||
$options = array();
|
||||
$type = explode('(',$res->get('Type'));
|
||||
|
||||
switch ($type[0]){
|
||||
case 'text':
|
||||
$type = 'textarea';
|
||||
break;
|
||||
case 'date':
|
||||
$type = 'date';
|
||||
break;
|
||||
default:
|
||||
$type = 'text';
|
||||
break;
|
||||
}
|
||||
if ($aData['DYN_TYPE']=='xmlform'){
|
||||
$attributes = array(
|
||||
'XMLNODE_NAME_OLD' => '',
|
||||
'XMLNODE_NAME' => $fieldName,
|
||||
'TYPE' => $type,
|
||||
'PMCONNECTION' => $pmConnectionName,
|
||||
'PMFIELD' => $fieldName,
|
||||
'REQUIRED' => $required,
|
||||
'DEFAULTVALUE' => $defaultValue
|
||||
);
|
||||
} else {
|
||||
$attributes = array(
|
||||
'XMLNODE_NAME_OLD' => '',
|
||||
'XMLNODE_NAME' => $fieldName,
|
||||
'TYPE' => $type,
|
||||
'REQUIRED' => $required,
|
||||
'DEFAULTVALUE' => $defaultValue
|
||||
);
|
||||
}
|
||||
$fieldXML->Save($attributes, $labels, $options);
|
||||
}
|
||||
$labels = array ( SYS_LANG => 'Submit' );
|
||||
$attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => 'SUBMIT', 'TYPE' => 'submit');
|
||||
$fieldXML->Save($attributes, $labels, $options);
|
||||
}
|
||||
/**
|
||||
* Load the Dynaform row specified in [dyn_id] column value.
|
||||
*
|
||||
* @param string $ProUid the uid of the Prolication
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $ProUid ) {
|
||||
$con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oPro = DynaformPeer::retrieveByPk( $ProUid );
|
||||
if ( get_class ($oPro) == 'Dynaform' ) {
|
||||
$aFields = $oPro->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$aFields['DYN_TITLE'] = $oPro->getDynTitle();
|
||||
$aFields['DYN_DESCRIPTION'] = $oPro->getDynDescription();
|
||||
$this->setDynTitle ( $oPro->getDynTitle() );
|
||||
$this->setDynDescription ( $oPro->getDynDescription() );
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Prolication row
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$con = Propel::getConnection( DynaformPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oPro = DynaformPeer::retrieveByPK( $aData['DYN_UID'] );
|
||||
if ( get_class ($oPro) == 'Dynaform' ) {
|
||||
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oPro->validate()) {
|
||||
if ( isset ( $aData['DYN_TITLE'] ) )
|
||||
$oPro->setDynTitle( $aData['DYN_TITLE'] );
|
||||
if ( isset ( $aData['DYN_DESCRIPTION'] ) )
|
||||
$oPro->setDynDescription( $aData['DYN_DESCRIPTION'] );
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "The row '" . $aData['DYN_UID'] . "' in table Dynaform doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the Prolication document registry
|
||||
* @param array $aData or string $ProUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($ProUid)
|
||||
{
|
||||
if ( is_array ( $ProUid ) ) {
|
||||
$ProUid = ( isset ( $ProUid['DYN_UID'] ) ? $ProUid['DYN_UID'] : '' );
|
||||
}
|
||||
try {
|
||||
$oPro = DynaformPeer::retrieveByPK( $ProUid );
|
||||
if (!is_null($oPro))
|
||||
{
|
||||
Content::removeContent('DYN_TITLE', '', $oPro->getDynUid());
|
||||
Content::removeContent('DYN_DESCRIPTION', '', $oPro->getDynUid());
|
||||
$iResult = $oPro->delete();
|
||||
if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml')) {
|
||||
unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml');
|
||||
}
|
||||
if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.xml')) {
|
||||
unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.xml');
|
||||
}
|
||||
if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.html')) {
|
||||
unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.html');
|
||||
}
|
||||
if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.html')) {
|
||||
unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.html');
|
||||
}
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function exists($DynUid)
|
||||
{
|
||||
$oPro = DynaformPeer::retrieveByPk( $DynUid );
|
||||
return ( get_class ($oPro) == 'Dynaform' );
|
||||
}
|
||||
|
||||
/**
|
||||
* verify if Dynaform row specified in [DynUid] exists.
|
||||
*
|
||||
* @param string $sProUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function dynaformExists ( $DynUid ) {
|
||||
$con = Propel::getConnection(TaskPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oDyn = DynaformPeer::retrieveByPk( $DynUid );
|
||||
if ( get_class ($oDyn) == 'Dynaform' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function getDynaformContent( $dynaformUid) {
|
||||
$content = '';
|
||||
$fields = $this->Load ( $dynaformUid);
|
||||
$filename = PATH_DYNAFORM . $fields['PRO_UID'] . PATH_SEP . $fields['DYN_UID'] . '.xml';
|
||||
if (file_exists( $filename )) {
|
||||
$content = file_get_contents ( $filename );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function getDynaformFields( $dynaformUid) {
|
||||
$content = '';
|
||||
$fields = $this->Load ( $dynaformUid);
|
||||
$filename = PATH_DYNAFORM . $fields['PRO_UID'] . PATH_SEP . $fields['DYN_UID'] . '.xml';
|
||||
if (file_exists( $filename )) {
|
||||
$content = file_get_contents ( $filename );
|
||||
}
|
||||
|
||||
$G_FORM = new xmlform ( $fields['DYN_FILENAME'] , PATH_DYNAFORM );
|
||||
$G_FORM->parseFile( $filename , SYS_LANG, true );
|
||||
|
||||
return $G_FORM->fields;
|
||||
}
|
||||
|
||||
} // Dynaform
|
||||
46
workflow/engine/classes/model/DynaformPeer.php
Normal file
46
workflow/engine/classes/model/DynaformPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* DynaformPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseDynaformPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Dynaform.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'DYNAFORM' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class DynaformPeer extends BaseDynaformPeer {
|
||||
|
||||
} // DynaformPeer
|
||||
743
workflow/engine/classes/model/Event.php
Normal file
743
workflow/engine/classes/model/Event.php
Normal file
@@ -0,0 +1,743 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/om/BaseEvent.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'EVENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
|
||||
require_once 'classes/model/AppDelegation.php';
|
||||
require_once 'classes/model/AppEvent.php';
|
||||
require_once 'classes/model/Triggers.php';
|
||||
|
||||
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() {
|
||||
if ( $this->getEvnUid() == "" ) {
|
||||
throw ( new Exception( "Error in getEvnDescription, the getEvnUid() can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->evn_description = Content::load ( 'EVN_DESCRIPTION', '', $this->getEvnUid(), $lang );
|
||||
return $this->evn_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the evn_description column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setEvnDescription($v)
|
||||
{
|
||||
if ( $this->getEvnUid() == "" ) {
|
||||
throw ( new Exception( "Error in setEvnDescription, the setEvnUid() can't be blank") );
|
||||
}
|
||||
$v=isset($v)?((string)$v):'';
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
if ($this->evn_description !== $v || $v==="") {
|
||||
$this->evn_description = $v;
|
||||
$res = Content::addContent( 'EVN_DESCRIPTION', '', $this->getEvnUid(), $lang, $this->evn_description );
|
||||
return $res;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function load($sUID) {
|
||||
try {
|
||||
$oEvent = EventPeer::retrieveByPK($sUID);
|
||||
if (!is_null($oEvent)) {
|
||||
$aFields = $oEvent->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
$this->setEvnDescription($aFields['EVN_DESCRIPTION'] = $this->getEvnDescription());
|
||||
//$aFields['EVN_CONDITIONS'] = unserialize($aFields['EVN_CONDITIONS']);
|
||||
$aFields['EVN_ACTION_PARAMETERS'] = unserialize($aFields['EVN_ACTION_PARAMETERS']);
|
||||
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function create($aData) {
|
||||
if (!isset($aData['EVN_UID']) || $aData['EVN_UID'] == '' ) {
|
||||
$aData['EVN_UID'] = G::generateUniqueID();
|
||||
}
|
||||
|
||||
$oConnection = Propel::getConnection(EventPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oEvent = new Event();
|
||||
$oEvent->setEvnUid( $aData['EVN_UID'] );
|
||||
$oEvent->setProUid( $aData['PRO_UID'] );
|
||||
$oEvent->setEvnRelatedTo( $aData['EVN_RELATED_TO'] );
|
||||
if ( $aData['EVN_RELATED_TO'] == 'SINGLE' ) {
|
||||
$oEvent->setTasUid( $aData['TAS_UID'] );
|
||||
$oEvent->setEvnTasUidTo( '');
|
||||
$oEvent->setEvnTasUidFrom( '' );
|
||||
}
|
||||
else {
|
||||
$oEvent->setTasUid('');
|
||||
$oEvent->setEvnTasUidTo( $aData['EVN_TAS_UID_TO'] );
|
||||
$oEvent->setEvnTasUidFrom( $aData['EVN_TAS_UID_FROM'] );
|
||||
}
|
||||
$oEvent->setEvnTasEstimatedDuration( $aData['EVN_TAS_ESTIMATED_DURATION'] );
|
||||
$oEvent->setEvnWhenOccurs( $aData['EVN_WHEN_OCCURS'] );
|
||||
$oEvent->setEvnStatus( $aData['EVN_STATUS'] );
|
||||
$oEvent->setEvnWhen( $aData['EVN_WHEN'] );
|
||||
$oEvent->setEvnAction( $aData['EVN_ACTION'] );
|
||||
$oEvent->setEvnMaxAttempts( 3 );
|
||||
$oEvent->setEvnConditions( $aData['EVN_CONDITIONS'] );
|
||||
|
||||
//start the transaction
|
||||
$oConnection->begin();
|
||||
|
||||
$oTrigger = new Triggers();
|
||||
if( trim($aData['TRI_UID']) === "" || ( ! $oTrigger->TriggerExists ( $aData['TRI_UID'] ))){
|
||||
//create an empty trigger
|
||||
|
||||
$aTrigger = array();
|
||||
$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'];;
|
||||
$oTrigger->create($aTrigger);
|
||||
|
||||
} else {
|
||||
$oTrigger = TriggersPeer::retrieveByPk($aData['TRI_UID']);
|
||||
}
|
||||
|
||||
$oEvent->setTriUid( $oTrigger->getTriUid() );
|
||||
|
||||
$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;
|
||||
$parameters->CC = $aData['EVN_ACTION_PARAMETERS']->CC;
|
||||
$parameters->BCC = $aData['EVN_ACTION_PARAMETERS']->BCC;
|
||||
$parameters->TEMPLATE = $aData['EVN_ACTION_PARAMETERS']->TEMPLATE;
|
||||
}
|
||||
|
||||
$oEvent->setEvnActionParameters( serialize ($parameters ) );
|
||||
|
||||
if ($oEvent->validate()) {
|
||||
$iResult = $oEvent->save();
|
||||
$oEvent->setEvnDescription($aData['EVN_DESCRIPTION']);
|
||||
$oConnection->commit();
|
||||
return $aData['EVN_UID'];
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oEvent->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The row Event cannot be created!<br />' . $sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
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'] );
|
||||
$oEvent->setEvnRelatedTo( $aData['EVN_RELATED_TO'] );
|
||||
if ( $aData['EVN_RELATED_TO'] == 'SINGLE' ) {
|
||||
$oEvent->setTasUid( $aData['TAS_UID'] );
|
||||
$oEvent->setEvnTasUidTo( '');
|
||||
$oEvent->setEvnTasUidFrom( '' );
|
||||
}
|
||||
else {
|
||||
$oEvent->setTasUid( '' );
|
||||
$oEvent->setEvnTasUidTo( $aData['EVN_TAS_UID_TO'] );
|
||||
$oEvent->setEvnTasUidFrom( $aData['EVN_TAS_UID_FROM'] );
|
||||
}
|
||||
$oEvent->setEvnTasEstimatedDuration( $aData['EVN_TAS_ESTIMATED_DURATION'] );
|
||||
$oEvent->setEvnWhenOccurs( $aData['EVN_WHEN_OCCURS'] );
|
||||
$oEvent->setEvnStatus( $aData['EVN_STATUS'] );
|
||||
$oEvent->setEvnWhen( $aData['EVN_WHEN'] );
|
||||
|
||||
$oEvent->setTriUid( $aData['TRI_UID'] );
|
||||
$oEvent->setEvnConditions( $aData['EVN_CONDITIONS'] );
|
||||
|
||||
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'])) {
|
||||
|
||||
$oTP = new TemplatePower(PATH_TPL . 'events' . PATH_SEP . 'sendMessage.tpl');
|
||||
$oTP->prepare();
|
||||
|
||||
$oTP->assign('from', 'info@processmaker.com');
|
||||
$oTP->assign('subject', addslashes($aData['EVN_ACTION_PARAMETERS']['SUBJECT']));
|
||||
$oTP->assign('template', $aData['EVN_ACTION_PARAMETERS']['TEMPLATE']);
|
||||
$oTP->assign('timestamp', date("l jS \of F Y h:i:s A"));
|
||||
|
||||
$recipientTO = implode(',', $aData['EVN_ACTION_PARAMETERS']['TO']);
|
||||
$recipientCC = implode(',', $aData['EVN_ACTION_PARAMETERS']['CC']);
|
||||
$recipientBCC = implode(',', $aData['EVN_ACTION_PARAMETERS']['BCC']);
|
||||
|
||||
$oTP->assign('TO', addslashes($recipientTO));
|
||||
$oTP->assign('CC', addslashes($recipientCC));
|
||||
$oTP->assign('BCC', addslashes($recipientBCC));
|
||||
|
||||
$sTrigger = $oTP->getOutputContent();
|
||||
|
||||
$oTrigger = new Triggers();
|
||||
$aTrigger = $oTrigger->load($oEvent->getTriUid());
|
||||
$aTrigger['TRI_WEBBOT'] = $sTrigger;
|
||||
$oTrigger->update($aTrigger);
|
||||
$oParameters = new StdClass();
|
||||
$oParameters->hash = md5($sTrigger);
|
||||
$oParameters->SUBJECT = $aData['EVN_ACTION_PARAMETERS']['SUBJECT'];
|
||||
$oParameters->TO = $aData['EVN_ACTION_PARAMETERS']['TO'];
|
||||
$oParameters->CC = $aData['EVN_ACTION_PARAMETERS']['CC'];
|
||||
$oParameters->BCC = $aData['EVN_ACTION_PARAMETERS']['BCC'];
|
||||
$oParameters->TEMPLATE = $aData['EVN_ACTION_PARAMETERS']['TEMPLATE'];
|
||||
|
||||
//$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']);
|
||||
$iResult = $oEvent->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oEvent->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($sUID) {
|
||||
$oConnection = Propel::getConnection(EventPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oEvent = EventPeer::retrieveByPK($sUID);
|
||||
if (!is_null($oEvent)) {
|
||||
/* with the new feature for events, a event can to relate a existing trigger
|
||||
or more of one events can be reusing the same trigger
|
||||
so, in this point we should't to delete the trigger
|
||||
|
||||
$oConnection->begin();
|
||||
$oTrigger = new Triggers();
|
||||
$oAppEvent = new AppEvent();
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->clearSelectColumns();
|
||||
$oCriteria->addSelectColumn( AppEventPeer::EVN_UID );
|
||||
$oCriteria->addSelectColumn( EventPeer::TRI_UID );
|
||||
$oCriteria->addSelectColumn( AppEventPeer::APP_UID );
|
||||
$oCriteria->addSelectColumn( AppEventPeer::DEL_INDEX );
|
||||
$oCriteria->add(AppEventPeer::EVN_UID, $sUID );
|
||||
$oCriteria->addJoin(EventPeer::EVN_UID, AppEventPeer::EVN_UID, Criteria::JOIN);
|
||||
$oDataset = AppEventPeer::doSelectRs($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while ($row = $oDataset->getRow()) {
|
||||
$oTrigger->remove($row['TRI_UID']);
|
||||
$oAppEvent->remove( $row['APP_UID'], $row['DEL_INDEX'], $sUID );
|
||||
$oDataset->next();
|
||||
}*/
|
||||
Content::removeContent('EVN_DESCRIPTION', '', $oEvent->getEvnUid());
|
||||
|
||||
$iResult = $oEvent->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function calculateEventsExecutionDate() {
|
||||
$line1 = '';
|
||||
$line2 = '';
|
||||
$line1 = $this->calculateExecutionDateSingle();
|
||||
//$line2 = $this->calculateExecutionDateMultiple();
|
||||
return $line1 . "<br>\n" . $line2;
|
||||
}
|
||||
|
||||
function calculateExecutionDateSingle() {
|
||||
try {
|
||||
$rowsCreated = 0;
|
||||
$rowsRejected = 0;
|
||||
G::LoadClass('dates');
|
||||
$oDates = new dates();
|
||||
|
||||
//SELECT
|
||||
// EVENT.PRO_UID,
|
||||
// EVENT.TAS_UID ,
|
||||
// EVENT.EVN_TAS_ESTIMATED_DURATION ,
|
||||
// EVENT.EVN_WHEN,
|
||||
// APP_DELEGATION.APP_UID ,
|
||||
// APP_DELEGATION.DEL_INDEX ,
|
||||
// APP_DELEGATION.TAS_UID ,
|
||||
// APP_DELEGATION.DEL_DELEGATE_DATE ,
|
||||
// APP_DELEGATION.DEL_INIT_DATE ,
|
||||
// APP_DELEGATION.DEL_TASK_DUE_DATE ,
|
||||
// APP_DELEGATION.DEL_FINISH_DATE
|
||||
//from APP_DELEGATION
|
||||
// JOIN EVENT ON ( APP_DELEGATION.TAS_UID = EVENT.TAS_UID AND APP_DELEGATION.DEL_FINISH_DATE IS NULL )
|
||||
// LEFT JOIN APP_EVENT ON ( APP_EVENT.APP_UID = APP_DELEGATION.APP_UID AND APP_EVENT.DEL_INDEX = APP_DELEGATION.DEL_INDEX )
|
||||
// WHERE
|
||||
// APP_EVENT.APP_UID IS NULL
|
||||
// and EVN_STATUS = 'ACTIVE'
|
||||
// AND EVN_RELATED_TO = 'SINGLE'
|
||||
// and DEL_FINISH_DATE IS NULL
|
||||
//-- 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);
|
||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::TAS_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_ESTIMATED_DURATION);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN_OCCURS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_MAX_ATTEMPTS);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
|
||||
$aConditions = array();
|
||||
$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 );
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
|
||||
$oCriteria->add(AppEventPeer::APP_UID, null, Criteria::ISNULL );
|
||||
$oCriteria->add(EventPeer::EVN_STATUS, 'ACTIVE' );
|
||||
$oCriteria->add(EventPeer::EVN_RELATED_TO, 'SINGLE' );
|
||||
$oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL );
|
||||
// $oCriteria->add(AppDelegationPeer::DEL_DELEGATE_DATE, date('Y-m-d') , Criteria::GREATER_THAN );
|
||||
$oDataset = EventPeer::doSelectRs($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$aRows = Array();
|
||||
while($oDataset->next()) $aRows[]= $oDataset->getRow();
|
||||
|
||||
g::pr($aRows);
|
||||
die;
|
||||
|
||||
$oDataset->next();
|
||||
|
||||
while ($aData = $oDataset->getRow()) {
|
||||
$estimatedDuration = (float)$aData['EVN_TAS_ESTIMATED_DURATION'];
|
||||
$when = (float)$aData['EVN_WHEN'];
|
||||
$whenOccurs = $aData['EVN_WHEN_OCCURS'];
|
||||
|
||||
if ( $whenOccurs == 'AFTER_TIME' ) {
|
||||
//for multiple $sDueDate = date('Y-m-d H:i:s', $oDates->calculateDate($aData['DEL_DELEGATE_DATE'], $estimatedDuration, 'days', 1));
|
||||
$sDueDate = $aData['DEL_TASK_DUE_DATE'];
|
||||
$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 {
|
||||
$sDueDate = $aData['DEL_DELEGATE_DATE'];
|
||||
$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'] );
|
||||
}
|
||||
$aData['APP_EVN_ACTION_DATE'] = $sActionDate;
|
||||
$aData['APP_EVN_ATTEMPTS'] = $aData['EVN_MAX_ATTEMPTS'];
|
||||
|
||||
if ( $validStartDate ) {
|
||||
$rowsCreated++ ;
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->create( $aData );
|
||||
}
|
||||
else {
|
||||
$rowsRejected++;
|
||||
$aData['APP_EVN_STATUS'] = 'INVALID';
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->create( $aData );
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
return "Created $rowsCreated SINGLE rows in APP_EVENT and rejected $rowsRejected rows ";
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw new Exception ( $oError->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function calculateExecutionDateMultiple() {
|
||||
try {
|
||||
$rowsCreated = 0;
|
||||
$rowsRejected = 0;
|
||||
G::LoadClass('dates');
|
||||
$oDates = new dates();
|
||||
// SELECT TASK2.* ,
|
||||
// EVENT.EVN_UID, EVENT.PRO_UID, EVENT.EVN_TAS_UID_FROM,
|
||||
// EVENT.EVN_TAS_ESTIMATED_DURATION, EVENT.EVN_WHEN,
|
||||
// EVENT.EVN_WHEN_OCCURS, EVENT.EVN_RELATED_TO, APP_DELEGATION.APP_UID, APP_DELEGATION.DEL_INDEX, APP_DELEGATION.TAS_UID,
|
||||
// APP_DELEGATION.DEL_DELEGATE_DATE, APP_DELEGATION.DEL_INIT_DATE, APP_DELEGATION.DEL_TASK_DUE_DATE,
|
||||
// APP_DELEGATION.DEL_FINISH_DATE
|
||||
// FROM
|
||||
// APP_DELEGATION
|
||||
// LEFT JOIN EVENT ON (APP_DELEGATION.TAS_UID=EVENT.EVN_TAS_UID_FROM)
|
||||
// LEFT JOIN APP_EVENT ON (APP_DELEGATION.APP_UID=APP_EVENT.APP_UID AND APP_DELEGATION.DEL_INDEX=APP_EVENT.DEL_INDEX)
|
||||
// LEFT JOIN APP_DELEGATION AS TASK2 ON (TASK2.TAS_UID = EVENT.EVN_TAS_UID_TO AND TASK2.APP_UID = APP_DELEGATION.APP_UID )
|
||||
//
|
||||
// WHERE
|
||||
// APP_EVENT.APP_UID IS NULL
|
||||
// AND EVENT.EVN_STATUS='ACTIVE'
|
||||
// AND EVENT.EVN_RELATED_TO='MULTIPLE'
|
||||
// AND TASK2.DEL_FINISH_DATE IS NULL
|
||||
//get info about the Event and the APP_DELEGATION to process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_UID_FROM );
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_ESTIMATED_DURATION);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN_OCCURS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||
$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::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 );
|
||||
$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' );
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
|
||||
$oCriteria->add(AppEventPeer::APP_UID, null, Criteria::ISNULL );
|
||||
$oCriteria->add(EventPeer::EVN_STATUS, 'ACTIVE' );
|
||||
$oCriteria->add(EventPeer::EVN_RELATED_TO, 'MULTIPLE' );
|
||||
$oCriteria->add('DEL2.DEL_FINISH_DATE', null, Criteria::ISNULL );
|
||||
// $oCriteria->add(AppDelegationPeer::DEL_DELEGATE_DATE, date('Y-m-d') , Criteria::GREATER_THAN );
|
||||
$oDataset = EventPeer::doSelectRs($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while ($aData = $oDataset->getRow()) {
|
||||
$estimatedDuration = (float)$aData['EVN_TAS_ESTIMATED_DURATION'];
|
||||
$when = (float)$aData['EVN_WHEN'];
|
||||
$whenOccurs = $aData['EVN_WHEN_OCCURS'];
|
||||
|
||||
if ( $whenOccurs == 'AFTER_TIME' ) {
|
||||
//for multiple $sDueDate = date('Y-m-d H:i:s', $oDates->calculateDate($aData['DEL_DELEGATE_DATE'], $estimatedDuration, 'days', 1));
|
||||
$sDueDate = $aData['DEL_TASK_DUE_DATE'];
|
||||
$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 {
|
||||
$sDueDate = $aData['DEL_DELEGATE_DATE'];
|
||||
$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'] );
|
||||
}
|
||||
$aData['APP_EVN_ACTION_DATE'] = $sActionDate;
|
||||
|
||||
if ( $validStartDate ) {
|
||||
$rowsCreated++ ;
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->create( $aData );
|
||||
}
|
||||
else {
|
||||
$rowsRejected++;
|
||||
$aData['APP_EVN_STATUS'] = 'INVALID';
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->create( $aData );
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
return "Created $rowsCreated MULTIPLE rows in APP_EVENT and rejected $rowsRejected rows ";
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw new Exception ( $oError->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function closeAppEvents($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID){
|
||||
|
||||
$aAppEvents = $this->getAppEvents($APP_UID, $DEL_INDEX);
|
||||
if($aAppEvents){
|
||||
foreach ( $aAppEvents as $aRow ) {
|
||||
if($aRow['EVN_RELATED_TO'] == 'SINGLE' || ($aRow['EVN_RELATED_TO'] == $TAS_UID) ){
|
||||
$oAppEvent = AppEventPeer::retrieveByPK($aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID']);
|
||||
$oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
|
||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||
$oAppEvent->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function createAppEvents($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID){
|
||||
$aRows = Array();
|
||||
$aEventsRows = $this->getBy($PRO_UID, Array('TAS_UID'=>$TAS_UID));
|
||||
if( $aEventsRows !== false ){
|
||||
$aRows = array_merge($aRows, $aEventsRows);
|
||||
}
|
||||
|
||||
$aEventsRows = $this->getBy($PRO_UID, Array('EVN_TAS_UID_FROM'=>$TAS_UID));
|
||||
if( $aEventsRows !== false ){
|
||||
$aRows = array_merge($aRows, $aEventsRows);
|
||||
}
|
||||
|
||||
foreach($aRows as $aData){
|
||||
|
||||
// if the events has a condition
|
||||
if( trim($aData['EVN_CONDITIONS']) != '' ) {
|
||||
G::LoadClass('case');
|
||||
$oCase = new Cases();
|
||||
$aFields = $oCase->loadCase($APP_UID);
|
||||
|
||||
$Fields = $aFields['APP_DATA'];
|
||||
$conditionContents = trim($aData['EVN_CONDITIONS']);
|
||||
|
||||
//$sContent = G::unhtmlentities($sContent);
|
||||
$iAux = 0;
|
||||
$iOcurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $conditionContents, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
|
||||
if ($iOcurrences) {
|
||||
for($i = 0; $i < $iOcurrences; $i++) {
|
||||
preg_match_all('/@>' . $aMatch[2][$i][0] . '([\w\W]*)' . '@<' . $aMatch[2][$i][0] . '/', $conditionContents, $aMatch2, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
$sGridName = $aMatch[2][$i][0];
|
||||
$sStringToRepeat = $aMatch2[1][0][0];
|
||||
if (isset($Fields[$sGridName])) {
|
||||
if (is_array($Fields[$sGridName])) {
|
||||
$sAux = '';
|
||||
foreach ($Fields[$sGridName] as $aRow) {
|
||||
$sAux .= G::replaceDataField($sStringToRepeat, $aRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
$conditionContents = str_replace('@>' . $sGridName . $sStringToRepeat . '@<' . $sGridName, $sAux, $conditionContents);
|
||||
}
|
||||
}
|
||||
|
||||
$sCondition = G::replaceDataField( $conditionContents, $Fields);
|
||||
|
||||
$evalConditionResult = false;
|
||||
|
||||
$sCond = 'try{ $evalConditionResult=('.$sCondition.')? true: false; } catch(Exception $e){$evalConditionResult=false;}';
|
||||
@eval($sCond);
|
||||
|
||||
if( !$evalConditionResult ){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$appEventData['APP_UID'] = $APP_UID;
|
||||
$appEventData['DEL_INDEX'] = $DEL_INDEX;
|
||||
$appEventData['EVN_UID'] = $aData['EVN_UID'];
|
||||
$appEventData['APP_EVN_ACTION_DATE'] = $this->toCalculateTime($aData);
|
||||
$appEventData['APP_EVN_ATTEMPTS'] = 3;
|
||||
$appEventData['APP_EVN_LAST_EXECUTION_DATE'] = null;
|
||||
$appEventData['APP_EVN_STATUS'] = 'OPEN';
|
||||
|
||||
$oAppEvent = new AppEvent();
|
||||
$oAppEvent->create( $appEventData );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function getBy($PRO_UID, $aFilers){
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_STATUS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN_OCCURS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
|
||||
$oCriteria->addSelectColumn(EventPeer::TAS_UID );
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_UID_FROM );
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_UID_TO );
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_ESTIMATED_DURATION);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_MAX_ATTEMPTS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_CONDITIONS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
|
||||
$oCriteria->addSelectColumn(EventPeer::TRI_UID);
|
||||
|
||||
$oCriteria->add(EventPeer::EVN_STATUS, 'ACTIVE' );
|
||||
foreach($aFilers as $sFilter=>$sValue){
|
||||
switch($sFilter){
|
||||
case 'TAS_UID':
|
||||
$oCriteria->add(EventPeer::TAS_UID, $sValue, Criteria::EQUAL);
|
||||
break;
|
||||
case 'EVN_TAS_UID_FROM':
|
||||
$oCriteria->add(EventPeer::EVN_TAS_UID_FROM, $sValue, Criteria::EQUAL);
|
||||
break;
|
||||
case 'EVN_TAS_UID_TO':
|
||||
$oCriteria->add(EventPeer::EVN_TAS_UID_TO, $sValue, Criteria::EQUAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$oDataset = EventPeer::doSelectRs($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$aRows = Array();
|
||||
while($oDataset->next()) $aRows[]= $oDataset->getRow();
|
||||
|
||||
return (count($aRows) > 0)? $aRows: false;
|
||||
}
|
||||
|
||||
function getAppEvents($APP_UID, $DEL_INDEX){
|
||||
//for single task event
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_UID);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS );
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
|
||||
$oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_STATUS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN_OCCURS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
|
||||
$oCriteria->addSelectColumn(EventPeer::TAS_UID );
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_UID_FROM );
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_UID_TO );
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_TAS_ESTIMATED_DURATION);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_WHEN);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_MAX_ATTEMPTS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_CONDITIONS);
|
||||
$oCriteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
|
||||
$oCriteria->addSelectColumn(EventPeer::TRI_UID);
|
||||
|
||||
$oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID);
|
||||
|
||||
$oCriteria->add(AppEventPeer::APP_UID, $APP_UID);
|
||||
$oCriteria->add(AppEventPeer::DEL_INDEX, $DEL_INDEX);
|
||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
|
||||
|
||||
$oDataset = AppEventPeer::doSelectRs($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$aRows = Array();
|
||||
while($oDataset->next()) $aRows[]= $oDataset->getRow();
|
||||
|
||||
return (count($aRows) > 0)? $aRows: false;
|
||||
}
|
||||
|
||||
function toCalculateTime($aData, $iDate=null){
|
||||
G::LoadClass('dates');
|
||||
$oDates = new dates();
|
||||
|
||||
$iDate = isset($iDate)? $iDate: date('Y-m-d H:i:s');
|
||||
|
||||
$estimatedDuration = $aData['EVN_TAS_ESTIMATED_DURATION']; //task duration
|
||||
$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);
|
||||
|
||||
$sActionDate = date('Y-m-d H:i:s', $calculatedDueDateA['DUE_DATE_SECONDS']);
|
||||
} else {
|
||||
$calculatedDueDateA=$oDates->calculateDate( $iDate, $estimatedDuration+$when, 'days', 1);
|
||||
$sActionDate = date('Y-m-d H:i:s', $calculatedDueDateA['DUE_DATE_SECONDS']);
|
||||
}
|
||||
|
||||
return $sActionDate;
|
||||
}
|
||||
|
||||
function Exists ( $sUid ) {
|
||||
try {
|
||||
$oObj = EventPeer::retrieveByPk($sUid);
|
||||
return (get_class($oObj) == 'Event');
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
} // Event
|
||||
?>
|
||||
23
workflow/engine/classes/model/EventPeer.php
Normal file
23
workflow/engine/classes/model/EventPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseEventPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Event.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'EVENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class EventPeer extends BaseEventPeer {
|
||||
|
||||
} // EventPeer
|
||||
345
workflow/engine/classes/model/FieldCondition.php
Normal file
345
workflow/engine/classes/model/FieldCondition.php
Normal file
@@ -0,0 +1,345 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseFieldCondition.php';
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'FIELD_CONDITION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class FieldCondition extends BaseFieldCondition {
|
||||
|
||||
var $oDynaformHandler;
|
||||
/**
|
||||
* Quick get all records into a criteria object
|
||||
*
|
||||
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
||||
*/
|
||||
public function get( $UID ) {
|
||||
|
||||
$obj = FieldConditionPeer::retrieveByPk($UID);
|
||||
if( !isset($obj) ) {
|
||||
throw new Exception("the record with UID: $UID doesn't exits!");
|
||||
}
|
||||
//TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
return $obj->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick get all records into a criteria object
|
||||
*
|
||||
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
||||
*/
|
||||
public function getAllCriteriaByDynUid( $DYN_UID, $filter='all' ) {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_UID);
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_FUNCTION);
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_FIELDS);
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_CONDITION);
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_EVENTS);
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_EVENT_OWNERS);
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_STATUS);
|
||||
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_DYN_UID);
|
||||
|
||||
$oCriteria->add(FieldConditionPeer::FCD_DYN_UID, $DYN_UID);
|
||||
switch( $filter ) {
|
||||
case 'active':
|
||||
$oCriteria->add(FieldConditionPeer::FCD_STATUS, '1', Criteria::EQUAL);
|
||||
break;
|
||||
}
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick get all records into a associative array
|
||||
*
|
||||
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
||||
*/
|
||||
public function getAllByDynUid( $DYN_UID, $filter='all' ) {
|
||||
$aRows = Array();
|
||||
|
||||
$oCriteria = $this->getAllCriteriaByDynUid($DYN_UID, $filter);
|
||||
|
||||
$oDataset = FieldConditionPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while( $aRow = $oDataset->getRow() ) {
|
||||
$aRows[] = $aRow;
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
return $aRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick save a record
|
||||
*
|
||||
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
||||
*/
|
||||
public function quickSave($aData) {
|
||||
$con = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
|
||||
try {
|
||||
if( isset($aData['FCD_UID']) && trim($aData['FCD_UID']) != '' ) {
|
||||
$obj = FieldConditionPeer::retrieveByPk( $aData['FCD_UID'] );
|
||||
if( get_class($obj) != 'FieldCondition') {
|
||||
$obj = new FieldCondition();
|
||||
}
|
||||
} else {
|
||||
if ( isset ( $aData['FCD_UID'] ) && $aData['FCD_UID']== '' )
|
||||
unset ( $aData['FCD_UID'] );
|
||||
if ( !isset ( $aData['FCD_UID'] ) )
|
||||
$aData['FCD_UID'] = G::generateUniqueID();
|
||||
$obj = new FieldCondition();
|
||||
}
|
||||
|
||||
$obj->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($obj->validate()) {
|
||||
$result = $obj->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
} else {
|
||||
$e = new Exception("Failed Validation in class " . get_class($this) . ".");
|
||||
$e->aValidationFailures = $obj->getValidationFailures();
|
||||
throw ($e);
|
||||
}
|
||||
} catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function getConditionScript($DYN_UID) {
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
G::LoadSystem('dynaformhandler');
|
||||
|
||||
$oDynaform = DynaformPeer::retrieveByPk($DYN_UID);
|
||||
$PRO_UID = $oDynaform->getProUid();
|
||||
|
||||
$this->oDynaformHandler = new dynaFormHandler(PATH_DYNAFORM . "$PRO_UID/$DYN_UID" . '.xml');
|
||||
$aDynaformFields = $this->oDynaformHandler->getFieldNames();
|
||||
for ( $i = 0; $i < count($aDynaformFields); $i++ ) {
|
||||
$aDynaformFields[$i] = "'$aDynaformFields[$i]'";
|
||||
}
|
||||
|
||||
$sDynaformFieldsAsStrings = implode(',', $aDynaformFields);
|
||||
|
||||
$aRows = $this->getAllByDynUid($DYN_UID, 'active');
|
||||
$sCode = '';
|
||||
|
||||
if( sizeof($aRows) != 0 ) {
|
||||
|
||||
foreach ( $aRows as $aRow ) {
|
||||
$hashCond = md5($aRow['FCD_UID']);
|
||||
$sCondition = $this->parseCondition($aRow['FCD_CONDITION']);
|
||||
$sCondition = addslashes($sCondition);
|
||||
|
||||
$sCode .= "function __condition__$hashCond() { ";
|
||||
$sCode .= "if( eval(\"{$sCondition}\") ) { ";
|
||||
|
||||
$aFields = explode(',', $aRow['FCD_FIELDS']);
|
||||
|
||||
switch( $aRow['FCD_FUNCTION'] ) {
|
||||
case 'show':
|
||||
foreach ( $aFields as $aField ) {
|
||||
$sCode .= "showRowById('$aField');";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'showOnly':
|
||||
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
|
||||
foreach ( $aFields as $aField ) {
|
||||
$sCode .= "showRowById('$aField');";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'showAll':
|
||||
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
|
||||
break;
|
||||
|
||||
case 'hide':
|
||||
foreach ( $aFields as $aField ) {
|
||||
$sCode .= "hideRowById('$aField');";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'hideOnly':
|
||||
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
|
||||
foreach ( $aFields as $aField ) {
|
||||
$sCode .= "hideRowById('$aField');";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'hideAll':
|
||||
$aDynaFields = array();
|
||||
$aEventOwner = explode(',', $aRow['FCD_EVENT_OWNERS'] );
|
||||
foreach($aDynaformFields as $sDynaformFields){
|
||||
if(! in_array(str_replace("'", "", $sDynaformFields), $aEventOwner) ) {
|
||||
$aDynaFields[] = $sDynaformFields;
|
||||
}
|
||||
}
|
||||
$sDynaformFieldsAsStrings = implode(',', $aDynaFields);
|
||||
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
|
||||
|
||||
break;
|
||||
}
|
||||
$sCode .= " } ";
|
||||
$sCode .= "} ";
|
||||
$aFieldOwners = explode(',', $aRow['FCD_EVENT_OWNERS']);
|
||||
$aEvents = explode(',', $aRow['FCD_EVENTS']);
|
||||
if( in_array('onchange', $aEvents) ) {
|
||||
foreach ( $aFieldOwners as $aField ) {
|
||||
|
||||
//verify the field type
|
||||
$node = $this->oDynaformHandler->getNode($aField);
|
||||
$nodeType = $node->getAttribute('type');
|
||||
|
||||
switch($nodeType){
|
||||
case 'checkbox':
|
||||
$sJSEvent = 'click';
|
||||
break;
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'currency':
|
||||
case 'percentage':
|
||||
$sJSEvent = 'blur';
|
||||
break;
|
||||
|
||||
default:
|
||||
$sJSEvent = 'change';
|
||||
break;
|
||||
}
|
||||
$sCode .= "leimnud.event.add(getField('$aField'), '$sJSEvent', function() {";
|
||||
$sCode .= " __condition__$hashCond(); ";
|
||||
$sCode .= "}.extend(getField('$aField')));";
|
||||
}
|
||||
|
||||
}
|
||||
if( in_array('onload', $aEvents) ) {
|
||||
foreach ( $aFieldOwners as $aField ) {
|
||||
$sCode .= " __condition__$hashCond(); ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $sCode;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function parseCondition($sCondition) {
|
||||
preg_match_all('/@#[a-zA-Z0-9_.]+/', $sCondition, $result);
|
||||
if ( sizeof($result[0]) > 0 ) {
|
||||
foreach( $result[0] as $fname ) {
|
||||
preg_match_all('/(@#[a-zA-Z0-9_]+)\.([@#[a-zA-Z0-9_]+)/', $fname, $result2);
|
||||
if( isset($result2[2][0]) && $result2[1][0]){
|
||||
$sCondition = str_replace($fname, "getField('".str_replace('@#', '', $result2[1][0])."').".$result2[2][0], $sCondition);
|
||||
} else {
|
||||
$field = str_replace('@#', '', $fname);
|
||||
$node = $this->oDynaformHandler->getNode($field);
|
||||
if(isset($node)) {
|
||||
$nodeType = $node->getAttribute('type');
|
||||
switch($nodeType){
|
||||
case 'checkbox':
|
||||
$sAtt = 'checked';
|
||||
break;
|
||||
default:
|
||||
$sAtt = 'value';
|
||||
}
|
||||
} else {
|
||||
$sAtt = 'value';
|
||||
}
|
||||
$sCondition = str_replace($fname, "getField('".$field."').$sAtt", $sCondition);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sCondition;
|
||||
}
|
||||
|
||||
public function create($aData) {
|
||||
$oConnection = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
|
||||
try {
|
||||
// $aData['FCD_UID'] = '';
|
||||
if ( isset ( $aData['FCD_UID'] ) && $aData['FCD_UID']== '' )
|
||||
unset ( $aData['FCD_UID'] );
|
||||
if ( !isset ( $aData['FCD_UID'] ) )
|
||||
$aData['FCD_UID'] = G::generateUniqueID();
|
||||
|
||||
$oFieldCondition = new FieldCondition();
|
||||
$oFieldCondition->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oFieldCondition->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oFieldCondition->save();
|
||||
$oConnection->commit();
|
||||
return true;
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oFieldCondition->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function remove($sUID) {
|
||||
$oConnection = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oConnection->begin();
|
||||
$this->setFcdUid($sUID);
|
||||
$iResult = $this->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function fieldConditionExists ( $sUid, $aDynaform ) {
|
||||
try {
|
||||
$found = false;
|
||||
$obj = FieldConditionPeer::retrieveByPk( $sUid );
|
||||
if( isset($obj) ) {
|
||||
$aFields = $obj->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
foreach($aDynaform as $key => $row){
|
||||
if($row['DYN_UID'] == $aFields['FCD_DYN_UID'])
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
// return( get_class($obj) == 'FieldCondition') ;
|
||||
return($found);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function Exists ( $sUid ) {
|
||||
try {
|
||||
$obj = FieldConditionPeer::retrieveByPk( $sUid );
|
||||
return( get_class($obj) == 'FieldCondition') ;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
} // FieldCondition
|
||||
23
workflow/engine/classes/model/FieldConditionPeer.php
Normal file
23
workflow/engine/classes/model/FieldConditionPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseFieldConditionPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/FieldCondition.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'FIELD_CONDITION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class FieldConditionPeer extends BaseFieldConditionPeer {
|
||||
|
||||
} // FieldConditionPeer
|
||||
119
workflow/engine/classes/model/Fields.php
Normal file
119
workflow/engine/classes/model/Fields.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseFields.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'FIELDS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Fields extends BaseFields {
|
||||
public function load($sUID) {
|
||||
try {
|
||||
$oFields = FieldsPeer::retrieveByPK($sUID);
|
||||
if (!is_null($oFields)) {
|
||||
$aFields = $oFields->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function create($aData) {
|
||||
if (!isset($aData['FLD_UID'])) {
|
||||
$aData['FLD_UID'] = G::generateUniqueID();
|
||||
}
|
||||
else {
|
||||
if ($aData['FLD_UID'] == '') {
|
||||
$aData['FLD_UID'] = G::generateUniqueID();
|
||||
}
|
||||
}
|
||||
$oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oFields = new Fields();
|
||||
$oFields->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oFields->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oFields->save();
|
||||
$oConnection->commit();
|
||||
return $aData['FLD_UID'];
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oFields->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />' . $sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function update($aData) {
|
||||
$oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oFields = FieldsPeer::retrieveByPK($aData['FLD_UID']);
|
||||
if (!is_null($oFields)) {
|
||||
$oFields->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oFields->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oFields->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oFields->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($sUID) {
|
||||
$oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oFields = FieldsPeer::retrieveByPK($sUID);
|
||||
if (!is_null($oFields)) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oFields->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
} // Fields
|
||||
23
workflow/engine/classes/model/FieldsPeer.php
Normal file
23
workflow/engine/classes/model/FieldsPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseFieldsPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Fields.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'FIELDS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class FieldsPeer extends BaseFieldsPeer {
|
||||
|
||||
} // FieldsPeer
|
||||
102
workflow/engine/classes/model/GroupUser.php
Normal file
102
workflow/engine/classes/model/GroupUser.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* GroupUser.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseGroupUser.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'GROUP_USER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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 input directory.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class GroupUser extends BaseGroupUser {
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(GroupUserPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oGroupUser = new GroupUser();
|
||||
$oGroupUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oGroupUser->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oGroupUser->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oGroupUser->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
* @param string $sGrpUid
|
||||
* @param string $sUserUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sGrpUid, $sUserUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(GroupUserPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oGroupUser = GroupUserPeer::retrieveByPK($sGrpUid, $sUserUid);
|
||||
if (!is_null($oGroupUser))
|
||||
{
|
||||
$oConnection->begin();
|
||||
$iResult = $oGroupUser->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
} // GroupUser
|
||||
46
workflow/engine/classes/model/GroupUserPeer.php
Normal file
46
workflow/engine/classes/model/GroupUserPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* GroupUserPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseGroupUserPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/GroupUser.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'GROUP_USER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class GroupUserPeer extends BaseGroupUserPeer {
|
||||
|
||||
} // GroupUserPeer
|
||||
263
workflow/engine/classes/model/Groupwf.php
Normal file
263
workflow/engine/classes/model/Groupwf.php
Normal file
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
/**
|
||||
* Groupwf.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseGroupwf.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'GROUPWF' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Groupwf extends BaseGroupwf {
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $grp_title = '';
|
||||
|
||||
/**
|
||||
* Get the [grp_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getGrpTitle()
|
||||
{
|
||||
if ( $this->getGrpUid() == '' ) {
|
||||
throw ( new Exception( "Error in getGrpTitle, the GRP_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->grp_title = Content::load ( 'GRP_TITLE', '', $this->getGrpUid(), $lang );
|
||||
return $this->grp_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [grp_title] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setGrpTitle($v)
|
||||
{
|
||||
if ( $this->getGrpUid() == '' ) {
|
||||
throw ( new Exception( "Error in setGrpTitle, the GRP_UID can't be blank") );
|
||||
}
|
||||
// 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->grp_title !== $v || $v === '') {
|
||||
$this->grp_title = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'GRP_TITLE', '', $this->getGrpUid(), $lang, $this->grp_title );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
/**
|
||||
* Creates the Group
|
||||
*
|
||||
* @param array $aData $oData is not necessary
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($aData ) {
|
||||
//$oData is not necessary
|
||||
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
|
||||
try {
|
||||
if ( isset ( $aData['GRP_UID'] ) )
|
||||
$this->setGrpUid ( $aData['GRP_UID'] );
|
||||
else
|
||||
$this->setGrpUid ( G::generateUniqueID() );
|
||||
|
||||
if ( isset ( $aData['GRP_STATUS'] ) )
|
||||
$this->setGrpStatus ( $aData['GRP_STATUS'] );
|
||||
else
|
||||
$this->setGrpStatus ( 'ACTIVE' );
|
||||
|
||||
if ( $this->validate() ) {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
if (isset ( $aData['GRP_TITLE'] ) )
|
||||
$this->setGrpTitle ( $aData['GRP_TITLE'] );
|
||||
else
|
||||
$this->setGrpTitle ( 'Default Group Title' );
|
||||
|
||||
$con->commit();
|
||||
return $this->getGrpUid();
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Process row specified in [grp_id] column value.
|
||||
*
|
||||
* @param string $ProUid the uid of the Prolication
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $ProUid ) {
|
||||
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oPro = GroupwfPeer::retrieveByPk( $ProUid );
|
||||
if ( get_class ($oPro) == 'Groupwf' ) {
|
||||
$aFields = $oPro->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$aFields['GRP_TITLE'] = $oPro->getGrpTitle();
|
||||
$this->setGrpTitle ( $oPro->getGrpTitle() );
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Group row
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oPro = GroupwfPeer::retrieveByPK( $aData['GRP_UID'] );
|
||||
if ( get_class ($oPro) == 'Groupwf' ) {
|
||||
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oPro->validate()) {
|
||||
if ( isset ( $aData['GRP_TITLE'] ) )
|
||||
$oPro->setGrpTitle( $aData['GRP_TITLE'] );
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "The row '" . $aData['GRP_UID'] . "' in table Group doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the Prolication document registry
|
||||
* @param array $aData or string $ProUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($ProUid)
|
||||
{
|
||||
if ( is_array ( $ProUid ) ) {
|
||||
$ProUid = ( isset ( $ProUid['GRP_UID'] ) ? $ProUid['GRP_UID'] : '' );
|
||||
}
|
||||
try {
|
||||
$oPro = GroupwfPeer::retrieveByPK( $ProUid );
|
||||
if (!is_null($oPro))
|
||||
{
|
||||
Content::removeContent('GRP_TITLE', '', $oPro->getGrpUid());
|
||||
Content::removeContent('GRP_DESCRIPTION', '', $oPro->getGrpUid());
|
||||
return $oPro->delete();
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verify if row specified in [GrpUid] exists.
|
||||
*
|
||||
* @param string $sProUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function GroupwfExists ( $GrpUid ) {
|
||||
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oPro = GroupwfPeer::retrieveByPk( $GrpUid );
|
||||
if ( get_class ($oPro) == 'Groupwf' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function loadByGroupname ( $Groupname ) {
|
||||
$c = new Criteria('workflow');
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
|
||||
$c->addSelectColumn( ContentPeer::CON_VALUE );
|
||||
|
||||
$c->add(ContentPeer::CON_CATEGORY, 'GRP_TITLE');
|
||||
$c->add(ContentPeer::CON_VALUE, $Groupname);
|
||||
$c->add(ContentPeer::CON_LANG, SYS_LANG );
|
||||
return $c;
|
||||
}
|
||||
|
||||
} // Groupwf
|
||||
46
workflow/engine/classes/model/GroupwfPeer.php
Normal file
46
workflow/engine/classes/model/GroupwfPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* GroupwfPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseGroupwfPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Groupwf.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'GROUPWF' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class GroupwfPeer extends BaseGroupwfPeer {
|
||||
|
||||
} // GroupwfPeer
|
||||
42
workflow/engine/classes/model/Holiday.php
Normal file
42
workflow/engine/classes/model/Holiday.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Holiday.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseHoliday.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'HOLIDAY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Holiday extends BaseHoliday {
|
||||
|
||||
} // Holiday
|
||||
46
workflow/engine/classes/model/HolidayPeer.php
Normal file
46
workflow/engine/classes/model/HolidayPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* HolidayPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseHolidayPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Holiday.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'HOLIDAY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class HolidayPeer extends BaseHolidayPeer {
|
||||
|
||||
} // HolidayPeer
|
||||
317
workflow/engine/classes/model/InputDocument.php
Normal file
317
workflow/engine/classes/model/InputDocument.php
Normal file
@@ -0,0 +1,317 @@
|
||||
<?php
|
||||
/**
|
||||
* InputDocument.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseInputDocument.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'INPUT_DOCUMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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 input directory.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class InputDocument extends BaseInputDocument {
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $inp_doc_title = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $inp_doc_description = '';
|
||||
|
||||
/*
|
||||
* Load the application document registry
|
||||
* @param string $sAppDocUid
|
||||
* @return variant
|
||||
*/
|
||||
public function load($sInpDocUid)
|
||||
{
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($sInpDocUid);
|
||||
if (!is_null($oInputDocument))
|
||||
{
|
||||
$aFields = $oInputDocument->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
||||
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function getByUid($sInpDocUid)
|
||||
{
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($sInpDocUid);
|
||||
if( is_null($oInputDocument))
|
||||
return false;
|
||||
|
||||
$aFields = $oInputDocument->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
||||
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
if ( isset ( $aData['INP_DOC_UID'] ) && $aData['INP_DOC_UID']== '' )
|
||||
unset ( $aData['INP_DOC_UID'] );
|
||||
if ( !isset ( $aData['INP_DOC_UID'] ) )
|
||||
$aData['INP_DOC_UID'] = G::generateUniqueID();
|
||||
$oInputDocument = new InputDocument();
|
||||
$oInputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oInputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['INP_DOC_TITLE'])) {
|
||||
$oInputDocument->setInpDocTitle($aData['INP_DOC_TITLE']);
|
||||
}
|
||||
if (isset($aData['INP_DOC_DESCRIPTION'])) {
|
||||
$oInputDocument->setInpDocDescription($aData['INP_DOC_DESCRIPTION']);
|
||||
}
|
||||
$iResult = $oInputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $aData['INP_DOC_UID'];
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oInputDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($aData['INP_DOC_UID']);
|
||||
if (!is_null($oInputDocument))
|
||||
{
|
||||
$oInputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oInputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['INP_DOC_TITLE']))
|
||||
{
|
||||
$oInputDocument->setInpDocTitle($aData['INP_DOC_TITLE']);
|
||||
}
|
||||
if (isset($aData['INP_DOC_DESCRIPTION']))
|
||||
{
|
||||
$oInputDocument->setInpDocDescription($aData['INP_DOC_DESCRIPTION']);
|
||||
}
|
||||
$iResult = $oInputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oInputDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sInpDocUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($sInpDocUid);
|
||||
if (!is_null($oInputDocument))
|
||||
{
|
||||
$oConnection->begin();
|
||||
Content::removeContent('INP_DOC_TITLE', '', $oInputDocument->getInpDocUid());
|
||||
Content::removeContent('INP_DOC_DESCRIPTION', '', $oInputDocument->getInpDocUid());
|
||||
$iResult = $oInputDocument->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [inp_doc_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getInpDocTitle()
|
||||
{
|
||||
if ($this->inp_doc_title == '') {
|
||||
try {
|
||||
$this->inp_doc_title = Content::load('INP_DOC_TITLE', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->inp_doc_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [inp_doc_title] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setInpDocTitle($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->inp_doc_title !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->inp_doc_title = $sValue;
|
||||
$iResult = Content::addContent('INP_DOC_TITLE', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->inp_doc_title);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->inp_doc_title = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [inp_doc_comment] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getInpDocDescription()
|
||||
{
|
||||
if ($this->inp_doc_description == '') {
|
||||
try {
|
||||
$this->inp_doc_description = Content::load('INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->inp_doc_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [inp_doc_comment] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setInpDocDescription($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->inp_doc_description !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->inp_doc_description = $sValue;
|
||||
$iResult = Content::addContent('INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->inp_doc_description);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->inp_doc_description = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verify if Input row specified in [DynUid] exists.
|
||||
*
|
||||
* @param string $sUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function InputExists ( $sUid ) {
|
||||
$con = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oObj = InputDocumentPeer::retrieveByPk( $sUid );
|
||||
if ( get_class ($oObj) == 'InputDocument' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
} // InputDocument
|
||||
46
workflow/engine/classes/model/InputDocumentPeer.php
Normal file
46
workflow/engine/classes/model/InputDocumentPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* InputDocumentPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseInputDocumentPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/InputDocument.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'INPUT_DOCUMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class InputDocumentPeer extends BaseInputDocumentPeer {
|
||||
|
||||
} // InputDocumentPeer
|
||||
62
workflow/engine/classes/model/IsoCountry.php
Normal file
62
workflow/engine/classes/model/IsoCountry.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* IsoCountry.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseIsoCountry.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'ISO_COUNTRY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class IsoCountry extends BaseIsoCountry {
|
||||
function findById($UID){
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(IsoCountryPeer::IC_UID);
|
||||
$oCriteria->addSelectColumn(IsoCountryPeer::IC_NAME);
|
||||
$oCriteria->add(IsoCountryPeer::IC_UID, $UID);
|
||||
$oDataset = IsoCountryPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
return $oDataset->getRow();
|
||||
}
|
||||
|
||||
function findByIcName($IC_NAME){
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(IsoCountryPeer::IC_UID);
|
||||
$oCriteria->addSelectColumn(IsoCountryPeer::IC_NAME);
|
||||
$oCriteria->add(IsoCountryPeer::IC_NAME, $IC_NAME);
|
||||
$oDataset = IsoCountryPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
return $oDataset->getRow();
|
||||
}
|
||||
} // IsoCountry
|
||||
46
workflow/engine/classes/model/IsoCountryPeer.php
Normal file
46
workflow/engine/classes/model/IsoCountryPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* IsoCountryPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseIsoCountryPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/IsoCountry.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'ISO_COUNTRY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class IsoCountryPeer extends BaseIsoCountryPeer {
|
||||
|
||||
} // IsoCountryPeer
|
||||
67
workflow/engine/classes/model/IsoLocation.php
Normal file
67
workflow/engine/classes/model/IsoLocation.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* IsoLocation.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseIsoLocation.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'ISO_LOCATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class IsoLocation extends BaseIsoLocation {
|
||||
|
||||
function getAllRowsLike($word)
|
||||
{
|
||||
try {
|
||||
//require_once 'classes/model/IsoLocation.php';
|
||||
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn(IsoLocationPeer::IC_UID);
|
||||
$c->addSelectColumn(IsoLocationPeer::IL_NORMAL_NAME);
|
||||
$c->add(IsoLocationPeer::IL_NORMAL_NAME, $word."%", Criteria::LIKE);
|
||||
|
||||
$rs = IsoLocationPeer::doSelectRS($c);
|
||||
//$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rows = Array();
|
||||
while($rs->next()){
|
||||
array_push($rows, $rs->getRow());
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
} // IsoLocation
|
||||
46
workflow/engine/classes/model/IsoLocationPeer.php
Normal file
46
workflow/engine/classes/model/IsoLocationPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* IsoLocationPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseIsoLocationPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/IsoLocation.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'ISO_LOCATION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class IsoLocationPeer extends BaseIsoLocationPeer {
|
||||
|
||||
} // IsoLocationPeer
|
||||
42
workflow/engine/classes/model/IsoSubdivision.php
Normal file
42
workflow/engine/classes/model/IsoSubdivision.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* IsoSubdivision.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseIsoSubdivision.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'ISO_SUBDIVISION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class IsoSubdivision extends BaseIsoSubdivision {
|
||||
|
||||
} // IsoSubdivision
|
||||
46
workflow/engine/classes/model/IsoSubdivisionPeer.php
Normal file
46
workflow/engine/classes/model/IsoSubdivisionPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* IsoSubdivisionPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseIsoSubdivisionPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/IsoSubdivision.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'ISO_SUBDIVISION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class IsoSubdivisionPeer extends BaseIsoSubdivisionPeer {
|
||||
|
||||
} // IsoSubdivisionPeer
|
||||
120
workflow/engine/classes/model/Language.php
Normal file
120
workflow/engine/classes/model/Language.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* Language.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseLanguage.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'LANGUAGE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Language extends BaseLanguage {
|
||||
function load($sLanUid) {
|
||||
try {
|
||||
$oRow = LanguagePeer::retrieveByPK($sLanUid);
|
||||
if (!is_null($oRow)) {
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function update($aFields) {
|
||||
$oConnection = Propel::getConnection(LanguagePeer::DATABASE_NAME);
|
||||
try {
|
||||
$oConnection->begin();
|
||||
$this->load($aFields['LAN_ID']);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
if ($this->validate()) {
|
||||
$iResult = $this->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$oConnection->rollback();
|
||||
throw(new Exception('Failed Validation in class ' . get_class($this) . '.'));
|
||||
}
|
||||
}
|
||||
catch(Exception $e) {
|
||||
$oConnection->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
//SELECT LAN_ID, LAN_NAME FROM LANGUAGE WHERE LAN_ENABLED = '1' ORDER BY LAN_WEIGHT DESC
|
||||
function getActiveLanguages(){
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(LanguagePeer::LAN_ID);
|
||||
$oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
|
||||
$oCriteria->add(LanguagePeer::LAN_ENABLED , '1');
|
||||
$oCriteria->addDescendingOrderByColumn(LanguagePeer::LAN_WEIGHT);
|
||||
|
||||
$oDataset = ContentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$oContent = new Content();
|
||||
$rows = Array();
|
||||
while ($oDataset->next())
|
||||
array_push($rows, $oDataset->getRow());
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function findById($LAN_ID){
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
|
||||
$oCriteria->add(LanguagePeer::LAN_ID, $LAN_ID);
|
||||
$oDataset = LanguagePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
return $oDataset->getRow();
|
||||
}
|
||||
|
||||
function findByLanName($LAN_NAME){
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(LanguagePeer::LAN_ID);
|
||||
$oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
|
||||
$oCriteria->add(LanguagePeer::LAN_NAME, $LAN_NAME, Criteria::LIKE);
|
||||
$oDataset = LanguagePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
return $oDataset->getRow();
|
||||
}
|
||||
|
||||
} // Language
|
||||
46
workflow/engine/classes/model/LanguagePeer.php
Normal file
46
workflow/engine/classes/model/LanguagePeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* LanguagePeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseLanguagePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Language.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'LANGUAGE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class LanguagePeer extends BaseLanguagePeer {
|
||||
|
||||
} // LanguagePeer
|
||||
42
workflow/engine/classes/model/Lexico.php
Normal file
42
workflow/engine/classes/model/Lexico.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Lexico.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseLexico.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'LEXICO' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Lexico extends BaseLexico {
|
||||
|
||||
} // Lexico
|
||||
46
workflow/engine/classes/model/LexicoPeer.php
Normal file
46
workflow/engine/classes/model/LexicoPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* LexicoPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseLexicoPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Lexico.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'LEXICO' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class LexicoPeer extends BaseLexicoPeer {
|
||||
|
||||
} // LexicoPeer
|
||||
74
workflow/engine/classes/model/LogCasesScheduler.php
Normal file
74
workflow/engine/classes/model/LogCasesScheduler.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseLogCasesScheduler.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'LOG_CASES_SCHEDULER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class LogCasesScheduler extends BaseLogCasesScheduler {
|
||||
function getAllCriteria() {
|
||||
$c = new Criteria('workflow');
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::LOG_CASE_UID);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::PRO_UID);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::TAS_UID);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::USR_NAME);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::EXEC_DATE);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::EXEC_HOUR);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::RESULT);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::SCH_UID);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::WS_CREATE_CASE_STATUS);
|
||||
$c->addSelectColumn(LogCasesSchedulerPeer::WS_ROUTE_CASE_STATUS);
|
||||
return $c;
|
||||
}
|
||||
|
||||
function getAll(){
|
||||
$oCriteria = $this->getAllCriteria();
|
||||
$oDataset = LogCasesSchedulerPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRows = Array();
|
||||
while( $aRow = $oDataset->getRow() ) {
|
||||
$aRows[] = $aRow;
|
||||
$oDataset->next();
|
||||
}
|
||||
/*foreach($aRows as $k => $aRow){
|
||||
$oProcess = new Process();
|
||||
$aProcessRow = $oProcess->load($aRow['PRO_UID']);
|
||||
$oTask = new Task();
|
||||
$aTaskRow = $oTask->load($aRow['TAS_UID']);
|
||||
$aRows[$k] = array_merge($aRow, $aProcessRow, $aTaskRow);
|
||||
}*/
|
||||
|
||||
return $aRows;
|
||||
}
|
||||
function saveLogParameters($params){
|
||||
|
||||
if ( isset ( $params['LOG_CASE_UID'] ) && $params['LOG_CASE_UID']== '' )
|
||||
unset ( $params['LOG_CASE_UID'] );
|
||||
if ( !isset ( $params['LOG_CASE_UID'] ) )
|
||||
$params['LOG_CASE_UID'] = G::generateUniqueID();
|
||||
$this->setLogCaseUid($params['LOG_CASE_UID']);
|
||||
$this->setProUid($params['PRO_UID']);
|
||||
$this->setTasUid($params['TAS_UID']);
|
||||
$this->setSchUid($params['SCH_UID']);
|
||||
$this->setUsrName($params['USR_NAME']);
|
||||
$this->setExecDate($params['EXEC_DATE']);
|
||||
$this->setExecHour($params['EXEC_HOUR']);
|
||||
$this->setResult($params['RESULT']);
|
||||
$this->setWsCreateCaseStatus($params['WS_CREATE_CASE_STATUS']);
|
||||
$this->setWsRouteCaseStatus($params['WS_ROUTE_CASE_STATUS']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // LogCasesScheduler
|
||||
23
workflow/engine/classes/model/LogCasesSchedulerPeer.php
Normal file
23
workflow/engine/classes/model/LogCasesSchedulerPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseLogCasesSchedulerPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/LogCasesScheduler.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'LOG_CASES_SCHEDULER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class LogCasesSchedulerPeer extends BaseLogCasesSchedulerPeer {
|
||||
|
||||
} // LogCasesSchedulerPeer
|
||||
109
workflow/engine/classes/model/LoginLog.php
Normal file
109
workflow/engine/classes/model/LoginLog.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseLoginLog.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'LOGIN_LOG' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class LoginLog extends BaseLoginLog {
|
||||
function create ($aData)
|
||||
{
|
||||
$con = Propel::getConnection(LoginLogPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$this->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$e=new Exception("Failed Validation in class ".get_class($this).".");
|
||||
$e->aValidationFailures=$this->getValidationFailures();
|
||||
throw($e);
|
||||
}
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function load($LogUid)
|
||||
{
|
||||
try {
|
||||
$oRow = LoginLogPeer::retrieveByPK( $LogUid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '" . $LogUid . "' in table LOGIN_LOG doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($fields)
|
||||
{
|
||||
$con = Propel::getConnection(LoginLogPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->load($fields['LOG_UID']);
|
||||
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($LogUid)
|
||||
{
|
||||
$con = Propel::getConnection(LoginLogPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->setWlUid($LogUid);
|
||||
$result=$this->delete();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
} // LoginLog
|
||||
23
workflow/engine/classes/model/LoginLogPeer.php
Normal file
23
workflow/engine/classes/model/LoginLogPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseLoginLogPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/LoginLog.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'LOGIN_LOG' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class LoginLogPeer extends BaseLoginLogPeer {
|
||||
|
||||
} // LoginLogPeer
|
||||
135
workflow/engine/classes/model/ObjectPermission.php
Normal file
135
workflow/engine/classes/model/ObjectPermission.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseObjectPermission.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'OBJECT_PERMISSION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ObjectPermission extends BaseObjectPermission {
|
||||
|
||||
public function load($UID)
|
||||
{
|
||||
try {
|
||||
$oRow = ObjectPermissionPeer::retrieveByPK( $UID );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '" . $UsrUid . "' in table USER doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function create ($aData)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->fromArray($aData,BasePeer::TYPE_FIELDNAME);
|
||||
$result=$this->save();
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
function Exists ( $Uid ) {
|
||||
try {
|
||||
$oPro = ObjectPermissionPeer::retrieveByPk( $Uid );
|
||||
if ( get_class ($oPro) == 'ObjectPermission' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($Uid)
|
||||
{
|
||||
$con = Propel::getConnection(ObjectPermissionPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oObjPer = ObjectPermissionPeer::retrieveByPK($Uid);
|
||||
if (get_class($oObjPer) == 'ObjectPermission')
|
||||
{
|
||||
$con->begin();
|
||||
$iResult = $oObjPer->delete();
|
||||
$con->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '" . $Uid . "' in table CaseTrackerObject doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function update($aFields) {
|
||||
$oConnection = Propel::getConnection(ObjectPermissionPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oConnection->begin();
|
||||
$this->load($aFields['OP_UID']);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
if ($this->validate()) {
|
||||
$iResult = $this->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$oConnection->rollback();
|
||||
throw(new Exception('Failed Validation in class ' . get_class($this) . '.'));
|
||||
}
|
||||
}
|
||||
catch(Exception $e) {
|
||||
$oConnection->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
function removeByObject($sType, $sObjUid) {
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ObjectPermissionPeer::OP_OBJ_TYPE, $sType);
|
||||
$oCriteria->add(ObjectPermissionPeer::OP_OBJ_UID, $sObjUid);
|
||||
ObjectPermissionPeer::doDelete($oCriteria);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
function loadInfo($sObjUID){
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ObjectPermissionPeer::OP_OBJ_UID, $sObjUID);
|
||||
$oDataset = ObjectPermissionPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
return($aRow);
|
||||
}
|
||||
|
||||
} // ObjectPermission
|
||||
23
workflow/engine/classes/model/ObjectPermissionPeer.php
Normal file
23
workflow/engine/classes/model/ObjectPermissionPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseObjectPermissionPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/ObjectPermission.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'OBJECT_PERMISSION' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ObjectPermissionPeer extends BaseObjectPermissionPeer {
|
||||
|
||||
} // ObjectPermissionPeer
|
||||
795
workflow/engine/classes/model/OutputDocument.php
Normal file
795
workflow/engine/classes/model/OutputDocument.php
Normal file
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
/**
|
||||
* OutputDocument.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseOutputDocument.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'OUTPUT_DOCUMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class OutputDocument extends BaseOutputDocument {
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $out_doc_title = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $out_doc_description = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $out_doc_filename = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $out_doc_template = '';
|
||||
|
||||
|
||||
function __construct() {
|
||||
$javaInput = PATH_C . 'javaBridgePM' . PATH_SEP . 'input' . PATH_SEP;
|
||||
$javaOutput = PATH_C . 'javaBridgePM' . PATH_SEP . 'output' . PATH_SEP;
|
||||
G::mk_dir ( $javaInput );
|
||||
G::mk_dir ( $javaOutput );
|
||||
}
|
||||
|
||||
public function getByUid($sOutDocUid)
|
||||
{
|
||||
try {
|
||||
$oOutputDocument = OutputDocumentPeer::retrieveByPK( $sOutDocUid );
|
||||
if( is_null($oOutputDocument) )
|
||||
return false;
|
||||
|
||||
$aFields = $oOutputDocument->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle();
|
||||
$aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription();
|
||||
$aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename();
|
||||
$aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate();
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load the application document registry
|
||||
* @param string $sAppDocUid
|
||||
* @return variant
|
||||
*/
|
||||
public function load($sOutDocUid)
|
||||
{
|
||||
try {
|
||||
$oOutputDocument = OutputDocumentPeer::retrieveByPK( $sOutDocUid );
|
||||
if (!is_null($oOutputDocument))
|
||||
{
|
||||
$aFields = $oOutputDocument->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle();
|
||||
$aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription();
|
||||
$aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename();
|
||||
$aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate();
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
if ( isset ( $aData['OUT_DOC_UID'] ) && $aData['OUT_DOC_UID']== '' )
|
||||
unset ( $aData['OUT_DOC_UID'] );
|
||||
if ( !isset ( $aData['OUT_DOC_UID'] ) )
|
||||
$aData['OUT_DOC_UID'] = G::generateUniqueID();
|
||||
if (!isset($aData['OUT_DOC_GENERATE'])) {
|
||||
$aData['OUT_DOC_GENERATE'] = 'BOTH';
|
||||
}
|
||||
else {
|
||||
if ($aData['OUT_DOC_GENERATE'] == '') {
|
||||
$aData['OUT_DOC_GENERATE'] = 'BOTH';
|
||||
}
|
||||
}
|
||||
$oOutputDocument = new OutputDocument();
|
||||
$oOutputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oOutputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['OUT_DOC_TITLE'])) {
|
||||
$oOutputDocument->setOutDocTitle($aData['OUT_DOC_TITLE']);
|
||||
}
|
||||
if (isset($aData['OUT_DOC_DESCRIPTION'])) {
|
||||
$oOutputDocument->setOutDocDescription($aData['OUT_DOC_DESCRIPTION']);
|
||||
}
|
||||
$oOutputDocument->setOutDocFilename($aData['OUT_DOC_FILENAME']);
|
||||
if (isset($aData['OUT_DOC_TEMPLATE'])) {
|
||||
$oOutputDocument->setOutDocTemplate($aData['OUT_DOC_TEMPLATE']);
|
||||
}
|
||||
$iResult = $oOutputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $aData['OUT_DOC_UID'];
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oOutputDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oOutputDocument = OutputDocumentPeer::retrieveByPK($aData['OUT_DOC_UID']);
|
||||
if (!is_null($oOutputDocument))
|
||||
{
|
||||
$oOutputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oOutputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['OUT_DOC_TITLE']))
|
||||
{
|
||||
$oOutputDocument->setOutDocTitle($aData['OUT_DOC_TITLE']);
|
||||
}
|
||||
if (isset($aData['OUT_DOC_DESCRIPTION']))
|
||||
{
|
||||
$oOutputDocument->setOutDocDescription($aData['OUT_DOC_DESCRIPTION']);
|
||||
}
|
||||
if (isset($aData['OUT_DOC_FILENAME']))
|
||||
{
|
||||
$oOutputDocument->setOutDocFilename($aData['OUT_DOC_FILENAME']);
|
||||
}
|
||||
if (isset($aData['OUT_DOC_TEMPLATE']))
|
||||
{
|
||||
$oOutputDocument->setOutDocTemplate($aData['OUT_DOC_TEMPLATE']);
|
||||
}
|
||||
$iResult = $oOutputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oOutputDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sOutDocUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oOutputDocument = OutputDocumentPeer::retrieveByPK($sOutDocUid);
|
||||
if (!is_null($oOutputDocument))
|
||||
{
|
||||
$oConnection->begin();
|
||||
Content::removeContent('OUT_DOC_TITLE', '', $oOutputDocument->getOutDocUid());
|
||||
Content::removeContent('OUT_DOC_DESCRIPTION', '', $oOutputDocument->getOutDocUid());
|
||||
Content::removeContent('OUT_DOC_FILENAME', '', $oOutputDocument->getOutDocUid());
|
||||
Content::removeContent('OUT_DOC_TEMPLATE', '', $oOutputDocument->getOutDocUid());
|
||||
$iResult = $oOutputDocument->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [out_doc_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getOutDocTitle()
|
||||
{
|
||||
if ($this->out_doc_title == '') {
|
||||
try {
|
||||
$this->out_doc_title = Content::load('OUT_DOC_TITLE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->out_doc_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [out_doc_title] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setOutDocTitle($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->out_doc_title !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->out_doc_title = $sValue;
|
||||
$iResult = Content::addContent('OUT_DOC_TITLE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_title);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->out_doc_title = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [out_doc_comment] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getOutDocDescription()
|
||||
{
|
||||
if ($this->out_doc_description == '') {
|
||||
try {
|
||||
$this->out_doc_description = Content::load('OUT_DOC_DESCRIPTION', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->out_doc_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [out_doc_comment] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setOutDocDescription($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->out_doc_description !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->out_doc_description = $sValue;
|
||||
$iResult = Content::addContent('OUT_DOC_DESCRIPTION', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_description);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->out_doc_description = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [out_doc_filename] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getOutDocFilename()
|
||||
{
|
||||
if ($this->out_doc_filename == '') {
|
||||
try {
|
||||
$this->out_doc_filename = Content::load('OUT_DOC_FILENAME', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->out_doc_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [out_doc_filename] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setOutDocFilename($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->out_doc_filename !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->out_doc_filename = $sValue;
|
||||
$iResult = Content::addContent('OUT_DOC_FILENAME', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_filename);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->out_doc_filename = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [out_doc_template] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getOutDocTemplate()
|
||||
{
|
||||
if ($this->out_doc_template == '') {
|
||||
try {
|
||||
$this->out_doc_template = Content::load('OUT_DOC_TEMPLATE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->out_doc_template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [out_doc_template] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setOutDocTemplate($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->out_doc_template !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->out_doc_template = $sValue;
|
||||
$iResult = Content::addContent('OUT_DOC_TEMPLATE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_template);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->out_doc_template = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate the output document
|
||||
* @param string $sUID
|
||||
* @param array $aFields
|
||||
* @param string $sPath
|
||||
* @return variant
|
||||
*/
|
||||
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array()) {
|
||||
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
|
||||
$sContent = G::unhtmlentities($sContent);
|
||||
$iAux = 0;
|
||||
$iOcurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $sContent, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
if ($iOcurrences) {
|
||||
for($i = 0; $i < $iOcurrences; $i++) {
|
||||
preg_match_all('/@>' . $aMatch[2][$i][0] . '([\w\W]*)' . '@<' . $aMatch[2][$i][0] . '/', $sContent, $aMatch2, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
$sGridName = $aMatch[2][$i][0];
|
||||
$sStringToRepeat = $aMatch2[1][0][0];
|
||||
if (isset($aFields[$sGridName])) {
|
||||
if (is_array($aFields[$sGridName])) {
|
||||
$sAux = '';
|
||||
foreach ($aFields[$sGridName] as $aRow) {
|
||||
foreach ($aRow as $sKey => $vValue) {
|
||||
if (!is_array($vValue)) {
|
||||
$aRow[$sKey] = nl2br($aRow[$sKey]);
|
||||
}
|
||||
}
|
||||
$sAux .= G::replaceDataField($sStringToRepeat, $aRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
$sContent = str_replace('@>' . $sGridName . $sStringToRepeat . '@<' . $sGridName, $sAux, $sContent);
|
||||
}
|
||||
}
|
||||
foreach ($aFields as $sKey => $vValue) {
|
||||
if (!is_array($vValue)) {
|
||||
$aFields[$sKey] = nl2br($aFields[$sKey]);
|
||||
}
|
||||
}
|
||||
$sContent = G::replaceDataField($sContent, $aFields);
|
||||
G::verifyPath($sPath, true);
|
||||
/* Start - Create .doc */
|
||||
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
|
||||
$size = array();
|
||||
$size["Letter"] = "216mm 279mm";
|
||||
$size["Legal"] = "216mm 357mm";
|
||||
$size["Executive"] = "184mm 267mm";
|
||||
$size["B5"] = "182mm 257mm";
|
||||
$size["Folio"] = "216mm 330mm";
|
||||
$size["A0Oversize"] = "882mm 1247mm";
|
||||
$size["A0"] = "841mm 1189mm";
|
||||
$size["A1"] = "594mm 841mm";
|
||||
$size["A2"] = "420mm 594mm";
|
||||
$size["A3"] = "297mm 420mm";
|
||||
$size["A4"] = "210mm 297mm";
|
||||
$size["A5"] = "148mm 210mm";
|
||||
$size["A6"] = "105mm 148mm";
|
||||
$size["A7"] = "74mm 105mm";
|
||||
$size["A8"] = "52mm 74mm";
|
||||
$size["A9"] = "37mm 52mm";
|
||||
$size["A10"] = "26mm 37mm";
|
||||
$size["Screenshot640"] = "640mm 480mm";
|
||||
$size["Screenshot800"] = "800mm 600mm";
|
||||
$size["Screenshot1024"] = "1024mm 768mm";
|
||||
|
||||
$sizeLandscape["Letter"] = "279mm 216mm";
|
||||
$sizeLandscape["Legal"] = "357mm 216mm";
|
||||
$sizeLandscape["Executive"] = "267mm 184mm";
|
||||
$sizeLandscape["B5"] = "257mm 182mm";
|
||||
$sizeLandscape["Folio"] = "330mm 216mm";
|
||||
$sizeLandscape["A0Oversize"] = "1247mm 882mm";
|
||||
$sizeLandscape["A0"] = "1189mm 841mm";
|
||||
$sizeLandscape["A1"] = "841mm 594mm";
|
||||
$sizeLandscape["A2"] = "594mm 420mm";
|
||||
$sizeLandscape["A3"] = "420mm 297mm";
|
||||
$sizeLandscape["A4"] = "297mm 210mm";
|
||||
$sizeLandscape["A5"] = "210mm 148mm";
|
||||
$sizeLandscape["A6"] = "148mm 105mm";
|
||||
$sizeLandscape["A7"] = "105mm 74mm";
|
||||
$sizeLandscape["A8"] = "74mm 52mm";
|
||||
$sizeLandscape["A9"] = "52mm 37mm";
|
||||
$sizeLandscape["A10"] = "37mm 26mm";
|
||||
$sizeLandscape["Screenshot640"] = "480mm 640mm";
|
||||
$sizeLandscape["Screenshot800"] = "600mm 800mm";
|
||||
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
|
||||
|
||||
if(!isset($aProperties['media']))
|
||||
$aProperties['media'] = 'Letter';
|
||||
|
||||
if($sLandscape)
|
||||
$media = $sizeLandscape[$aProperties['media']];
|
||||
else
|
||||
$media = $size[$aProperties['media']];
|
||||
|
||||
$marginLeft = '15';
|
||||
if(isset($aProperties['margins']['left']))
|
||||
$marginLeft = $aProperties['margins']['left'];
|
||||
|
||||
$marginRight = '15';
|
||||
if(isset($aProperties['margins']['right']))
|
||||
$marginRight = $aProperties['margins']['right'];
|
||||
|
||||
$marginTop = '15';
|
||||
if(isset($aProperties['margins']['top']))
|
||||
$marginTop = $aProperties['margins']['top'];
|
||||
|
||||
$marginBottom = '15';
|
||||
if(isset($aProperties['margins']['bottom']))
|
||||
$marginBottom = $aProperties['margins']['bottom'];
|
||||
|
||||
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<head>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
|
||||
<meta name=ProgId content=Word.Document>
|
||||
<meta name=Generator content="Microsoft Word 9">
|
||||
<meta name=Originator content="Microsoft Word 9">
|
||||
<!--[if !mso]>
|
||||
<style>
|
||||
v\:* {behavior:url(#default#VML);}
|
||||
o\:* {behavior:url(#default#VML);}
|
||||
w\:* {behavior:url(#default#VML);}
|
||||
.shape {behavior:url(#default#VML);}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<!--[if gte mso 9]><xml>
|
||||
<w:WordDocument>
|
||||
<w:View>Print</w:View>
|
||||
<w:DoNotHyphenateCaps/>
|
||||
<w:PunctuationKerning/>
|
||||
<w:DrawingGridHorizontalSpacing>9.35 pt</w:DrawingGridHorizontalSpacing>
|
||||
<w:DrawingGridVerticalSpacing>9.35 pt</w:DrawingGridVerticalSpacing>
|
||||
</w:WordDocument>
|
||||
</xml><![endif]-->
|
||||
|
||||
<style>
|
||||
<!--
|
||||
@page WordSection1
|
||||
{size:'.$media.';
|
||||
margin-left:'.$marginLeft.'mm;
|
||||
margin-right:'.$marginRight.'mm;
|
||||
margin-bottom:'.$marginBottom.'mm;
|
||||
margin-top:'.$marginTop.'mm;
|
||||
mso-header-margin:35.4pt;
|
||||
mso-footer-margin:35.4pt;
|
||||
mso-paper-source:0;}
|
||||
div.WordSection1
|
||||
{page:WordSection1;}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class=WordSection1>');
|
||||
fwrite($oFile, $sContent);
|
||||
fwrite($oFile, "\n</div></body></html>\n\n");
|
||||
fclose($oFile);
|
||||
/* End - Create .doc */
|
||||
|
||||
if($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF'){
|
||||
/* Start - Create .pdf */
|
||||
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
|
||||
fwrite($oFile, $sContent);
|
||||
fclose($oFile);
|
||||
|
||||
define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/');
|
||||
G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
|
||||
require_once(PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php');
|
||||
require_once(PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php');
|
||||
parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
|
||||
$GLOBALS['g_config'] = array('cssmedia' => 'screen',
|
||||
'media' => 'Letter',
|
||||
'scalepoints' => false,
|
||||
'renderimages' => true,
|
||||
'renderfields' => true,
|
||||
'renderforms' => false,
|
||||
'pslevel' => 3,
|
||||
'renderlinks' => true,
|
||||
'pagewidth' => 800,
|
||||
'landscape' => $sLandscape,
|
||||
'method' => 'fpdf',
|
||||
'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15,),
|
||||
'encoding' => '',
|
||||
'ps2pdf' => false,
|
||||
'compress' => false,
|
||||
'output' => 2,
|
||||
'pdfversion' => '1.3',
|
||||
'transparency_workaround' => false,
|
||||
'imagequality_workaround' => false,
|
||||
'draw_page_border' => isset($_REQUEST['pageborder']),
|
||||
'debugbox' => false,
|
||||
'html2xhtml' => true,
|
||||
'mode' => 'html',
|
||||
'smartpagebreak' => true);
|
||||
$GLOBALS['g_config']= array_merge($GLOBALS['g_config'],$aProperties);
|
||||
$g_media = Media::predefined($GLOBALS['g_config']['media']);
|
||||
$g_media->set_landscape($GLOBALS['g_config']['landscape']);
|
||||
$g_media->set_margins($GLOBALS['g_config']['margins']);
|
||||
$g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
|
||||
$pipeline = new Pipeline();
|
||||
if (extension_loaded('curl'))
|
||||
{
|
||||
require_once(HTML2PS_DIR . 'fetcher.url.curl.class.php');
|
||||
$pipeline->fetchers = array(new FetcherURLCurl());
|
||||
if (isset($proxy)) {
|
||||
if ($proxy != '')
|
||||
{
|
||||
$pipeline->fetchers[0]->set_proxy($proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once(HTML2PS_DIR . 'fetcher.url.class.php');
|
||||
$pipeline->fetchers[] = new FetcherURL();
|
||||
}
|
||||
$pipeline->data_filters[] = new DataFilterDoctype();
|
||||
$pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']);
|
||||
if ($GLOBALS['g_config']['html2xhtml'])
|
||||
{
|
||||
$pipeline->data_filters[] = new DataFilterHTML2XHTML();
|
||||
}
|
||||
else
|
||||
{
|
||||
$pipeline->data_filters[] = new DataFilterXHTML2XHTML();
|
||||
}
|
||||
$pipeline->parser = new ParserXHTML();
|
||||
$pipeline->pre_tree_filters = array();
|
||||
$header_html = '';
|
||||
$footer_html = '';
|
||||
$filter = new PreTreeFilterHeaderFooter($header_html, $footer_html);
|
||||
$pipeline->pre_tree_filters[] = $filter;
|
||||
if ($GLOBALS['g_config']['renderfields'])
|
||||
{
|
||||
$pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields();
|
||||
}
|
||||
if ($GLOBALS['g_config']['method'] === 'ps')
|
||||
{
|
||||
$pipeline->layout_engine = new LayoutEnginePS();
|
||||
}
|
||||
else
|
||||
{
|
||||
$pipeline->layout_engine = new LayoutEngineDefault();
|
||||
}
|
||||
$pipeline->post_tree_filters = array();
|
||||
if ($GLOBALS['g_config']['pslevel'] == 3)
|
||||
{
|
||||
$image_encoder = new PSL3ImageEncoderStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
$image_encoder = new PSL2ImageEncoderStream();
|
||||
}
|
||||
switch ($GLOBALS['g_config']['method'])
|
||||
{
|
||||
case 'fastps':
|
||||
if ($GLOBALS['g_config']['pslevel'] == 3)
|
||||
{
|
||||
$pipeline->output_driver = new OutputDriverFastPS($image_encoder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pipeline->output_driver = new OutputDriverFastPSLevel2($image_encoder);
|
||||
}
|
||||
break;
|
||||
case 'pdflib':
|
||||
$pipeline->output_driver = new OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']);
|
||||
break;
|
||||
case 'fpdf':
|
||||
$pipeline->output_driver = new OutputDriverFPDF();
|
||||
break;
|
||||
case 'png':
|
||||
$pipeline->output_driver = new OutputDriverPNG();
|
||||
break;
|
||||
case 'pcl':
|
||||
$pipeline->output_driver = new OutputDriverPCL();
|
||||
break;
|
||||
default:
|
||||
die('Unknown output method');
|
||||
}
|
||||
if (isset($GLOBALS['g_config']['watermarkhtml'])) {
|
||||
$watermark_text = $GLOBALS['g_config']['watermarkhtml'];
|
||||
}
|
||||
else {
|
||||
$watermark_text = '';
|
||||
}
|
||||
$pipeline->output_driver->set_watermark($watermark_text);
|
||||
if ($watermark_text != '')
|
||||
{
|
||||
$dispatcher =& $pipeline->getDispatcher();
|
||||
}
|
||||
if ($GLOBALS['g_config']['debugbox'])
|
||||
{
|
||||
$pipeline->output_driver->set_debug_boxes(true);
|
||||
}
|
||||
if ($GLOBALS['g_config']['draw_page_border'])
|
||||
{
|
||||
$pipeline->output_driver->set_show_page_border(true);
|
||||
}
|
||||
if ($GLOBALS['g_config']['ps2pdf'])
|
||||
{
|
||||
$pipeline->output_filters[] = new OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']);
|
||||
}
|
||||
if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps')
|
||||
{
|
||||
$pipeline->output_filters[] = new OutputFilterGZip();
|
||||
}
|
||||
if (!isset($GLOBALS['g_config']['process_mode'])) {
|
||||
$GLOBALS['g_config']['process_mode'] = '';
|
||||
}
|
||||
if ($GLOBALS['g_config']['process_mode'] == 'batch')
|
||||
{
|
||||
$filename = 'batch';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename = $sFilename;
|
||||
}
|
||||
switch ($GLOBALS['g_config']['output'])
|
||||
{
|
||||
case 0:
|
||||
$pipeline->destination = new DestinationBrowser($filename);
|
||||
break;
|
||||
case 1:
|
||||
$pipeline->destination = new DestinationDownload($filename);
|
||||
break;
|
||||
case 2:
|
||||
$pipeline->destination = new DestinationFile($filename);
|
||||
break;
|
||||
}
|
||||
copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
|
||||
$status = $pipeline->process(( (isset($_SERVER['HTTPS']))&&($_SERVER['HTTPS']=='on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media);
|
||||
|
||||
copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf');
|
||||
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf');
|
||||
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
|
||||
|
||||
}//end if $sTypeDocToGener
|
||||
/* End - Create .pdf */
|
||||
}
|
||||
else
|
||||
{
|
||||
return PEAR::raiseError(null,
|
||||
G_ERROR_USER_UID,
|
||||
null,
|
||||
null,
|
||||
'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!',
|
||||
'G_Error',
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* verify if Output row specified in [sUid] exists.
|
||||
*
|
||||
* @param string $sUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function OutputExists ( $sUid ) {
|
||||
$con = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oObj = OutputDocumentPeer::retrieveByPk( $sUid );
|
||||
if ( get_class ($oObj) == 'OutputDocument' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
} // OutputDocument
|
||||
46
workflow/engine/classes/model/OutputDocumentPeer.php
Normal file
46
workflow/engine/classes/model/OutputDocumentPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* OutputDocumentPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseOutputDocumentPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/OutputDocument.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'OUTPUT_DOCUMENT' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class OutputDocumentPeer extends BaseOutputDocumentPeer {
|
||||
|
||||
} // OutputDocumentPeer
|
||||
610
workflow/engine/classes/model/Process.php
Normal file
610
workflow/engine/classes/model/Process.php
Normal file
@@ -0,0 +1,610 @@
|
||||
<?php
|
||||
/**
|
||||
* Process.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
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.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
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()
|
||||
{
|
||||
if ( $this->getProUid() == '' ) {
|
||||
throw ( new Exception( "Error in getProTitle, the PRO_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->pro_title = Content::load ( 'PRO_TITLE', '', $this->getProUid(), $lang );
|
||||
return $this->pro_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [Pro_title] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setProTitle($v)
|
||||
{
|
||||
if ( $this->getProUid() == '' ) {
|
||||
throw ( new Exception( "Error in setProTitle, the PRO_UID can't be blank") );
|
||||
}
|
||||
// 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->pro_title !== $v || $v === '') {
|
||||
$this->pro_title = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'PRO_TITLE', '', $this->getProUid(), $lang, $this->pro_title );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $pro_description = '';
|
||||
|
||||
/**
|
||||
* Get the [Pro_description] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getProDescription()
|
||||
{
|
||||
if ( $this->getProUid() == '' ) {
|
||||
throw ( new Exception( "Error in getProDescription, the PRO_UID can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->pro_description = Content::load ( 'PRO_DESCRIPTION', '', $this->getProUid(), $lang );
|
||||
return $this->pro_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [Pro_description] column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setProDescription($v)
|
||||
{
|
||||
if ( $this->getProUid() == '' ) {
|
||||
throw ( new Exception( "Error in setProDescription, the PRO_UID can't be blank") );
|
||||
}
|
||||
// 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->pro_description !== $v || $v === '') {
|
||||
$this->pro_description = $v;
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'PRO_DESCRIPTION', '', $this->getProUid(), $lang, $this->pro_description );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
/**
|
||||
* Creates the Process
|
||||
*
|
||||
* @param array $aData Fields with :
|
||||
* $aData['PRO_UID'] the process id
|
||||
* $aData['USR_UID'] the userid
|
||||
$aData['PRO_CATEGORY'] the id category
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($aData ) {
|
||||
if ( !isset ( $aData['USR_UID'] ) ) {
|
||||
throw ( new PropelException ( 'The process cannot be created. The USR_UID is empty.' ) );
|
||||
}
|
||||
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
||||
try {
|
||||
do {
|
||||
$sNewProUid = G::generateUniqueID() ;
|
||||
} while ( $this->processExists ( $sNewProUid ) );
|
||||
|
||||
$this->setProUid ( $sNewProUid );
|
||||
$this->setProParent ( $sNewProUid );
|
||||
$this->setProTime ( 1 );
|
||||
$this->setProTimeunit ( 'DAYS' );
|
||||
$this->setProStatus ( 'ACTIVE' );
|
||||
$this->setProTypeDay ( '' );
|
||||
$this->setProType ( 'NORMAL' );
|
||||
$this->setProAssignment ( 'FALSE' );
|
||||
$this->setProShowMap ( '' );
|
||||
$this->setProShowMessage ( '' );
|
||||
$this->setProShowDelegate ( '' );
|
||||
$this->setProShowDynaform ( '' );
|
||||
$this->setProCategory ( $aData['PRO_CATEGORY'] );
|
||||
$this->setProSubCategory ( '' );
|
||||
$this->setProIndustry ( '' );
|
||||
$this->setProCreateDate ('now' );
|
||||
$this->setProCreateUser ( $aData['USR_UID'] );
|
||||
$this->setProHeight ( 5000 );
|
||||
$this->setProWidth ( 10000 );
|
||||
$this->setProTitleX ( 0 );
|
||||
$this->setProTitleY ( 0 );
|
||||
|
||||
if ( $this->validate() ) {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
if (isset ( $aData['PRO_TITLE'] ) )
|
||||
$this->setProTitle ( $aData['PRO_TITLE'] );
|
||||
else
|
||||
$this->setProTitle ( 'Default Process Title' );
|
||||
|
||||
if (isset ( $aData['PRO_DESCRIPTION'] ) )
|
||||
$this->setProDescription ( $aData['PRO_DESCRIPTION'] );
|
||||
else
|
||||
$this->setProDescription ( 'Default Process Description' );
|
||||
|
||||
$con->commit();
|
||||
return $this->getProUid();
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verify if Process row specified in [pro_id] exists.
|
||||
*
|
||||
* @param string $sProUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function processExists ( $ProUid ) {
|
||||
$con = Propel::getConnection(ProcessPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oPro = ProcessPeer::retrieveByPk( $ProUid );
|
||||
if ( get_class($oPro) == 'Process' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load the Process row specified in [pro_id] column value.
|
||||
*
|
||||
* @param string $ProUid the uid of the Prolication
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function load ( $ProUid , $getAllLang=false) {
|
||||
|
||||
$con = Propel::getConnection(ProcessPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oPro = ProcessPeer::retrieveByPk( $ProUid );
|
||||
if ( get_class ($oPro) == 'Process' ) {
|
||||
$aFields = $oPro->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
|
||||
//optimized to avoid double and multiple execution of the same query
|
||||
// $aFields['PRO_TITLE'] = $oPro->getProTitle();
|
||||
// $aFields['PRO_DESCRIPTION'] = $oPro->getProDescription();
|
||||
// $this->pro_title = $aFields['PRO_TITLE'];
|
||||
// $this->pro_description = $aFields['PRO_DESCRIPTION'];
|
||||
|
||||
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(ContentPeer::CON_CATEGORY);
|
||||
$c->addSelectColumn(ContentPeer::CON_VALUE);
|
||||
$c->add(ContentPeer::CON_ID, $ProUid );
|
||||
if(!$getAllLang) $c->add(ContentPeer::CON_LANG, $lang );
|
||||
$rs = ProcessPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
|
||||
while (is_array($row)) {
|
||||
switch ( $row['CON_CATEGORY'] ) {
|
||||
case 'PRO_TITLE' : $aFields['PRO_TITLE'] = $row['CON_VALUE'];
|
||||
$this->pro_title = $row['CON_VALUE'];
|
||||
if ( $row['CON_VALUE'] !== '' )
|
||||
$this->setProTitle($aFields['PRO_TITLE']);
|
||||
break;
|
||||
case 'PRO_DESCRIPTION' : $aFields['PRO_DESCRIPTION'] = $row['CON_VALUE'];
|
||||
$this->pro_description = $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();
|
||||
$this->setProTitle($aFields['PRO_TITLE']);
|
||||
}
|
||||
if(!isset($aFields['PRO_DESCRIPTION'])){
|
||||
$aFields['PRO_DESCRIPTION'] = $oPro->getProDescription();
|
||||
$this->setProDescription($aFields['PRO_DESCRIPTION']);
|
||||
}
|
||||
|
||||
//the following code is to copy the parent in old process, when the parent was empty.
|
||||
if ( $oPro->getProParent() == '' ) {
|
||||
$oPro->setProParent ( $oPro->getProUid() );
|
||||
$oPro->save();
|
||||
}
|
||||
|
||||
//Get category Name, by default No category
|
||||
$aFields['PRO_CATEGORY_LABEL']=G::LoadTranslation("ID_PROCESS_NO_CATEGORY");
|
||||
if($aFields['PRO_CATEGORY']!=""){
|
||||
$oProCat = ProcessCategoryPeer::retrieveByPk( $aFields['PRO_CATEGORY'] );
|
||||
if ( get_class ($oProCat) == 'ProcessCategory' ) {
|
||||
$aFields['PRO_CATEGORY_LABEL']=$oProCat->getCategoryName();
|
||||
}
|
||||
}
|
||||
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$ProUid' in table Process doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getAll($getAllLang=false) {
|
||||
$c = new Criteria('workflow');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Prolication row
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
|
||||
public function update($aData)
|
||||
{
|
||||
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oPro = ProcessPeer::retrieveByPK( $aData['PRO_UID'] );
|
||||
if ( get_class ($oPro) == 'Process' ) {
|
||||
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oPro->validate()) {
|
||||
if ( isset ( $aData['PRO_TITLE'] ) )
|
||||
$oPro->setProTitle( $aData['PRO_TITLE'] );
|
||||
|
||||
if ( isset ( $aData['PRO_DESCRIPTION'] ) )
|
||||
$oPro->setProDescription( $aData['PRO_DESCRIPTION'] );
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($oPro->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new Exception ( 'The row cannot be updated!' . $msg ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$con->rollback();
|
||||
throw( new Exception( "The row '" . $aData['PRO_UID'] ."' in table Process doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an Application row
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
|
||||
public function createRow($aData)
|
||||
{
|
||||
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
||||
$con->begin();
|
||||
$this->setProUid ( $aData['PRO_UID'] );
|
||||
$this->setProParent ( $aData['PRO_PARENT'] );
|
||||
$this->setProTime ( $aData['PRO_TIME'] );
|
||||
$this->setProTimeunit ( $aData['PRO_TIMEUNIT'] );
|
||||
$this->setProStatus ( $aData['PRO_STATUS'] );
|
||||
$this->setProTypeDay ( $aData['PRO_TYPE_DAY'] );
|
||||
$this->setProType ( $aData['PRO_TYPE'] );
|
||||
$this->setProAssignment ( $aData['PRO_ASSIGNMENT'] );
|
||||
$this->setProShowMap ( $aData['PRO_SHOW_MAP'] );
|
||||
$this->setProShowMessage ( $aData['PRO_SHOW_MESSAGE'] );
|
||||
$this->setProShowDelegate ( $aData['PRO_SHOW_DELEGATE'] );
|
||||
$this->setProShowDynaform ( $aData['PRO_SHOW_DYNAFORM'] );
|
||||
$this->setProCategory ( $aData['PRO_CATEGORY'] );
|
||||
$this->setProSubCategory ( $aData['PRO_SUB_CATEGORY'] );
|
||||
$this->setProIndustry ( $aData['PRO_INDUSTRY'] );
|
||||
$this->setProCreateDate ( $aData['PRO_CREATE_DATE'] );
|
||||
$this->setProCreateUser ( $aData['PRO_CREATE_USER'] );
|
||||
$this->setProHeight ( $aData['PRO_HEIGHT'] );
|
||||
$this->setProWidth ( $aData['PRO_WIDTH'] );
|
||||
$this->setProTitleX ( $aData['PRO_TITLE_X'] );
|
||||
$this->setProTitleY ( $aData['PRO_TITLE_Y'] );
|
||||
if ( $this->validate() ) {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
if (isset ( $aData['PRO_TITLE'] ) )
|
||||
$this->setProTitle ( $aData['PRO_TITLE'] );
|
||||
else
|
||||
$this->setProTitle ( 'Default Process Title' );
|
||||
|
||||
if (isset ( $aData['PRO_DESCRIPTION'] ) )
|
||||
$this->setProDescription ( $aData['PRO_DESCRIPTION'] );
|
||||
else
|
||||
$this->setProDescription ( 'Default Process Description' );
|
||||
|
||||
$con->commit();
|
||||
return $this->getProUid();
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the Prolication document registry
|
||||
* @param array $aData or string $ProUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($ProUid)
|
||||
{
|
||||
if ( is_array ( $ProUid ) ) {
|
||||
$ProUid = ( isset ( $ProUid['PRO_UID'] ) ? $ProUid['PRO_UID'] : '' );
|
||||
}
|
||||
try {
|
||||
$oPro = ProcessPeer::retrieveByPK( $ProUid );
|
||||
if (!is_null($oPro))
|
||||
{
|
||||
Content::removeContent('PRO_TITLE', '', $oPro->getProUid());
|
||||
Content::removeContent('PRO_DESCRIPTION', '', $oPro->getProUid());
|
||||
return $oPro->delete();
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$ProUid' in table Process doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function exists($ProUid)
|
||||
{
|
||||
$oPro = ProcessPeer::retrieveByPk( $ProUid );
|
||||
return ( get_class ($oPro) == 'Process' );
|
||||
}
|
||||
|
||||
//new functions
|
||||
function getAllProcessesCount(){
|
||||
$c = $this->tmpCriteria;
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn('COUNT(*)');
|
||||
$oDataset = ProcessPeer::doSelectRS($c);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
if( is_array($aRow) )
|
||||
return $aRow[0];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getAllProcesses($start, $limit, $category=NULL, $processName=NULL)
|
||||
{
|
||||
require_once PATH_RBAC . "model/RbacUsers.php";
|
||||
require_once "classes/model/ProcessCategory.php";
|
||||
require_once "classes/model/Users.php";
|
||||
|
||||
$user = new RbacUsers;
|
||||
$aProcesses = Array();
|
||||
$categories = Array();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
|
||||
//$oCriteria->addSelectColumn(ProcessPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(ProcessPeer::TABLE_NAME . '.*');
|
||||
$oCriteria->addSelectColumn(UsersPeer::TABLE_NAME . '.*');
|
||||
$oCriteria->addSelectColumn(ProcessCategoryPeer::TABLE_NAME . '.*');
|
||||
|
||||
$oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL);
|
||||
$oCriteria->addJoin(ProcessPeer::PRO_CREATE_USER, UsersPeer::USR_UID);
|
||||
$oCriteria->addJoin(ProcessPeer::PRO_CATEGORY, ProcessCategoryPeer::CATEGORY_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->addDescendingOrderByColumn(ProcessPeer::PRO_CREATE_DATE);
|
||||
|
||||
if( isset($category) )
|
||||
$oCriteria->add(ProcessPeer::PRO_CATEGORY, $category, Criteria::EQUAL);
|
||||
|
||||
/*if($start != '')
|
||||
$oCriteria->setOffset($start);
|
||||
if($limit != '')
|
||||
$oCriteria->setLimit($limit);
|
||||
*/
|
||||
|
||||
$this->tmpCriteria = $oCriteria;
|
||||
$oDataset = ProcessPeer::doSelectRS ( $oCriteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$casesCnt = $this->getCasesCountInAllProcesses();
|
||||
$processes = Array();
|
||||
$uids=array();
|
||||
while( $oDataset->next() ) {
|
||||
$processes[] = $oDataset->getRow();
|
||||
$uids[] = $processes[sizeof($processes)-1]['PRO_UID'];
|
||||
}
|
||||
|
||||
$c = new Criteria('workflow');
|
||||
//$c->add ( ContentPeer::CON_CATEGORY, 'PRO_TITLE', Criteria::EQUAL );
|
||||
$c->add ( ContentPeer::CON_LANG, defined('SYS_LANG')?SYS_LANG:'en', Criteria::EQUAL );
|
||||
$c->add ( ContentPeer::CON_ID, $uids, Criteria::IN );
|
||||
|
||||
$dt = ContentPeer::doSelectRS ($c);
|
||||
$dt->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$processesDetails = Array();
|
||||
while( $dt->next() ) {
|
||||
$row = $dt->getRow();
|
||||
$processesDetails[$row['CON_ID']][$row['CON_CATEGORY']] = $row['CON_VALUE'];
|
||||
}
|
||||
|
||||
G::loadClass('configuration');
|
||||
$oConf = new Configurations;
|
||||
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS','');
|
||||
|
||||
foreach( $processes as $process ) {
|
||||
|
||||
$proTitle = isset($processesDetails[$process['PRO_UID']]) && isset($processesDetails[$process['PRO_UID']]['PRO_TITLE']) ? $processesDetails[$process['PRO_UID']]['PRO_TITLE']: '';
|
||||
$proDescription = isset($processesDetails[$process['PRO_UID']]) && isset($processesDetails[$process['PRO_UID']]['PRO_DESCRIPTION']) ? $processesDetails[$process['PRO_UID']]['PRO_DESCRIPTION']: '';
|
||||
|
||||
if( isset($processName) && $processName != '' && stripos($proTitle, $processName) === false){
|
||||
continue;
|
||||
}
|
||||
|
||||
$casesCountTotal = 0;
|
||||
if( isset($casesCnt[$process['PRO_UID']]) ) {
|
||||
foreach($casesCnt[$process['PRO_UID']] as $item) {
|
||||
$casesCountTotal += $item;
|
||||
}
|
||||
}
|
||||
|
||||
$userOwner = isset($oConf->aConfig['format'])? $oConf->aConfig['format']: '';
|
||||
$creationDateMask = isset($oConf->aConfig['dateFormat'])? $oConf->aConfig['dateFormat']: '';
|
||||
|
||||
if( $userOwner != '' ){
|
||||
$userOwner = str_replace('@userName', $process['USR_USERNAME'], $userOwner);
|
||||
$userOwner = str_replace('@firstName', $process['USR_FIRSTNAME'], $userOwner);
|
||||
$userOwner = str_replace('@lastName', $process['USR_LASTNAME'], $userOwner);
|
||||
} else {
|
||||
$userOwner = $process['USR_FIRSTNAME'].' '.$process['USR_LASTNAME'];
|
||||
}
|
||||
|
||||
if( $creationDateMask != '' ){
|
||||
list($date, $time) = explode(' ', $process['PRO_CREATE_DATE']);
|
||||
list($y, $m, $d) = explode('-', $date);
|
||||
list($h, $i, $s) = explode(':', $time);
|
||||
|
||||
$process['PRO_CREATE_DATE'] = date($creationDateMask, mktime($h, $i, $s, $m, $d, $y));
|
||||
}
|
||||
|
||||
|
||||
$process['PRO_CATEGORY_LABEL'] = trim($process['PRO_CATEGORY']) != ''? $process['CATEGORY_NAME']: G::LoadTranslation('ID_PROCESS_NO_CATEGORY');
|
||||
$process['PRO_TITLE'] = $proTitle;
|
||||
$process['PRO_DESCRIPTION'] = $proDescription;
|
||||
$process['PRO_DEBUG_LABEL'] = ($process['PRO_DEBUG']=="1")? G::LoadTranslation('ID_ON'): G::LoadTranslation('ID_OFF');
|
||||
$process['PRO_STATUS_LABEL'] = $process ['PRO_STATUS'] == 'ACTIVE'? G::LoadTranslation ('ID_ACTIVE'): G::LoadTranslation('ID_INACTIVE');
|
||||
$process['PRO_CREATE_USER_LABEL'] = $userOwner;
|
||||
$process['CASES_COUNT_TO_DO'] = (isset($casesCnt[$process['PRO_UID']]['TO_DO'])? $casesCnt[$process['PRO_UID']]['TO_DO']: 0);
|
||||
$process['CASES_COUNT_COMPLETED'] = (isset($casesCnt[$process['PRO_UID']]['COMPLETED'])? $casesCnt[$process['PRO_UID']]['COMPLETED']: 0);
|
||||
$process['CASES_COUNT_DRAFT'] = (isset($casesCnt[$process['PRO_UID']]['DRAFT'])? $casesCnt[$process['PRO_UID']]['DRAFT']: 0);
|
||||
$process['CASES_COUNT_CANCELLED'] = (isset($casesCnt[$process['PRO_UID']]['CANCELLED'])? $casesCnt[$process['PRO_UID']]['CANCELLED']: 0);
|
||||
$process['CASES_COUNT'] = $casesCountTotal;
|
||||
$aProcesses[] = $process;
|
||||
|
||||
}
|
||||
return $aProcesses;
|
||||
}
|
||||
|
||||
function getCasesCountInAllProcesses(){
|
||||
/*SELECT PRO_UID, APP_STATUS, COUNT( * )
|
||||
FROM APPLICATION
|
||||
GROUP BY PRO_UID, APP_STATUS*/
|
||||
require_once 'classes/model/Application.php';
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(ApplicationPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(ApplicationPeer::APP_STATUS);
|
||||
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
|
||||
$oCriteria->addGroupByColumn(ApplicationPeer::PRO_UID);
|
||||
$oCriteria->addGroupByColumn(ApplicationPeer::APP_STATUS);
|
||||
|
||||
$oDataset = ProcessPeer::doSelectRS ( $oCriteria );
|
||||
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$aProcesses = Array();
|
||||
while($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
$aProcesses[$row['PRO_UID']][$row['APP_STATUS']] = $row['CNT'];
|
||||
}
|
||||
return $aProcesses;
|
||||
}
|
||||
} // Process
|
||||
57
workflow/engine/classes/model/ProcessCategory.php
Normal file
57
workflow/engine/classes/model/ProcessCategory.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseProcessCategory.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'PROCESS_CATEGORY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ProcessCategory extends BaseProcessCategory {
|
||||
function getAll($type='criteria'){
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
|
||||
$c->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
|
||||
$dataset = ProcessCategoryPeer::doSelectRS($c);
|
||||
$dataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
if( $type == 'array' ){
|
||||
$result = Array();
|
||||
while ( $dataset->next() ) {
|
||||
$result[] = $dataset->getRow();
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
return $c;
|
||||
}
|
||||
}
|
||||
|
||||
function loadByCategoryName($sCategoryName)
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( ProcessCategoryPeer::CATEGORY_UID );
|
||||
$c->addSelectColumn( ProcessCategoryPeer::CATEGORY_NAME);
|
||||
|
||||
$c->add(ProcessCategoryPeer::CATEGORY_NAME, $sCategoryName);
|
||||
$dataset = ProcessCategoryPeer::doSelectRS($c);
|
||||
$dataset->next();
|
||||
$aRow = $dataset->getRow();
|
||||
return $aRow;
|
||||
}
|
||||
|
||||
|
||||
} // ProcessCategory
|
||||
|
||||
|
||||
|
||||
|
||||
23
workflow/engine/classes/model/ProcessCategoryPeer.php
Normal file
23
workflow/engine/classes/model/ProcessCategoryPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseProcessCategoryPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/ProcessCategory.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'PROCESS_CATEGORY' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ProcessCategoryPeer extends BaseProcessCategoryPeer {
|
||||
|
||||
} // ProcessCategoryPeer
|
||||
42
workflow/engine/classes/model/ProcessOwner.php
Normal file
42
workflow/engine/classes/model/ProcessOwner.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* ProcessOwner.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseProcessOwner.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'PROCESS_OWNER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ProcessOwner extends BaseProcessOwner {
|
||||
|
||||
} // ProcessOwner
|
||||
46
workflow/engine/classes/model/ProcessOwnerPeer.php
Normal file
46
workflow/engine/classes/model/ProcessOwnerPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* ProcessOwnerPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseProcessOwnerPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/ProcessOwner.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'PROCESS_OWNER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ProcessOwnerPeer extends BaseProcessOwnerPeer {
|
||||
|
||||
} // ProcessOwnerPeer
|
||||
46
workflow/engine/classes/model/ProcessPeer.php
Normal file
46
workflow/engine/classes/model/ProcessPeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* ProcessPeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseProcessPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Process.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'PROCESS' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ProcessPeer extends BaseProcessPeer {
|
||||
|
||||
} // ProcessPeer
|
||||
96
workflow/engine/classes/model/ProcessUser.php
Normal file
96
workflow/engine/classes/model/ProcessUser.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseProcessUser.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'PROCESS_USER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ProcessUser extends BaseProcessUser {
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(ProcessUserPeer::DATABASE_NAME);
|
||||
try {
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->add(ProcessUserPeer::PU_UID, $aData['PU_UID'] );
|
||||
$criteria->add(ProcessUserPeer::PRO_UID, $aData['PRO_UID'] );
|
||||
$criteria->add(ProcessUserPeer::USR_UID, $aData['USR_UID'] );
|
||||
$criteria->add(ProcessUserPeer::PU_TYPE, $aData['PU_TYPE'] );
|
||||
$objects = ProcessUserPeer::doSelect($criteria, $oConnection);
|
||||
$oConnection->begin();
|
||||
foreach($objects as $row) {
|
||||
$this->remove($row->getTasUid(), $row->getUsrUid(), $row->getTuType(), $row->getTuRelation() );
|
||||
}
|
||||
$oConnection->commit();
|
||||
|
||||
|
||||
$oProcessUser = new ProcessUser();
|
||||
$oProcessUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oProcessUser->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oProcessUser->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oProcessUser->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
* @param string $sPuUid
|
||||
* @param string $sProUid
|
||||
* @param string $sUserUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sPuUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(ProcessUserPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oProcessUser = ProcessUserPeer::retrieveByPK($sPuUid);
|
||||
if (!is_null($oProcessUser))
|
||||
{
|
||||
$oConnection->begin();
|
||||
$iResult = $oProcessUser->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function Exists ( $sUid ) {
|
||||
try {
|
||||
$oObj = ProcessUserPeer::retrieveByPk($sUid);
|
||||
return (get_class($oObj) == 'ProcessUser');
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
} // ProcessUser
|
||||
23
workflow/engine/classes/model/ProcessUserPeer.php
Normal file
23
workflow/engine/classes/model/ProcessUserPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseProcessUserPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/ProcessUser.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'PROCESS_USER' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ProcessUserPeer extends BaseProcessUserPeer {
|
||||
|
||||
} // ProcessUserPeer
|
||||
219
workflow/engine/classes/model/ReportTable.php
Normal file
219
workflow/engine/classes/model/ReportTable.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* ReportTable.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/om/BaseReportTable.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'REPORT_TABLE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ReportTable extends BaseReportTable {
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $rep_tab_title = '';
|
||||
|
||||
/**
|
||||
* Get the rep_tab_title column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getRepTabTitle() {
|
||||
if ( $this->getRepTabUid() == "" ) {
|
||||
throw ( new Exception( "Error in getRepTabTitle, the getRepTabUid() can't be blank") );
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->rep_tab_title = Content::load ( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang );
|
||||
return $this->rep_tab_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rep_tab_title column value.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setRepTabTitle($v)
|
||||
{
|
||||
if ( $this->getRepTabUid() == "" ) {
|
||||
throw ( new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank") );
|
||||
}
|
||||
$v=isset($v)?((string)$v):'';
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
if ($this->rep_tab_title !== $v || $v==="") {
|
||||
$this->rep_tab_title = $v;
|
||||
$res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title );
|
||||
return $res;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function load($RepTabUid)
|
||||
{
|
||||
try {
|
||||
$oRow = ReportTablePeer::retrieveByPK( $RepTabUid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
$this->setRepTabTitle($aFields['REP_TAB_TITLE']=$this->getRepTabTitle());
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
public function create($aData)
|
||||
{
|
||||
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
if ( isset ( $aData['REP_TAB_UID'] ) && $aData['REP_TAB_UID']== '' )
|
||||
unset ( $aData['REP_TAB_UID'] );
|
||||
if ( !isset ( $aData['REP_TAB_UID'] ) )
|
||||
$this->setRepTabUid(G::generateUniqueID());
|
||||
else
|
||||
$this->setRepTabUid($aData['REP_TAB_UID'] );
|
||||
|
||||
$this->setProUid($aData['PRO_UID']);
|
||||
$this->setRepTabName($aData['REP_TAB_NAME']);
|
||||
$this->setRepTabType($aData['REP_TAB_TYPE']);
|
||||
if ( !isset ( $aData['REP_TAB_GRID'] ) )
|
||||
$this->setRepTabGrid("");
|
||||
else
|
||||
$this->setRepTabGrid( $aData['REP_TAB_GRID'] );
|
||||
if ( !isset ( $aData['REP_TAB_CONNECTION'] ) )
|
||||
$this->setRepTabConnection("report");
|
||||
else
|
||||
$this->setRepTabConnection( $aData['REP_TAB_CONNECTION'] );
|
||||
$this->setRepTabCreateDate(date('Y-m-d H:i:s'));
|
||||
$this->setRepTabStatus('ACTIVE');
|
||||
|
||||
if($this->validate())
|
||||
{
|
||||
if ( !isset ( $aData['REP_TAB_TITLE'] ) )
|
||||
$this->setRepTabTitle("");
|
||||
else
|
||||
$this->setRepTabTitle( $aData['REP_TAB_TITLE'] );
|
||||
|
||||
$result=$this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
public function update($fields)
|
||||
{
|
||||
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->load($fields['REP_TAB_UID']);
|
||||
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$contentResult=0;
|
||||
if (array_key_exists("REP_TAB_TITLE", $fields)) $contentResult+=$this->setRepTabTitle($fields["REP_TAB_TITLE"]);
|
||||
$result=$this->save();
|
||||
$result=($result==0)?($contentResult>0?1:0):$result;
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
$validationE=new Exception("Failed Validation in class ".get_class($this).".");
|
||||
$validationE->aValidationFailures = $this->getValidationFailures();
|
||||
throw($validationE);
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
public function remove($RepTabUid)
|
||||
{
|
||||
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$oRepTab = ReportTablePeer::retrieveByPK( $RepTabUid );
|
||||
if (!is_null($oRepTab)) {
|
||||
Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid());
|
||||
$result = $oRepTab->delete();
|
||||
$con->commit();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
function reportTableExists ( $RepTabUid ) {
|
||||
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
|
||||
try {
|
||||
$oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid );
|
||||
if ( get_class ($oRepTabUid) == 'ReportTable' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
} // ReportTable
|
||||
23
workflow/engine/classes/model/ReportTablePeer.php
Normal file
23
workflow/engine/classes/model/ReportTablePeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseReportTablePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/ReportTable.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'REPORT_TABLE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ReportTablePeer extends BaseReportTablePeer {
|
||||
|
||||
} // ReportTablePeer
|
||||
158
workflow/engine/classes/model/ReportVar.php
Normal file
158
workflow/engine/classes/model/ReportVar.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseReportVar.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'REPORT_VAR' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ReportVar extends BaseReportVar {
|
||||
/*
|
||||
* Load the report var registry
|
||||
* @param string $sRepVarUid
|
||||
* @return variant
|
||||
*/
|
||||
public function load($sRepVarUid)
|
||||
{
|
||||
try {
|
||||
$oReportVar = ReportVarPeer::retrieveByPK( $sRepVarUid );
|
||||
if (!is_null($oReportVar))
|
||||
{
|
||||
$aFields = $oReportVar->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the report var registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
|
||||
try {
|
||||
if ( isset ( $aData['REP_VAR_UID'] ) && $aData['REP_VAR_UID']== '' )
|
||||
unset ( $aData['REP_VAR_UID'] );
|
||||
if ( !isset ( $aData['REP_VAR_UID'] ) )
|
||||
$aData['REP_VAR_UID'] = G::generateUniqueID();
|
||||
$oReportVar = new ReportVar();
|
||||
$oReportVar->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oReportVar->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oReportVar->save();
|
||||
$oConnection->commit();
|
||||
return $aData['REP_VAR_UID'];
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oReportVar->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the report var registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oReportVar = ReportVarPeer::retrieveByPK($aData['REP_VAR_UID']);
|
||||
if (!is_null($oReportVar))
|
||||
{
|
||||
$oReportVar->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oReportVar->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oReportVar->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oReportVar->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the report var registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sRepVarUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oReportVar = ReportVarPeer::retrieveByPK($sRepVarUid);
|
||||
if (!is_null($oReportVar))
|
||||
{
|
||||
$oConnection->begin();
|
||||
$iResult = $oReportVar->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function reportVarExists ( $sRepVarUid ) {
|
||||
$con = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oRepVarUid = ReportVarPeer::retrieveByPk( $sRepVarUid );
|
||||
if ( get_class ($oRepVarUid) == 'ReportVar' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
} // ReportVar
|
||||
23
workflow/engine/classes/model/ReportVarPeer.php
Normal file
23
workflow/engine/classes/model/ReportVarPeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseReportVarPeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/ReportVar.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'REPORT_VAR' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class ReportVarPeer extends BaseReportVarPeer {
|
||||
|
||||
} // ReportVarPeer
|
||||
181
workflow/engine/classes/model/Route.php
Normal file
181
workflow/engine/classes/model/Route.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/**
|
||||
* Route.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseRoute.php';
|
||||
require_once 'classes/model/Content.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'ROUTE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class Route extends BaseRoute {
|
||||
|
||||
/*
|
||||
* Load the application document registry
|
||||
* @param string $sRouUid
|
||||
* @return variant
|
||||
*/
|
||||
public function load($sRouUid)
|
||||
{
|
||||
try {
|
||||
$oRoute = RoutePeer::retrieveByPK($sRouUid);
|
||||
if (!is_null($oRoute))
|
||||
{
|
||||
$aFields = $oRoute->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
try {
|
||||
$sRouteUID = G::generateUniqueID();
|
||||
$aData['ROU_UID'] = $sRouteUID;
|
||||
$oRoute = new Route();
|
||||
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oRoute->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oRoute->save();
|
||||
$oConnection->commit();
|
||||
return $sRouteUID;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oRoute->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
try {
|
||||
$oRoute = RoutePeer::retrieveByPK($aData['ROU_UID']);
|
||||
if (!is_null($oRoute))
|
||||
{
|
||||
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oRoute->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oRoute->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oRoute->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The ROUTE tables cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row " . $aData['ROU_UID'] . " doesn't exists!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sRouUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
try {
|
||||
$oRoute = RoutePeer::retrieveByPK($sRouUid);
|
||||
if (!is_null($oRoute))
|
||||
{
|
||||
$oConnection->begin();
|
||||
$iResult = $oRoute->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exists!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function routeExists ( $sRouUid ) {
|
||||
$con = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
try {
|
||||
$oRouUid = RoutePeer::retrieveByPk( $sRouUid );
|
||||
if ( get_class ($oRouUid) == 'Route' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
} // Route
|
||||
46
workflow/engine/classes/model/RoutePeer.php
Normal file
46
workflow/engine/classes/model/RoutePeer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* RoutePeer.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseRoutePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/Route.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'ROUTE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class RoutePeer extends BaseRoutePeer {
|
||||
|
||||
} // RoutePeer
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user