BUG 6556 Grid-Dropdowns error solved in output documents.

This commit is contained in:
Enrique Ponce De Leon
2011-04-25 12:33:04 -04:00
parent e5bbfd9cb8
commit 1806c10eff

View File

@@ -320,40 +320,31 @@ class Form extends XmlForm
// also we need to know if the $values array has dropdown labels added // also we need to know if the $values array has dropdown labels added
if(!$fieldIsSet) { if(!$fieldIsSet) {
$values[$k][$j] = $this->fields[$k]->maskValue( $newValues[$k][$j], $this ); $values[$k][$j] = $this->fields[$k]->maskValue( $newValues[$k][$j], $this );
$values[$k][$j][$kk. '_label'] = $this->fields[$k]->fields[$kk]->options[$vv]; if (isset($this->fields[$k]->fields[$kk]->options[$vv])){
$fieldIsSet = true; $values[$k][$j][$kk. '_label'] = $this->fields[$k]->fields[$kk]->options[$vv];
$fieldIsSet = true;
}else{
$query = G::replaceDataField($this->fields[$k]->fields[$kk]->sql,$values[$k][$j]);
$con = Propel::getConnection('workflow');
$stmt = $con->prepareStatement($query);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
while ($rs->next()){
// from the query executed we only need certain elements
$row = $rs->getRow();
$rowId = $row['0'];
$rowContent = $row['1'];
if ($vv==$rowId){
$values[$k][$j][$kk. '_label'] = $rowContent;
$fieldIsSet = true;
break;
}
}
}
} else { } else {
// if a dropdown label been set there is no need to load the default values. // if a dropdown label been set there is no need to load the default values.
if(isset($this->fields[$k]->fields[$kk]->options[$vv])) if(isset($this->fields[$k]->fields[$kk]->options[$vv]))
$values[$k][$j][$kk. '_label'] = $this->fields[$k]->fields[$kk]->options[$vv]; $values[$k][$j][$kk. '_label'] = $this->fields[$k]->fields[$kk]->options[$vv];
} }
$query = G::replaceDataField($this->fields[$k]->fields[$kk]->sql,$values[$k][$j]);
//$query = $this->fields[$k]->fields[$kk]->sql;
// added in order to save the label of dropdowns with data from a sql query
if (trim($this->fields[$k]->fields[$kk]->options[$vv])==''){
// a better approach could be use instead the method
// $dropdown->executeSQL($owner, $row);
// that is part of the dropdown class
$con = Propel::getConnection('workflow');
$stmt = $con->prepareStatement($query);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
while ($rs->next()){
// from the query executed we only need certain elements
$row = $rs->getRow();
$rowId = $row['0'];
$rowContent = $row['1'];
// we need only the first element and this is a one element array
foreach ($newValues[$k][$j] as $newValue){
$valueId = $vv;
break;
}
if ($valueId==$rowId){
$values[$k][$j][$kk. '_label'] = $rowContent;
break;
}
}
}
} }
}else{ }else{
if ($this->fields[$k]->validateValue($newValues[$k][$j], $this )){ if ($this->fields[$k]->validateValue($newValues[$k][$j], $this )){
@@ -390,18 +381,10 @@ class Form extends XmlForm
} }
if ($v->type == 'dropdown') { if ($v->type == 'dropdown') {
if ($v->saveLabel == 1) { if ($v->saveLabel == 1) {
if(isset($v->option[$newValues[$k]])) if(isset($v->option[$newValues[$k]])){
$values[$k . '_label'] = $v->option[$newValues[$k]]; $values[$k . '_label'] = $v->option[$newValues[$k]];
//* Fixed when the dropdowns has a sql statement }else{
//* By krlos <carlos /a/ colosa.com> $query = G::replaceDataField($this->fields[$k]->sql,$newValues);
//* Aug 3rd, 2010
// added in order to save the label of dropdowns with data from a sql query
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
//if the value is empty there is a sql query
if (!(isset($v->option[$newValues[$k]])) && trim($v->option[$newValues[$k]])==''){
// a better approach could be use instead the method
// $dropdown->executeSQL($owner, $row);
// that is part of the dropdown class
$con = Propel::getConnection('workflow'); $con = Propel::getConnection('workflow');
$stmt = $con->prepareStatement($query); $stmt = $con->prepareStatement($query);
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM); $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);