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

View File

@@ -123,22 +123,29 @@ try {
$aAux = explode( '|', $oForm->fields[$oForm->fields[$sField]->pmconnection]->keys ); $aAux = explode( '|', $oForm->fields[$oForm->fields[$sField]->pmconnection]->keys );
$i = 0; $i = 0;
$aValues = array (); $aValues = array ();
foreach ($aData['FIELDS'] as $aField) { if($aData == "" || count($aData['FIELDS']) < 1){
if ($aField['FLD_KEY'] == '1') { $message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUNDED_SAVED_DATA' );
$aKeys[$aField['FLD_NAME']] = (isset( $aAux[$i] ) ? G::replaceDataField( $aAux[$i], $Fields['APP_DATA'] ) : ''); G::SendMessageText( $message, "WARNING" );
$i ++; $aRow = false;
} } else {
if ($aField['FLD_NAME'] == $oForm->fields[$sField]->pmfield) { foreach ($aData['FIELDS'] as $aField) {
$aValues[$aField['FLD_NAME']] = $Fields['APP_DATA'][$sField]; if ($aField['FLD_KEY'] == '1') {
} else { $aKeys[$aField['FLD_NAME']] = (isset( $aAux[$i] ) ? G::replaceDataField( $aAux[$i], $Fields['APP_DATA'] ) : '');
$aValues[$aField['FLD_NAME']] = ''; $i ++;
} }
} if ($aField['FLD_NAME'] == $oForm->fields[$sField]->pmfield) {
try { $aValues[$aField['FLD_NAME']] = $Fields['APP_DATA'][$sField];
$aRow = $oAdditionalTables->getDataTable( $oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, $aKeys ); } else {
} catch (Exception $oError) { $aValues[$aField['FLD_NAME']] = '';
$aRow = false; }
}
try {
$aRow = $oAdditionalTables->getDataTable( $oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, $aKeys );
} catch (Exception $oError) {
$aRow = false;
}
} }
if ($aRow) { if ($aRow) {
foreach ($aValues as $sKey => $sValue) { foreach ($aValues as $sKey => $sValue) {
if ($sKey != $oForm->fields[$sField]->pmfield) { if ($sKey != $oForm->fields[$sField]->pmfield) {