From d61dcc2778feaf20eab3a5e1f1bdc0cd29d9a85a Mon Sep 17 00:00:00 2001 From: jennylee Date: Wed, 12 Nov 2014 12:32:15 -0400 Subject: [PATCH] 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. --- gulliver/system/class.xmlform.php | 87 ++++++++++--------- .../engine/methods/cases/cases_SaveData.php | 37 ++++---- 2 files changed, 69 insertions(+), 55 deletions(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index bdd08eb9f..7911fec92 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -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]; + } } + } } } diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index 0a0a719e4..3958810bf 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -123,22 +123,29 @@ try { $aAux = explode( '|', $oForm->fields[$oForm->fields[$sField]->pmconnection]->keys ); $i = 0; $aValues = array (); - foreach ($aData['FIELDS'] as $aField) { - if ($aField['FLD_KEY'] == '1') { - $aKeys[$aField['FLD_NAME']] = (isset( $aAux[$i] ) ? G::replaceDataField( $aAux[$i], $Fields['APP_DATA'] ) : ''); - $i ++; - } - if ($aField['FLD_NAME'] == $oForm->fields[$sField]->pmfield) { - $aValues[$aField['FLD_NAME']] = $Fields['APP_DATA'][$sField]; - } else { - $aValues[$aField['FLD_NAME']] = ''; - } - } - try { - $aRow = $oAdditionalTables->getDataTable( $oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, $aKeys ); - } catch (Exception $oError) { - $aRow = false; + if($aData == "" || count($aData['FIELDS']) < 1){ + $message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUNDED_SAVED_DATA' ); + G::SendMessageText( $message, "WARNING" ); + $aRow = false; + } else { + foreach ($aData['FIELDS'] as $aField) { + if ($aField['FLD_KEY'] == '1') { + $aKeys[$aField['FLD_NAME']] = (isset( $aAux[$i] ) ? G::replaceDataField( $aAux[$i], $Fields['APP_DATA'] ) : ''); + $i ++; + } + if ($aField['FLD_NAME'] == $oForm->fields[$sField]->pmfield) { + $aValues[$aField['FLD_NAME']] = $Fields['APP_DATA'][$sField]; + } else { + $aValues[$aField['FLD_NAME']] = ''; + } + } + try { + $aRow = $oAdditionalTables->getDataTable( $oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, $aKeys ); + } catch (Exception $oError) { + $aRow = false; + } } + if ($aRow) { foreach ($aValues as $sKey => $sValue) { if ($sKey != $oForm->fields[$sField]->pmfield) {