Merge pull request #170 from hector-cortez/BUG-8369
BUG 8369 Adjustment for standardization of code SOLVED
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AdditionalTables.php
|
* AdditionalTables.php
|
||||||
* @package workflow.engine.classes.model
|
* @package workflow.engine.classes.model
|
||||||
*/
|
*/
|
||||||
require_once 'classes/model/om/BaseAdditionalTables.php';
|
require_once 'classes/model/om/BaseAdditionalTables.php';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skeleton subclass for representing a row from the 'ADDITIONAL_TABLES' table.
|
* Skeleton subclass for representing a row from the 'ADDITIONAL_TABLES' table.
|
||||||
*
|
*
|
||||||
@@ -18,7 +18,8 @@ require_once 'classes/model/om/BaseAdditionalTables.php';
|
|||||||
*
|
*
|
||||||
* @package workflow.engine.classes.model
|
* @package workflow.engine.classes.model
|
||||||
*/
|
*/
|
||||||
class AdditionalTables extends BaseAdditionalTables {
|
class AdditionalTables extends BaseAdditionalTables
|
||||||
|
{
|
||||||
|
|
||||||
public $fields = array();
|
public $fields = array();
|
||||||
public $primaryKeys = array();
|
public $primaryKeys = array();
|
||||||
@@ -27,7 +28,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
* Function load
|
* Function load
|
||||||
* access public
|
* access public
|
||||||
*/
|
*/
|
||||||
public function load($sUID, $bFields = false)
|
public function load($sUID, $bFields=false)
|
||||||
{
|
{
|
||||||
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
||||||
|
|
||||||
@@ -81,15 +82,15 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
return $this->fields;
|
return $this->fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrimaryKeys($type = 'complete')
|
public function getPrimaryKeys($type='complete')
|
||||||
{
|
{
|
||||||
$this->primaryKeys = array();
|
$this->primaryKeys = array();
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
if ($field['FLD_KEY'] == '1') {
|
if ($field['FLD_KEY'] == '1') {
|
||||||
if ($type == 'complete') {
|
if ($type == 'complete') {
|
||||||
$this->primaryKeys[] = $field;
|
$this->primaryKeys[] = $field;
|
||||||
}
|
} else {
|
||||||
else { // just field names
|
// just field names
|
||||||
$this->primaryKeys[] = $field['FLD_NAME'];
|
$this->primaryKeys[] = $field['FLD_NAME'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +98,8 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
return $this->primaryKeys;
|
return $this->primaryKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadByName($name) {
|
public function loadByName($name)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID);
|
$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID);
|
||||||
@@ -126,8 +128,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
|
|
||||||
return $oDataset->getRow();
|
return $oDataset->getRow();
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +136,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
/**
|
/**
|
||||||
* Create & Update function
|
* Create & Update function
|
||||||
*/
|
*/
|
||||||
function create($aData, $aFields = array())
|
public function create($aData, $aFields=array())
|
||||||
{
|
{
|
||||||
if (!isset($aData['ADD_TAB_UID']) || (isset($aData['ADD_TAB_UID']) && $aData['ADD_TAB_UID'] == '')) {
|
if (!isset($aData['ADD_TAB_UID']) || (isset($aData['ADD_TAB_UID']) && $aData['ADD_TAB_UID'] == '')) {
|
||||||
$aData['ADD_TAB_UID'] = G::generateUniqueID();
|
$aData['ADD_TAB_UID'] = G::generateUniqueID();
|
||||||
@@ -151,7 +152,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oConnection->begin();
|
$oConnection->begin();
|
||||||
$iResult = $oAdditionalTables->save();
|
$iResult = $oAdditionalTables->save();
|
||||||
$oConnection->commit();
|
$oConnection->commit();
|
||||||
/****DEPRECATED
|
/* * **DEPRECATED
|
||||||
require_once 'classes/model/ShadowTable.php';
|
require_once 'classes/model/ShadowTable.php';
|
||||||
$oShadowTable = new ShadowTable();
|
$oShadowTable = new ShadowTable();
|
||||||
$oShadowTable->create(array('ADD_TAB_UID' => $aData['ADD_TAB_UID'],
|
$oShadowTable->create(array('ADD_TAB_UID' => $aData['ADD_TAB_UID'],
|
||||||
@@ -165,19 +166,19 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
} else {
|
} else {
|
||||||
$sMessage = '';
|
$sMessage = '';
|
||||||
$aValidationFailures = $oAdditionalTables->getValidationFailures();
|
$aValidationFailures = $oAdditionalTables->getValidationFailures();
|
||||||
foreach($aValidationFailures as $oValidationFailure) {
|
foreach ($aValidationFailures as $oValidationFailure) {
|
||||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
$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();
|
$oConnection->rollback();
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($aData, $aFields = array()) {
|
public function update($aData, $aFields=array())
|
||||||
|
{
|
||||||
$oConnection = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
$oConnection = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||||
try {
|
try {
|
||||||
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($aData['ADD_TAB_UID']);
|
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($aData['ADD_TAB_UID']);
|
||||||
@@ -187,7 +188,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oConnection->begin();
|
$oConnection->begin();
|
||||||
$iResult = $oAdditionalTables->save();
|
$iResult = $oAdditionalTables->save();
|
||||||
$oConnection->commit();
|
$oConnection->commit();
|
||||||
/*** DEPRECATED
|
/* * * DEPRECATED
|
||||||
require_once 'classes/model/ShadowTable.php';
|
require_once 'classes/model/ShadowTable.php';
|
||||||
$oShadowTable = new ShadowTable();
|
$oShadowTable = new ShadowTable();
|
||||||
$oShadowTable->create(array('ADD_TAB_UID' => $aData['ADD_TAB_UID'],
|
$oShadowTable->create(array('ADD_TAB_UID' => $aData['ADD_TAB_UID'],
|
||||||
@@ -196,28 +197,26 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
'USR_UID' => (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''),
|
'USR_UID' => (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''),
|
||||||
'APP_UID' => '',
|
'APP_UID' => '',
|
||||||
'SHD_DATE' => date('Y-m-d H:i:s')));
|
'SHD_DATE' => date('Y-m-d H:i:s')));
|
||||||
return $iResult;*/
|
return $iResult; */
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$sMessage = '';
|
$sMessage = '';
|
||||||
$aValidationFailures = $oAdditionalTables->getValidationFailures();
|
$aValidationFailures = $oAdditionalTables->getValidationFailures();
|
||||||
foreach($aValidationFailures as $oValidationFailure) {
|
foreach ($aValidationFailures as $oValidationFailure) {
|
||||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
$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 {
|
||||||
else {
|
|
||||||
throw(new Exception('This row doesn\'t exist!'));
|
throw(new Exception('This row doesn\'t exist!'));
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
$oConnection->rollback();
|
$oConnection->rollback();
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove($sUID) {
|
public function remove($sUID)
|
||||||
|
{
|
||||||
$oConnection = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
$oConnection = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||||
try {
|
try {
|
||||||
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
||||||
@@ -228,18 +227,16 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oConnection->commit();
|
$oConnection->commit();
|
||||||
|
|
||||||
return $iResult;
|
return $iResult;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw(new Exception('This row doesn\'t exist!'));
|
throw(new Exception('This row doesn\'t exist!'));
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
$oConnection->rollback();
|
$oConnection->rollback();
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAll($id)
|
public function deleteAll($id)
|
||||||
{
|
{
|
||||||
//deleting pm table
|
//deleting pm table
|
||||||
$additionalTable = AdditionalTables::load($id);
|
$additionalTable = AdditionalTables::load($id);
|
||||||
@@ -258,7 +255,8 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$pmTable->remove();
|
$pmTable->remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPHPName($sName) {
|
public function getPHPName($sName)
|
||||||
|
{
|
||||||
$sName = trim($sName);
|
$sName = trim($sName);
|
||||||
$aAux = explode('_', $sName);
|
$aAux = explode('_', $sName);
|
||||||
foreach ($aAux as $iKey => $sPart) {
|
foreach ($aAux as $iKey => $sPart) {
|
||||||
@@ -267,20 +265,24 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
return implode('', $aAux);
|
return implode('', $aAux);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteMultiple($arrUID){
|
public function deleteMultiple($arrUID)
|
||||||
$arrUIDs = explode(",",$arrUID);
|
{
|
||||||
foreach ($arrUIDs as $UID){
|
$arrUIDs = explode(",", $arrUID);
|
||||||
|
foreach ($arrUIDs as $UID) {
|
||||||
$this->deleteAll($UID);
|
$this->deleteAll($UID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDataCriteria($sUID) {
|
public function getDataCriteria($sUID)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$aData = $this->load($sUID, true);
|
$aData = $this->load($sUID, true);
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $this->getPHPName($aData['ADD_TAB_NAME']));
|
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != ''
|
||||||
|
? $aData['ADD_TAB_CLASS_NAME']
|
||||||
|
: $this->getPHPName($aData['ADD_TAB_NAME']));
|
||||||
|
|
||||||
if (file_exists ($sPath . $sClassName . '.php') ) {
|
if (file_exists($sPath . $sClassName . '.php')) {
|
||||||
require_once $sPath . $sClassName . '.php';
|
require_once $sPath . $sClassName . '.php';
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -300,35 +302,38 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
case 'VARCHAR':
|
case 'VARCHAR':
|
||||||
case 'TEXT':
|
case 'TEXT':
|
||||||
case 'DATE':
|
case 'DATE':
|
||||||
// if($aField['FLD_NULL']!=1)
|
// if($aField['FLD_NULL']!=1)
|
||||||
// eval('$oCriteria->add(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ', \'(<28>_<EFBFBD>_<EFBFBD>)\', Criteria::NOT_EQUAL);');
|
// eval('$oCriteria->add(' . $sClassPeerName . '::' . $aField['FLD_NAME']
|
||||||
|
//. ', \'(<28>_<EFBFBD>_<EFBFBD>)\', Criteria::NOT_EQUAL);');
|
||||||
break;
|
break;
|
||||||
case 'INT';
|
case 'INT';
|
||||||
case 'FLOAT':
|
case 'FLOAT':
|
||||||
eval('$oCriteria->add(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ', -99999999999, Criteria::NOT_EQUAL);');
|
eval('$oCriteria->add(' . $sClassPeerName . '::' . $aField['FLD_NAME']
|
||||||
|
.', -99999999999, Criteria::NOT_EQUAL);');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//eval('$oCriteria->addAscendingOrderByColumn(' . $sClassPeerName . '::PM_UNIQUE_ID);');
|
//eval('$oCriteria->addAscendingOrderByColumn(' . $sClassPeerName . '::PM_UNIQUE_ID);');
|
||||||
//echo $oCriteria->toString();
|
//echo $oCriteria->toString();
|
||||||
return $oCriteria;
|
return $oCriteria;
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllData($sUID, $start=NULL, $limit=NULL, $keyOrderUppercase = true)
|
public function getAllData($sUID, $start=null, $limit=null, $keyOrderUppercase=true)
|
||||||
{
|
{
|
||||||
$addTab = new AdditionalTables();
|
$addTab = new AdditionalTables();
|
||||||
$aData = $addTab->load($sUID, true);
|
$aData = $addTab->load($sUID, true);
|
||||||
if (! isset($_SESSION['PROCESS'])) {
|
if (!isset($_SESSION['PROCESS'])) {
|
||||||
$_SESSION["PROCESS"] = $aData['PRO_UID'];
|
$_SESSION["PROCESS"] = $aData['PRO_UID'];
|
||||||
}
|
}
|
||||||
$aData['DBS_UID'] = $aData['DBS_UID'] ? $aData['DBS_UID'] : 'workflow';
|
$aData['DBS_UID'] = $aData['DBS_UID'] ? $aData['DBS_UID'] : 'workflow';
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $this->getPHPName($aData['ADD_TAB_NAME']));
|
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != ''
|
||||||
|
? $aData['ADD_TAB_CLASS_NAME']
|
||||||
|
: $this->getPHPName($aData['ADD_TAB_NAME']));
|
||||||
|
|
||||||
if (file_exists ($sPath . $sClassName . '.php') ) {
|
if (file_exists($sPath . $sClassName . '.php')) {
|
||||||
require_once $sPath . $sClassName . '.php';
|
require_once $sPath . $sClassName . '.php';
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -339,17 +344,17 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oCriteria = new Criteria($aData['DBS_UID']);
|
$oCriteria = new Criteria($aData['DBS_UID']);
|
||||||
|
|
||||||
//eval('$oCriteria->addSelectColumn("\'1\' AS DUMMY");');
|
//eval('$oCriteria->addSelectColumn("\'1\' AS DUMMY");');
|
||||||
if($keyOrderUppercase==true){
|
if ($keyOrderUppercase == true) {
|
||||||
foreach ($aData['FIELDS'] as $aField) {
|
foreach ($aData['FIELDS'] as $aField) {
|
||||||
eval('$oCriteria->addSelectColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');');
|
eval('$oCriteria->addSelectColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');');
|
||||||
if ($aField['FLD_KEY'] == '1') {
|
if ($aField['FLD_KEY'] == '1') {
|
||||||
eval('$oCriteria->addAscendingOrderByColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');');
|
eval('$oCriteria->addAscendingOrderByColumn('. $sClassPeerName . '::' . $aField['FLD_NAME'] . ');');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$oCriteriaCount = clone $oCriteria;
|
$oCriteriaCount = clone $oCriteria;
|
||||||
//$count = $sClassPeerName::doCount($oCriteria);
|
//$count = $sClassPeerName::doCount($oCriteria);
|
||||||
eval('$count = '.$sClassPeerName.'::doCount($oCriteria);');
|
eval('$count = ' . $sClassPeerName . '::doCount($oCriteria);');
|
||||||
|
|
||||||
if (isset($limit)) {
|
if (isset($limit)) {
|
||||||
$oCriteria->setLimit($limit);
|
$oCriteria->setLimit($limit);
|
||||||
@@ -358,8 +363,8 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oCriteria->setOffset($start);
|
$oCriteria->setOffset($start);
|
||||||
}
|
}
|
||||||
//$rs = $sClassPeerName::doSelectRS($oCriteria);
|
//$rs = $sClassPeerName::doSelectRS($oCriteria);
|
||||||
eval('$rs = '.$sClassPeerName.'::doSelectRS($oCriteria);');
|
eval('$rs = ' . $sClassPeerName . '::doSelectRS($oCriteria);');
|
||||||
$rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
$rows = Array();
|
$rows = Array();
|
||||||
while ($rs->next()) {
|
while ($rs->next()) {
|
||||||
@@ -369,28 +374,33 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
return array('rows' => $rows, 'count' => $count);
|
return array('rows' => $rows, 'count' => $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkClassNotExist($sUID) {
|
public function checkClassNotExist($sUID)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$aData = $this->load($sUID, true);
|
$aData = $this->load($sUID, true);
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $this->getPHPName($aData['ADD_TAB_NAME']));
|
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != ''
|
||||||
|
? $aData['ADD_TAB_CLASS_NAME']
|
||||||
|
: $this->getPHPName($aData['ADD_TAB_NAME']));
|
||||||
|
|
||||||
if (file_exists ($sPath . $sClassName . '.php') ) {
|
if (file_exists($sPath . $sClassName . '.php')) {
|
||||||
return $sClassName;
|
return $sClassName;
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $oError) {
|
} catch (Exception $oError) {
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveDataInTable($sUID, $aFields) {
|
public function saveDataInTable($sUID, $aFields)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$aData = $this->load($sUID, true);
|
$aData = $this->load($sUID, true);
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $this->getPHPName($aData['ADD_TAB_NAME']));
|
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != ''
|
||||||
|
? $aData['ADD_TAB_CLASS_NAME']
|
||||||
|
: $this->getPHPName($aData['ADD_TAB_NAME']));
|
||||||
// $oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
// $oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
||||||
$oConnection = Propel::getConnection($aData['DBS_UID']);
|
$oConnection = Propel::getConnection($aData['DBS_UID']);
|
||||||
$stmt = $oConnection->createStatement();
|
$stmt = $oConnection->createStatement();
|
||||||
@@ -406,24 +416,27 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$sKeys = substr($sKeys, 0, -1);
|
$sKeys = substr($sKeys, 0, -1);
|
||||||
$oClass = new $sClassName;
|
$oClass = new $sClassName;
|
||||||
foreach ($aFields as $sKey => $sValue) {
|
foreach ($aFields as $sKey => $sValue) {
|
||||||
if(!preg_match("/\(?\)/", $sKey))
|
if (!preg_match("/\(?\)/", $sKey)) {
|
||||||
eval('$oClass->set' . $this->getPHPName($sKey) . '($aFields["' . $sKey . '"]);');
|
eval('$oClass->set' . $this->getPHPName($sKey) . '($aFields["' . $sKey . '"]);');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($oClass->validate()) {
|
if ($oClass->validate()) {
|
||||||
$iResult = $oClass->save();
|
$iResult = $oClass->save();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDataTable($sUID, $aKeys) {
|
public function getDataTable($sUID, $aKeys)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$aData = $this->load($sUID, true);
|
$aData = $this->load($sUID, true);
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $this->getPHPName($aData['ADD_TAB_NAME']));
|
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != ''
|
||||||
|
? $aData['ADD_TAB_CLASS_NAME']
|
||||||
|
: $this->getPHPName($aData['ADD_TAB_NAME']));
|
||||||
require_once $sPath . $sClassName . '.php';
|
require_once $sPath . $sClassName . '.php';
|
||||||
$sKeys = '';
|
$sKeys = '';
|
||||||
foreach ($aKeys as $sName => $vValue) {
|
foreach ($aKeys as $sName => $vValue) {
|
||||||
@@ -435,26 +448,27 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
//eval('$oClass = ' . $sClassName . 'Peer::retrieveByPK($sPMUID);');
|
//eval('$oClass = ' . $sClassName . 'Peer::retrieveByPK($sPMUID);');
|
||||||
if (!is_null($oClass)) {
|
if (!is_null($oClass)) {
|
||||||
return $oClass->toArray(BasePeer::TYPE_FIELDNAME);
|
return $oClass->toArray(BasePeer::TYPE_FIELDNAME);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDataInTable($sUID, $aFields) {
|
public function updateDataInTable($sUID, $aFields)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
//$sPMUID = $aFields['PM_UNIQUE_ID'];
|
//$sPMUID = $aFields['PM_UNIQUE_ID'];
|
||||||
$aData = $this->load($sUID, true);
|
$aData = $this->load($sUID, true);
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $this->getPHPName($aData['ADD_TAB_NAME']));
|
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != ''
|
||||||
|
? $aData['ADD_TAB_CLASS_NAME']
|
||||||
|
: $this->getPHPName($aData['ADD_TAB_NAME']));
|
||||||
$oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
$oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
||||||
require_once $sPath . $sClassName . '.php';
|
require_once $sPath . $sClassName . '.php';
|
||||||
$sKeys = '';
|
$sKeys = '';
|
||||||
foreach ($aData['FIELDS'] as $aField) {//$sName => $vValue
|
foreach ($aData['FIELDS'] as $aField) {
|
||||||
if ($aField['FLD_KEY'] == 1) {
|
if ($aField['FLD_KEY'] == 1) {
|
||||||
$vValue = $aFields[$aField['FLD_NAME']];
|
$vValue = $aFields[$aField['FLD_NAME']];
|
||||||
eval('$' . $aField['FLD_NAME'] . ' = $vValue;');
|
eval('$' . $aField['FLD_NAME'] . ' = $vValue;');
|
||||||
@@ -472,32 +486,32 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oConnection->commit();
|
$oConnection->commit();
|
||||||
return $iResult;
|
return $iResult;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$sMessage = '';
|
$sMessage = '';
|
||||||
if ($oClass) {
|
if ($oClass) {
|
||||||
$aValidationFailures = $oClass->getValidationFailures();
|
$aValidationFailures = $oClass->getValidationFailures();
|
||||||
foreach($aValidationFailures as $oValidationFailure) {
|
foreach ($aValidationFailures as $oValidationFailure) {
|
||||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$sMessage = 'Error, row cannot updated';
|
$sMessage = 'Error, row cannot updated';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
throw(new Exception('The registry cannot be updated!<br />' . $sMessage));
|
throw(new Exception('The registry cannot be updated!<br />' . $sMessage));
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteDataInTable($sUID, $aKeys) {
|
public function deleteDataInTable($sUID, $aKeys)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$aData = $this->load($sUID, true);
|
$aData = $this->load($sUID, true);
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $this->getPHPName($aData['ADD_TAB_NAME']));
|
$sClassName = ($aData['ADD_TAB_CLASS_NAME'] != ''
|
||||||
|
? $aData['ADD_TAB_CLASS_NAME']
|
||||||
|
: $this->getPHPName($aData['ADD_TAB_NAME']));
|
||||||
$oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
$oConnection = Propel::getConnection(FieldsPeer::DATABASE_NAME);
|
||||||
require_once $sPath . $sClassName . '.php';
|
require_once $sPath . $sClassName . '.php';
|
||||||
$sKeys = '';
|
$sKeys = '';
|
||||||
@@ -515,22 +529,19 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oConnection->commit();
|
$oConnection->commit();
|
||||||
return $iResult;
|
return $iResult;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$sMessage = '';
|
$sMessage = '';
|
||||||
$aValidationFailures = $oConnection-->getValidationFailures();
|
$aValidationFailures = $oConnection-- > getValidationFailures();
|
||||||
foreach($aValidationFailures as $oValidationFailure) {
|
foreach ($aValidationFailures as $oValidationFailure) {
|
||||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||||
}
|
}
|
||||||
throw(new Exception('The registry cannot be updated!<br />' . $sMessage));
|
throw(new Exception('The registry cannot be updated!<br />' . $sMessage));
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the report table with all case data
|
* Populate the report table with all case data
|
||||||
* @param string $sType
|
* @param string $sType
|
||||||
@@ -538,15 +549,16 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
* @param string $sGrid
|
* @param string $sGrid
|
||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
public function populateReportTable($tableName, $sConnection = 'rp', $type = 'NORMAL', $processUid = '', $gridKey = '')
|
public function populateReportTable($tableName, $sConnection='rp', $type='NORMAL', $processUid='', $gridKey='')
|
||||||
{
|
{
|
||||||
require_once "classes/model/Application.php";
|
require_once "classes/model/Application.php";
|
||||||
|
|
||||||
$this->className = $this->getPHPName($tableName);
|
$this->className = $this->getPHPName($tableName);
|
||||||
$this->classPeerName = $this->className . 'Peer';
|
$this->classPeerName = $this->className . 'Peer';
|
||||||
|
|
||||||
if (!file_exists (PATH_WORKSPACE . 'classes/' . $this->className . '.php') ) {
|
if (!file_exists(PATH_WORKSPACE . 'classes/' . $this->className . '.php')) {
|
||||||
throw new Exception("ERROR: ".PATH_WORKSPACE . 'classes/' . $this->className . '.php'." class file doesn't exit!");
|
throw new Exception( "ERROR: " . PATH_WORKSPACE . 'classes/' . $this->className . '.php'
|
||||||
|
. " class file doesn't exit!");
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once PATH_WORKSPACE . 'classes/' . $this->className . '.php';
|
require_once PATH_WORKSPACE . 'classes/' . $this->className . '.php';
|
||||||
@@ -563,7 +575,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
while ($dataset->next()) {
|
while ($dataset->next()) {
|
||||||
$row = $dataset->getRow();
|
$row = $dataset->getRow();
|
||||||
//remove old applications references
|
//remove old applications references
|
||||||
$deleteSql = "DELETE FROM $tableName WHERE APP_UID = '".$row['APP_UID']."'";
|
$deleteSql = "DELETE FROM $tableName WHERE APP_UID = '" . $row['APP_UID'] . "'";
|
||||||
$rs = $stmt->executeQuery($deleteSql);
|
$rs = $stmt->executeQuery($deleteSql);
|
||||||
// getting the case data
|
// getting the case data
|
||||||
$caseData = unserialize($row['APP_DATA']);
|
$caseData = unserialize($row['APP_DATA']);
|
||||||
@@ -571,16 +583,17 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
// quick fix
|
// quick fix
|
||||||
// map all empty values as NULL for Database
|
// map all empty values as NULL for Database
|
||||||
foreach ($caseData as $dKey => $dValue) {
|
foreach ($caseData as $dKey => $dValue) {
|
||||||
if (!is_array($dValue)) { // normal fields
|
if (!is_array($dValue)) {
|
||||||
|
// normal fields
|
||||||
if (trim($dValue) === '') {
|
if (trim($dValue) === '') {
|
||||||
$caseData[$dKey] = NULL;
|
$caseData[$dKey] = null;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else { // grids
|
// grids
|
||||||
foreach ($caseData[$dKey] as $dIndex => $dRow) {
|
foreach ($caseData[$dKey] as $dIndex => $dRow) {
|
||||||
foreach ($dRow as $k => $v) {
|
foreach ($dRow as $k => $v) {
|
||||||
if (trim($v) === '') {
|
if (trim($v) === '') {
|
||||||
$caseData[$dKey][$dIndex][$k] = NULL;
|
$caseData[$dKey][$dIndex][$k] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -592,17 +605,17 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$gridData = isset($caseData[$gridName]) ? $caseData[$gridName] : array();
|
$gridData = isset($caseData[$gridName]) ? $caseData[$gridName] : array();
|
||||||
|
|
||||||
foreach ($gridData as $i => $gridRow) {
|
foreach ($gridData as $i => $gridRow) {
|
||||||
eval('$obj = new ' .$this->className. '();');
|
eval('$obj = new ' . $this->className . '();');
|
||||||
$obj->fromArray($caseData, BasePeer::TYPE_FIELDNAME);
|
$obj->fromArray($caseData, BasePeer::TYPE_FIELDNAME);
|
||||||
$obj->setAppUid($row['APP_UID']);
|
$obj->setAppUid($row['APP_UID']);
|
||||||
$obj->setAppNumber($row['APP_NUMBER']);
|
$obj->setAppNumber($row['APP_NUMBER']);
|
||||||
$obj->fromArray(array_change_key_case($gridRow, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
$obj->fromArray(array_change_key_case($gridRow, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
||||||
$obj->setRow($i);
|
$obj->setRow($i);
|
||||||
$obj->save();
|
$obj->save();
|
||||||
eval('$obj = new ' .$this->className. '();');
|
eval('$obj = new ' . $this->className . '();');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eval('$obj = new ' .$this->className. '();');
|
eval('$obj = new ' . $this->className . '();');
|
||||||
$obj->fromArray(array_change_key_case($caseData, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
$obj->fromArray(array_change_key_case($caseData, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
||||||
$obj->setAppUid($row['APP_UID']);
|
$obj->setAppUid($row['APP_UID']);
|
||||||
$obj->setAppNumber($row['APP_NUMBER']);
|
$obj->setAppNumber($row['APP_NUMBER']);
|
||||||
@@ -628,39 +641,42 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$dataset = AdditionalTablesPeer::doSelectRS($criteria);
|
$dataset = AdditionalTablesPeer::doSelectRS($criteria);
|
||||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
// accomplish all related report tables for this process that contain case data for the target ($appUid) application
|
// accomplish all related report tables for this process that contain case data
|
||||||
|
// for the target ($appUid) application
|
||||||
while ($dataset->next()) {
|
while ($dataset->next()) {
|
||||||
$row = $dataset->getRow();
|
$row = $dataset->getRow();
|
||||||
$className = $row['ADD_TAB_CLASS_NAME'];
|
$className = $row['ADD_TAB_CLASS_NAME'];
|
||||||
// verify if the report table class exists
|
// verify if the report table class exists
|
||||||
if (!file_exists (PATH_WORKSPACE . 'classes/' . $className . '.php') ) {
|
if (!file_exists(PATH_WORKSPACE . 'classes/' . $className . '.php')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// the class exists then load it.
|
// the class exists then load it.
|
||||||
require_once PATH_WORKSPACE . 'classes/' . $className . '.php'; //
|
require_once PATH_WORKSPACE . 'classes/' . $className . '.php';
|
||||||
|
|
||||||
// create a criteria object of report table class
|
// create a criteria object of report table class
|
||||||
$c = new Criteria(pmTable::resolveDbSource($row['DBS_UID']));
|
$c = new Criteria(pmTable::resolveDbSource($row['DBS_UID']));
|
||||||
// select all related records with this $appUid
|
// select all related records with this $appUid
|
||||||
eval('$c->add(' . $className . 'Peer::APP_UID, \'' . $appUid . '\');');
|
eval('$c->add(' . $className . 'Peer::APP_UID, \'' . $appUid . '\');');
|
||||||
eval('$records = ' . $className . 'Peer::doSelect($c);');
|
eval('$records = ' . $className . 'Peer::doSelect($c);');
|
||||||
|
|
||||||
switch ($row['ADD_TAB_TYPE']) { //switching by report table type
|
switch ($row['ADD_TAB_TYPE']) {
|
||||||
|
//switching by report table type
|
||||||
case 'NORMAL':
|
case 'NORMAL':
|
||||||
// parsing empty values to null
|
// parsing empty values to null
|
||||||
foreach ($caseData as $i => $v) {
|
foreach ($caseData as $i => $v) {
|
||||||
$caseData[$i] = $v === '' ? NULL : $v;
|
$caseData[$i] = $v === '' ? null : $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($records) && count($records) > 0) { // if the record already exists on the report table
|
if (is_array($records) && count($records) > 0) {
|
||||||
foreach ($records as $record) { //update all records
|
// if the record already exists on the report table
|
||||||
|
foreach ($records as $record) {
|
||||||
|
//update all records
|
||||||
$record->fromArray(array_change_key_case($caseData, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
$record->fromArray(array_change_key_case($caseData, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
||||||
if ($record->validate()) {
|
if ($record->validate()) {
|
||||||
$record->save();
|
$record->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else { // there are not any record for this application on the table, then create it
|
// there are not any record for this application on the table, then create it
|
||||||
eval('$obj = new ' . $className . '();');
|
eval('$obj = new ' . $className . '();');
|
||||||
$obj->fromArray(array_change_key_case($caseData, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
$obj->fromArray(array_change_key_case($caseData, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
|
||||||
$obj->setAppUid($appUid);
|
$obj->setAppUid($appUid);
|
||||||
@@ -668,7 +684,6 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$obj->save();
|
$obj->save();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'GRID':
|
case 'GRID':
|
||||||
list($gridName, $gridUid) = explode('-', $row['ADD_TAB_GRID']);
|
list($gridName, $gridUid) = explode('-', $row['ADD_TAB_GRID']);
|
||||||
$gridData = isset($caseData[$gridName]) ? $caseData[$gridName] : array();
|
$gridData = isset($caseData[$gridName]) ? $caseData[$gridName] : array();
|
||||||
@@ -693,7 +708,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTableVars($uid, $bWhitType = false)
|
public function getTableVars($uid, $bWhitType=false)
|
||||||
{
|
{
|
||||||
require_once 'classes/model/Fields.php';
|
require_once 'classes/model/Fields.php';
|
||||||
try {
|
try {
|
||||||
@@ -707,26 +722,27 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
$aVars = array();
|
$aVars = array();
|
||||||
$aImportedVars = array();//This array will help to control if the variable already exist
|
$aImportedVars = array(); //This array will help to control if the variable already exist
|
||||||
while ($aRow = $oDataset->getRow()) {
|
while ($aRow = $oDataset->getRow()) {
|
||||||
if ($bWhitType) {
|
if ($bWhitType) {
|
||||||
if (!in_array($aRow['FLD_NAME'], $aImportedVars)) {
|
if (!in_array($aRow['FLD_NAME'], $aImportedVars)) {
|
||||||
$aImportedVars[]=$aRow['FLD_NAME'];
|
$aImportedVars[] = $aRow['FLD_NAME'];
|
||||||
$aVars[] = array('sFieldName' => $aRow['FLD_NAME'], 'sFieldDynName' => $aRow['FLD_DYN_NAME'], 'sType' => $aRow['FLD_TYPE']);
|
$aVars[] = array('sFieldName' => $aRow['FLD_NAME'],
|
||||||
|
'sFieldDynName' => $aRow['FLD_DYN_NAME'],
|
||||||
|
'sType' => $aRow['FLD_TYPE']);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
$aVars[] = $aRow['FLD_NAME'];
|
$aVars[] = $aRow['FLD_NAME'];
|
||||||
}
|
}
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
}
|
}
|
||||||
return $aVars;
|
return $aVars;
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAll($start = 0, $limit = 20, $filter = '', $process = null)
|
public function getAll($start=0, $limit=20, $filter='', $process=null)
|
||||||
{
|
{
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID);
|
$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID);
|
||||||
@@ -739,17 +755,18 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
|
|
||||||
if (isset($process)) {
|
if (isset($process)) {
|
||||||
foreach ($process as $key => $pro_uid) {
|
foreach ($process as $key => $pro_uid) {
|
||||||
if ($key == 'equal')
|
if ($key == 'equal') {
|
||||||
$oCriteria->add(AdditionalTablesPeer::PRO_UID, $pro_uid, Criteria::EQUAL);
|
$oCriteria->add(AdditionalTablesPeer::PRO_UID, $pro_uid, Criteria::EQUAL);
|
||||||
else
|
} else {
|
||||||
$oCriteria->add(AdditionalTablesPeer::PRO_UID, $pro_uid, Criteria::NOT_EQUAL);
|
$oCriteria->add(AdditionalTablesPeer::PRO_UID, $pro_uid, Criteria::NOT_EQUAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($filter != '' && is_string($filter)) {
|
if ($filter != '' && is_string($filter)) {
|
||||||
$oCriteria->add(
|
$oCriteria->add(
|
||||||
$oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_NAME, '%'.$filter.'%',Criteria::LIKE)->addOr(
|
$oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_NAME, '%' . $filter . '%', Criteria::LIKE)->addOr(
|
||||||
$oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_DESCRIPTION, '%'.$filter.'%',Criteria::LIKE))
|
$oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,7 +782,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$addTables = Array();
|
$addTables = Array();
|
||||||
$proUids = Array();
|
$proUids = Array();
|
||||||
|
|
||||||
while( $oDataset->next() ) {
|
while ($oDataset->next()) {
|
||||||
$row = $oDataset->getRow();
|
$row = $oDataset->getRow();
|
||||||
$row['PRO_TITLE'] = $row['PRO_DESCRIPTION'] = '';
|
$row['PRO_TITLE'] = $row['PRO_DESCRIPTION'] = '';
|
||||||
$addTables[] = $row;
|
$addTables[] = $row;
|
||||||
@@ -781,10 +798,10 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
//now get the labels for all process, using an array of Uids,
|
//now get the labels for all process, using an array of Uids,
|
||||||
$c = new Criteria('workflow');
|
$c = new Criteria('workflow');
|
||||||
//$c->add ( ContentPeer::CON_CATEGORY, 'PRO_TITLE', Criteria::EQUAL );
|
//$c->add ( ContentPeer::CON_CATEGORY, 'PRO_TITLE', Criteria::EQUAL );
|
||||||
$c->add(ContentPeer::CON_LANG, defined('SYS_LANG')? SYS_LANG: 'en', Criteria::EQUAL);
|
$c->add(ContentPeer::CON_LANG, defined('SYS_LANG') ? SYS_LANG : 'en', Criteria::EQUAL);
|
||||||
$c->add(ContentPeer::CON_ID, $proUids, Criteria::IN);
|
$c->add(ContentPeer::CON_ID, $proUids, Criteria::IN);
|
||||||
|
|
||||||
$dt = ContentPeer::doSelectRS ($c);
|
$dt = ContentPeer::doSelectRS($c);
|
||||||
$dt->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$dt->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
while ($dt->next()) {
|
while ($dt->next()) {
|
||||||
@@ -793,13 +810,15 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($addTables as $i => $addTable) {
|
foreach ($addTables as $i => $addTable) {
|
||||||
if (isset($procDetails[$addTable['PRO_UID']]['PRO_TITLE']))
|
if (isset($procDetails[$addTable['PRO_UID']]['PRO_TITLE'])) {
|
||||||
$addTables[$i]['PRO_TITLE'] = $procDetails[$addTable['PRO_UID']]['PRO_TITLE'];
|
$addTables[$i]['PRO_TITLE'] = $procDetails[$addTable['PRO_UID']]['PRO_TITLE'];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($procDetails[$addTable['PRO_UID']]['PRO_DESCRIPTION']))
|
if (isset($procDetails[$addTable['PRO_UID']]['PRO_DESCRIPTION'])) {
|
||||||
$addTables[$i]['PRO_DESCRIPTION'] = $procDetails[$addTable['PRO_UID']]['PRO_DESCRIPTION'];
|
$addTables[$i]['PRO_DESCRIPTION'] = $procDetails[$addTable['PRO_UID']]['PRO_DESCRIPTION'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// // fltering by proces title
|
// // fltering by proces title
|
||||||
// if(isset($filter['process'])) {
|
// if(isset($filter['process'])) {
|
||||||
@@ -809,7 +828,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return array('rows'=>$addTables, 'count'=>$count);
|
return array('rows' => $addTables, 'count' => $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -818,17 +837,16 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
* Don't use this method, it was left only for backward compatibility
|
* Don't use this method, it was left only for backward compatibility
|
||||||
* for some external plugins that still is using it
|
* for some external plugins that still is using it
|
||||||
*/
|
*/
|
||||||
|
public function createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid, $connection='workflow')
|
||||||
function createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid, $connection='workflow')
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/*$aUID = array('FLD_NAME' => 'PM_UNIQUE_ID',
|
/* $aUID = array('FLD_NAME' => 'PM_UNIQUE_ID',
|
||||||
'FLD_TYPE' => 'INT',
|
'FLD_TYPE' => 'INT',
|
||||||
'FLD_KEY' => 'on',
|
'FLD_KEY' => 'on',
|
||||||
'FLD_SIZE' => '11',
|
'FLD_SIZE' => '11',
|
||||||
'FLD_NULL' => '',
|
'FLD_NULL' => '',
|
||||||
'FLD_AUTO_INCREMENT' => 'on');
|
'FLD_AUTO_INCREMENT' => 'on');
|
||||||
array_unshift($aFields, $aUID);*/
|
array_unshift($aFields, $aUID); */
|
||||||
$aTypes = array(
|
$aTypes = array(
|
||||||
'VARCHAR' => 'string',
|
'VARCHAR' => 'string',
|
||||||
'TEXT' => 'string',
|
'TEXT' => 'string',
|
||||||
@@ -864,7 +882,9 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$aData['connection'] = $connection;
|
$aData['connection'] = $connection;
|
||||||
$aData['GUID'] = $sAddTabUid;
|
$aData['GUID'] = $sAddTabUid;
|
||||||
|
|
||||||
$aData['firstColumn'] = isset($aFields[0])? strtoupper($aFields[0]['FLD_NAME']) : ($aFields[1]['FLD_NAME']);
|
$aData['firstColumn'] = isset($aFields[0])
|
||||||
|
? strtoupper($aFields[0]['FLD_NAME'])
|
||||||
|
: ($aFields[1]['FLD_NAME']);
|
||||||
$aData['totalColumns'] = count($aFields);
|
$aData['totalColumns'] = count($aFields);
|
||||||
$aData['useIdGenerator'] = 'false';
|
$aData['useIdGenerator'] = 'false';
|
||||||
$oTP1 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'Table.tpl');
|
$oTP1 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'Table.tpl');
|
||||||
@@ -879,18 +899,26 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$aPKs = array();
|
$aPKs = array();
|
||||||
$aNotPKs = array();
|
$aNotPKs = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($aFields as $iKey => $aField) {
|
foreach ($aFields as $iKey => $aField) {
|
||||||
$aField['FLD_NAME'] = strtoupper($aField['FLD_NAME']);
|
$aField['FLD_NAME'] = strtoupper($aField['FLD_NAME']);
|
||||||
if ($aField['FLD_TYPE']=='DATE') $aField['FLD_NULL'] = '';
|
if ($aField['FLD_TYPE'] == 'DATE') {
|
||||||
|
$aField['FLD_NULL'] = '';
|
||||||
|
}
|
||||||
$aColumn = array(
|
$aColumn = array(
|
||||||
'name' => $aField['FLD_NAME'],
|
'name' => $aField['FLD_NAME'],
|
||||||
'phpName' => $this->getPHPName($aField['FLD_NAME']),
|
'phpName' => $this->getPHPName($aField['FLD_NAME']),
|
||||||
'type' => $aTypes[$aField['FLD_TYPE']],
|
'type' => $aTypes[$aField['FLD_TYPE']],
|
||||||
'creoleType' => $aCreoleTypes[$aField['FLD_TYPE']],
|
'creoleType' => $aCreoleTypes[$aField['FLD_TYPE']],
|
||||||
'notNull' => ($aField['FLD_NULL'] == 'on' ? 'true' : 'false'),
|
'notNull' => ($aField['FLD_NULL'] == 'on' ? 'true' : 'false'),
|
||||||
'size' => (($aField['FLD_TYPE'] == 'VARCHAR') || ($aField['FLD_TYPE'] == 'INT') || ($aField['FLD_TYPE'] == 'FLOAT') ? $aField['FLD_SIZE'] : 'null'),
|
'size' => (($aField['FLD_TYPE'] == 'VARCHAR')
|
||||||
|
|| ($aField['FLD_TYPE'] == 'INT')
|
||||||
|
|| ($aField['FLD_TYPE'] == 'FLOAT') ? $aField['FLD_SIZE'] : 'null'),
|
||||||
'var' => strtolower($aField['FLD_NAME']),
|
'var' => strtolower($aField['FLD_NAME']),
|
||||||
'attribute' => (($aField['FLD_TYPE'] == 'VARCHAR') || ($aField['FLD_TYPE'] == 'TEXT') || ($aField['FLD_TYPE'] == 'DATE') ? '$' . strtolower($aField['FLD_NAME']) . " = ''" : '$' . strtolower($aField['FLD_NAME']) . ' = 0'),
|
'attribute' => (($aField['FLD_TYPE'] == 'VARCHAR')
|
||||||
|
|| ($aField['FLD_TYPE'] == 'TEXT')
|
||||||
|
|| ($aField['FLD_TYPE'] == 'DATE')
|
||||||
|
? '$' . strtolower($aField['FLD_NAME']) . " = ''"
|
||||||
|
: '$' . strtolower($aField['FLD_NAME']) . ' = 0'),
|
||||||
'index' => $i,
|
'index' => $i,
|
||||||
);
|
);
|
||||||
if ($aField['FLD_TYPE'] == 'DATE') {
|
if ($aField['FLD_TYPE'] == 'DATE') {
|
||||||
@@ -909,14 +937,16 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
return null;
|
return null;
|
||||||
} elseif (!is_int($this->' . $aColumn['var'] . ')) {
|
} elseif (!is_int($this->' . $aColumn['var'] . ')) {
|
||||||
// a non-timestamp value was set externally, so we convert it
|
// a non-timestamp value was set externally, so we convert it
|
||||||
if (($this->' . $aColumn['var'] . ' == "0000-00-00 00:00:00") || ($this->' . $aColumn['var'] . ' == "0000-00-00") || !$this->' . $aColumn['var'] . ') {
|
if (($this->' . $aColumn['var'] . ' == "0000-00-00 00:00:00")
|
||||||
|
|| ($this->' . $aColumn['var'] . ' == "0000-00-00") || !$this->' . $aColumn['var'] . ') {
|
||||||
$ts = "0";
|
$ts = "0";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ts = strtotime($this->' . $aColumn['var'] . ');
|
$ts = strtotime($this->' . $aColumn['var'] . ');
|
||||||
}
|
}
|
||||||
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
||||||
throw new PropelException("Unable to parse value of [' . $aColumn['var'] . '] as date/time value: " . var_export($this->' . $aColumn['var'] . ', true));
|
throw new PropelException("Unable to parse value of [' . $aColumn['var'] . '] as date/time value: "
|
||||||
|
. var_export($this->' . $aColumn['var'] . ', true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ts = $this->' . $aColumn['var'] . ';
|
$ts = $this->' . $aColumn['var'] . ';
|
||||||
@@ -929,8 +959,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
return date($format, $ts);
|
return date($format, $ts);
|
||||||
}
|
}
|
||||||
}';
|
}';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$aColumn['getFunction'] = '/**
|
$aColumn['getFunction'] = '/**
|
||||||
* Get the [' . $aColumn['var'] . '] column value.
|
* Get the [' . $aColumn['var'] . '] column value.
|
||||||
*
|
*
|
||||||
@@ -963,7 +992,8 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
// else
|
// else
|
||||||
$ts = strtotime($v);
|
$ts = strtotime($v);
|
||||||
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
||||||
//throw new PropelException("Unable to parse date/time value for [' . $aColumn['var'] . '] from input: " . var_export($v, true));
|
//throw new PropelException("Unable to parse date/time value for [' . $aColumn['var'] . '] from input: "
|
||||||
|
// . var_export($v, true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ts = $v;
|
$ts = $v;
|
||||||
@@ -994,8 +1024,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$aColumns[] = $aColumn;
|
$aColumns[] = $aColumn;
|
||||||
if ($aField['FLD_KEY'] == 1 || $aField['FLD_KEY'] === 'on') {
|
if ($aField['FLD_KEY'] == 1 || $aField['FLD_KEY'] === 'on') {
|
||||||
$aPKs[] = $aColumn;
|
$aPKs[] = $aColumn;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$aNotPKs[] = $aColumn;
|
$aNotPKs[] = $aColumn;
|
||||||
}
|
}
|
||||||
if ($aField['FLD_AUTO_INCREMENT'] == 1 || $aField['FLD_AUTO_INCREMENT'] === 'on') {
|
if ($aField['FLD_AUTO_INCREMENT'] == 1 || $aField['FLD_AUTO_INCREMENT'] === 'on') {
|
||||||
@@ -1003,7 +1032,8 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$oTP3 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'map' . PATH_SEP . 'TableMapBuilder.tpl');
|
$oTP3 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'map'
|
||||||
|
. PATH_SEP . 'TableMapBuilder.tpl');
|
||||||
$oTP3->prepare();
|
$oTP3->prepare();
|
||||||
$oTP3->assignGlobal($aData);
|
$oTP3->assignGlobal($aData);
|
||||||
foreach ($aPKs as $iIndex => $aColumn) {
|
foreach ($aPKs as $iIndex => $aColumn) {
|
||||||
@@ -1021,7 +1051,8 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oTP3->assign($sKey, $aColumn[$sKey]);
|
$oTP3->assign($sKey, $aColumn[$sKey]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_put_contents($sPath . PATH_SEP . 'map' . PATH_SEP . $sClassName . 'MapBuilder.php', $oTP3->getOutputContent());
|
file_put_contents($sPath . PATH_SEP . 'map' . PATH_SEP . $sClassName
|
||||||
|
. 'MapBuilder.php', $oTP3->getOutputContent());
|
||||||
$oTP4 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'om' . PATH_SEP . 'BaseTable.tpl');
|
$oTP4 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'om' . PATH_SEP . 'BaseTable.tpl');
|
||||||
$oTP4->prepare();
|
$oTP4->prepare();
|
||||||
switch (count($aPKs)) {
|
switch (count($aPKs)) {
|
||||||
@@ -1037,8 +1068,10 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$aData['getPrimaryKeyFunction'] = '$pks = array();' . "\n";
|
$aData['getPrimaryKeyFunction'] = '$pks = array();' . "\n";
|
||||||
$aData['setPrimaryKeyFunction'] = '';
|
$aData['setPrimaryKeyFunction'] = '';
|
||||||
foreach ($aPKs as $iIndex => $aColumn) {
|
foreach ($aPKs as $iIndex => $aColumn) {
|
||||||
$aData['getPrimaryKeyFunction'] .= '$pks[' . $iIndex . '] = $this->get' . $aColumn['phpName'] . '();' . "\n";
|
$aData['getPrimaryKeyFunction'] .= '$pks[' . $iIndex . '] = $this->get'
|
||||||
$aData['setPrimaryKeyFunction'] .= '$this->set' . $aColumn['phpName'] . '($keys[' . $iIndex . ']);' . "\n";
|
. $aColumn['phpName'] . '();' . "\n";
|
||||||
|
$aData['setPrimaryKeyFunction'] .= '$this->set' . $aColumn['phpName']
|
||||||
|
. '($keys[' . $iIndex . ']);' . "\n";
|
||||||
}
|
}
|
||||||
$aData['getPrimaryKeyFunction'] .= 'return $pks;' . "\n";
|
$aData['getPrimaryKeyFunction'] .= 'return $pks;' . "\n";
|
||||||
break;
|
break;
|
||||||
@@ -1115,7 +1148,8 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oTP4->assign($sKey, $aColumn[$sKey]);
|
$oTP4->assign($sKey, $aColumn[$sKey]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_put_contents($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . '.php', $oTP4->getOutputContent());
|
file_put_contents($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base'
|
||||||
|
. $sClassName . '.php', $oTP4->getOutputContent());
|
||||||
$oTP5 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'om' . PATH_SEP . 'BaseTablePeer.tpl');
|
$oTP5 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'om' . PATH_SEP . 'BaseTablePeer.tpl');
|
||||||
$oTP5->prepare();
|
$oTP5->prepare();
|
||||||
$sKeys = '';
|
$sKeys = '';
|
||||||
@@ -1126,8 +1160,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
//$sKeys = '$pm_unique_id';
|
//$sKeys = '$pm_unique_id';
|
||||||
if ($sKeys != '') {
|
if ($sKeys != '') {
|
||||||
$aData['sKeys'] = $sKeys;
|
$aData['sKeys'] = $sKeys;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$aData['sKeys'] = '$DUMMY';
|
$aData['sKeys'] = '$DUMMY';
|
||||||
}
|
}
|
||||||
$oTP5->assignGlobal($aData);
|
$oTP5->assignGlobal($aData);
|
||||||
@@ -1198,10 +1231,12 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
$oTP5->assign($sKey, $aColumn[$sKey]);
|
$oTP5->assign($sKey, $aColumn[$sKey]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_put_contents($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . 'Peer.php', $oTP5->getOutputContent());
|
file_put_contents($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base'
|
||||||
}
|
. $sClassName . 'Peer.php', $oTP5->getOutputContent());
|
||||||
catch (Exception $oError) {
|
} catch (Exception $oError) {
|
||||||
throw($oError);
|
throw($oError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // AdditionalTables
|
}
|
||||||
|
// AdditionalTables
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user