From c2b661aebe13de0397eb0fabc8a2dd1385a1b292 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Mon, 5 May 2014 12:39:39 -0400 Subject: [PATCH] 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;