diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index ba781ed51..2a93278fd 100755 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -2230,6 +2230,14 @@ function setCaseTrackerCode ($sApplicationUID, $sCode, $sPIN = '') $aFields['APP_PIN'] = md5( $sPIN ); } $oCase->updateCase( $sApplicationUID, $aFields ); + if (isset($_SESSION['APPLICATION'])) { + if ($sApplicationUID == $_SESSION['APPLICATION']) { + global $oPMScript; + if (isset($oPMScript->aFields) && is_array($oPMScript->aFields)) { + $oPMScript->aFields['PIN'] = $aFields['APP_DATA']['PIN']; + } + } + } return 1; } else { return 0; diff --git a/workflow/engine/classes/model/AdditionalTables.php b/workflow/engine/classes/model/AdditionalTables.php index c0999578c..ddb42a712 100755 --- a/workflow/engine/classes/model/AdditionalTables.php +++ b/workflow/engine/classes/model/AdditionalTables.php @@ -591,7 +591,7 @@ class AdditionalTables extends BaseAdditionalTables * @param string $sGrid * @return number */ - public function populateReportTable($tableName, $sConnection = 'rp', $type = 'NORMAL', $processUid = '', $gridKey = '') + public function populateReportTable($tableName, $sConnection = 'rp', $type = 'NORMAL', $processUid = '', $gridKey = '', $addTabUid = '') { require_once "classes/model/Application.php"; @@ -621,11 +621,41 @@ class AdditionalTables extends BaseAdditionalTables $rs = $stmt->executeQuery($deleteSql); // getting the case data $caseData = unserialize($row['APP_DATA']); + + $fieldTypes = array(); + + if ($addTabUid != '') { + require_once 'classes/model/Fields.php'; + $criteriaField = new Criteria('workflow'); + $criteriaField->add(FieldsPeer::ADD_TAB_UID, $addTabUid); + $datasetField = FieldsPeer::doSelectRS($criteriaField); + $datasetField->setFetchmode(ResultSet::FETCHMODE_ASSOC); + while ($datasetField->next()) { + $rowfield = $datasetField->getRow(); + switch ($rowfield['FLD_TYPE']) { + case 'FLOAT': + case 'DOUBLE': + case 'INTEGER': + $fieldTypes[] = array($rowfield['FLD_NAME']=>$rowfield['FLD_TYPE']); + break; + default: + break; + } + } + } // quick fix // map all empty values as NULL for Database foreach ($caseData as $dKey => $dValue) { if (!is_array($dValue)) { + foreach ($fieldTypes as $key => $fieldType) { + foreach ($fieldType as $name => $type) { + if (strtoupper($dKey) == $name) { + $caseData[$dKey] = validateType ($dValue, $type); + unset($name); + } + } + } // normal fields if (trim($dValue) === '') { $caseData[$dKey] = null; diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index cc70cbbbe..25707f3f3 100755 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -317,7 +317,7 @@ class pmTablesProxy extends HttpProxyController if ($isReportTable && $alterTable) { // the table was create successfully but we're catching problems while populating table try { - $oAdditionalTables->populateReportTable( $data['REP_TAB_NAME'], $pmTable->getDataSource(), $data['REP_TAB_TYPE'], $data['PRO_UID'], $data['REP_TAB_GRID'] ); + $oAdditionalTables->populateReportTable( $data['REP_TAB_NAME'], $pmTable->getDataSource(), $data['REP_TAB_TYPE'], $data['PRO_UID'], $data['REP_TAB_GRID'], $addTabData['ADD_TAB_UID'] ); } catch (Exception $e) { $result->message = $result->msg = $e->getMessage(); } @@ -883,7 +883,7 @@ class pmTablesProxy extends HttpProxyController $table = $additionalTable->loadByName( $tableNameMap[$contentSchema['ADD_TAB_NAME']] ); if ($table['PRO_UID'] != '') { // is a report table, try populate it - $additionalTable->populateReportTable( $table['ADD_TAB_NAME'], pmTable::resolveDbSource( $table['DBS_UID'] ), $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID'] ); + $additionalTable->populateReportTable( $table['ADD_TAB_NAME'], pmTable::resolveDbSource( $table['DBS_UID'] ), $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID'], $table['ADD_TAB_UID'] ); } break; case '@DATA': @@ -1214,7 +1214,7 @@ class pmTablesProxy extends HttpProxyController $additionalTables = new AdditionalTables(); $table = $additionalTables->load( $httpData->id ); if ($table['PRO_UID'] != '') { - $additionalTables->populateReportTable( $table['ADD_TAB_NAME'], pmTable::resolveDbSource( $table['DBS_UID'] ), $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID'] ); + $additionalTables->populateReportTable( $table['ADD_TAB_NAME'], pmTable::resolveDbSource( $table['DBS_UID'] ), $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID'], $table['ADD_TAB_UID'] ); $result->message = 'generated for table ' . $table['ADD_TAB_NAME']; } diff --git a/workflow/engine/methods/reportTables/reportTables_Ajax.php b/workflow/engine/methods/reportTables/reportTables_Ajax.php index 540ea28ed..c9c4e8bb0 100755 --- a/workflow/engine/methods/reportTables/reportTables_Ajax.php +++ b/workflow/engine/methods/reportTables/reportTables_Ajax.php @@ -260,7 +260,7 @@ switch ($action) { $oAdditionalTables->createPropelClasses( $data['REP_TAB_NAME'], $repTabClassName, $fieldsList, $addTabUid ); - $oAdditionalTables->populateReportTable( $data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $data['REP_TAB_TYPE'], $fieldsList, $data['PRO_UID'], $data['REP_TAB_GRID'] ); + $oAdditionalTables->populateReportTable( $data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $data['REP_TAB_TYPE'], $fieldsList, $data['PRO_UID'], $data['REP_TAB_GRID'], $repTabData['ADD_TAB_UID'] ); $result->success = true; } catch (Exception $e) {