2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Process.php
|
2012-10-18 15:11:53 -04:00
|
|
|
*
|
|
|
|
|
* @package workflow.engine.classes.model
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
2011-01-31 14:14:55 +00:00
|
|
|
* Copyright (C) 2004 - 2011 Colosa Inc.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2012-10-18 15:11:53 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-12-02 23:34:41 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2012-10-18 15:11:53 -04:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2012-11-16 17:13:48 -04:00
|
|
|
//require_once 'classes/model/om/BaseProcess.php';
|
|
|
|
|
//require_once 'classes/model/Content.php';
|
|
|
|
|
//require_once 'classes/model/ProcessCategory.php';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Skeleton subclass for representing a row from the 'PROCESS' table.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* You should add additional methods to this class to meet the
|
2012-10-18 15:11:53 -04:00
|
|
|
* application requirements. This class will only be generated as
|
2010-12-02 23:34:41 +00:00
|
|
|
* long as it does not already exist in the output directory.
|
|
|
|
|
*
|
2012-10-18 15:11:53 -04:00
|
|
|
* @package workflow.engine.classes.model
|
2010-12-02 23:34:41 +00:00
|
|
|
*/
|
2012-10-18 15:11:53 -04:00
|
|
|
class Process extends BaseProcess
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* This value goes in the content table
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2016-06-20 16:50:57 -04:00
|
|
|
protected $pro_title_content = '';
|
2013-12-17 11:14:36 -04:00
|
|
|
public $dir = 'ASC';
|
2013-11-12 10:50:26 -04:00
|
|
|
public $sort = 'PRO_TITLE';
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the [Pro_title] column value.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2016-06-20 16:50:57 -04:00
|
|
|
public function getProTitleContent ()
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
if ($this->getProUid() == '') {
|
|
|
|
|
throw (new Exception( "Error in getProTitle, the PRO_UID can't be blank" ));
|
|
|
|
|
}
|
|
|
|
|
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->pro_title_content = Content::load( 'PRO_TITLE', '', $this->getProUid(), $lang );
|
|
|
|
|
return $this->pro_title_content;
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the [Pro_title] column value.
|
|
|
|
|
*
|
|
|
|
|
* @param string $v new value
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2016-06-20 16:50:57 -04:00
|
|
|
public function setProTitleContent ($v)
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
if ($this->getProUid() == '') {
|
|
|
|
|
throw (new Exception( "Error in setProTitle, the PRO_UID can't be blank" . print_r( debug_backtrace(), 1 ) ));
|
|
|
|
|
}
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
2012-08-07 11:29:18 -04:00
|
|
|
|
2017-04-06 10:04:29 -04:00
|
|
|
if (in_array(ProcessPeer::PRO_TITLE, $this->modifiedColumns) || $v === '') {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->pro_title_content = $v;
|
2012-10-18 15:11:53 -04:00
|
|
|
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2016-06-20 16:50:57 -04:00
|
|
|
$res = Content::addContent( 'PRO_TITLE', '', $this->getProUid(), $lang, $this->pro_title_content );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
} // set()
|
2011-08-01 17:52:16 -04:00
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* This value goes in the content table
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2016-06-20 16:50:57 -04:00
|
|
|
protected $pro_description_content = '';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* Get the [Pro_description] column value.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2016-06-20 16:50:57 -04:00
|
|
|
public function getProDescriptionContent ()
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
if ($this->getProUid() == '') {
|
|
|
|
|
throw (new Exception( "Error in getProDescription, the PRO_UID can't be blank" ));
|
|
|
|
|
}
|
|
|
|
|
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->pro_description_content = Content::load( 'PRO_DESCRIPTION', '', $this->getProUid(), $lang );
|
|
|
|
|
return $this->pro_description_content;
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the [Pro_description] column value.
|
|
|
|
|
*
|
|
|
|
|
* @param string $v new value
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2016-06-20 16:50:57 -04:00
|
|
|
public function setProDescriptionContent ($v)
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2017-04-06 10:04:29 -04:00
|
|
|
if (in_array(ProcessPeer::PRO_DESCRIPTION, $this->modifiedColumns) || $v === '') {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->pro_description_content = $v;
|
2012-10-18 15:11:53 -04:00
|
|
|
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2016-06-20 16:50:57 -04:00
|
|
|
$res = Content::addContent( 'PRO_DESCRIPTION', '', $this->getProUid(), $lang, $this->pro_description_content );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
} // set()
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* 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
|
2014-03-26 20:04:31 -04:00
|
|
|
* @return string
|
2012-10-18 15:11:53 -04:00
|
|
|
*/
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2013-12-17 11:14:36 -04:00
|
|
|
public function create ($aData, $generateUid = true)
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
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 {
|
2013-12-17 11:14:36 -04:00
|
|
|
if ($generateUid) {
|
|
|
|
|
do {
|
|
|
|
|
$sNewProUid = G::generateUniqueID();
|
|
|
|
|
} while ($this->processExists( $sNewProUid ));
|
|
|
|
|
} else {
|
|
|
|
|
$sNewProUid = $aData['PRO_UID'];
|
2017-03-06 17:17:48 -04:00
|
|
|
if (!empty($aData['PRO_ID'])) {
|
|
|
|
|
$this->setProId($aData['PRO_ID']);
|
|
|
|
|
}
|
2013-12-17 11:14:36 -04:00
|
|
|
}
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
$this->setProUid( $sNewProUid );
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProTitle((isset($aData['PRO_TITLE'])) ? $aData['PRO_TITLE'] : 'Default Process Title');
|
|
|
|
|
$this->setProDescription((isset($aData['PRO_DESCRIPTION'])) ? $aData['PRO_DESCRIPTION'] : 'Default Process Description');
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->setProParent( $sNewProUid );
|
|
|
|
|
$this->setProTime( 1 );
|
|
|
|
|
$this->setProTimeunit( 'DAYS' );
|
2017-04-04 14:46:56 -04:00
|
|
|
$this->setProStatus((isset($aData["PRO_STATUS"])) ? $aData["PRO_STATUS"] : 'ACTIVE');
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->setProTypeDay( '' );
|
2015-11-12 19:39:35 -04:00
|
|
|
$this->setProType((isset($aData["PRO_TYPE"]))? $aData["PRO_TYPE"]: "NORMAL");
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->setProAssignment( 'FALSE' );
|
|
|
|
|
$this->setProShowMap( '' );
|
|
|
|
|
$this->setProShowMessage( '' );
|
|
|
|
|
$this->setProShowDelegate( '' );
|
|
|
|
|
$this->setProShowDynaform( '' );
|
2015-11-12 19:39:35 -04:00
|
|
|
$this->setProCategory((isset($aData["PRO_CATEGORY"]))? $aData["PRO_CATEGORY"]: "");
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->setProSubCategory( '' );
|
|
|
|
|
$this->setProIndustry( '' );
|
2015-02-20 14:26:57 -04:00
|
|
|
$this->setProCreateDate( date("Y-m-d H:i:s") );
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->setProCreateUser( $aData['USR_UID'] );
|
|
|
|
|
$this->setProHeight( 5000 );
|
|
|
|
|
$this->setProWidth( 10000 );
|
|
|
|
|
$this->setProTitleX( 0 );
|
|
|
|
|
$this->setProTitleY( 0 );
|
2016-06-09 16:14:50 -04:00
|
|
|
$this->setProItee( 1 );
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->setProDynaforms( isset( $aData['PRO_DYNAFORMS'] ) ? (is_array( $aData['PRO_DYNAFORMS'] ) ? serialize( $aData['PRO_DYNAFORMS'] ) : $aData['PRO_DYNAFORMS']) : '' );
|
|
|
|
|
|
|
|
|
|
if ($this->validate()) {
|
|
|
|
|
$con->begin();
|
|
|
|
|
|
|
|
|
|
if (isset( $aData['PRO_TITLE'] )) {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProTitleContent( $aData['PRO_TITLE'] );
|
2012-10-18 15:11:53 -04:00
|
|
|
} else {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProTitleContent( 'Default Process Title' );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset( $aData['PRO_DESCRIPTION'] )) {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProDescriptionContent( $aData['PRO_DESCRIPTION'] );
|
2012-10-18 15:11:53 -04:00
|
|
|
} else {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProDescriptionContent( 'Default Process Description' );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
|
2017-04-07 16:28:20 -04:00
|
|
|
$res = $this->save();
|
2012-10-18 15:11:53 -04:00
|
|
|
$con->commit();
|
|
|
|
|
|
|
|
|
|
$this->memcachedDelete();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* verify if Process row specified in [pro_id] exists.
|
|
|
|
|
*
|
|
|
|
|
* @param string $sProUid the uid of the Prolication
|
|
|
|
|
*/
|
2012-10-20 16:52:15 -04:00
|
|
|
public function processExists ($ProUid)
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$oPro = ProcessPeer::retrieveByPk( $ProUid );
|
|
|
|
|
if (is_object( $oPro ) && get_class( $oPro ) == 'Process') {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* Load the Process row specified in [pro_id] column value.
|
|
|
|
|
*
|
|
|
|
|
* @param string $ProUid the uid of the Prolication
|
|
|
|
|
* @return array $Fields the fields
|
|
|
|
|
*/
|
2012-10-20 16:52:15 -04:00
|
|
|
public function load ($ProUid, $getAllLang = false)
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$oPro = ProcessPeer::retrieveByPk( $ProUid );
|
|
|
|
|
if (is_object( $oPro ) && 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'];
|
|
|
|
|
|
|
|
|
|
//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 (is_object( $oProCat ) && get_class( $oProCat ) == 'ProcessCategory') {
|
|
|
|
|
$aFields['PRO_CATEGORY_LABEL'] = $oProCat->getCategoryName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$aFields['PRO_DYNAFORMS'] = @unserialize( $aFields['PRO_DYNAFORMS'] );
|
2015-02-13 16:30:11 -04:00
|
|
|
//Check if is BPMN process
|
|
|
|
|
$aFields['PRO_BPMN'] = $this->isBpmnProcess($ProUid);
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
return $aFields;
|
|
|
|
|
} else {
|
|
|
|
|
throw (new Exception( "The row '$ProUid' in table Process doesn't exist!" ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function getAll ()
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
|
|
|
|
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_UID );
|
2016-06-20 16:50:57 -04:00
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_TITLE );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_DESCRIPTION );
|
2012-10-18 15:11:53 -04:00
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_PARENT );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_STATUS );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_CATEGORY );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_CREATE_DATE );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_CREATE_USER );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_DEBUG );
|
|
|
|
|
|
|
|
|
|
$oCriteria->add( ProcessPeer::PRO_UID, '', Criteria::NOT_EQUAL );
|
|
|
|
|
$oCriteria->add( ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL );
|
|
|
|
|
|
|
|
|
|
//execute the query
|
2014-10-07 14:39:40 -04:00
|
|
|
$oDataset = ProcessPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
2012-10-18 15:11:53 -04:00
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$processes = Array ();
|
|
|
|
|
$uids = array ();
|
|
|
|
|
while ($oDataset->next()) {
|
2016-01-29 18:24:50 -04:00
|
|
|
$row = $oDataset->getRow();
|
2016-06-15 17:03:07 -04:00
|
|
|
|
2016-01-29 18:24:50 -04:00
|
|
|
$processes[] = $row;
|
2012-10-18 15:11:53 -04:00
|
|
|
$uids[] = $processes[sizeof( $processes ) - 1]['PRO_UID'];
|
|
|
|
|
}
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
G::loadClass( 'configuration' );
|
|
|
|
|
$oConf = new Configurations();
|
|
|
|
|
$oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2013-12-17 11:14:36 -04:00
|
|
|
if ($this->dir=='ASC') {
|
|
|
|
|
usort( $processes, array($this, "ordProcessAsc") );
|
|
|
|
|
} else {
|
|
|
|
|
usort( $processes, array($this, "ordProcessDesc") );
|
2013-11-07 12:51:41 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
return $processes;
|
2011-06-28 12:53:25 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* Update the Prolication row
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return variant
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function update ($aData)
|
|
|
|
|
{
|
|
|
|
|
if (isset( $aData['PRO_DYNAFORMS'] ) && is_array( $aData['PRO_DYNAFORMS'] )) {
|
|
|
|
|
$aData['PRO_DYNAFORMS'] = @serialize( $aData['PRO_DYNAFORMS'] );
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$con->begin();
|
|
|
|
|
$oPro = ProcessPeer::retrieveByPK( $aData['PRO_UID'] );
|
|
|
|
|
if (is_object( $oPro ) && get_class( $oPro ) == 'Process') {
|
|
|
|
|
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
if ($oPro->validate()) {
|
|
|
|
|
if (isset( $aData['PRO_TITLE'] )) {
|
2016-06-20 16:50:57 -04:00
|
|
|
$oPro->setProTitleContent( $aData['PRO_TITLE'] );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
if (isset( $aData['PRO_DESCRIPTION'] )) {
|
2016-06-20 16:50:57 -04:00
|
|
|
$oPro->setProDescriptionContent( $aData['PRO_DESCRIPTION'] );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
$res = $oPro->save();
|
|
|
|
|
$con->commit();
|
|
|
|
|
|
|
|
|
|
$this->memcachedDelete();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2011-08-25 12:58:52 -04:00
|
|
|
}
|
2012-08-07 11:29:18 -04:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* creates an Application row
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return variant
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function createRow ($aData)
|
|
|
|
|
{
|
|
|
|
|
$con = Propel::getConnection( ProcessPeer::DATABASE_NAME );
|
|
|
|
|
//$con->begin(); //does not allow dual BEGIN
|
|
|
|
|
$this->setProUid( $aData['PRO_UID'] );
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProTitle((isset($aData['PRO_TITLE'])) ? $aData['PRO_TITLE'] : 'Default Process Title');
|
|
|
|
|
$this->setProDescription((isset($aData['PRO_DESCRIPTION'])) ? $aData['PRO_DESCRIPTION'] : 'Default Process Description');
|
2012-10-18 15:11:53 -04:00
|
|
|
$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->setProSubprocess( isset( $aData['PRO_SUBPROCESS'] ) ? $aData['PRO_SUBPROCESS'] : '' );
|
|
|
|
|
$this->setProTriDeleted( isset( $aData['PRO_TRI_DELETED'] ) ? $aData['PRO_TRI_DELETED'] : '' );
|
|
|
|
|
$this->setProTriCanceled( isset( $aData['PRO_TRI_CANCELED'] ) ? $aData['PRO_TRI_CANCELED'] : '' );
|
|
|
|
|
$this->setProTriPaused( isset( $aData['PRO_TRI_PAUSED'] ) ? $aData['PRO_TRI_PAUSED'] : '' );
|
|
|
|
|
$this->setProTriReassigned( isset( $aData['PRO_TRI_REASSIGNED'] ) ? $aData['PRO_TRI_REASSIGNED'] : '' );
|
2014-11-04 10:03:54 -04:00
|
|
|
$this->setProTriUnpaused( isset( $aData['PRO_TRI_UNPAUSED'] ) ? $aData['PRO_TRI_UNPAUSED'] : '' );
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->setProShowDelegate( $aData['PRO_SHOW_DELEGATE'] );
|
|
|
|
|
$this->setProShowDynaform( $aData['PRO_SHOW_DYNAFORM'] );
|
2013-04-02 13:28:06 -04:00
|
|
|
$this->setProDerivationScreenTpl( isset( $aData['PRO_DERIVATION_SCREEN_TPL']) ? $aData['PRO_DERIVATION_SCREEN_TPL'] : '' );
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
// validate if the category exists
|
|
|
|
|
$criteria = new Criteria( 'workflow' );
|
|
|
|
|
$criteria->add( ProcessCategoryPeer::CATEGORY_UID, $aData['PRO_CATEGORY'] );
|
2014-10-07 14:39:40 -04:00
|
|
|
$ds = ProcessCategoryPeer::doSelectRS( $criteria, Propel::getDbConnection('workflow_ro') );
|
2012-10-18 15:11:53 -04:00
|
|
|
$ds->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$ds->next();
|
|
|
|
|
// if it is not set, set value as empty "No Category"
|
|
|
|
|
if (! $ds->getRow()) {
|
|
|
|
|
$aData['PRO_CATEGORY'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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'] );
|
|
|
|
|
$this->setProDynaforms( isset( $aData['PRO_DYNAFORMS'] ) ? (is_array( $aData['PRO_DYNAFORMS'] ) ? serialize( $aData['PRO_DYNAFORMS'] ) : $aData['PRO_DYNAFORMS']) : '' );
|
|
|
|
|
if ($this->validate()) {
|
|
|
|
|
$con->begin();
|
|
|
|
|
|
|
|
|
|
if (isset( $aData['PRO_TITLE'] ) && trim( $aData['PRO_TITLE'] ) != '') {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProTitleContent( $aData['PRO_TITLE'] );
|
2012-10-18 15:11:53 -04:00
|
|
|
} else {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProTitleContent( 'Default Process Title' );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
if (isset( $aData['PRO_DESCRIPTION'] )) {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProDescriptionContent( $aData['PRO_DESCRIPTION'] );
|
2012-10-18 15:11:53 -04:00
|
|
|
} else {
|
2016-06-20 16:50:57 -04:00
|
|
|
$this->setProDescriptionContent( 'Default Process Description' );
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
2017-04-07 16:28:20 -04:00
|
|
|
|
|
|
|
|
$res = $this->save();
|
2012-10-18 15:11:53 -04:00
|
|
|
$con->commit();
|
|
|
|
|
|
|
|
|
|
$this->memcachedDelete();
|
|
|
|
|
|
|
|
|
|
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 ) ));
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
/**
|
|
|
|
|
* 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() );
|
|
|
|
|
$this->memcachedDelete();
|
|
|
|
|
return $oPro->delete();
|
|
|
|
|
} else {
|
|
|
|
|
throw (new Exception( "The row '$ProUid' in table Process doesn't exist!" ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
public function exists ($ProUid)
|
|
|
|
|
{
|
|
|
|
|
$oPro = ProcessPeer::retrieveByPk( $ProUid );
|
|
|
|
|
return (is_object( $oPro ) && get_class( $oPro ) == 'Process');
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 15:11:53 -04:00
|
|
|
|
2016-10-07 12:49:26 -04:00
|
|
|
/**
|
|
|
|
|
* @param $proTitle
|
|
|
|
|
* @return bool
|
|
|
|
|
* @throws PropelException
|
|
|
|
|
*/
|
|
|
|
|
public static function existsByProTitle($proTitle)
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
2014-06-20 11:48:57 -04:00
|
|
|
$oCriteria = new Criteria("workflow");
|
2016-06-20 16:50:57 -04:00
|
|
|
$oCriteria->addSelectColumn(ProcessPeer::PRO_TITLE);
|
2016-10-07 12:49:26 -04:00
|
|
|
$oCriteria->add(ProcessPeer::PRO_TITLE, $proTitle);
|
|
|
|
|
$oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
|
|
|
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2012-10-18 15:11:53 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
$aRow = $oDataset->getRow();
|
2016-10-07 12:49:26 -04:00
|
|
|
return ($aRow) ? true : false;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 15:11:53 -04:00
|
|
|
|
2016-06-20 16:50:57 -04:00
|
|
|
public static function getByProTitle($proTitle)
|
|
|
|
|
{
|
2015-01-29 10:59:45 -04:00
|
|
|
$oCriteria = new Criteria("workflow");
|
2016-06-20 16:50:57 -04:00
|
|
|
$oCriteria->add(ProcessPeer::PRO_TITLE, $proTitle);
|
|
|
|
|
$oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
2015-01-29 10:59:45 -04:00
|
|
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$aRow = $oDataset->getRow();
|
2016-06-20 16:50:57 -04:00
|
|
|
return isset($aRow) ? $aRow : null;
|
2015-01-29 10:59:45 -04:00
|
|
|
}
|
|
|
|
|
|
2016-06-20 16:50:57 -04:00
|
|
|
public static function getNextTitle($proTitle)
|
|
|
|
|
{
|
2015-01-29 10:59:45 -04:00
|
|
|
$oCriteria = new Criteria('workflow');
|
2016-06-20 16:50:57 -04:00
|
|
|
$oCriteria->addSelectColumn(ProcessPeer::PRO_TITLE);
|
|
|
|
|
$oCriteria->add(ProcessPeer::PRO_TITLE, $proTitle . '-%', Criteria::LIKE);
|
|
|
|
|
$oCriteria->addAscendingOrderByColumn(ProcessPeer::PRO_TITLE);
|
|
|
|
|
$oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
2015-01-29 10:59:45 -04:00
|
|
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$data = array();
|
|
|
|
|
$may = 0;
|
|
|
|
|
while ($oDataset->next()) {
|
|
|
|
|
$row = $oDataset->getRow();
|
2016-06-20 16:50:57 -04:00
|
|
|
$number = explode("-", $row["PRO_TITLE"]);
|
2015-01-29 10:59:45 -04:00
|
|
|
$number = $number[count($number) - 1] + 0;
|
|
|
|
|
if ($number > $may) {
|
|
|
|
|
$may = $number;
|
|
|
|
|
}
|
2016-06-20 16:50:57 -04:00
|
|
|
$row["PRO_TITLE"] = $number;
|
2015-01-29 10:59:45 -04:00
|
|
|
$data[] = $row;
|
|
|
|
|
}
|
2015-01-30 14:41:26 -04:00
|
|
|
return $proTitle . "-" . ($may + 1);
|
2015-01-29 10:59:45 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function getAllProcessesCount ()
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
$c = $this->tmpCriteria;
|
|
|
|
|
$c->clearSelectColumns();
|
|
|
|
|
$c->addSelectColumn( 'COUNT(*)' );
|
2014-10-07 14:39:40 -04:00
|
|
|
$oDataset = ProcessPeer::doSelectRS( $c, Propel::getDbConnection('workflow_ro') );
|
2012-10-18 15:11:53 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
$aRow = $oDataset->getRow();
|
|
|
|
|
|
|
|
|
|
if (is_array( $aRow )) {
|
|
|
|
|
return $aRow[0];
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2012-10-12 12:46:35 -04:00
|
|
|
}
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2014-09-30 09:47:35 -04:00
|
|
|
public function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false, $userLogged = "")
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
2013-11-06 13:34:25 -04:00
|
|
|
require_once PATH_RBAC . "model/RbacUsers.php";
|
2012-10-18 15:11:53 -04:00
|
|
|
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 );
|
2016-06-20 16:50:57 -04:00
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_TITLE );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_DESCRIPTION );
|
2012-10-18 15:11:53 -04:00
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_PARENT );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_STATUS );
|
2015-09-21 10:18:44 -04:00
|
|
|
$oCriteria->addSelectColumn(ProcessPeer::PRO_TYPE);
|
2012-10-18 15:11:53 -04:00
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_CATEGORY );
|
2014-02-26 12:53:17 -04:00
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_UPDATE_DATE );
|
2012-10-18 15:11:53 -04:00
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_CREATE_DATE );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_CREATE_USER );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_DEBUG );
|
2014-09-23 16:40:22 -04:00
|
|
|
$oCriteria->addSelectColumn(ProcessPeer::PRO_TYPE_PROCESS);
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
|
|
|
|
$oCriteria->addSelectColumn( UsersPeer::USR_USERNAME );
|
|
|
|
|
$oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
|
|
|
|
$oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
|
|
|
|
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessCategoryPeer::CATEGORY_UID );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessCategoryPeer::CATEGORY_NAME );
|
|
|
|
|
|
|
|
|
|
$oCriteria->add( ProcessPeer::PRO_UID, '', Criteria::NOT_EQUAL );
|
|
|
|
|
$oCriteria->add( ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL );
|
|
|
|
|
if ($reviewSubProcess) {
|
|
|
|
|
$oCriteria->add( ProcessPeer::PRO_SUBPROCESS, '1', Criteria::NOT_EQUAL );
|
|
|
|
|
}
|
2011-02-04 20:38:49 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
if (isset( $category )) {
|
|
|
|
|
$oCriteria->add( ProcessPeer::PRO_CATEGORY, $category, Criteria::EQUAL );
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
$oCriteria->addJoin( ProcessPeer::PRO_CREATE_USER, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
|
|
|
|
|
$oCriteria->addJoin( ProcessPeer::PRO_CATEGORY, ProcessCategoryPeer::CATEGORY_UID, Criteria::LEFT_JOIN );
|
2014-09-30 09:47:35 -04:00
|
|
|
|
2014-11-12 16:24:43 -04:00
|
|
|
if ($this->sort == "PRO_CREATE_DATE") {
|
|
|
|
|
if ($this->dir == "DESC") {
|
|
|
|
|
$oCriteria->addDescendingOrderByColumn(ProcessPeer::PRO_CREATE_DATE);
|
|
|
|
|
} else {
|
|
|
|
|
$oCriteria->addAscendingOrderByColumn(ProcessPeer::PRO_CREATE_DATE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-30 09:47:35 -04:00
|
|
|
if ($userLogged != "") {
|
|
|
|
|
$oCriteria->add(
|
2014-09-23 16:40:22 -04:00
|
|
|
$oCriteria->getNewCriterion(ProcessPeer::PRO_TYPE_PROCESS, "PUBLIC", Criteria::EQUAL)->addOr(
|
2014-09-30 09:47:35 -04:00
|
|
|
$oCriteria->getNewCriterion(ProcessPeer::PRO_CREATE_USER, $userLogged, Criteria::EQUAL))
|
|
|
|
|
);
|
|
|
|
|
}
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
$this->tmpCriteria = clone $oCriteria;
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2013-11-06 13:34:25 -04:00
|
|
|
//execute a query to obtain numbers, how many cases there are by process
|
2012-10-18 15:11:53 -04:00
|
|
|
if ($counters) {
|
|
|
|
|
$casesCnt = $this->getCasesCountInAllProcesses();
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
// getting bpmn projects
|
|
|
|
|
$c = new Criteria('workflow');
|
|
|
|
|
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
|
2014-10-07 14:39:40 -04:00
|
|
|
$ds = ProcessPeer::doSelectRS($c, Propel::getDbConnection('workflow_ro') );
|
2014-01-23 21:29:03 -04:00
|
|
|
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$bpmnProjects = array();
|
|
|
|
|
|
|
|
|
|
while ($ds->next()) {
|
|
|
|
|
$row = $ds->getRow();
|
|
|
|
|
$bpmnProjects[] = $row['PRJ_UID'];
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
//execute the query
|
|
|
|
|
$oDataset = ProcessPeer::doSelectRS( $oCriteria );
|
|
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$processes = Array ();
|
|
|
|
|
$uids = array ();
|
|
|
|
|
while ($oDataset->next()) {
|
2014-01-23 21:29:03 -04:00
|
|
|
$row = $oDataset->getRow();
|
2015-09-21 10:18:44 -04:00
|
|
|
|
|
|
|
|
$row["PROJECT_TYPE"] = ($row["PRO_TYPE"] == "NORMAL")? ((in_array($row["PRO_UID"], $bpmnProjects))? "bpmn" : "classic") : $row["PRO_TYPE"];
|
|
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
$processes[] = $row;
|
2012-10-18 15:11:53 -04:00
|
|
|
$uids[] = $processes[sizeof( $processes ) - 1]['PRO_UID'];
|
|
|
|
|
}
|
2011-02-04 20:38:49 +00:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
G::loadClass( 'configuration' );
|
|
|
|
|
$oConf = new Configurations();
|
|
|
|
|
$oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
|
|
|
|
|
|
|
|
|
|
foreach ($processes as $process) {
|
2016-06-20 16:50:57 -04:00
|
|
|
$proTitle = isset($process['PRO_TITLE'])? $process['PRO_TITLE'] : '';
|
2016-08-24 13:55:38 -04:00
|
|
|
$proDescription = isset($process['PRO_DESCRIPTION']) ? htmlspecialchars($process['PRO_DESCRIPTION']) : '';
|
2014-09-23 16:40:22 -04:00
|
|
|
$process["PRO_TYPE_PROCESS"] = ($process["PRO_TYPE_PROCESS"] == "PUBLIC") ? G::LoadTranslation("ID_PUBLIC") : G::LoadTranslation("ID_PRIVATE");
|
2012-10-18 15:11:53 -04:00
|
|
|
// verify if the title is already set on the current language
|
|
|
|
|
if (trim( $proTitle ) == '') {
|
|
|
|
|
// if not, then load the record to generate content for current language
|
|
|
|
|
$proData = $this->load( $process['PRO_UID'] );
|
|
|
|
|
$proTitle = $proData['PRO_TITLE'];
|
2016-08-24 13:55:38 -04:00
|
|
|
$proDescription = htmlspecialchars($proData['PRO_DESCRIPTION']);
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//filtering by $processName
|
|
|
|
|
if (isset( $processName ) && $processName != '' && stripos( $proTitle, $processName ) === false) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($counters) {
|
|
|
|
|
$casesCountTotal = 0;
|
|
|
|
|
if (isset( $casesCnt[$process['PRO_UID']] )) {
|
|
|
|
|
foreach ($casesCnt[$process['PRO_UID']] as $item) {
|
|
|
|
|
$casesCountTotal += $item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get user format from configuration
|
|
|
|
|
$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 );
|
|
|
|
|
if ($userOwner == " ( )") {
|
|
|
|
|
$userOwner = '-';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$userOwner = $process['USR_FIRSTNAME'] . ' ' . $process['USR_LASTNAME'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get date format from configuration
|
|
|
|
|
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 ) );
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-16 13:10:09 -04:00
|
|
|
$process['PRO_CATEGORY_LABEL'] = trim( $process['PRO_CATEGORY'] ) != '' ? $process['CATEGORY_NAME'] : '- ' . G::LoadTranslation( 'ID_PROCESS_NO_CATEGORY' ) . ' -';
|
2012-10-18 15:11:53 -04:00
|
|
|
$process['PRO_TITLE'] = $proTitle;
|
|
|
|
|
$process['PRO_DESCRIPTION'] = $proDescription;
|
|
|
|
|
$process['PRO_DEBUG'] = $process['PRO_DEBUG'];
|
|
|
|
|
$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;
|
|
|
|
|
if ($counters) {
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset( $process['PRO_CREATE_USER'] );
|
|
|
|
|
|
|
|
|
|
$aProcesses[] = $process;
|
|
|
|
|
|
|
|
|
|
}
|
2014-06-20 11:48:57 -04:00
|
|
|
|
2013-11-06 13:34:25 -04:00
|
|
|
$memcache = & PMmemcached::getSingleton( SYS_SYS );
|
2013-11-07 11:51:47 -04:00
|
|
|
if (isset($memcache) && $memcache->enabled == 1 ) {
|
|
|
|
|
return $aProcesses;
|
2013-11-06 13:34:25 -04:00
|
|
|
}
|
2013-11-07 11:51:47 -04:00
|
|
|
|
|
|
|
|
if ($limit == '') {
|
|
|
|
|
$limit = count($aProcesses);
|
|
|
|
|
}
|
2014-11-12 16:24:43 -04:00
|
|
|
|
|
|
|
|
if ($this->sort != "PRO_CREATE_DATE") {
|
|
|
|
|
if ($this->dir == "ASC") {
|
|
|
|
|
usort($aProcesses, array($this, "ordProcessAsc"));
|
|
|
|
|
} else {
|
|
|
|
|
usort($aProcesses, array($this, "ordProcessDesc"));
|
|
|
|
|
}
|
2013-11-21 11:55:48 -04:00
|
|
|
}
|
2013-11-07 11:51:47 -04:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
return $aProcesses;
|
2012-08-07 11:29:18 -04:00
|
|
|
}
|
2012-10-18 15:11:53 -04:00
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function getCasesCountInAllProcesses ()
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
/*SELECT PRO_UID, APP_STATUS, COUNT( * )
|
|
|
|
|
FROM APPLICATION
|
|
|
|
|
GROUP BY PRO_UID, APP_STATUS*/
|
|
|
|
|
require_once 'classes/model/Application.php';
|
|
|
|
|
|
|
|
|
|
$memcache = & PMmemcached::getSingleton( SYS_SYS );
|
|
|
|
|
$memkey = 'getCasesCountInAllProcesses';
|
|
|
|
|
if (($aProcesses = $memcache->get( $memkey )) === false) {
|
|
|
|
|
$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 );
|
|
|
|
|
|
2014-10-07 14:39:40 -04:00
|
|
|
$oDataset = ProcessPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
2012-10-18 15:11:53 -04:00
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
|
|
|
|
|
$aProcesses = Array ();
|
|
|
|
|
while ($oDataset->next()) {
|
|
|
|
|
$row = $oDataset->getRow();
|
|
|
|
|
$aProcesses[$row['PRO_UID']][$row['APP_STATUS']] = $row['CNT'];
|
|
|
|
|
}
|
|
|
|
|
$memcache->set( $memkey, $aProcesses, PMmemcached::ONE_HOUR );
|
|
|
|
|
}
|
|
|
|
|
return $aProcesses;
|
2012-10-16 00:29:52 -04:00
|
|
|
}
|
|
|
|
|
|
2014-04-25 11:38:53 -04:00
|
|
|
public function getCasesCountForProcess($pro_uid)
|
|
|
|
|
{
|
|
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
|
|
|
|
$oCriteria->addSelectColumn( 'COUNT(*) AS TOTAL_CASES' );
|
|
|
|
|
$oCriteria->add( ApplicationPeer::PRO_UID, $pro_uid );
|
2014-10-07 14:39:40 -04:00
|
|
|
$oDataset = ApplicationPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
2014-04-25 11:38:53 -04:00
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$cases = $oDataset->getRow();
|
|
|
|
|
return (int)$cases['TOTAL_CASES'];
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function getAllProcessesByCategory ()
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_CATEGORY );
|
|
|
|
|
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
|
|
|
|
|
$oCriteria->addGroupByColumn( ProcessPeer::PRO_CATEGORY );
|
2014-10-07 14:39:40 -04:00
|
|
|
$oDataSet = ProcessPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
2012-10-18 15:11:53 -04:00
|
|
|
$oDataSet->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$aProc = Array ();
|
|
|
|
|
while ($oDataSet->next()) {
|
|
|
|
|
$row = $oDataSet->getRow();
|
|
|
|
|
$aProc[$row['PRO_CATEGORY']] = $row['CNT'];
|
|
|
|
|
}
|
|
|
|
|
return $aProc;
|
2012-10-16 00:29:52 -04:00
|
|
|
}
|
2012-10-18 15:11:53 -04:00
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function getTriggerWebBotProcess ($proUid, $action)
|
2012-10-18 15:11:53 -04:00
|
|
|
{
|
|
|
|
|
require_once ("classes/model/Triggers.php");
|
|
|
|
|
|
|
|
|
|
if ((! isset( $proUid ) && $proUid == '') || (! isset( $action ) && $action == '')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$action = G::toUpper( $action );
|
2016-11-10 11:50:57 -05:00
|
|
|
$arrayWebBotTrigger = [];
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
switch ($action) {
|
2016-11-11 12:15:22 -04:00
|
|
|
case 'CREATE':
|
|
|
|
|
$var = ProcessPeer::PRO_TRI_CREATE;
|
|
|
|
|
break;
|
2015-11-10 11:37:39 -04:00
|
|
|
case 'OPEN':
|
|
|
|
|
$var = ProcessPeer::PRO_TRI_OPEN;
|
|
|
|
|
break;
|
2012-10-18 15:11:53 -04:00
|
|
|
case 'DELETED':
|
|
|
|
|
$var = ProcessPeer::PRO_TRI_DELETED;
|
|
|
|
|
break;
|
|
|
|
|
case 'CANCELED':
|
|
|
|
|
$var = ProcessPeer::PRO_TRI_CANCELED;
|
|
|
|
|
break;
|
|
|
|
|
case 'PAUSED':
|
|
|
|
|
$var = ProcessPeer::PRO_TRI_PAUSED;
|
|
|
|
|
break;
|
|
|
|
|
case 'REASSIGNED':
|
|
|
|
|
$var = ProcessPeer::PRO_TRI_REASSIGNED;
|
|
|
|
|
break;
|
2014-08-20 13:20:08 -04:00
|
|
|
case "UNPAUSE":
|
|
|
|
|
$var = ProcessPeer::PRO_TRI_UNPAUSED;
|
|
|
|
|
break;
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
2014-08-20 13:20:08 -04:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
|
|
|
|
$oCriteria->addSelectColumn( $var );
|
2016-11-10 11:50:57 -05:00
|
|
|
$oCriteria->addSelectColumn( TriggersPeer::TRI_UID);
|
2012-10-18 15:11:53 -04:00
|
|
|
$oCriteria->addSelectColumn( TriggersPeer::TRI_WEBBOT );
|
|
|
|
|
$oCriteria->addJoin( $var, TriggersPeer::TRI_UID, Criteria::LEFT_JOIN );
|
|
|
|
|
$oCriteria->add( ProcessPeer::PRO_UID, $proUid );
|
2014-10-07 14:39:40 -04:00
|
|
|
$oDataSet = ProcessPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
2012-10-18 15:11:53 -04:00
|
|
|
|
|
|
|
|
$oDataSet->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
if ($oDataSet->next()) {
|
|
|
|
|
$row = $oDataSet->getRow();
|
2016-11-10 11:50:57 -05:00
|
|
|
$arrayWebBotTrigger = ['TRI_UID' => $row['TRI_UID'], 'TRI_WEBBOT' => $row['TRI_WEBBOT']];
|
2012-10-18 15:11:53 -04:00
|
|
|
}
|
2014-08-20 13:20:08 -04:00
|
|
|
|
2016-11-10 11:50:57 -05:00
|
|
|
//Return
|
|
|
|
|
return $arrayWebBotTrigger;
|
2012-10-16 00:29:52 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
public function memcachedDelete ()
|
2012-08-07 11:29:18 -04:00
|
|
|
{
|
|
|
|
|
//Limit defined in processmaker/workflow/engine/templates/processes/main.js
|
|
|
|
|
$limit = 25;
|
|
|
|
|
$start = 0;
|
|
|
|
|
|
2014-01-30 19:15:10 -04:00
|
|
|
$memcache = PMmemcached::getSingleton( SYS_SYS );
|
2012-08-07 11:29:18 -04:00
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
for ($start = 0; $start <= 50 - 1; $start ++) {
|
2012-08-07 11:29:18 -04:00
|
|
|
$memkey = "processList-allProcesses-" . ($start * $limit) . "-" . $limit;
|
|
|
|
|
$memkeyTotal = $memkey . "-total";
|
|
|
|
|
|
2012-10-18 15:11:53 -04:00
|
|
|
$r = $memcache->delete( $memkey );
|
|
|
|
|
$r = $memcache->delete( $memkeyTotal );
|
2012-08-07 11:29:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
2014-06-20 11:48:57 -04:00
|
|
|
|
2013-11-08 09:06:18 -04:00
|
|
|
public function orderMemcache($dataMemcache, $start, $limit)
|
2013-11-06 13:34:25 -04:00
|
|
|
{
|
2013-11-08 09:06:18 -04:00
|
|
|
if ($this->dir=='ASC') {
|
|
|
|
|
usort( $dataMemcache, array($this, "ordProcessAsc") );
|
2013-11-07 10:09:37 -04:00
|
|
|
} else {
|
2013-11-08 09:06:18 -04:00
|
|
|
usort( $dataMemcache, array($this, "ordProcessDesc") );
|
2013-11-07 10:09:37 -04:00
|
|
|
}
|
2013-11-11 16:51:12 -04:00
|
|
|
$response = new stdclass();
|
|
|
|
|
$response->totalCount = count($dataMemcache);
|
|
|
|
|
$dataMemcache = array_splice($dataMemcache, $start, $limit);
|
|
|
|
|
$response->dataMemcache = $dataMemcache;
|
|
|
|
|
return $response;
|
2013-11-06 13:34:25 -04:00
|
|
|
}
|
2011-06-28 12:53:25 -04:00
|
|
|
|
2013-11-08 09:06:18 -04:00
|
|
|
public function ordProcessAsc ($a, $b)
|
2013-11-12 10:50:26 -04:00
|
|
|
{
|
2013-11-13 14:09:32 -04:00
|
|
|
if (($this->sort) == '') {
|
2014-06-20 11:48:57 -04:00
|
|
|
$this->sort = 'PRO_TITLE';
|
2013-11-13 14:09:32 -04:00
|
|
|
}
|
2014-01-23 21:26:44 -04:00
|
|
|
if (strtolower($a[$this->sort]) > strtolower($b[$this->sort])) {
|
2013-12-17 11:14:36 -04:00
|
|
|
return 1;
|
2014-01-21 17:14:09 -04:00
|
|
|
} elseif (strtolower($a[$this->sort]) < strtolower($b[$this->sort])) {
|
2013-12-17 11:14:36 -04:00
|
|
|
return - 1;
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
2013-11-07 10:09:37 -04:00
|
|
|
}
|
2013-11-08 09:06:18 -04:00
|
|
|
}
|
2013-11-07 10:09:37 -04:00
|
|
|
|
2013-12-17 11:14:36 -04:00
|
|
|
public function ordProcessDesc ($a, $b)
|
2013-11-13 14:09:32 -04:00
|
|
|
{
|
2013-12-17 11:14:36 -04:00
|
|
|
if (($this->sort) == '') {
|
|
|
|
|
$this->sort = 'PRO_TITLE';
|
|
|
|
|
}
|
2014-01-23 21:26:44 -04:00
|
|
|
if (strtolower($a[$this->sort]) > strtolower($b[$this->sort])) {
|
2013-12-17 11:14:36 -04:00
|
|
|
return - 1;
|
2014-01-23 21:26:44 -04:00
|
|
|
} elseif (strtolower($a[$this->sort]) < strtolower($b[$this->sort])) {
|
2013-12-17 11:14:36 -04:00
|
|
|
return 1;
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-11-08 09:06:18 -04:00
|
|
|
}
|
2015-02-13 16:33:22 -04:00
|
|
|
/**
|
|
|
|
|
* Check is the Process is BPMN.
|
|
|
|
|
*
|
|
|
|
|
* @param string $ProUid the uid of the Prolication
|
|
|
|
|
* @return int 1 if is BPMN process or 0 if a Normal process
|
|
|
|
|
*/
|
2015-02-13 16:30:11 -04:00
|
|
|
public function isBpmnProcess($proUid){
|
|
|
|
|
$c = new Criteria("workflow");
|
|
|
|
|
$c->add(BpmnProcessPeer::PRJ_UID, $proUid);
|
2015-09-21 10:18:44 -04:00
|
|
|
$res = BpmnProcessPeer::doSelect($c);
|
2015-02-13 16:30:11 -04:00
|
|
|
if( sizeof($res) == 0 ){
|
|
|
|
|
return 0;
|
|
|
|
|
}else{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-16 12:08:56 -04:00
|
|
|
|
|
|
|
|
public function getAllConfiguredCurrencies()
|
|
|
|
|
{
|
|
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
|
|
|
|
$oCriteria->addSelectColumn( ProcessPeer::PRO_UNIT_COST);
|
|
|
|
|
$oCriteria->setDistinct();
|
|
|
|
|
$oDataSet = ProcessPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
|
|
|
|
$oDataSet->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$aProc = Array ();
|
|
|
|
|
while ($oDataSet->next()) {
|
|
|
|
|
$row = $oDataSet->getRow();
|
|
|
|
|
$aProc[$row['PRO_UNIT_COST']] = $row['PRO_UNIT_COST'];
|
|
|
|
|
}
|
|
|
|
|
return $aProc;
|
|
|
|
|
}
|
2016-03-02 17:08:45 -04:00
|
|
|
|
|
|
|
|
public function deleteProcessCases($proUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
/*get cases by process uid*/
|
|
|
|
|
$oCase = new Cases();
|
|
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
|
|
|
|
$oCriteria->addSelectColumn( ApplicationPeer::APP_UID);
|
|
|
|
|
$oCriteria->add( ApplicationPeer::PRO_UID, $proUid );
|
|
|
|
|
$oDataset = ApplicationPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
|
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
while ($oDataset->next()) {
|
|
|
|
|
$row = $oDataset->getRow();
|
|
|
|
|
$oCase->removeCase($row['APP_UID'], false);
|
|
|
|
|
}
|
|
|
|
|
} catch(Exception $e) {
|
|
|
|
|
throw ($e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function refreshUserAllCountersByProcessesGroupUid($proUidArray)
|
|
|
|
|
{
|
|
|
|
|
$aTypes = array(
|
|
|
|
|
'to_do',
|
|
|
|
|
'draft',
|
|
|
|
|
'cancelled',
|
|
|
|
|
'sent',
|
|
|
|
|
'paused',
|
|
|
|
|
'completed',
|
|
|
|
|
'selfservice'
|
|
|
|
|
);
|
|
|
|
|
$usersArray = array();
|
|
|
|
|
$users = new Users();
|
|
|
|
|
$oCase = new Cases();
|
|
|
|
|
$oCriteria = new Criteria();
|
|
|
|
|
$oCriteria->addSelectColumn( AppDelegationPeer::APP_UID );
|
|
|
|
|
$oCriteria->addSelectColumn( AppDelegationPeer::USR_UID );
|
|
|
|
|
$oCriteria->setDistinct();
|
|
|
|
|
$oCriteria->add( AppDelegationPeer::PRO_UID, $proUidArray, Criteria::IN );
|
|
|
|
|
$oRuleSet = AppDelegationPeer::doSelectRS( $oCriteria );
|
|
|
|
|
$oRuleSet->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
while($oRuleSet->next()) {
|
|
|
|
|
$row = $oRuleSet->getRow();
|
2016-04-25 16:01:14 -04:00
|
|
|
if(isset($row['USR_UID']) && $row['USR_UID'] != '' ) {
|
2016-03-02 17:08:45 -04:00
|
|
|
$usersArray[$row['USR_UID']] = $row['USR_UID'];
|
|
|
|
|
}
|
|
|
|
|
$oCase->deleteDelegation($row['APP_UID']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($usersArray as $value) {
|
|
|
|
|
$oAppCache = new AppCacheView();
|
|
|
|
|
$aCount = $oAppCache->getAllCounters( $aTypes, $value );
|
|
|
|
|
$newData = array(
|
|
|
|
|
'USR_UID' => $value,
|
|
|
|
|
'USR_TOTAL_INBOX' => $aCount['to_do'],
|
|
|
|
|
'USR_TOTAL_DRAFT' => $aCount['draft'],
|
|
|
|
|
'USR_TOTAL_CANCELLED' => $aCount['cancelled'],
|
|
|
|
|
'USR_TOTAL_PARTICIPATED' => $aCount['sent'],
|
|
|
|
|
'USR_TOTAL_PAUSED' => $aCount['paused'],
|
|
|
|
|
'USR_TOTAL_COMPLETED' => $aCount['completed'],
|
|
|
|
|
'USR_TOTAL_UNASSIGNED' => $aCount['selfservice']
|
|
|
|
|
);
|
|
|
|
|
$users->update($newData);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-10 17:01:21 +00:00
|
|
|
}
|