HOR-3670-HQ
update
This commit is contained in:
@@ -1,45 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.reportTables.php
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
* ReportTables - Report tables
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* ReportTables - Report tables
|
||||
/**
|
||||
* ReportTables - Report tables class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
* @author Julio Cesar Laura Avenda<64>o
|
||||
* @copyright 2007 COLOSA
|
||||
*/class ReportTables
|
||||
class ReportTables
|
||||
{
|
||||
private $aDef = array ('mysql' => array ('number' => 'DOUBLE','char' => 'VARCHAR(255)','text' => 'TEXT','date' => 'DATETIME'
|
||||
),'pgsql' => array ('number' => 'DOUBLE','char' => 'VARCHAR(255)','text' => 'TEXT','date' => 'DATETIME'
|
||||
),'mssql' => array ('number' => 'FLOAT','char' => 'NVARCHAR(255)','text' => 'TEXT','date' => 'CHAR(19)'
|
||||
) /* Changed DATETIME CHAR(19) for compatibility issues. */ );
|
||||
private $aDef = array('mysql' => array('number' => 'DOUBLE', 'char' => 'VARCHAR(255)', 'text' => 'TEXT', 'date' => 'DATETIME'
|
||||
), 'pgsql' => array('number' => 'DOUBLE', 'char' => 'VARCHAR(255)', 'text' => 'TEXT', 'date' => 'DATETIME'
|
||||
), 'mssql' => array('number' => 'FLOAT', 'char' => 'NVARCHAR(255)', 'text' => 'TEXT', 'date' => 'CHAR(19)'
|
||||
) /* Changed DATETIME CHAR(19) for compatibility issues. */);
|
||||
//private $sPrefix = 'REP_';
|
||||
private $sPrefix = '';
|
||||
|
||||
@@ -51,12 +20,12 @@
|
||||
* @param string $$sRepTabUid
|
||||
* @return void
|
||||
*/
|
||||
public function deleteAllReportVars ($sRepTabUid = '')
|
||||
public function deleteAllReportVars($sRepTabUid = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( ReportVarPeer::REP_TAB_UID, $sRepTabUid );
|
||||
ReportVarPeer::doDelete( $oCriteria );
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ReportVarPeer::REP_TAB_UID, $sRepTabUid);
|
||||
ReportVarPeer::doDelete($oCriteria);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
@@ -71,21 +40,21 @@
|
||||
* @param string $sConnection Conexion
|
||||
* @return void
|
||||
*/
|
||||
public function dropTable ($sTableName, $sConnection = 'report')
|
||||
public function dropTable($sTableName, $sConnection = 'report')
|
||||
{
|
||||
$sTableName = $this->sPrefix . $sTableName;
|
||||
//we have to do the propel connection
|
||||
$PropelDatabase = $this->chooseDB( $sConnection );
|
||||
$con = Propel::getConnection( $PropelDatabase );
|
||||
$PropelDatabase = $this->chooseDB($sConnection);
|
||||
$con = Propel::getConnection($PropelDatabase);
|
||||
$stmt = $con->createStatement();
|
||||
try {
|
||||
switch (DB_ADAPTER) {
|
||||
case 'mysql':
|
||||
$rs = $stmt->executeQuery( 'DROP TABLE IF EXISTS `' . $sTableName . '`' );
|
||||
$rs = $stmt->executeQuery('DROP TABLE IF EXISTS `' . $sTableName . '`');
|
||||
break;
|
||||
case 'mssql':
|
||||
$rs = $stmt->executeQuery( "IF OBJECT_ID (N'" . $sTableName . "', N'U') IS NOT NULL
|
||||
DROP TABLE [" . $sTableName . "]" );
|
||||
$rs = $stmt->executeQuery("IF OBJECT_ID (N'" . $sTableName . "', N'U') IS NOT NULL
|
||||
DROP TABLE [" . $sTableName . "]");
|
||||
break;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
@@ -105,12 +74,12 @@
|
||||
* @param string $bDefaultFields
|
||||
* @return void
|
||||
*/
|
||||
public function createTable ($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $bDefaultFields = true)
|
||||
public function createTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $bDefaultFields = true)
|
||||
{
|
||||
$sTableName = $this->sPrefix . $sTableName;
|
||||
//we have to do the propel connection
|
||||
$PropelDatabase = $this->chooseDB( $sConnection );
|
||||
$con = Propel::getConnection( $PropelDatabase );
|
||||
$PropelDatabase = $this->chooseDB($sConnection);
|
||||
$con = Propel::getConnection($PropelDatabase);
|
||||
$stmt = $con->createStatement();
|
||||
try {
|
||||
switch (DB_ADAPTER) {
|
||||
@@ -142,7 +111,7 @@
|
||||
$sQuery .= 'PRIMARY KEY (APP_UID' . ($sType == 'GRID' ? ',ROW' : '') . ')) ';
|
||||
}
|
||||
$sQuery .= ' DEFAULT CHARSET=utf8;';
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
break;
|
||||
case 'mssql':
|
||||
$sQuery = 'CREATE TABLE [' . $sTableName . '] (';
|
||||
@@ -174,7 +143,7 @@
|
||||
$sQuery .= ' ';
|
||||
}
|
||||
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -196,88 +165,88 @@
|
||||
* @param string $sGrid
|
||||
* @return void
|
||||
*/
|
||||
public function populateTable ($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $sProcessUid = '', $sGrid = '')
|
||||
public function populateTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $sProcessUid = '', $sGrid = '')
|
||||
{
|
||||
$sTableName = $this->sPrefix . $sTableName;
|
||||
//we have to do the propel connection
|
||||
$PropelDatabase = $this->chooseDB( $sConnection );
|
||||
$con = Propel::getConnection( $PropelDatabase );
|
||||
$PropelDatabase = $this->chooseDB($sConnection);
|
||||
$con = Propel::getConnection($PropelDatabase);
|
||||
$stmt = $con->createStatement();
|
||||
if ($sType == 'GRID') {
|
||||
$aAux = explode( '-', $sGrid );
|
||||
$aAux = explode('-', $sGrid);
|
||||
$sGrid = $aAux[0];
|
||||
}
|
||||
try {
|
||||
switch (DB_ADAPTER) {
|
||||
case 'mysql':
|
||||
//select cases for this Process, ordered by APP_NUMBER
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( ApplicationPeer::PRO_UID, $sProcessUid );
|
||||
$oCriteria->addAscendingOrderByColumn( ApplicationPeer::APP_NUMBER );
|
||||
$oDataset = ApplicationPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUid);
|
||||
$oCriteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER);
|
||||
$oDataset = ApplicationPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aData = unserialize( $aRow['APP_DATA'] );
|
||||
$aData = unserialize($aRow['APP_DATA']);
|
||||
//delete previous record from this report table ( previous records in case this is a grid )
|
||||
$deleteSql = 'DELETE FROM `' . $sTableName . "` WHERE APP_UID = '" . $aRow['APP_UID'] . "'";
|
||||
$rsDel = $stmt->executeQuery( $deleteSql );
|
||||
$rsDel = $stmt->executeQuery($deleteSql);
|
||||
if ($sType == 'NORMAL') {
|
||||
$sQuery = 'INSERT INTO `' . $sTableName . '` (';
|
||||
$sQuery .= '`APP_UID`,`APP_NUMBER`';
|
||||
foreach ($aFields as $aField) {
|
||||
$sQuery .= ',`' . $aField['sFieldName'] . '`';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'];
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'];
|
||||
foreach ($aFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aData[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aData[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aData[$aField['sFieldName']]) ? (float)str_replace(',', '', $aData[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aData[$aField['sFieldName']] )) {
|
||||
if (!isset($aData[$aField['sFieldName']])) {
|
||||
$aData[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aData[$aField['sFieldName']] ) ? @mysql_real_escape_string( $aData[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? @mysql_real_escape_string($aData[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$value = (isset( $aData[$aField['sFieldName']] ) && trim( $aData[$aField['sFieldName']] )) != '' ? "'" . $aData[$aField['sFieldName']] . "'" : 'NULL';
|
||||
$value = (isset($aData[$aField['sFieldName']]) && trim($aData[$aField['sFieldName']])) != '' ? "'" . $aData[$aField['sFieldName']] . "'" : 'NULL';
|
||||
$sQuery .= "," . $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
} else {
|
||||
if (isset( $aData[$sGrid] )) {
|
||||
if (isset($aData[$sGrid])) {
|
||||
foreach ($aData[$sGrid] as $iRow => $aGridRow) {
|
||||
$sQuery = 'INSERT INTO `' . $sTableName . '` (';
|
||||
$sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
|
||||
foreach ($aFields as $aField) {
|
||||
$sQuery .= ',`' . $aField['sFieldName'] . '`';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'] . ',' . $iRow;
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'] . ',' . $iRow;
|
||||
foreach ($aFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aGridRow[$aField['sFieldName']] )) {
|
||||
if (!isset($aGridRow[$aField['sFieldName']])) {
|
||||
$aGridRow[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$value = (isset( $aGridRow[$aField['sFieldName']] ) && trim( $aGridRow[$aField['sFieldName']] )) != '' ? "'" . $aGridRow[$aField['sFieldName']] . "'" : 'NULL';
|
||||
$value = (isset($aGridRow[$aField['sFieldName']]) && trim($aGridRow[$aField['sFieldName']])) != '' ? "'" . $aGridRow[$aField['sFieldName']] . "'" : 'NULL';
|
||||
$sQuery .= "," . $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,69 +258,69 @@
|
||||
* For SQLServer code
|
||||
*/
|
||||
case 'mssql':
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( ApplicationPeer::PRO_UID, $sProcessUid );
|
||||
$oCriteria->addAscendingOrderByColumn( ApplicationPeer::APP_NUMBER );
|
||||
$oDataset = ApplicationPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUid);
|
||||
$oCriteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER);
|
||||
$oDataset = ApplicationPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aData = unserialize( $aRow['APP_DATA'] );
|
||||
mysql_query( 'DELETE FROM [' . $sTableName . "] WHERE APP_UID = '" . $aRow['APP_UID'] . "'" );
|
||||
$aData = unserialize($aRow['APP_DATA']);
|
||||
mysql_query('DELETE FROM [' . $sTableName . "] WHERE APP_UID = '" . $aRow['APP_UID'] . "'");
|
||||
if ($sType == 'NORMAL') {
|
||||
$sQuery = 'INSERT INTO [' . $sTableName . '] (';
|
||||
$sQuery .= '[APP_UID],[APP_NUMBER]';
|
||||
foreach ($aFields as $aField) {
|
||||
$sQuery .= ',[' . $aField['sFieldName'] . ']';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'];
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'];
|
||||
foreach ($aFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aData[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aData[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aData[$aField['sFieldName']]) ? (float)str_replace(',', '', $aData[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aData[$aField['sFieldName']] )) {
|
||||
if (!isset($aData[$aField['sFieldName']])) {
|
||||
$aData[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aData[$aField['sFieldName']] ) ? mysql_real_escape_string( $aData[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? mysql_real_escape_string($aData[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$sQuery .= ",'" . (isset( $aData[$aField['sFieldName']] ) ? $aData[$aField['sFieldName']] : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? $aData[$aField['sFieldName']] : '') . "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
} else {
|
||||
if (isset( $aData[$sGrid] )) {
|
||||
if (isset($aData[$sGrid])) {
|
||||
foreach ($aData[$sGrid] as $iRow => $aGridRow) {
|
||||
$sQuery = 'INSERT INTO [' . $sTableName . '] (';
|
||||
$sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
|
||||
foreach ($aFields as $aField) {
|
||||
$sQuery .= ',[' . $aField['sFieldName'] . ']';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'] . ',' . $iRow;
|
||||
$sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'] . ',' . $iRow;
|
||||
foreach ($aFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aGridRow[$aField['sFieldName']] )) {
|
||||
if (!isset($aGridRow[$aField['sFieldName']])) {
|
||||
$aGridRow[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? $aGridRow[$aField['sFieldName']] : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? $aGridRow[$aField['sFieldName']] : '') . "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,21 +342,21 @@
|
||||
* @param boolean $bWhitType
|
||||
* @return void
|
||||
*/
|
||||
public function getTableVars ($sRepTabUid, $bWhitType = false)
|
||||
public function getTableVars($sRepTabUid, $bWhitType = false)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( ReportVarPeer::REP_TAB_UID, $sRepTabUid );
|
||||
$oDataset = ReportVarPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ReportVarPeer::REP_TAB_UID, $sRepTabUid);
|
||||
$oDataset = ReportVarPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aVars = array ();
|
||||
$aImportedVars = array (); //This array will help to control if the variable already exist
|
||||
$aVars = array();
|
||||
$aImportedVars = array(); //This array will help to control if the variable already exist
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if ($bWhitType) {
|
||||
if (! in_array( $aRow['REP_VAR_NAME'], $aImportedVars )) {
|
||||
if (!in_array($aRow['REP_VAR_NAME'], $aImportedVars)) {
|
||||
$aImportedVars[] = $aRow['REP_VAR_NAME'];
|
||||
$aVars[] = array ('sFieldName' => $aRow['REP_VAR_NAME'],'sType' => $aRow['REP_VAR_TYPE']
|
||||
$aVars[] = array('sFieldName' => $aRow['REP_VAR_NAME'], 'sType' => $aRow['REP_VAR_TYPE']
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -409,17 +378,17 @@
|
||||
* @param string $sRepTabUid
|
||||
* @return void
|
||||
*/
|
||||
public function deleteReportTable ($sRepTabUid)
|
||||
public function deleteReportTable($sRepTabUid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new ReportTable();
|
||||
$aFields = $oReportTable->load( $sRepTabUid );
|
||||
if (! (empty( $aFields ))) {
|
||||
$this->dropTable( $aFields['REP_TAB_NAME'], $aFields['REP_TAB_CONNECTION'] );
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( ReportVarPeer::REP_TAB_UID, $sRepTabUid );
|
||||
$oDataset = ReportVarPeer::doDelete( $oCriteria );
|
||||
$oReportTable->remove( $sRepTabUid );
|
||||
$aFields = $oReportTable->load($sRepTabUid);
|
||||
if (!(empty($aFields))) {
|
||||
$this->dropTable($aFields['REP_TAB_NAME'], $aFields['REP_TAB_CONNECTION']);
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ReportVarPeer::REP_TAB_UID, $sRepTabUid);
|
||||
$oDataset = ReportVarPeer::doDelete($oCriteria);
|
||||
$oReportTable->remove($sRepTabUid);
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
@@ -435,22 +404,22 @@
|
||||
* @param string $mask
|
||||
* @return array
|
||||
*/
|
||||
public function getSplitDate ($date, $mask)
|
||||
public function getSplitDate($date, $mask)
|
||||
{
|
||||
$sw1 = false;
|
||||
for ($i = 0; $i < 3; $i ++) {
|
||||
$item = substr( $mask, $i * 2, 1 );
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$item = substr($mask, $i * 2, 1);
|
||||
switch ($item) {
|
||||
case 'Y':
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$d1 = substr( $date, 0, 4 );
|
||||
$d1 = substr($date, 0, 4);
|
||||
break;
|
||||
case 1:
|
||||
$d1 = substr( $date, 3, 4 );
|
||||
$d1 = substr($date, 3, 4);
|
||||
break;
|
||||
case 2:
|
||||
$d1 = substr( $date, 6, 4 );
|
||||
$d1 = substr($date, 6, 4);
|
||||
break;
|
||||
}
|
||||
$sw1 = true;
|
||||
@@ -458,45 +427,45 @@
|
||||
case 'y':
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$d1 = substr( $date, 0, 2 );
|
||||
$d1 = substr($date, 0, 2);
|
||||
break;
|
||||
case 1:
|
||||
$d1 = substr( $date, 3, 2 );
|
||||
$d1 = substr($date, 3, 2);
|
||||
break;
|
||||
case 2:
|
||||
$d1 = substr( $date, 6, 2 );
|
||||
$d1 = substr($date, 6, 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$d2 = substr( $date, 0, 2 );
|
||||
$d2 = substr($date, 0, 2);
|
||||
break;
|
||||
case 1:
|
||||
$d2 = ($sw1) ? substr( $date, 5, 2 ) : substr( $date, 3, 2 );
|
||||
$d2 = ($sw1) ? substr($date, 5, 2) : substr($date, 3, 2);
|
||||
break;
|
||||
case 2:
|
||||
$d2 = ($sw1) ? substr( $date, 8, 2 ) : substr( $date, 5, 2 );
|
||||
$d2 = ($sw1) ? substr($date, 8, 2) : substr($date, 5, 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$d3 = substr( $date, 0, 2 );
|
||||
$d3 = substr($date, 0, 2);
|
||||
break;
|
||||
case 1:
|
||||
$d3 = ($sw1) ? substr( $date, 5, 2 ) : substr( $date, 3, 2 );
|
||||
$d3 = ($sw1) ? substr($date, 5, 2) : substr($date, 3, 2);
|
||||
break;
|
||||
case 2:
|
||||
$d3 = ($sw1) ? substr( $date, 8, 2 ) : substr( $date, 5, 2 );
|
||||
$d3 = ($sw1) ? substr($date, 8, 2) : substr($date, 5, 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Array (isset( $d1 ) ? $d1 : '',isset( $d2 ) ? $d2 : '',isset( $d3 ) ? $d3 : ''
|
||||
return Array(isset($d1) ? $d1 : '', isset($d2) ? $d2 : '', isset($d3) ? $d3 : ''
|
||||
);
|
||||
}
|
||||
|
||||
@@ -509,30 +478,30 @@
|
||||
* @param date $sMask
|
||||
* @return date
|
||||
*/
|
||||
public function getFormatDate ($sDate, $sMask)
|
||||
public function getFormatDate($sDate, $sMask)
|
||||
{
|
||||
//print $sDate." *** ". $sMask."<BR>";
|
||||
$dateTime = explode( " ", $sDate ); //To accept the Hour part
|
||||
$aDate = explode( '-', str_replace( "/", "-", $dateTime[0] ) );
|
||||
$dateTime = explode(" ", $sDate); //To accept the Hour part
|
||||
$aDate = explode('-', str_replace("/", "-", $dateTime[0]));
|
||||
$bResult = true;
|
||||
foreach ($aDate as $sDate) {
|
||||
if (! is_numeric( $sDate )) {
|
||||
if (!is_numeric($sDate)) {
|
||||
$bResult = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($sMask != '') {
|
||||
$aDate = $this->getSplitDate( $dateTime[0], $sMask );
|
||||
$aDate[0] = ($aDate[0] == '') ? date( 'Y' ) : $aDate[0];
|
||||
$aDate[1] = ($aDate[1] == '') ? date( 'm' ) : $aDate[1];
|
||||
$aDate[2] = ($aDate[2] == '') ? date( 'd' ) : $aDate[2];
|
||||
if (checkdate( $aDate[1], $aDate[2], $aDate[0] )) {
|
||||
$aDate = $this->getSplitDate($dateTime[0], $sMask);
|
||||
$aDate[0] = ($aDate[0] == '') ? date('Y') : $aDate[0];
|
||||
$aDate[1] = ($aDate[1] == '') ? date('m') : $aDate[1];
|
||||
$aDate[2] = ($aDate[2] == '') ? date('d') : $aDate[2];
|
||||
if (checkdate($aDate[1], $aDate[2], $aDate[0])) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$sDateC = '';
|
||||
for ($i = 0; $i < count( $aDate ); $i ++) {
|
||||
for ($i = 0; $i < count($aDate); $i++) {
|
||||
$sDateC .= (($i == 0) ? "" : "-") . $aDate[$i];
|
||||
}
|
||||
return ($sDateC);
|
||||
@@ -549,7 +518,7 @@
|
||||
* @param string $aFields
|
||||
* @return void
|
||||
*/
|
||||
public function updateTables ($sProcessUid, $sApplicationUid, $iApplicationNumber, $aFields)
|
||||
public function updateTables($sProcessUid, $sApplicationUid, $iApplicationNumber, $aFields)
|
||||
{
|
||||
try {
|
||||
$c = new Criteria('workflow');
|
||||
@@ -562,73 +531,73 @@
|
||||
$isBpmn = isset($row['PRJ_UID']);
|
||||
|
||||
if (!class_exists('ReportTablePeer')) {
|
||||
require_once 'classes/model/ReportTablePeer.php';
|
||||
}
|
||||
require_once 'classes/model/ReportTablePeer.php';
|
||||
}
|
||||
//get all Active Report Tables
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( ReportTablePeer::PRO_UID, $sProcessUid );
|
||||
$oCriteria->add( ReportTablePeer::REP_TAB_STATUS, 'ACTIVE' );
|
||||
$oDataset = ReportTablePeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUid);
|
||||
$oCriteria->add(ReportTablePeer::REP_TAB_STATUS, 'ACTIVE');
|
||||
$oDataset = ReportTablePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aVars = array ();
|
||||
$aVars = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aRow['REP_TAB_NAME'] = $this->sPrefix . $aRow['REP_TAB_NAME'];
|
||||
$PropelDatabase = $this->chooseDB( $aRow['REP_TAB_CONNECTION'] );
|
||||
$con = Propel::getConnection( $PropelDatabase );
|
||||
$PropelDatabase = $this->chooseDB($aRow['REP_TAB_CONNECTION']);
|
||||
$con = Propel::getConnection($PropelDatabase);
|
||||
$stmt = $con->createStatement();
|
||||
switch (DB_ADAPTER) {
|
||||
case 'mysql':
|
||||
$aTableFields = $this->getTableVars( $aRow['REP_TAB_UID'], true );
|
||||
$aTableFields = $this->getTableVars($aRow['REP_TAB_UID'], true);
|
||||
if ($aRow['REP_TAB_TYPE'] == 'NORMAL') {
|
||||
$sqlExists = "SELECT * FROM `" . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
|
||||
$rsExists = $stmt->executeQuery( $sqlExists, ResultSet::FETCHMODE_ASSOC );
|
||||
$rsExists = $stmt->executeQuery($sqlExists, ResultSet::FETCHMODE_ASSOC);
|
||||
$rsExists->next();
|
||||
$aRow2 = $rsExists->getRow();
|
||||
|
||||
if (is_array( $aRow2 )) {
|
||||
if (is_array($aRow2)) {
|
||||
$sQuery = 'UPDATE `' . $aRow['REP_TAB_NAME'] . '` SET ';
|
||||
foreach ($aTableFields as $aField) {
|
||||
$sQuery .= '`' . $aField['sFieldName'] . '` = ';
|
||||
|
||||
if(!$isBpmn && !isset($aFields[$aField['sFieldName']])){
|
||||
foreach($aFields as $row){
|
||||
if(is_array($row) && isset($row[count($row)])){
|
||||
$aFields = $row[count($row)];
|
||||
}
|
||||
}
|
||||
if (!$isBpmn && !isset($aFields[$aField['sFieldName']])) {
|
||||
foreach ($aFields as $row) {
|
||||
if (is_array($row) && isset($row[count($row)])) {
|
||||
$aFields = $row[count($row)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0') . ',';
|
||||
$sQuery .= (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0') . ',';
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aFields[$aField['sFieldName']] )) {
|
||||
if (!isset($aFields[$aField['sFieldName']])) {
|
||||
$aFields[$aField['sFieldName']] = '';
|
||||
}
|
||||
if (! isset( $aFields[$aField['sFieldName'] . '_label'] )) {
|
||||
if (!isset($aFields[$aField['sFieldName'] . '_label'])) {
|
||||
$aFields[$aField['sFieldName'] . '_label'] = '';
|
||||
}
|
||||
if(is_array($aFields[$aField['sFieldName']])){
|
||||
$sQuery .= "'" . (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']][0] : '') . "',";
|
||||
}else{
|
||||
$sQuery .= '\'' . ((isset($aFields[$aField['sFieldName']]))? @mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . '\',';
|
||||
if (is_array($aFields[$aField['sFieldName']])) {
|
||||
$sQuery .= "'" . (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']][0] : '') . "',";
|
||||
} else {
|
||||
$sQuery .= '\'' . ((isset($aFields[$aField['sFieldName']])) ? @mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . '\',';
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
$mysqlDate = (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '');
|
||||
$mysqlDate = (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '');
|
||||
if ($mysqlDate != '') {
|
||||
$mysqlDate = str_replace( '/', '-', $mysqlDate );
|
||||
$mysqlDate = date( 'Y-m-d', strtotime( $mysqlDate ) );
|
||||
$mysqlDate = str_replace('/', '-', $mysqlDate);
|
||||
$mysqlDate = date('Y-m-d', strtotime($mysqlDate));
|
||||
}
|
||||
$value = trim( $mysqlDate ) != '' ? "'" . $mysqlDate . "'" : 'NULL';
|
||||
$value = trim($mysqlDate) != '' ? "'" . $mysqlDate . "'" : 'NULL';
|
||||
$sQuery .= $value . ",";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery = substr( $sQuery, 0, - 1 );
|
||||
$sQuery = substr($sQuery, 0, -1);
|
||||
$sQuery .= " WHERE APP_UID = '" . $sApplicationUid . "'";
|
||||
} else {
|
||||
$sQuery = 'INSERT INTO `' . $aRow['REP_TAB_NAME'] . '` (';
|
||||
@@ -636,40 +605,40 @@
|
||||
foreach ($aTableFields as $aField) {
|
||||
$sQuery .= ',`' . $aField['sFieldName'] . '`';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber;
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber;
|
||||
foreach ($aTableFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aFields[$aField['sFieldName']] )) {
|
||||
if (!isset($aFields[$aField['sFieldName']])) {
|
||||
$aFields[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aFields[$aField['sFieldName']] ) ? mysql_real_escape_string( $aFields[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aFields[$aField['sFieldName']]) ? mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$mysqlDate = (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '');
|
||||
$mysqlDate = (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '');
|
||||
if ($mysqlDate != '') {
|
||||
$mysqlDate = str_replace( '/', '-', $mysqlDate );
|
||||
$mysqlDate = date( 'Y-m-d', strtotime( $mysqlDate ) );
|
||||
$mysqlDate = str_replace('/', '-', $mysqlDate);
|
||||
$mysqlDate = date('Y-m-d', strtotime($mysqlDate));
|
||||
}
|
||||
$value = trim( $mysqlDate ) != '' ? "'" . $mysqlDate . "'" : 'NULL';
|
||||
$value = trim($mysqlDate) != '' ? "'" . $mysqlDate . "'" : 'NULL';
|
||||
$sQuery .= "," . $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
}
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
} else {
|
||||
//remove old rows from database
|
||||
$sqlDelete = 'DELETE FROM `' . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
|
||||
$rsDelete = $stmt->executeQuery( $sqlDelete );
|
||||
$rsDelete = $stmt->executeQuery($sqlDelete);
|
||||
|
||||
$aAux = explode( '-', $aRow['REP_TAB_GRID'] );
|
||||
if (isset( $aFields[$aAux[0]] )) {
|
||||
$aAux = explode('-', $aRow['REP_TAB_GRID']);
|
||||
if (isset($aFields[$aAux[0]])) {
|
||||
if (is_array($aFields[$aAux[0]])) {
|
||||
foreach ($aFields[$aAux[0]] as $iRow => $aGridRow) {
|
||||
$sQuery = 'INSERT INTO `' . $aRow['REP_TAB_NAME'] . '` (';
|
||||
@@ -677,26 +646,26 @@
|
||||
foreach ($aTableFields as $aField) {
|
||||
$sQuery .= ',`' . $aField['sFieldName'] . '`';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber . ',' . $iRow;
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber . ',' . $iRow;
|
||||
foreach ($aTableFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aGridRow[$aField['sFieldName']] )) {
|
||||
if (!isset($aGridRow[$aField['sFieldName']])) {
|
||||
$aGridRow[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? $aGridRow[$aField['sFieldName']] : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? $aGridRow[$aField['sFieldName']] : '') . "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -707,30 +676,30 @@
|
||||
* For SQLServer code
|
||||
*/
|
||||
case 'mssql':
|
||||
$aTableFields = $this->getTableVars( $aRow['REP_TAB_UID'], true );
|
||||
$aTableFields = $this->getTableVars($aRow['REP_TAB_UID'], true);
|
||||
if ($aRow['REP_TAB_TYPE'] == 'NORMAL') {
|
||||
$oDataset2 = mssql_query( "SELECT * FROM [" . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'" );
|
||||
if ($aRow2 = mssql_fetch_row( $oDataset2 )) {
|
||||
$oDataset2 = mssql_query("SELECT * FROM [" . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'");
|
||||
if ($aRow2 = mssql_fetch_row($oDataset2)) {
|
||||
$sQuery = 'UPDATE [' . $aRow['REP_TAB_NAME'] . '] SET ';
|
||||
foreach ($aTableFields as $aField) {
|
||||
$sQuery .= '[' . $aField['sFieldName'] . '] = ';
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0') . ',';
|
||||
$sQuery .= (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0') . ',';
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aFields[$aField['sFieldName']] )) {
|
||||
if (!isset($aFields[$aField['sFieldName']])) {
|
||||
$aFields[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= "'" . (isset( $aFields[$aField['sFieldName']] ) ? mysql_real_escape_string( $aFields[$aField['sFieldName']] ) : '') . "',";
|
||||
$sQuery .= "'" . (isset($aFields[$aField['sFieldName']]) ? mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . "',";
|
||||
break;
|
||||
case 'date':
|
||||
$sQuery .= "'" . (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '') . "',";
|
||||
$sQuery .= "'" . (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '') . "',";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery = substr( $sQuery, 0, - 1 );
|
||||
$sQuery = substr($sQuery, 0, -1);
|
||||
$sQuery .= " WHERE APP_UID = '" . $sApplicationUid . "'";
|
||||
} else {
|
||||
$sQuery = 'INSERT INTO [' . $aRow['REP_TAB_NAME'] . '] (';
|
||||
@@ -738,57 +707,57 @@
|
||||
foreach ($aTableFields as $aField) {
|
||||
$sQuery .= ',[' . $aField['sFieldName'] . ']';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber;
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber;
|
||||
foreach ($aTableFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aFields[$aField['sFieldName']] )) {
|
||||
if (!isset($aFields[$aField['sFieldName']])) {
|
||||
$aFields[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aFields[$aField['sFieldName']] ) ? mysql_real_escape_string( $aFields[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aFields[$aField['sFieldName']]) ? mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$sQuery .= ",'" . (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '') . "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
}
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
} else {
|
||||
mysql_query( 'DELETE FROM [' . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'" );
|
||||
$aAux = explode( '-', $aRow['REP_TAB_GRID'] );
|
||||
if (isset( $aFields[$aAux[0]] )) {
|
||||
mysql_query('DELETE FROM [' . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'");
|
||||
$aAux = explode('-', $aRow['REP_TAB_GRID']);
|
||||
if (isset($aFields[$aAux[0]])) {
|
||||
foreach ($aFields[$aAux[0]] as $iRow => $aGridRow) {
|
||||
$sQuery = 'INSERT INTO [' . $aRow['REP_TAB_NAME'] . '] (';
|
||||
$sQuery .= '[APP_UID],[APP_NUMBER],[ROW]';
|
||||
foreach ($aTableFields as $aField) {
|
||||
$sQuery .= ',[' . $aField['sFieldName'] . ']';
|
||||
}
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber . ',' . $iRow;
|
||||
$sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber . ',' . $iRow;
|
||||
foreach ($aTableFields as $aField) {
|
||||
switch ($aField['sType']) {
|
||||
case 'number':
|
||||
$sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
|
||||
$sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
|
||||
break;
|
||||
case 'char':
|
||||
case 'text':
|
||||
if (! isset( $aGridRow[$aField['sFieldName']] )) {
|
||||
if (!isset($aGridRow[$aField['sFieldName']])) {
|
||||
$aGridRow[$aField['sFieldName']] = '';
|
||||
}
|
||||
$sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
|
||||
break;
|
||||
case 'date':
|
||||
$sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? $aGridRow[$aField['sFieldName']] : '') . "'";
|
||||
$sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? $aGridRow[$aField['sFieldName']] : '') . "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sQuery .= ')';
|
||||
$rs = $stmt->executeQuery( $sQuery );
|
||||
$rs = $stmt->executeQuery($sQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -809,10 +778,10 @@
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function tableExist ()
|
||||
public function tableExist()
|
||||
{
|
||||
$bExists = true;
|
||||
$sDataBase = 'database_' . strtolower( DB_ADAPTER );
|
||||
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
||||
|
||||
$oDataBase = new database();
|
||||
$bExists = $oDataBase->reportTableExist();
|
||||
@@ -828,9 +797,9 @@
|
||||
* @param string $TabConnectionk
|
||||
* @return string
|
||||
*/
|
||||
public function chooseDB ($TabConnectionk)
|
||||
public function chooseDB($TabConnectionk)
|
||||
{
|
||||
$repTabConnection = trim( strtoupper( $TabConnectionk ) );
|
||||
$repTabConnection = trim(strtoupper($TabConnectionk));
|
||||
$PropelDatabase = 'rp';
|
||||
if ($repTabConnection == '' || $repTabConnection == 'REPORT') {
|
||||
$PropelDatabase = 'rp';
|
||||
|
||||
Reference in New Issue
Block a user