Se agregan validaciones en Output Document

This commit is contained in:
Daniel Rojas
2014-04-15 14:43:29 -04:00
parent 14f0576099
commit 08eccc2dd5

View File

@@ -307,8 +307,11 @@ class OutputDocument
if ($oOutputDocument->validate()) { if ($oOutputDocument->validate()) {
$oConnection->begin(); $oConnection->begin();
if (isset($aData['OUT_DOC_TITLE'])) { if (isset($aData['OUT_DOC_TITLE'])) {
if ($this->existsTitle($sProcessUID, $aData["OUT_DOC_TITLE"]) && $sFlag == 0) { $uid = $this->existsTitlePut($sProcessUID, $aData["OUT_DOC_TITLE"]);
throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE"))); if ($uid != '') {
if ($uid != $sOutputDocumentUID && $sFlag == 0) {
throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE")));
}
} }
$oOutputDocument->setOutDocTitle($aData['OUT_DOC_TITLE']); $oOutputDocument->setOutDocTitle($aData['OUT_DOC_TITLE']);
} }
@@ -374,7 +377,6 @@ class OutputDocument
* *
* @param string $processUid Unique id of Process * @param string $processUid Unique id of Process
* @param string $title Title * @param string $title Title
* @param string $outputDocumentUidExclude Unique id of InputDocument to exclude
* *
* return bool Return true if the title exists in the OutputDocuments of Process, false otherwise * return bool Return true if the title exists in the OutputDocuments of Process, false otherwise
*/ */
@@ -403,5 +405,36 @@ class OutputDocument
throw $e; throw $e;
} }
} }
/**
* Checks if the title exists in the OutputDocuments of Process
*
* @param string $processUid Unique id of Process
* @param string $title Title
*
*/
public function existsTitlePut($processUid, $title)
{
try {
$aResp = '';
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
$criteria->add(\OutputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
$criteria->add(\ContentPeer::CON_VALUE, $title, \Criteria::EQUAL);
$criteria->add(\ContentPeer::CON_CATEGORY, "OUT_DOC_TITLE", \Criteria::EQUAL);
$criteria->add(\ContentPeer::CON_LANG, SYS_LANG, \Criteria::EQUAL);
$criteria->addJoin( \ContentPeer::CON_ID, \OutputDocumentPeer::OUT_DOC_UID, \Criteria::LEFT_JOIN );
$rsCriteria = \OutputDocumentPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
while ($aRow = $rsCriteria->getRow()) {
$aResp = $aRow['OUT_DOC_UID'];
$rsCriteria->next();
}
return $aResp;
} catch (\Exception $e) {
throw $e;
}
}
} }