From c2b661aebe13de0397eb0fabc8a2dd1385a1b292 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Mon, 5 May 2014 12:39:39 -0400 Subject: [PATCH 1/4] Add validation primary keys in pmtables dynaforms --- .../engine/methods/cases/cases_SaveData.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index 7721b9047..89db581c7 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -165,9 +165,19 @@ try { // saving the data ina pm table in case that is a new record if (! empty( $newValues )) { $id = key( $newValues ); - $newValues[$id] = $aData['APP_DATA'][$id]; - $idPmtable = $oForm->fields[$id]->pmconnection->pmtable != '' ? $oForm->fields[$id]->pmconnection->pmtable : $oForm->fields[$id]->owner->tree->children[0]->attributes['pmtable']; - + $newValues[$id] = $aData['APP_DATA'][$id]; + $sw = false; + foreach ($aKeys as $key => $value) { + if ($newValues[$key] == '') { + $G_PUBLISH = new Publisher(); + $aMessage = array (); + $aMessage['MESSAGE'] = G::LoadTranslation('ID_FILL_PRIMARY_KEYS'); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); + G::RenderPage( 'publish', 'blank' ); + die(); + } + } + $idPmtable = $oForm->fields[$id]->pmconnection->pmtable != '' ? $oForm->fields[$id]->pmconnection->pmtable : $oForm->fields[$id]->owner->tree->children[0]->attributes['pmtable']; if (!($oAdditionalTables->updateDataInTable($idPmtable, $newValues ))) { //<--This is to know if it is a new registry on the PM Table $oAdditionalTables->saveDataInTable($idPmtable, $newValues ); @@ -310,16 +320,6 @@ try { //$oJSON = new Services_JSON(); $_POST['__notValidateThisFields__'] = (isset( $_POST['__notValidateThisFields__'] ) && $_POST['__notValidateThisFields__'] != '') ? $_POST['__notValidateThisFields__'] : $_POST['DynaformRequiredFields']; if ($missing_req_values = $oForm->validateRequiredFields( $_POST['form'], Bootstrap::json_decode( stripslashes( $_POST['__notValidateThisFields__'] ) ) )) { - $fieldsRequired = Bootstrap::json_decode(str_replace(array("%27", "%39"), array("\"", "'"), $_POST["DynaformRequiredFields"])); - - foreach ($fieldsRequired as $key1 => $value1) { - foreach ($missing_req_values as $key2 => $value2) { - if ($value1->name == $value2) { - $missing_req_values[$key2] = $value1->label; - } - } - } - $_POST['next_step'] = $aNextStep; $_POST['previous_step'] = $oCase->getPreviousStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); $_POST['req_val'] = $missing_req_values; From 3f2d2bf29e203c4bd7d7398a6c45d7fdd551968d Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Mon, 5 May 2014 14:09:22 -0400 Subject: [PATCH 2/4] Improvement keys pmtables in dynaform --- workflow/engine/methods/cases/cases_SaveData.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index 89db581c7..8d9529c4f 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -166,7 +166,6 @@ try { if (! empty( $newValues )) { $id = key( $newValues ); $newValues[$id] = $aData['APP_DATA'][$id]; - $sw = false; foreach ($aKeys as $key => $value) { if ($newValues[$key] == '') { $G_PUBLISH = new Publisher(); @@ -178,6 +177,7 @@ try { } } $idPmtable = $oForm->fields[$id]->pmconnection->pmtable != '' ? $oForm->fields[$id]->pmconnection->pmtable : $oForm->fields[$id]->owner->tree->children[0]->attributes['pmtable']; + if (!($oAdditionalTables->updateDataInTable($idPmtable, $newValues ))) { //<--This is to know if it is a new registry on the PM Table $oAdditionalTables->saveDataInTable($idPmtable, $newValues ); @@ -320,6 +320,16 @@ try { //$oJSON = new Services_JSON(); $_POST['__notValidateThisFields__'] = (isset( $_POST['__notValidateThisFields__'] ) && $_POST['__notValidateThisFields__'] != '') ? $_POST['__notValidateThisFields__'] : $_POST['DynaformRequiredFields']; if ($missing_req_values = $oForm->validateRequiredFields( $_POST['form'], Bootstrap::json_decode( stripslashes( $_POST['__notValidateThisFields__'] ) ) )) { + $fieldsRequired = Bootstrap::json_decode(str_replace(array("%27", "%39"), array("\"", "'"), $_POST["DynaformRequiredFields"])); + + foreach ($fieldsRequired as $key1 => $value1) { + foreach ($missing_req_values as $key2 => $value2) { + if ($value1->name == $value2) { + $missing_req_values[$key2] = $value1->label; + } + } + } + $_POST['next_step'] = $aNextStep; $_POST['previous_step'] = $oCase->getPreviousStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); $_POST['req_val'] = $missing_req_values; From c774f22c975ea11de7e4f3cd7243958f20d0cf05 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Mon, 5 May 2014 15:00:44 -0400 Subject: [PATCH 3/4] Improvement keys pmtables in dynaform --- workflow/engine/methods/cases/cases_SaveData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index 8d9529c4f..bbd25523b 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -167,7 +167,7 @@ try { $id = key( $newValues ); $newValues[$id] = $aData['APP_DATA'][$id]; foreach ($aKeys as $key => $value) { - if ($newValues[$key] == '') { + if (!isset($newValues[$key]) || $newValues[$key] == '') { $G_PUBLISH = new Publisher(); $aMessage = array (); $aMessage['MESSAGE'] = G::LoadTranslation('ID_FILL_PRIMARY_KEYS'); From e90e3fe34284fdf1b0aa443f0d1cf9cad103f38b Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Mon, 5 May 2014 15:06:36 -0400 Subject: [PATCH 4/4] Improvement keys pmtables in dynaform --- workflow/engine/methods/cases/cases_SaveData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index bbd25523b..66cd3f7b9 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -170,7 +170,7 @@ try { if (!isset($newValues[$key]) || $newValues[$key] == '') { $G_PUBLISH = new Publisher(); $aMessage = array (); - $aMessage['MESSAGE'] = G::LoadTranslation('ID_FILL_PRIMARY_KEYS'); + $aMessage['MESSAGE'] = G::LoadTranslation('ID_FILL_PRIMARY_KEYS') . ' ('. $key . ') '; $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); G::RenderPage( 'publish', 'blank' ); die();