PM-815 Al correr caso con PMtable de dynaform eliminado sale error.

PROBLEMA:
Cuando se elimina un PMTABLE que se uso para crear un dynaform y se corre un caso sale un error impidiendo correr el caso.

Se intentaba buscar el PMTable y argar los datos del dynaform en el mismo.

SOLUCION:
Se agrego una validacion para que cuando no encuentre el pmtable lance un mensaje de warning para advertir al usuario q no se encontro la tabla, pero aun asi mostrar el dynafomr de modo normal.

Cuando se guardan los datos del dynaform tambien se muestra un mensaje advirtiendo q no se pudo guardar los datos en la PM table pero si se guardo con normalidad en la BD.
This commit is contained in:
jennylee
2014-11-12 12:32:15 -04:00
parent 8c7a9bd449
commit d61dcc2778
2 changed files with 69 additions and 55 deletions

View File

@@ -737,47 +737,54 @@ class XmlForm_Field
$aKeys = array ();
$aValues = explode( '|', $oOwner->fields[$this->pmconnection]->keys );
$i = 0;
foreach ($aData['FIELDS'] as $aField) {
if ($aField['FLD_KEY'] == '1') {
// note added by gustavo cruz gustavo[at]colosa[dot]com
// this additional [if] checks if a case variable has been set
// in the keys attribute, so it can be parsed and replaced for
// their respective value.
if (preg_match( "/@#/", $aValues[$i] )) {
// check if a case are running in order to prevent that preview is
// erroneous rendered.
if (isset( $_SESSION['APPLICATION'] )) {
G::LoadClass( 'case' );
$oApp = new Cases();
if ($oApp->loadCase( $_SESSION['APPLICATION'] ) != null) {
$aFields = $oApp->loadCase( $_SESSION['APPLICATION'] );
$formVariable = substr( $aValues[$i], 2 );
if (isset( $aFields['APP_DATA'][$formVariable] )) {
$formVariableValue = $aFields['APP_DATA'][$formVariable];
$aKeys[$aField['FLD_NAME']] = (isset( $formVariableValue ) ? G::replaceDataField( $formVariableValue, $oOwner->values ) : '');
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = (isset( $aValues[$i] ) ? G::replaceDataField( $aValues[$i], $oOwner->values ) : '');
}
$i ++;
}
}
try {
$aData = $oAdditionalTables->getDataTable( $oOwner->fields[$this->pmconnection]->pmtable, $aKeys );
} catch (Exception $oError) {
$aData = array ();
}
if (isset( $aData[$this->pmfield] )) {
$sValue = $aData[$this->pmfield];
if($aData == "" || count($aData['FIELDS']) < 1){
$message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUND' );
G::SendMessageText( $message, "WARNING" );
$sValue = "";
} else {
foreach ($aData['FIELDS'] as $aField) {
if ($aField['FLD_KEY'] == '1') {
// note added by gustavo cruz gustavo[at]colosa[dot]com
// this additional [if] checks if a case variable has been set
// in the keys attribute, so it can be parsed and replaced for
// their respective value.
if (preg_match( "/@#/", $aValues[$i] )) {
// check if a case are running in order to prevent that preview is
// erroneous rendered.
if (isset( $_SESSION['APPLICATION'] )) {
G::LoadClass( 'case' );
$oApp = new Cases();
if ($oApp->loadCase( $_SESSION['APPLICATION'] ) != null) {
$aFields = $oApp->loadCase( $_SESSION['APPLICATION'] );
$formVariable = substr( $aValues[$i], 2 );
if (isset( $aFields['APP_DATA'][$formVariable] )) {
$formVariableValue = $aFields['APP_DATA'][$formVariable];
$aKeys[$aField['FLD_NAME']] = (isset( $formVariableValue ) ? G::replaceDataField( $formVariableValue, $oOwner->values ) : '');
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = (isset( $aValues[$i] ) ? G::replaceDataField( $aValues[$i], $oOwner->values ) : '');
}
$i ++;
}
}
try {
$aData = $oAdditionalTables->getDataTable( $oOwner->fields[$this->pmconnection]->pmtable, $aKeys );
} catch (Exception $oError) {
$aData = array ();
}
if (isset( $aData[$this->pmfield] )) {
$sValue = $aData[$this->pmfield];
}
}
}
}
}