BUG 8376 The Key Autoincrement in PMT Dynaform is requeried SOLVED
- I add the field Key Autoincrement no requeried in PMT dynaform
This commit is contained in:
@@ -406,8 +406,16 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
$stmt = $oConnection->createStatement();
|
||||
require_once $sPath . $sClassName . '.php';
|
||||
$sKeys = '';
|
||||
$keysAutoIncrement = 0;
|
||||
$keyUIDAutoIncrement = '';
|
||||
foreach ($aData['FIELDS'] as $aField) {
|
||||
if ($aField['FLD_KEY'] == 1) {
|
||||
if ($aField['FLD_AUTO_INCREMENT'] == 1) {
|
||||
if ($keysAutoIncrement == 0) {
|
||||
$keyUIDAutoIncrement = $aField['FLD_NAME'];
|
||||
}
|
||||
$keysAutoIncrement++;
|
||||
}
|
||||
$vValue = $aFields[$aField['FLD_NAME']];
|
||||
eval('$' . $aField['FLD_NAME'] . ' = $vValue;');
|
||||
$sKeys .= '$' . $aField['FLD_NAME'] . ',';
|
||||
@@ -421,7 +429,16 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
}
|
||||
}
|
||||
if ($oClass->validate()) {
|
||||
$iResult = $oClass->save();
|
||||
$iResult = $oClass->save();
|
||||
if ($keysAutoIncrement == 1 && $aFields[$keyUIDAutoIncrement] == '' && isset($_SESSION['APPLICATION']) && $_SESSION['APPLICATION'] != '') {
|
||||
G::LoadClass('case');
|
||||
$oCaseKeyAuto = new Cases();
|
||||
$newId = $oClass->getId();
|
||||
$aFields = $oCaseKeyAuto->loadCase($_SESSION['APPLICATION']);
|
||||
$aFields['APP_DATA'][$keyUIDAutoIncrement] = $newId;
|
||||
$_POST['form'][$keyUIDAutoIncrement] = $newId;
|
||||
$oCaseKeyAuto->updateCase($_SESSION['APPLICATION'], $aFields);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Exception $oError) {
|
||||
|
||||
@@ -270,10 +270,30 @@ class Dynaform extends BaseDynaform {
|
||||
$attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS'=>$keys);
|
||||
$fieldXML->Save($attributes, $labels, $options);
|
||||
}
|
||||
|
||||
$keyRequered = '';
|
||||
$countKeys = 0;
|
||||
while ($res->next()) {
|
||||
if ($res->get('Key') != '') {
|
||||
$countKeys++;
|
||||
}
|
||||
if ($res->get('Extra') == 'auto_increment') {
|
||||
$keyRequered .= $res->get('Field');
|
||||
}
|
||||
}
|
||||
|
||||
$dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||
$sth = $dbh->createStatement();
|
||||
$res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($res->next()){
|
||||
// if(strtoupper($res->get('Null'))=='NO') {
|
||||
if(strtoupper($res->get($oDataBase->getFieldNull() ))=='NO'){
|
||||
$required = '1';
|
||||
if(strtoupper($res->get($oDataBase->getFieldNull() ))=='NO'){
|
||||
if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
|
||||
$required = '0';
|
||||
} else {
|
||||
$required = '1';
|
||||
}
|
||||
} else {
|
||||
$required = '0';
|
||||
}
|
||||
|
||||
@@ -138,16 +138,7 @@ try {
|
||||
}
|
||||
}
|
||||
}
|
||||
// saving the data ina pm table in case that is a new record
|
||||
if (!empty($newValues)) {
|
||||
$id = key($newValues);
|
||||
while (strlen($id) < 3) {
|
||||
$id = '_' . $id;
|
||||
}
|
||||
if (! $oAdditionalTables->updateDataInTable( $oForm->fields [$oForm->fields[$id]->pmconnection]->pmtable, $newValues) ) {//<--This is to know if it is a new registry on the PM Table
|
||||
$oAdditionalTables->saveDataInTable( $oForm->fields [$oForm->fields[$id]->pmconnection]->pmtable, $newValues);
|
||||
}
|
||||
}
|
||||
|
||||
//save data
|
||||
$aData = array ();
|
||||
$aData ['APP_NUMBER'] = $Fields ['APP_NUMBER'];
|
||||
@@ -161,6 +152,15 @@ try {
|
||||
$aData ['PRO_UID'] = $_SESSION ['PROCESS'];
|
||||
|
||||
$oCase->updateCase ( $_SESSION ['APPLICATION'], $aData );
|
||||
|
||||
// saving the data ina pm table in case that is a new record
|
||||
if (!empty($newValues)) {
|
||||
$id = key($newValues);
|
||||
if (! $oAdditionalTables->updateDataInTable( $oForm->fields [$oForm->fields[$id]->pmconnection]->pmtable, $newValues) ) {//<--This is to know if it is a new registry on the PM Table
|
||||
$oAdditionalTables->saveDataInTable( $oForm->fields [$oForm->fields[$id]->pmconnection]->pmtable, $newValues);
|
||||
}
|
||||
}
|
||||
|
||||
//save files
|
||||
require_once 'classes/model/AppDocument.php';
|
||||
if (isset ( $_FILES ['form'] )) {
|
||||
|
||||
Reference in New Issue
Block a user