Merge pull request #1235 from marcoAntonioNina/BUG-10458
BUG 10458 Error creating report table with currency text field SOLVED
This commit is contained in:
@@ -18,6 +18,40 @@ require_once 'classes/model/om/BaseAdditionalTables.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
|
||||
function validateType ($value, $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'INTEGER':
|
||||
$value = str_replace(",", "", $value);
|
||||
$value = str_replace(".", "", $value);
|
||||
break;
|
||||
case 'FLOAT':
|
||||
case 'DOUBLE':
|
||||
$pos = strrpos($value, ",");
|
||||
$pos = ($pos === false) ? 0 : $pos;
|
||||
|
||||
$posPoint = strrpos($value, ".");
|
||||
$posPoint = ($posPoint === false) ? 0 : $posPoint;
|
||||
|
||||
if ($pos > $posPoint) {
|
||||
$value2 = substr($value, $pos+1);
|
||||
$value1 = substr($value, 0, $pos);
|
||||
$value1 = str_replace(".", "", $value1);
|
||||
$value = $value1.".".$value2;
|
||||
} else {
|
||||
$value2 = substr($value, $posPoint+1);
|
||||
$value1 = substr($value, 0, $posPoint);
|
||||
$value1 = str_replace(",", "", $value1);
|
||||
$value = $value1.".".$value2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
class AdditionalTables extends BaseAdditionalTables
|
||||
{
|
||||
public $fields = array();
|
||||
@@ -669,8 +703,35 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
switch ($row['ADD_TAB_TYPE']) {
|
||||
//switching by report table type
|
||||
case 'NORMAL':
|
||||
require_once 'classes/model/Fields.php';
|
||||
$criteriaField = new Criteria('workflow');
|
||||
$criteriaField->add(FieldsPeer::ADD_TAB_UID, $row['ADD_TAB_UID']);
|
||||
$datasetField = FieldsPeer::doSelectRS($criteriaField);
|
||||
$datasetField->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$fieldTypes = array();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// parsing empty values to null
|
||||
foreach ($caseData as $i => $v) {
|
||||
foreach ($fieldTypes as $key => $fieldType) {
|
||||
foreach ($fieldType as $name => $type) {
|
||||
if ( strtoupper ( $i) == $name) {
|
||||
$v = validateType ($v, $type);
|
||||
unset($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
$caseData[$i] = $v === '' ? null : $v;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,6 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
@@ -1384,14 +1383,25 @@ class pmTablesProxy extends HttpProxyController
|
||||
$arrayNode = $dynaformHandler->getArray( $node );
|
||||
$fieldName = $arrayNode['__nodeName__'];
|
||||
$fieldType = $arrayNode['type'];
|
||||
$fieldValidate = ( isset($arrayNode['validate'])) ? $arrayNode['validate'] : '';
|
||||
|
||||
if (! in_array( $fieldType, $excludeFieldsList ) && ! in_array( $fieldName, $fieldsNames )) {
|
||||
$fields[] = array ('FIELD_UID' => $fieldName . '-' . $fieldType,'FIELD_NAME' => $fieldName,'_index' => $index ++,'_isset' => true
|
||||
if (! in_array( $fieldType, $excludeFieldsList ) && ! in_array( $fieldName, $fieldsNames ) ) {
|
||||
$fields[] = array (
|
||||
'FIELD_UID' => $fieldName . '-' . $fieldType,
|
||||
'FIELD_NAME' => $fieldName,
|
||||
'FIELD_VALIDATE'=>$fieldValidate,
|
||||
'_index' => $index ++,
|
||||
'_isset' => true
|
||||
);
|
||||
$fieldsNames[] = $fieldName;
|
||||
|
||||
if (in_array( $fieldType, $labelFieldsTypeList ) && ! in_array( $fieldName . '_label', $fieldsNames )) {
|
||||
$fields[] = array ('FIELD_UID' => $fieldName . '_label' . '-' . $fieldType,'FIELD_NAME' => $fieldName . '_label','_index' => $index ++,'_isset' => true
|
||||
$fields[] = array (
|
||||
'FIELD_UID' => $fieldName . '_label' . '-' . $fieldType,
|
||||
'FIELD_NAME' => $fieldName . '_label',
|
||||
'FIELD_VALIDATE'=>$fieldValidate,
|
||||
'_index' => $index ++,
|
||||
'_isset' => true
|
||||
);
|
||||
$fieldsNames[] = $fieldName;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ Ext.onReady(function(){
|
||||
totalProperty: 'count',
|
||||
fields : [
|
||||
{name : 'FIELD_UID'},
|
||||
{name : 'FIELD_VALIDATE'},
|
||||
{name : 'FIELD_NAME'},
|
||||
{name : '_index'},
|
||||
{name : '_isset'}
|
||||
@@ -69,6 +70,11 @@ Ext.onReady(function(){
|
||||
hidden:true,
|
||||
hideable:false
|
||||
}, {
|
||||
dataIndex:'FIELD_VALIDATE',
|
||||
hidden:true,
|
||||
hideable:false
|
||||
}
|
||||
, {
|
||||
dataIndex:'_index',
|
||||
hidden:true,
|
||||
hideable:false
|
||||
@@ -1175,6 +1181,15 @@ function setReportFields(records) {
|
||||
}
|
||||
|
||||
var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||
var typeField = meta.type;
|
||||
var sizeField = meta.size;
|
||||
if (records[i].data['FIELD_VALIDATE'].toUpperCase() == 'REAL') {
|
||||
typeField = 'DOUBLE';
|
||||
sizeField = '';
|
||||
}
|
||||
if (records[i].data['FIELD_VALIDATE'].toUpperCase() == 'INT') {
|
||||
typeField = 'INTEGER';
|
||||
}
|
||||
var row = new PMRow({
|
||||
uid : '',
|
||||
_index : records[i].data['_index'] !== '' ? records[i].data['_index'] : records[i].data['FIELD_DYN'],
|
||||
@@ -1182,8 +1197,8 @@ function setReportFields(records) {
|
||||
field_dyn : records[i].data['FIELD_NAME'],
|
||||
field_name : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_label : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_type : meta.type,
|
||||
field_size : meta.size,
|
||||
field_type : typeField,
|
||||
field_size : sizeField,
|
||||
field_key : 0,
|
||||
field_null : 1,
|
||||
field_filter: 0,
|
||||
|
||||
Reference in New Issue
Block a user