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();
|
$stmt = $oConnection->createStatement();
|
||||||
require_once $sPath . $sClassName . '.php';
|
require_once $sPath . $sClassName . '.php';
|
||||||
$sKeys = '';
|
$sKeys = '';
|
||||||
|
$keysAutoIncrement = 0;
|
||||||
|
$keyUIDAutoIncrement = '';
|
||||||
foreach ($aData['FIELDS'] as $aField) {
|
foreach ($aData['FIELDS'] as $aField) {
|
||||||
if ($aField['FLD_KEY'] == 1) {
|
if ($aField['FLD_KEY'] == 1) {
|
||||||
|
if ($aField['FLD_AUTO_INCREMENT'] == 1) {
|
||||||
|
if ($keysAutoIncrement == 0) {
|
||||||
|
$keyUIDAutoIncrement = $aField['FLD_NAME'];
|
||||||
|
}
|
||||||
|
$keysAutoIncrement++;
|
||||||
|
}
|
||||||
$vValue = $aFields[$aField['FLD_NAME']];
|
$vValue = $aFields[$aField['FLD_NAME']];
|
||||||
eval('$' . $aField['FLD_NAME'] . ' = $vValue;');
|
eval('$' . $aField['FLD_NAME'] . ' = $vValue;');
|
||||||
$sKeys .= '$' . $aField['FLD_NAME'] . ',';
|
$sKeys .= '$' . $aField['FLD_NAME'] . ',';
|
||||||
@@ -421,7 +429,16 @@ class AdditionalTables extends BaseAdditionalTables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($oClass->validate()) {
|
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;
|
return true;
|
||||||
} catch (Exception $oError) {
|
} 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);
|
$attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS'=>$keys);
|
||||||
$fieldXML->Save($attributes, $labels, $options);
|
$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()){
|
while ($res->next()){
|
||||||
// if(strtoupper($res->get('Null'))=='NO') {
|
// if(strtoupper($res->get('Null'))=='NO') {
|
||||||
if(strtoupper($res->get($oDataBase->getFieldNull() ))=='NO'){
|
if(strtoupper($res->get($oDataBase->getFieldNull() ))=='NO'){
|
||||||
$required = '1';
|
if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
|
||||||
|
$required = '0';
|
||||||
|
} else {
|
||||||
|
$required = '1';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$required = '0';
|
$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
|
//save data
|
||||||
$aData = array ();
|
$aData = array ();
|
||||||
$aData ['APP_NUMBER'] = $Fields ['APP_NUMBER'];
|
$aData ['APP_NUMBER'] = $Fields ['APP_NUMBER'];
|
||||||
@@ -161,6 +152,15 @@ try {
|
|||||||
$aData ['PRO_UID'] = $_SESSION ['PROCESS'];
|
$aData ['PRO_UID'] = $_SESSION ['PROCESS'];
|
||||||
|
|
||||||
$oCase->updateCase ( $_SESSION ['APPLICATION'], $aData );
|
$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
|
//save files
|
||||||
require_once 'classes/model/AppDocument.php';
|
require_once 'classes/model/AppDocument.php';
|
||||||
if (isset ( $_FILES ['form'] )) {
|
if (isset ( $_FILES ['form'] )) {
|
||||||
|
|||||||
Reference in New Issue
Block a user