Various settings for compatibility with MSSQL
This commit is contained in:
@@ -424,7 +424,7 @@ class Cases {
|
|||||||
$oApp = new Application;
|
$oApp = new Application;
|
||||||
$aFields = $oApp->Load($sAppUid);
|
$aFields = $oApp->Load($sAppUid);
|
||||||
//$aFields = $oApp->toArray(BasePeer::TYPE_FIELDNAME);
|
//$aFields = $oApp->toArray(BasePeer::TYPE_FIELDNAME);
|
||||||
$aFields['APP_DATA'] = G::array_merges(G::getSystemConstants(), unserialize($aFields['APP_DATA']));
|
$aFields['APP_DATA'] = G::array_merges(G::getSystemConstants(), @unserialize($aFields['APP_DATA']));
|
||||||
switch ($oApp->getAppStatus()) {
|
switch ($oApp->getAppStatus()) {
|
||||||
case 'COMPLETED':
|
case 'COMPLETED':
|
||||||
$aFields['STATUS'] = G::LoadTranslation('ID_COMPLETED');
|
$aFields['STATUS'] = G::LoadTranslation('ID_COMPLETED');
|
||||||
@@ -868,7 +868,7 @@ class Cases {
|
|||||||
$oReportTables->updateTables($appFields['PRO_UID'], $sAppUid, $Fields['APP_NUMBER'], $aApplicationFields);
|
$oReportTables->updateTables($appFields['PRO_UID'], $sAppUid, $Fields['APP_NUMBER'], $aApplicationFields);
|
||||||
|
|
||||||
//now update the priority in appdelegation table, using the defined variable in task
|
//now update the priority in appdelegation table, using the defined variable in task
|
||||||
if ($DEL_INDEX != '' && $TAS_UID != '') {
|
if (trim($DEL_INDEX) != '' && trim($TAS_UID) != '') {
|
||||||
//optimized code to avoid load task content row.
|
//optimized code to avoid load task content row.
|
||||||
$c = new Criteria();
|
$c = new Criteria();
|
||||||
$c->clearSelectColumns();
|
$c->clearSelectColumns();
|
||||||
@@ -887,7 +887,7 @@ class Cases {
|
|||||||
|
|
||||||
$x = unserialize($Fields['APP_DATA']);
|
$x = unserialize($Fields['APP_DATA']);
|
||||||
if (isset($x[$VAR_PRI])) {
|
if (isset($x[$VAR_PRI])) {
|
||||||
if ($x[$VAR_PRI] != '') {
|
if (trim($x[$VAR_PRI]) != '') {
|
||||||
$oDel = new AppDelegation;
|
$oDel = new AppDelegation;
|
||||||
$array = array();
|
$array = array();
|
||||||
$array['APP_UID'] = $sAppUid;
|
$array['APP_UID'] = $sAppUid;
|
||||||
@@ -1818,7 +1818,7 @@ class Cases {
|
|||||||
$oStep = new Step;
|
$oStep = new Step;
|
||||||
$oStep = $oStep->loadByProcessTaskPosition($sProUid, $sTaskUid, $iPosition);
|
$oStep = $oStep->loadByProcessTaskPosition($sProUid, $sTaskUid, $iPosition);
|
||||||
if ($oStep) {
|
if ($oStep) {
|
||||||
if ($oStep->getStepCondition() !== '') {
|
if (trim($oStep->getStepCondition()) !== '') {
|
||||||
$oPMScript->setScript($oStep->getStepCondition());
|
$oPMScript->setScript($oStep->getStepCondition());
|
||||||
$bAccessStep = $oPMScript->evaluate();
|
$bAccessStep = $oPMScript->evaluate();
|
||||||
} else {
|
} else {
|
||||||
@@ -1925,7 +1925,7 @@ class Cases {
|
|||||||
$oStep = new Step;
|
$oStep = new Step;
|
||||||
$oStep = $oStep->loadByProcessTaskPosition($sProUid, $sTaskUid, $iPosition);
|
$oStep = $oStep->loadByProcessTaskPosition($sProUid, $sTaskUid, $iPosition);
|
||||||
if ($oStep) {
|
if ($oStep) {
|
||||||
if ($oStep->getStepCondition() !== '') {
|
if (trim($oStep->getStepCondition()) !== '') {
|
||||||
$oPMScript->setScript($oStep->getStepCondition());
|
$oPMScript->setScript($oStep->getStepCondition());
|
||||||
$bAccessStep = $oPMScript->evaluate();
|
$bAccessStep = $oPMScript->evaluate();
|
||||||
} else {
|
} else {
|
||||||
@@ -2060,13 +2060,22 @@ class Cases {
|
|||||||
$c->addSelectColumn(AppDelegationPeer::TAS_UID);
|
$c->addSelectColumn(AppDelegationPeer::TAS_UID);
|
||||||
$c->addSelectColumn(AppDelegationPeer::APP_UID);
|
$c->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||||
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||||
$c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
|
///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
|
||||||
|
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
||||||
|
if(G::LoadSystemExist($sDataBase)){
|
||||||
|
G::LoadSystem($sDataBase);
|
||||||
|
$oDataBase = new database();
|
||||||
|
$c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME"));
|
||||||
|
$c->addAsColumn('DEL_FINISH_DATE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE ) );
|
||||||
|
$c->addAsColumn('APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE ) );
|
||||||
|
}
|
||||||
|
|
||||||
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||||
//$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
//$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||||
$c->addAsColumn('DEL_FINISH_DATE', "IF (DEL_FINISH_DATE IS NULL, '-', " . AppDelegationPeer::DEL_FINISH_DATE . ") ");
|
///-- $c->addAsColumn('DEL_FINISH_DATE', "IF (DEL_FINISH_DATE IS NULL, '-', " . AppDelegationPeer::DEL_FINISH_DATE . ") ");
|
||||||
|
|
||||||
//$c->addSelectColumn(AppDelayPeer::APP_TYPE);
|
//$c->addSelectColumn(AppDelayPeer::APP_TYPE);
|
||||||
$c->addAsColumn('APP_TYPE', "IF (DEL_FINISH_DATE IS NULL, 'IN_PROGRESS', " . AppDelayPeer::APP_TYPE . ") ");
|
///-- $c->addAsColumn('APP_TYPE', "IF (DEL_FINISH_DATE IS NULL, 'IN_PROGRESS', " . AppDelayPeer::APP_TYPE . ") ");
|
||||||
$c->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
|
$c->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
|
||||||
$c->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE);
|
$c->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE);
|
||||||
//APP_DELEGATION LEFT JOIN USERS
|
//APP_DELEGATION LEFT JOIN USERS
|
||||||
@@ -3975,6 +3984,10 @@ class Cases {
|
|||||||
$oCriteria->addJoin(StepPeer::STEP_UID_OBJ, DynaformPeer::DYN_UID);
|
$oCriteria->addJoin(StepPeer::STEP_UID_OBJ, DynaformPeer::DYN_UID);
|
||||||
$oCriteria->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM');
|
$oCriteria->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM');
|
||||||
$oCriteria->add(StepPeer::STEP_UID_OBJ, $aObjectPermissions['DYNAFORMS'], Criteria::IN);
|
$oCriteria->add(StepPeer::STEP_UID_OBJ, $aObjectPermissions['DYNAFORMS'], Criteria::IN);
|
||||||
|
|
||||||
|
///-- Adding column STEP_POSITION for standardization
|
||||||
|
$oCriteria->addSelectColumn(StepPeer::STEP_POSITION);
|
||||||
|
|
||||||
$oCriteria->addAscendingOrderByColumn(StepPeer::STEP_POSITION);
|
$oCriteria->addAscendingOrderByColumn(StepPeer::STEP_POSITION);
|
||||||
$oCriteria->setDistinct();
|
$oCriteria->setDistinct();
|
||||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||||
@@ -4463,10 +4476,21 @@ class Cases {
|
|||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function verifyTable() {
|
function verifyTable()
|
||||||
|
{
|
||||||
|
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
$del = DBAdapter::getStringDelimiter();
|
$del = DBAdapter::getStringDelimiter();
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS `OBJECT_PERMISSION` (
|
|
||||||
|
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
||||||
|
if(G::LoadSystemExist($sDataBase)){
|
||||||
|
G::LoadSystem($sDataBase);
|
||||||
|
$oDataBase = new database();
|
||||||
|
$sql = $oDataBase->createTableObjectPermission();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
$sql = "CREATE TABLE IF NOT EXISTS `OBJECT_PERMISSION` (
|
||||||
`OP_UID` varchar(32) NOT NULL,
|
`OP_UID` varchar(32) NOT NULL,
|
||||||
`PRO_UID` varchar(32) NOT NULL,
|
`PRO_UID` varchar(32) NOT NULL,
|
||||||
`TAS_UID` varchar(32) NOT NULL,
|
`TAS_UID` varchar(32) NOT NULL,
|
||||||
@@ -4479,7 +4503,7 @@ class Cases {
|
|||||||
`OP_ACTION` varchar(10) NOT NULL default 'VIEW',
|
`OP_ACTION` varchar(10) NOT NULL default 'VIEW',
|
||||||
KEY `PRO_UID` (`PRO_UID`,`TAS_UID`,`USR_UID`,`OP_TASK_SOURCE`,`OP_OBJ_UID`)
|
KEY `PRO_UID` (`PRO_UID`,`TAS_UID`,`USR_UID`,`OP_TASK_SOURCE`,`OP_OBJ_UID`)
|
||||||
)ENGINE=MyISAM DEFAULT CHARSET=latin1;";
|
)ENGINE=MyISAM DEFAULT CHARSET=latin1;";
|
||||||
|
*/
|
||||||
$con = Propel::getConnection("workflow");
|
$con = Propel::getConnection("workflow");
|
||||||
$stmt = $con->prepareStatement($sql);
|
$stmt = $con->prepareStatement($sql);
|
||||||
$rs = $stmt->executeQuery();
|
$rs = $stmt->executeQuery();
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ class Report {
|
|||||||
$proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
|
$proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
|
||||||
$oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
|
$oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
|
||||||
$oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
|
$oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
|
||||||
|
$oCriteria->addGroupByColumn('C1.CON_VALUE');
|
||||||
|
|
||||||
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
@@ -142,6 +143,7 @@ class Report {
|
|||||||
if($startedby!='') $oCriteria->add(ApplicationPeer::APP_INIT_USER, $startedby);
|
if($startedby!='') $oCriteria->add(ApplicationPeer::APP_INIT_USER, $startedby);
|
||||||
|
|
||||||
$oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
|
$oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
|
||||||
|
$oCriteria->addGroupByColumn('C1.CON_VALUE');
|
||||||
|
|
||||||
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
@@ -436,7 +438,8 @@ class Report {
|
|||||||
$proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
|
$proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
|
||||||
$oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
|
$oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
|
||||||
$oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
|
$oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
|
||||||
|
$oCriteria->addGroupByColumn('C1.CON_VALUE');
|
||||||
|
|
||||||
$oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $from.' 00:00:00', Criteria::GREATER_EQUAL)->addAnd($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $to.' 23:59:59', Criteria::LESS_EQUAL)));
|
$oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $from.' 00:00:00', Criteria::GREATER_EQUAL)->addAnd($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $to.' 23:59:59', Criteria::LESS_EQUAL)));
|
||||||
|
|
||||||
if($startedby!='') $oCriteria->add(AppDelegationPeer::USR_UID, $startedby);
|
if($startedby!='') $oCriteria->add(AppDelegationPeer::USR_UID, $startedby);
|
||||||
|
|||||||
@@ -15,6 +15,26 @@ require_once 'classes/model/om/BaseAdditionalTables.php';
|
|||||||
* @package classes.model
|
* @package classes.model
|
||||||
*/
|
*/
|
||||||
class AdditionalTables extends BaseAdditionalTables {
|
class AdditionalTables extends BaseAdditionalTables {
|
||||||
|
private $aDef = array('mysql' => array('TEXT' => 'TEXT',
|
||||||
|
'CHAR' => 'CHAR',
|
||||||
|
'VARCHAR' => 'VARCHAR',
|
||||||
|
'INT' => 'INT',
|
||||||
|
'FLOAT' => 'FLOAT',
|
||||||
|
'DATE' => 'DATE'),
|
||||||
|
'pgsql' => array('TEXT' => 'TEXT',
|
||||||
|
'CHAR' => 'CHAR',
|
||||||
|
'VARCHAR' => 'VARCHAR',
|
||||||
|
'INT' => 'INTEGER',
|
||||||
|
'FLOAT' => 'REAL',
|
||||||
|
'DATE' => 'DATE'),
|
||||||
|
'mssql' => array('TEXT' => 'TEXT',
|
||||||
|
'CHAR' => 'NCHAR',
|
||||||
|
'VARCHAR' => 'NVARCHAR',
|
||||||
|
'INT' => 'INTEGER',
|
||||||
|
'FLOAT' => 'FLOAT',
|
||||||
|
'DATE' => 'CHAR (19)')
|
||||||
|
);
|
||||||
|
|
||||||
public function load($sUID, $bFields = false) {
|
public function load($sUID, $bFields = false) {
|
||||||
try {
|
try {
|
||||||
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
||||||
@@ -267,6 +287,66 @@ public function loadByName($name) {
|
|||||||
throw new Exception('Cannot create the table "' . $sTableName . '"!');
|
throw new Exception('Cannot create the table "' . $sTableName . '"!');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'mssql':
|
||||||
|
$sDBAdapter = DB_ADAPTER;
|
||||||
|
$sDBUser = DB_USER;
|
||||||
|
$sDBPass = DB_PASS;
|
||||||
|
$sDBHost = DB_HOST; // substr(DB_HOST, 0, strpos(DB_HOST,':'));
|
||||||
|
$sDBName = DB_NAME;
|
||||||
|
|
||||||
|
$sDBHost = substr($sDBHost, 0, strpos($sDBHost,':'));
|
||||||
|
|
||||||
|
$dsn = $sDBAdapter . '://' . $sDBUser . ':' . $sDBPass . '@' . $sDBHost . '/' . $sDBName;
|
||||||
|
|
||||||
|
|
||||||
|
$db =& DB::Connect( $dsn);
|
||||||
|
if (PEAR::isError($db)) { die($db->getMessage()); }
|
||||||
|
|
||||||
|
$sQuery = 'CREATE TABLE ' . $sTableName . ' (';
|
||||||
|
$aPKs = array();
|
||||||
|
foreach ($aFields as $aField) {
|
||||||
|
switch ($aField['sType']) {
|
||||||
|
case 'VARCHAR':
|
||||||
|
$sQuery .= ' ' . $aField['sFieldName'] . ' ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '',";
|
||||||
|
break;
|
||||||
|
case 'TEXT':
|
||||||
|
$sQuery .= ' ' . $aField['sFieldName'] . ' ' . $aField['sType'] . ' ,' ; ///-- " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '',";
|
||||||
|
break;
|
||||||
|
case 'DATE':
|
||||||
|
// In cases of incompatibility, use char(19)
|
||||||
|
$sQuery .= $aField['sFieldName'] . " char(19) " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '0000-00-00',";
|
||||||
|
break;
|
||||||
|
case 'INT':
|
||||||
|
$sQuery .= $aField['sFieldName'] . ' ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . ' ' . ($aField['bAI'] ? 'AUTO_INCREMENT' : "DEFAULT '0'") . ',';
|
||||||
|
if ($aField['bAI']) {
|
||||||
|
if (!in_array(' ' . $aField['sFieldName'] . ' ', $aPKs)) {
|
||||||
|
$aPKs[] = ' ' . $aField['sFieldName'] . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'FLOAT':
|
||||||
|
$sQuery .= ' ' . $aField['sFieldName'] . ' ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '0',";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ($aField['bPrimaryKey'] == 1) {
|
||||||
|
if (!in_array(' ' . $aField['sFieldName'] . ' ', $aPKs)) {
|
||||||
|
$aPKs[] = ' ' . $aField['sFieldName'] . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sQuery = substr($sQuery, 0, -1);
|
||||||
|
if (!empty($aPKs)) {
|
||||||
|
$sQuery .= ',PRIMARY KEY (' . implode(',', $aPKs) . ')';
|
||||||
|
}
|
||||||
|
$sQuery .= ') ';
|
||||||
|
$res = @$db->query($sQuery);
|
||||||
|
if (!$res) {
|
||||||
|
throw new Exception('Cannot create the table "' . $sTableName . '"!');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
catch (Exception $oError) {
|
||||||
|
|||||||
Reference in New Issue
Block a user