CODE STYLE Format
Change format
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* ReportTable.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -27,7 +28,6 @@
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/om/BaseReportTable.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'REPORT_TABLE' table.
|
||||
*
|
||||
@@ -39,23 +39,27 @@ require_once 'classes/model/om/BaseReportTable.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class ReportTable extends BaseReportTable {
|
||||
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") );
|
||||
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 );
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->rep_tab_title = Content::load( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang );
|
||||
return $this->rep_tab_title;
|
||||
}
|
||||
|
||||
@@ -65,14 +69,14 @@ class ReportTable extends BaseReportTable {
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setRepTabTitle($v)
|
||||
public function setRepTabTitle ($v)
|
||||
{
|
||||
if ( $this->getRepTabUid() == "" ) {
|
||||
throw ( new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank") );
|
||||
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==="") {
|
||||
$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;
|
||||
@@ -80,152 +84,144 @@ class ReportTable extends BaseReportTable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function load($RepTabUid)
|
||||
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());
|
||||
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 {
|
||||
} else {
|
||||
//throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" ));
|
||||
return array();
|
||||
return array ();
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
public function create($aData)
|
||||
{
|
||||
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
|
||||
try
|
||||
|
||||
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'] );
|
||||
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->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
|
||||
}
|
||||
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');
|
||||
}
|
||||
$this->setRepTabCreateDate( date( 'Y-m-d H:i:s' ) );
|
||||
$this->setRepTabStatus( 'ACTIVE' );
|
||||
|
||||
if($this->validate())
|
||||
{
|
||||
if ( !isset ( $aData['REP_TAB_TITLE'] ) )
|
||||
$this->setRepTabTitle("");
|
||||
else
|
||||
if ($this->validate()) {
|
||||
if (! isset( $aData['REP_TAB_TITLE'] )) {
|
||||
$this->setRepTabTitle( "" );
|
||||
} else {
|
||||
$this->setRepTabTitle( $aData['REP_TAB_TITLE'] );
|
||||
|
||||
$result=$this->save();
|
||||
}
|
||||
$result = $this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
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);
|
||||
|
||||
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
||||
if(G::LoadSystemExist($sDataBase)){
|
||||
G::LoadSystem($sDataBase);
|
||||
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 );
|
||||
|
||||
$sDataBase = 'database_' . strtolower( DB_ADAPTER );
|
||||
if (G::LoadSystemExist( $sDataBase )) {
|
||||
G::LoadSystem( $sDataBase );
|
||||
$oDataBase = new database();
|
||||
$oValidate = $oDataBase->getValidate($this->validate());
|
||||
$oValidate = $oDataBase->getValidate( $this->validate() );
|
||||
} else {
|
||||
$oValidate = $this->validate();
|
||||
}
|
||||
// if($this->validate())
|
||||
if($oValidate)
|
||||
{
|
||||
$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;
|
||||
if ($oValidate) {
|
||||
$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
|
||||
{
|
||||
} else {
|
||||
$con->rollback();
|
||||
$validationE=new Exception("Failed Validation in class ".get_class($this).".");
|
||||
$validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
|
||||
$validationE->aValidationFailures = $this->getValidationFailures();
|
||||
throw($validationE);
|
||||
throw ($validationE);
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
public function remove($RepTabUid)
|
||||
{
|
||||
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
|
||||
try
|
||||
|
||||
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());
|
||||
if (! is_null( $oRepTab )) {
|
||||
Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid() );
|
||||
$result = $oRepTab->delete();
|
||||
$con->commit();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function reportTableExists ( $RepTabUid ) {
|
||||
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
|
||||
public function reportTableExists ($RepTabUid)
|
||||
{
|
||||
$con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
|
||||
try {
|
||||
$oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid );
|
||||
if (is_object($oRepTabUid) && get_class ($oRepTabUid) == 'ReportTable' ) {
|
||||
if (is_object( $oRepTabUid ) && get_class( $oRepTabUid ) == 'ReportTable') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
} // ReportTable
|
||||
}
|
||||
// ReportTable
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Route.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -38,162 +39,161 @@ require_once 'classes/model/Content.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Route extends BaseRoute {
|
||||
class Route extends BaseRoute
|
||||
{
|
||||
|
||||
/*
|
||||
* Load the application document registry
|
||||
* @param string $sRouUid
|
||||
* @return variant
|
||||
*/
|
||||
public function load($sRouUid)
|
||||
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);
|
||||
$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!' ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
*
|
||||
*/
|
||||
public function create ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
|
||||
try {
|
||||
$sRouteUID = G::generateUniqueID();
|
||||
$aData['ROU_UID'] = $sRouteUID;
|
||||
$oRoute = new Route();
|
||||
|
||||
// validating default values
|
||||
$aData['ROU_TO_LAST_USER'] = $this->validateValue(isset($aData['ROU_TO_LAST_USER']) ? $aData['ROU_TO_LAST_USER'] : '', array('TRUE', 'FALSE'), 'FALSE');
|
||||
$aData['ROU_OPTIONAL'] = $this->validateValue(isset($aData['ROU_OPTIONAL']) ? $aData['ROU_OPTIONAL'] : '', array('TRUE', 'FALSE'), 'FALSE');
|
||||
$aData['ROU_SEND_EMAIL'] = $this->validateValue(isset($aData['ROU_SEND_EMAIL']) ? $aData['ROU_SEND_EMAIL']: '', array('TRUE', 'FALSE'), 'TRUE');
|
||||
$aData['ROU_TO_LAST_USER'] = $this->validateValue( isset( $aData['ROU_TO_LAST_USER'] ) ? $aData['ROU_TO_LAST_USER'] : '', array ('TRUE','FALSE'
|
||||
), 'FALSE' );
|
||||
$aData['ROU_OPTIONAL'] = $this->validateValue( isset( $aData['ROU_OPTIONAL'] ) ? $aData['ROU_OPTIONAL'] : '', array ('TRUE','FALSE'
|
||||
), 'FALSE' );
|
||||
$aData['ROU_SEND_EMAIL'] = $this->validateValue( isset( $aData['ROU_SEND_EMAIL'] ) ? $aData['ROU_SEND_EMAIL'] : '', array ('TRUE','FALSE'
|
||||
), 'TRUE' );
|
||||
|
||||
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
|
||||
if ($oRoute->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oRoute->save();
|
||||
$oConnection->commit();
|
||||
return $sRouteUID;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oRoute->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application document registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
*
|
||||
*/
|
||||
public function update ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
|
||||
try {
|
||||
$oRoute = RoutePeer::retrieveByPK($aData['ROU_UID']);
|
||||
if (!is_null($oRoute))
|
||||
{
|
||||
$oRoute = RoutePeer::retrieveByPK( $aData['ROU_UID'] );
|
||||
if (! is_null( $oRoute )) {
|
||||
// validating default values
|
||||
if (isset($aData['ROU_TO_LAST_USER'])) {
|
||||
$aData['ROU_TO_LAST_USER'] = $this->validateValue($aData['ROU_TO_LAST_USER'], array('TRUE', 'FALSE'), 'FALSE');
|
||||
if (isset( $aData['ROU_TO_LAST_USER'] )) {
|
||||
$aData['ROU_TO_LAST_USER'] = $this->validateValue( $aData['ROU_TO_LAST_USER'], array ('TRUE','FALSE'
|
||||
), 'FALSE' );
|
||||
}
|
||||
if (isset($aData['ROU_OPTIONAL'])) {
|
||||
$aData['ROU_OPTIONAL'] = $this->validateValue($aData['ROU_OPTIONAL'], array('TRUE', 'FALSE'), 'FALSE');
|
||||
if (isset( $aData['ROU_OPTIONAL'] )) {
|
||||
$aData['ROU_OPTIONAL'] = $this->validateValue( $aData['ROU_OPTIONAL'], array ('TRUE','FALSE'
|
||||
), 'FALSE' );
|
||||
}
|
||||
if (isset($aData['ROU_SEND_EMAIL'])) {
|
||||
$aData['ROU_SEND_EMAIL'] = $this->validateValue($aData['ROU_SEND_EMAIL'], array('TRUE', 'FALSE'), 'TRUE');
|
||||
if (isset( $aData['ROU_SEND_EMAIL'] )) {
|
||||
$aData['ROU_SEND_EMAIL'] = $this->validateValue( $aData['ROU_SEND_EMAIL'], array ('TRUE','FALSE'
|
||||
), 'TRUE' );
|
||||
}
|
||||
|
||||
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oRoute->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oRoute->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oRoute->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The ROUTE tables cannot be updated!<br />'.$sMessage));
|
||||
throw (new Exception( 'The ROUTE tables cannot be updated!<br />' . $sMessage ));
|
||||
}
|
||||
} else {
|
||||
throw (new Exception( "The row " . $aData['ROU_UID'] . " doesn't exist!" ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row " . $aData['ROU_UID'] . " doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sRouUid)
|
||||
*
|
||||
*/
|
||||
public function remove ($sRouUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
|
||||
try {
|
||||
$oRoute = RoutePeer::retrieveByPK($sRouUid);
|
||||
if (!is_null($oRoute))
|
||||
{
|
||||
$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 exist!' ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function routeExists ( $sRouUid ) {
|
||||
$con = Propel::getConnection(RoutePeer::DATABASE_NAME);
|
||||
public function routeExists ($sRouUid)
|
||||
{
|
||||
$con = Propel::getConnection( RoutePeer::DATABASE_NAME );
|
||||
try {
|
||||
$oRouUid = RoutePeer::retrieveByPk( $sRouUid );
|
||||
if (is_object($oRouUid) && get_class ($oRouUid) == 'Route' ) {
|
||||
if (is_object( $oRouUid ) && get_class( $oRouUid ) == 'Route') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,12 +205,13 @@ class Route extends BaseRoute {
|
||||
* @param $default string default value, if the tested value is not valid the default value is returned
|
||||
* @return the tested and accepted value
|
||||
*/
|
||||
function validateValue($value, $validValues, $default)
|
||||
public function validateValue ($value, $validValues, $default)
|
||||
{
|
||||
if (!in_array($value, $validValues)) {
|
||||
if (! in_array( $value, $validValues )) {
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
} // Route
|
||||
}
|
||||
// Route
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Stage.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/om/BaseStage.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'STAGE' table.
|
||||
*
|
||||
@@ -19,24 +19,27 @@ require_once 'classes/model/om/BaseStage.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Stage extends BaseStage {
|
||||
|
||||
class Stage extends BaseStage
|
||||
{
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stg_title = '';
|
||||
|
||||
/**
|
||||
* Get the stg_title column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStgTitle() {
|
||||
if ( $this->getStgUid() == "" ) {
|
||||
throw ( new Exception( "Error in getStgTitle, the getStgUid() can't be blank") );
|
||||
public function getStgTitle ()
|
||||
{
|
||||
if ($this->getStgUid() == "") {
|
||||
throw (new Exception( "Error in getStgTitle, the getStgUid() can't be blank" ));
|
||||
}
|
||||
$lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->stg_title = Content::load ( 'STG_TITLE', '', $this->getStgUid(), $lang );
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->stg_title = Content::load( 'STG_TITLE', '', $this->getStgUid(), $lang );
|
||||
return $this->stg_title;
|
||||
}
|
||||
|
||||
@@ -46,14 +49,14 @@ class Stage extends BaseStage {
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setStgTitle($v)
|
||||
public function setStgTitle ($v)
|
||||
{
|
||||
if ( $this->getStgUid() == "" ) {
|
||||
throw ( new Exception( "Error in setStgTitle, the setStgUid() can't be blank") );
|
||||
if ($this->getStgUid() == "") {
|
||||
throw (new Exception( "Error in setStgTitle, the setStgUid() can't be blank" ));
|
||||
}
|
||||
$v=isset($v)?((string)$v):'';
|
||||
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
|
||||
if ($this->stg_title !== $v || $v==="") {
|
||||
$v = isset( $v ) ? ((string) $v) : '';
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
if ($this->stg_title !== $v || $v === "") {
|
||||
$this->stg_title = $v;
|
||||
$res = Content::addContent( 'STG_TITLE', '', $this->getStgUid(), $lang, $this->stg_title );
|
||||
return $res;
|
||||
@@ -61,140 +64,130 @@ class Stage extends BaseStage {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function load($StgUid)
|
||||
public function load ($StgUid)
|
||||
{
|
||||
try {
|
||||
$oRow = StagePeer::retrieveByPK( $StgUid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
$this->setStgTitle($aFields['STG_TITLE'] = $this->getStgTitle());
|
||||
if (! is_null( $oRow )) {
|
||||
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$this->setNew( false );
|
||||
$this->setStgTitle( $aFields['STG_TITLE'] = $this->getStgTitle() );
|
||||
return $aFields;
|
||||
} else {
|
||||
throw (new Exception( "The row '$StgUid' in table Stage doesn't exist!" ));
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$StgUid' in table Stage doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function create($aData) {
|
||||
$oConnection = Propel::getConnection(StagePeer::DATABASE_NAME);
|
||||
public function create ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection( StagePeer::DATABASE_NAME );
|
||||
try {
|
||||
if ( isset ( $aData['STG_UID'] ) && $aData['STG_UID']== '' )
|
||||
unset ( $aData['STG_UID'] );
|
||||
if ( !isset ( $aData['STG_UID'] ) )
|
||||
if (isset( $aData['STG_UID'] ) && $aData['STG_UID'] == '') {
|
||||
unset( $aData['STG_UID'] );
|
||||
}
|
||||
if (! isset( $aData['STG_UID'] )) {
|
||||
$aData['STG_UID'] = G::generateUniqueID();
|
||||
}
|
||||
$oStage = new Stage();
|
||||
$oStage->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$oStage->setStgTitle($aData['STG_TITLE']);
|
||||
$oStage->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
$oStage->setStgTitle( $aData['STG_TITLE'] );
|
||||
if ($oStage->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oStage->save();
|
||||
$oConnection->commit();
|
||||
return $aData['STG_UID'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oStage->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($fields)
|
||||
{
|
||||
$con = Propel::getConnection(StagePeer::DATABASE_NAME);
|
||||
try
|
||||
public function update ($fields)
|
||||
{
|
||||
$con = Propel::getConnection( StagePeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$this->load($fields['STG_UID']);
|
||||
$this->fromArray($fields, BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$contentResult=0;
|
||||
if (array_key_exists("STG_TITLE", $fields)) $contentResult+=$this->setStgTitle($fields["STG_TITLE"]);
|
||||
$result=$this->save();
|
||||
$result=($result==0)?($contentResult>0?1:0):$result;
|
||||
$this->load( $fields['STG_UID'] );
|
||||
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate()) {
|
||||
$contentResult = 0;
|
||||
if (array_key_exists( "STG_TITLE", $fields )) {
|
||||
$contentResult += $this->setStgTitle( $fields["STG_TITLE"] );
|
||||
}
|
||||
$result = $this->save();
|
||||
$result = ($result == 0) ? ($contentResult > 0 ? 1 : 0) : $result;
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$con->rollback();
|
||||
$validationE=new Exception("Failed Validation in class ".get_class($this).".");
|
||||
$validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
|
||||
$validationE->aValidationFailures = $this->getValidationFailures();
|
||||
throw($validationE);
|
||||
throw ($validationE);
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($StgUid)
|
||||
{
|
||||
$con = Propel::getConnection(StagePeer::DATABASE_NAME);
|
||||
try
|
||||
public function remove ($StgUid)
|
||||
{
|
||||
$con = Propel::getConnection( StagePeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$oStage = StagePeer::retrieveByPK( $StgUid );
|
||||
if (!is_null($oStage)) {
|
||||
Content::removeContent( 'STG_TITLE', '', $this->getStgUid());
|
||||
if (! is_null( $oStage )) {
|
||||
Content::removeContent( 'STG_TITLE', '', $this->getStgUid() );
|
||||
$result = $oStage->delete();
|
||||
$con->commit();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function reorderPositions($sProcessUID, $iIndex) {
|
||||
public function reorderPositions ($sProcessUID, $iIndex)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(StagePeer::PRO_UID, $sProcessUID);
|
||||
$oCriteria->add(StagePeer::STG_INDEX, $iIndex, '>');
|
||||
$oDataset = StagePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( StagePeer::PRO_UID, $sProcessUID );
|
||||
$oCriteria->add( StagePeer::STG_INDEX, $iIndex, '>' );
|
||||
$oDataset = StagePeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$this->update(array('STG_UID' => $aRow['STG_UID'],
|
||||
'PRO_UID' => $aRow['PRO_UID'],
|
||||
'STG_POSX' => $aRow['STG_POSX'],
|
||||
'STG_POSY' => $aRow['STG_POSY'],
|
||||
'STG_INDEX' => $aRow['STG_INDEX'] - 1));
|
||||
$this->update( array ('STG_UID' => $aRow['STG_UID'],'PRO_UID' => $aRow['PRO_UID'],'STG_POSX' => $aRow['STG_POSX'],'STG_POSY' => $aRow['STG_POSY'],'STG_INDEX' => $aRow['STG_INDEX'] - 1
|
||||
) );
|
||||
$oDataset->next();
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
} catch (Exception $oException) {
|
||||
throw $Exception;
|
||||
}
|
||||
}
|
||||
|
||||
function Exists ( $sUid ) {
|
||||
public function Exists ($sUid)
|
||||
{
|
||||
try {
|
||||
$oObj = StagePeer::retrieveByPk($sUid);
|
||||
return (is_object($oObj) && get_class($oObj) == 'Stage');
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
$oObj = StagePeer::retrieveByPk( $sUid );
|
||||
return (is_object( $oObj ) && get_class( $oObj ) == 'Stage');
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
} // Stage
|
||||
}
|
||||
// Stage
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* StepSupervisor.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseStepSupervisor.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'STEP_SUPERVISOR' table.
|
||||
*
|
||||
@@ -18,213 +18,212 @@ require_once 'classes/model/om/BaseStepSupervisor.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class StepSupervisor extends BaseStepSupervisor {
|
||||
|
||||
public function load($Uid)
|
||||
class StepSupervisor extends BaseStepSupervisor
|
||||
{
|
||||
public function load ($Uid)
|
||||
{
|
||||
try {
|
||||
$oRow = StepSupervisorPeer::retrieveByPK( $Uid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
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 StepSupervisor doesn't exist!" ));
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$Uid' in table StepSupervisor doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function Exists ( $Uid ) {
|
||||
public function Exists ($Uid)
|
||||
{
|
||||
try {
|
||||
$oPro = StepSupervisorPeer::retrieveByPk( $Uid );
|
||||
if (is_object($oPro) && get_class ($oPro) == 'StepSupervisor' ) {
|
||||
if (is_object( $oPro ) && get_class( $oPro ) == 'StepSupervisor') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the step supervisor registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return boolean
|
||||
**/
|
||||
public function create($aData)
|
||||
*
|
||||
*/
|
||||
public function create ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
|
||||
try {
|
||||
if ( isset ( $aData['STEP_UID'] ) && $aData['STEP_UID']== '' )
|
||||
unset ( $aData['STEP_UID'] );
|
||||
if ( !isset ( $aData['STEP_UID'] ) )
|
||||
if (isset( $aData['STEP_UID'] ) && $aData['STEP_UID'] == '') {
|
||||
unset( $aData['STEP_UID'] );
|
||||
}
|
||||
if (! isset( $aData['STEP_UID'] )) {
|
||||
$aData['STEP_UID'] = G::generateUniqueID();
|
||||
}
|
||||
$oStepSupervisor = new StepSupervisor();
|
||||
$oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oStepSupervisor->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oStepSupervisor->save();
|
||||
$oConnection->commit();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oStepSupervisor->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the step supervisor registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return integer
|
||||
**/
|
||||
public function update($aData)
|
||||
*
|
||||
*/
|
||||
public function update ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oStepSupervisor = StepSupervisorPeer::retrieveByPK($aData['STEP_UID']);
|
||||
if (!is_null($oStepSupervisor))
|
||||
{
|
||||
$oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$oStepSupervisor = StepSupervisorPeer::retrieveByPK( $aData['STEP_UID'] );
|
||||
if (! is_null( $oStepSupervisor )) {
|
||||
$oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oStepSupervisor->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oStepSupervisor->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oStepSupervisor->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
|
||||
}
|
||||
} else {
|
||||
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the step supervisor registry
|
||||
*
|
||||
* @param string $sStepUID
|
||||
* @return integer
|
||||
**/
|
||||
public function remove($sStepUID)
|
||||
*
|
||||
*/
|
||||
public function remove ($sStepUID)
|
||||
{
|
||||
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oConnection->begin();
|
||||
$this->setStepUid($sStepUID);
|
||||
$this->setStepUid( $sStepUID );
|
||||
$iResult = $this->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next position for a atep
|
||||
*
|
||||
* @param string $sProcessUID
|
||||
* @return integer
|
||||
**/
|
||||
function getNextPosition($sProcessUID, $sType) {
|
||||
*
|
||||
*/
|
||||
public function getNextPosition ($sProcessUID, $sType)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn('(COUNT(*) + 1) AS POSITION');
|
||||
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
|
||||
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType);
|
||||
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' );
|
||||
$oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID );
|
||||
$oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
|
||||
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
return (int)$aRow['POSITION'];
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
return (int) $aRow['POSITION'];
|
||||
} catch (Exception $oException) {
|
||||
throw $Exception;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder the steps positions
|
||||
*
|
||||
* @param string $sProcessUID
|
||||
* @param string $iPosition
|
||||
**/
|
||||
function reorderPositions($sProcessUID, $iPosition, $sType) {
|
||||
*
|
||||
*/
|
||||
public function reorderPositions ($sProcessUID, $iPosition, $sType)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
|
||||
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType);
|
||||
$oCriteria->add(StepSupervisorPeer::STEP_POSITION, $iPosition, '>');
|
||||
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();var_dump(StepSupervisorPeer::doCount($oCriteria));
|
||||
while ($aRow = $oDataset->getRow()) {var_dump($aRow);echo "\n";
|
||||
$this->update(array('STEP_UID' => $aRow['STEP_UID'],
|
||||
'PRO_UID' => $aRow['PRO_UID'],
|
||||
'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'],
|
||||
'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'],
|
||||
'STEP_POSITION' => $aRow['STEP_POSITION'] - 1));
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID );
|
||||
$oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
|
||||
$oCriteria->add( StepSupervisorPeer::STEP_POSITION, $iPosition, '>' );
|
||||
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
var_dump( StepSupervisorPeer::doCount( $oCriteria ) );
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
var_dump( $aRow );
|
||||
echo "\n";
|
||||
$this->update( array ('STEP_UID' => $aRow['STEP_UID'],'PRO_UID' => $aRow['PRO_UID'],'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'],'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'],'STEP_POSITION' => $aRow['STEP_POSITION'] - 1
|
||||
) );
|
||||
$oDataset->next();
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
} catch (Exception $oException) {
|
||||
throw $Exception;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function removeByObject($sType, $sObjUid) {
|
||||
public function removeByObject ($sType, $sObjUid)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType);
|
||||
$oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUid);
|
||||
StepSupervisorPeer::doDelete($oCriteria);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
throw($e);
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
|
||||
$oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUid );
|
||||
StepSupervisorPeer::doDelete( $oCriteria );
|
||||
} catch (Exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function loadInfo($sObjUID){
|
||||
public function loadInfo ($sObjUID)
|
||||
{
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUID);
|
||||
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUID );
|
||||
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
return($aRow);
|
||||
|
||||
|
||||
return ($aRow);
|
||||
}
|
||||
}
|
||||
// StepSupervisor
|
||||
|
||||
|
||||
} // StepSupervisor
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.pmSugar.pmFunctions.php
|
||||
*
|
||||
@@ -16,8 +17,9 @@
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
|
||||
function getSoapClientOptions() {
|
||||
$options = array('trace' => 1);
|
||||
function getSoapClientOptions ()
|
||||
{
|
||||
$options = array ('trace' => 1);
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = System::getSystemConfiguration();
|
||||
@@ -40,35 +42,36 @@ function getSoapClientOptions() {
|
||||
/**
|
||||
* This collection of triggers allows to interact by getting and sending information to SugarCRM
|
||||
* @class pmSugar
|
||||
*
|
||||
* @name Sugar CRM Triggers
|
||||
* @icon /images/triggers/icon_SugarCRM.gif
|
||||
* @className class.pmSugar.pmFunctions.php
|
||||
*/
|
||||
|
||||
function sugarLogin($sugarSoap, $user, $password) {
|
||||
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
|
||||
$auth_array = array ('user_auth' => array ('user_name' => $user, 'password' => md5 ( $password ), 'version' => '1.0' ) );
|
||||
$login_results = $client->__SoapCall ( 'login', $auth_array );
|
||||
|
||||
function sugarLogin ($sugarSoap, $user, $password)
|
||||
{
|
||||
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
|
||||
$auth_array = array ('user_auth' => array ('user_name' => $user,'password' => md5( $password ),'version' => '1.0') );
|
||||
$login_results = $client->__SoapCall( 'login', $auth_array );
|
||||
$session_id = $login_results->id;
|
||||
$user_guid = $client->__SoapCall ( 'get_user_id', array ($session_id ) );
|
||||
$user_guid = $client->__SoapCall( 'get_user_id', array ($session_id) );
|
||||
return $session_id;
|
||||
}
|
||||
|
||||
function objectToArray($object) {
|
||||
if (! is_object ( $object ) && ! is_array ( $object )) {
|
||||
function objectToArray ($object)
|
||||
{
|
||||
if (! is_object( $object ) && ! is_array( $object )) {
|
||||
return $object;
|
||||
}
|
||||
if (is_object ( $object )) {
|
||||
$object = get_object_vars ( $object );
|
||||
if (is_object( $object )) {
|
||||
$object = get_object_vars( $object );
|
||||
}
|
||||
return array_map ( "objectToArray", $object );
|
||||
return array_map( "objectToArray", $object );
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Gets SugarCRM entry using get_entry web service.
|
||||
* @method Gets SugarCRM entry using get_entry web service.
|
||||
*
|
||||
* @name GetSugarEntry
|
||||
* @label Get SugarCRM Entry
|
||||
@@ -86,24 +89,23 @@ function objectToArray($object) {
|
||||
*
|
||||
*/
|
||||
|
||||
function GetSugarEntry($sugarSoap, $user, $password, $module, $id, $selectFields, $linkNameToFieldsArray, $resultType = 'array') {
|
||||
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
|
||||
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'id' => $id,
|
||||
'select_fields' => $select_fields, 'link_name_to_fields_array' => $linkNameToFieldsArray);
|
||||
$sugarEntry = $client->__SoapCall ( 'get_entry', $request_array );
|
||||
function GetSugarEntry ($sugarSoap, $user, $password, $module, $id, $selectFields, $linkNameToFieldsArray, $resultType = 'array')
|
||||
{
|
||||
$sessionId = sugarLogin( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
|
||||
$request_array = array ('session' => $sessionId,'module_name' => $module,'id' => $id,'select_fields' => $select_fields,'link_name_to_fields_array' => $linkNameToFieldsArray);
|
||||
$sugarEntry = $client->__SoapCall( 'get_entry', $request_array );
|
||||
|
||||
if($resultType == 'array'){
|
||||
$sugarEntry = objectToArray ( $sugarEntry );
|
||||
if ($resultType == 'array') {
|
||||
$sugarEntry = objectToArray( $sugarEntry );
|
||||
}
|
||||
|
||||
return $sugarEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Gets SugarCRM entries from the indicated module.
|
||||
* @method Gets SugarCRM entries from the indicated module.
|
||||
*
|
||||
* @name GetSugarEntries
|
||||
* @label Get SugarCRM Entries
|
||||
@@ -122,25 +124,31 @@ function GetSugarEntry($sugarSoap, $user, $password, $module, $id, $selectFields
|
||||
*
|
||||
*/
|
||||
|
||||
function GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
|
||||
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
|
||||
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'query' => $query, 'order_by' => $orderBy, 'offset'=>"", 'select_fields'=>"", 'max_result'=>$maxResults );
|
||||
$sugarEntriesO = $client->__SoapCall ( 'get_entry_list', $request_array );
|
||||
function GetSugarEntries ($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
|
||||
{
|
||||
$sessionId = sugarLogin( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
|
||||
$request_array = array ('session' => $sessionId,'module_name' => $module,'query' => $query,'order_by' => $orderBy,'offset' => "",'select_fields' => "",'max_result' => $maxResults);
|
||||
$sugarEntriesO = $client->__SoapCall( 'get_entry_list', $request_array );
|
||||
|
||||
switch($resultType){
|
||||
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
|
||||
case 'object':$sugarEntries = $sugarEntriesO; break;
|
||||
default: $sugarEntries = objectToArray ( $sugarEntries );
|
||||
switch ($resultType) {
|
||||
case 'array':
|
||||
$sugarEntries = objectToArray( $sugarEntriesO );
|
||||
break;
|
||||
case 'object':
|
||||
$sugarEntries = $sugarEntriesO;
|
||||
break;
|
||||
default:
|
||||
$sugarEntries = objectToArray( $sugarEntries );
|
||||
}
|
||||
|
||||
return $sugarEntries;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Gets SugarCRM entries from the Calls module
|
||||
* @method Gets SugarCRM entries from the Calls module
|
||||
*
|
||||
* @name GetSugarCalls
|
||||
* @label Gets SugarCRM entries from the Calls module
|
||||
@@ -158,14 +166,15 @@ function GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy
|
||||
*
|
||||
*/
|
||||
|
||||
function GetSugarCalls($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
|
||||
$module="Calls";
|
||||
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
|
||||
function GetSugarCalls ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
|
||||
{
|
||||
$module = "Calls";
|
||||
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Gets SugarCRM entries from the Leads module.
|
||||
* @method Gets SugarCRM entries from the Leads module.
|
||||
*
|
||||
* @name GetSugarLeads
|
||||
* @label Gets SugarCRM entries from the Leads module.
|
||||
@@ -183,14 +192,15 @@ function GetSugarCalls($sugarSoap, $user, $password, $query, $orderBy, $selected
|
||||
*
|
||||
*/
|
||||
|
||||
function GetSugarLeads($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
|
||||
$module="Leads";
|
||||
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
|
||||
function GetSugarLeads ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
|
||||
{
|
||||
$module = "Leads";
|
||||
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Gets SugarCRM entries from the Contacts module.
|
||||
* @method Gets SugarCRM entries from the Contacts module.
|
||||
*
|
||||
* @name GetSugarContacts
|
||||
* @label Gets SugarCRM entries from the Contacts module.
|
||||
@@ -208,14 +218,15 @@ function GetSugarLeads($sugarSoap, $user, $password, $query, $orderBy, $selected
|
||||
*
|
||||
*/
|
||||
|
||||
function GetSugarContacts($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
|
||||
$module="Contacts";
|
||||
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
|
||||
function GetSugarContacts ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
|
||||
{
|
||||
$module = "Contacts";
|
||||
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Gets SugarCRM entries from the Opportunities module.
|
||||
* @method Gets SugarCRM entries from the Opportunities module.
|
||||
*
|
||||
* @name GetSugarOpportunities
|
||||
* @label Gets SugarCRM entries from the Opportunities module.
|
||||
@@ -233,15 +244,15 @@ function GetSugarContacts($sugarSoap, $user, $password, $query, $orderBy, $selec
|
||||
*
|
||||
*/
|
||||
|
||||
function GetSugarOpportunities($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
|
||||
$module="Opportunities";
|
||||
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
|
||||
function GetSugarOpportunities ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
|
||||
{
|
||||
$module = "Opportunities";
|
||||
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Gets SugarCRM entries from the Account module.
|
||||
* @method Gets SugarCRM entries from the Account module.
|
||||
*
|
||||
* @name GetSugarAccount
|
||||
* @label Gets SugarCRM entries from the Account module.
|
||||
@@ -259,16 +270,15 @@ function GetSugarOpportunities($sugarSoap, $user, $password, $query, $orderBy, $
|
||||
*
|
||||
*/
|
||||
|
||||
function GetSugarAccount($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
|
||||
$module="Accounts";
|
||||
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
|
||||
function GetSugarAccount ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
|
||||
{
|
||||
$module = "Accounts";
|
||||
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Creates SugarCRM entries from the Account module.
|
||||
* @method Creates SugarCRM entries from the Account module.
|
||||
*
|
||||
* @name CreateSugarAccount
|
||||
*
|
||||
@@ -283,30 +293,33 @@ function GetSugarAccount($sugarSoap, $user, $password, $query, $orderBy, $select
|
||||
* @return array/object | $sugarAccount | Sugar Opportunities (array or object)
|
||||
*
|
||||
*/
|
||||
function CreateSugarAccount($sugarSoap, $user, $password, $name, $resultType="array") {
|
||||
function CreateSugarAccount ($sugarSoap, $user, $password, $name, $resultType = "array")
|
||||
{
|
||||
|
||||
$module = "Accounts";
|
||||
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
|
||||
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' => array(
|
||||
array("name" => 'name', "value" => $name )
|
||||
) );
|
||||
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
|
||||
$account_id = $sugarEntriesO ->id;
|
||||
$sessionId = sugarLogin( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
|
||||
$request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ("name" => 'name',"value" => $name)));
|
||||
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
|
||||
$account_id = $sugarEntriesO->id;
|
||||
|
||||
switch($resultType){
|
||||
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO );break;
|
||||
case 'object':$sugarEntries = $sugarEntries ;break;
|
||||
default: $sugarEntries = objectToArray ( $sugarEntries );
|
||||
switch ($resultType) {
|
||||
case 'array':
|
||||
$sugarEntries = objectToArray( $sugarEntriesO );
|
||||
break;
|
||||
case 'object':
|
||||
$sugarEntries = $sugarEntries;
|
||||
break;
|
||||
default:
|
||||
$sugarEntries = objectToArray( $sugarEntries );
|
||||
}
|
||||
//return $sugarEntries;
|
||||
return $account_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Creates SugarCRM entries from the Account module
|
||||
* @method Creates SugarCRM entries from the Account module
|
||||
*
|
||||
* @name CreateSugarContact
|
||||
*
|
||||
@@ -326,46 +339,49 @@ function CreateSugarAccount($sugarSoap, $user, $password, $name, $resultType="a
|
||||
* @return array/object | $sugarContact | Sugar Opportunities (array or object)
|
||||
*
|
||||
*/
|
||||
function CreateSugarContact($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType="array") {
|
||||
|
||||
function CreateSugarContact ($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType = "array")
|
||||
{
|
||||
$module = "Contacts";
|
||||
/* $aValue = array(
|
||||
/* $aValue = array(
|
||||
array("name" => 'id', "value" => G::generateUniqueID()),
|
||||
array("name" => 'first_name', "value" => $first_name),
|
||||
array("name" => 'last_name', "value" => $last_name),
|
||||
);
|
||||
*/
|
||||
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
|
||||
*/
|
||||
$sessionId = sugarLogin( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
|
||||
|
||||
$request_array = array ('session' => $sessionId, 'module_name' => $module, array(
|
||||
array("name" => 'first_name',"value" => $first_name),
|
||||
array("name" => 'last_name',"value" => $last_name),
|
||||
array("name" => 'email1',"value" => $email),
|
||||
array("name" => 'title',"value" => $title),
|
||||
array("name" => 'phone_work',"value" => $phone),
|
||||
$request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name
|
||||
),array ("name" => 'last_name',"value" => $last_name
|
||||
),array ("name" => 'email1',"value" => $email
|
||||
),array ("name" => 'title',"value" => $title
|
||||
),array ("name" => 'phone_work',"value" => $phone
|
||||
),
|
||||
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
|
||||
array("name" => 'account_id',"value" => $account_id)
|
||||
));
|
||||
array ("name" => 'account_id',"value" => $account_id
|
||||
)));
|
||||
|
||||
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
|
||||
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
|
||||
|
||||
switch($resultType){
|
||||
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
|
||||
case 'object':$sugarEntries = $sugarEntries; break;
|
||||
default: $sugarEntries = objectToArray ( $sugarEntries );
|
||||
switch ($resultType) {
|
||||
case 'array':
|
||||
$sugarEntries = objectToArray( $sugarEntriesO );
|
||||
break;
|
||||
case 'object':
|
||||
$sugarEntries = $sugarEntries;
|
||||
break;
|
||||
default:
|
||||
$sugarEntries = objectToArray( $sugarEntries );
|
||||
}
|
||||
return $sugarEntries;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Creates SugarCRM entries from the Opportunities module.
|
||||
* @method Creates SugarCRM entries from the Opportunities module.
|
||||
*
|
||||
* @name CreateSugarOpportunity
|
||||
|
||||
*
|
||||
* @label Creates SugarCRM entries from the Opportunities module.
|
||||
*
|
||||
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
|
||||
@@ -381,8 +397,9 @@ function CreateSugarContact($sugarSoap, $user, $password, $first_name, $last_nam
|
||||
* @return array/object | $sugarOpportunity | Sugar Opportunities (array or object)
|
||||
*
|
||||
*/
|
||||
function CreateSugarOpportunity($sugarSoap, $user, $password, $name,$account_id,$amount, $date_closed, $sales_stage,$resultType="array") {
|
||||
// * @param string | $account_id | Account Id
|
||||
function CreateSugarOpportunity ($sugarSoap, $user, $password, $name, $account_id, $amount, $date_closed, $sales_stage, $resultType = "array")
|
||||
{
|
||||
// * @param string | $account_id | Account Id
|
||||
$module = "Opportunities";
|
||||
|
||||
/* $aValue = array(
|
||||
@@ -394,33 +411,36 @@ function CreateSugarOpportunity($sugarSoap, $user, $password, $name,$account_id,
|
||||
array("name" => 'sales_stage', "value" => $sales_stage)
|
||||
);*/
|
||||
|
||||
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
|
||||
$sessionId = sugarLogin( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
|
||||
|
||||
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' =>array(
|
||||
array('name' => 'name','value' => $name),
|
||||
array("name" => 'account_id',"value" => $account_id),
|
||||
array('name' => 'amount','value' => $amount),
|
||||
array('name' => 'date_closed','value' => $date_closed),
|
||||
array('name' => 'sales_stage','value' => $sales_stage),
|
||||
));
|
||||
$request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ('name' => 'name','value' => $name
|
||||
),array ("name" => 'account_id',"value" => $account_id
|
||||
),array ('name' => 'amount','value' => $amount
|
||||
),array ('name' => 'date_closed','value' => $date_closed
|
||||
),array ('name' => 'sales_stage','value' => $sales_stage
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
|
||||
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
|
||||
|
||||
switch($resultType){
|
||||
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
|
||||
case 'object':$sugarEntries = $sugarEntries; break;
|
||||
default: $sugarEntries = objectToArray ( $sugarEntries );
|
||||
switch ($resultType) {
|
||||
case 'array':
|
||||
$sugarEntries = objectToArray( $sugarEntriesO );
|
||||
break;
|
||||
case 'object':
|
||||
$sugarEntries = $sugarEntries;
|
||||
break;
|
||||
default:
|
||||
$sugarEntries = objectToArray( $sugarEntries );
|
||||
}
|
||||
return $sugarEntries;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @method
|
||||
*
|
||||
* Creates SugarCRM entries from the Account module
|
||||
* @method Creates SugarCRM entries from the Account module
|
||||
*
|
||||
* @name CreateSugarLeads
|
||||
*
|
||||
@@ -440,28 +460,37 @@ function CreateSugarOpportunity($sugarSoap, $user, $password, $name,$account_id,
|
||||
* @return array/object | $sugarContact | Sugar Opportunities (array or object)
|
||||
*
|
||||
*/
|
||||
function CreateSugarLeads($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType="array") {
|
||||
function CreateSugarLeads ($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType = "array")
|
||||
{
|
||||
|
||||
$module = "Leads";
|
||||
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
|
||||
$sessionId = sugarLogin( $sugarSoap, $user, $password );
|
||||
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
|
||||
|
||||
$request_array = array ('session' => $sessionId, 'module_name' => $module, array(
|
||||
array("name" => 'first_name',"value" => $first_name),
|
||||
array("name" => 'last_name',"value" => $last_name),
|
||||
array("name" => 'email1',"value" => $email),
|
||||
array("name" => 'title',"value" => $title),
|
||||
array("name" => 'phone_work',"value" => $phone),
|
||||
$request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name
|
||||
),array ("name" => 'last_name',"value" => $last_name
|
||||
),array ("name" => 'email1',"value" => $email
|
||||
),array ("name" => 'title',"value" => $title
|
||||
),array ("name" => 'phone_work',"value" => $phone
|
||||
),
|
||||
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
|
||||
array("name" => 'account_id',"value" => $account_id)
|
||||
));
|
||||
array ("name" => 'account_id',"value" => $account_id
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
|
||||
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
|
||||
|
||||
switch($resultType){
|
||||
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
|
||||
case 'object':$sugarEntries = $sugarEntries; break;
|
||||
default: $sugarEntries = objectToArray ( $sugarEntries );
|
||||
switch ($resultType) {
|
||||
case 'array':
|
||||
$sugarEntries = objectToArray( $sugarEntriesO );
|
||||
break;
|
||||
case 'object':
|
||||
$sugarEntries = $sugarEntries;
|
||||
break;
|
||||
default:
|
||||
$sugarEntries = objectToArray( $sugarEntries );
|
||||
}
|
||||
return $sugarEntries;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user