PMCORE-1175

This commit is contained in:
Julio Cesar Laura Avendaño
2020-10-26 22:14:48 +00:00
parent cedc5bbae5
commit 48f1088ec7
8 changed files with 181 additions and 164 deletions

View File

@@ -16,27 +16,34 @@ require_once 'classes/model/om/BaseAppSequence.php';
*/
class AppSequence extends BaseAppSequence {
const APP_TYPE_NORMAL = 'NORMAL';
const APP_TYPE_WEB_ENTRY = 'WEB_ENTRY';
/**
* Get an Set new sequence number
*
* @param string $sequenceType
* @return mixed
* @throws Exception
*/
public function sequenceNumber()
public function sequenceNumber($sequenceType)
{
try {
$con = Propel::getConnection('workflow');
$stmt = $con->createStatement();
//UPDATE SEQUENCES SET SEQ_VALUE = LAST_INSERT_ID(SEQ_VALUE + 1);
$sql = "UPDATE APP_SEQUENCE SET ID=LAST_INSERT_ID(ID+1)";
$sql = "UPDATE APP_SEQUENCE SET ID=LAST_INSERT_ID(ID+1) WHERE APP_TYPE = '{$sequenceType}'";
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
//SELECT LAST_INSERT_ID()
$sql = "SELECT LAST_INSERT_ID()";
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
$result = $row['LAST_INSERT_ID()'];
} catch (\Exception $e) {
// If the type is WEB_ENTRY, we need to change to negative
if ($sequenceType === 'WEB_ENTRY') {
$result *= -1;
}
} catch (Exception $e) {
throw ($e);
}
return $result;

View File

@@ -207,30 +207,31 @@ class Application extends BaseApplication
}
/**
* Creates the Application
* Creates an Application
*
* @param
* $sProUid the process id
* $sUsrUid the userid
* @return void
* @param string $processUid
* @param string $userUid
* @param string $sequenceType
* @throws PropelException
* @throws Exception
* @return string
*/
public function create($sProUid, $sUsrUid)
public function create($processUid, $userUid, $sequenceType)
{
require_once ("classes/model/AppSequence.php");
$con = Propel::getConnection('workflow');
try {
//fill the default values for new application row
// Fill the default values for new application row
$this->setAppUid(G::generateUniqueID());
$this->setAppParent('');
$this->setAppStatus('DRAFT');
$this->setAppStatusId(1);
$this->setProUid($sProUid);
$this->setProUid($processUid);
$this->setAppProcStatus('');
$this->setAppProcCode('');
$this->setAppParallel('N');
$this->setAppInitUser($sUsrUid);
$this->setAppCurUser($sUsrUid);
$this->setAppInitUser($userUid);
$this->setAppCurUser($userUid);
$this->setAppCreateDate('now');
$this->setAppInitDate('now');
$this->setAppUpdateDate('now');
@@ -241,8 +242,8 @@ class Application extends BaseApplication
$c = new Criteria();
$c->clearSelectColumns();
$oAppSequence = new AppSequence();
$maxNumber = $oAppSequence->sequenceNumber();
$appSequence = new AppSequence();
$maxNumber = $appSequence->sequenceNumber($sequenceType);
$this->setAppNumber($maxNumber);
$this->setAppData(serialize(['APP_NUMBER' => $maxNumber, 'PIN' => $pin]));
@@ -253,9 +254,7 @@ class Application extends BaseApplication
$con->begin();
$this->setAppTitleContent('#' . $maxNumber);
$this->setAppDescriptionContent('');
//to do: ID_CASE in translation $this->setAppTitle(G::LoadTranslation('ID_CASE') . $maxNumber);
//Content::insertContent('APP_PROC_CODE', '', $this->getAppUid(), $lang, '');
$res = $this->save();
$this->save();
$con->commit();
return $this->getAppUid();