diff --git a/workflow/engine/methods/tracker/tracker_Ajax.php b/workflow/engine/methods/tracker/tracker_Ajax.php index 4d1f48a7e..5764a84f9 100755 --- a/workflow/engine/methods/tracker/tracker_Ajax.php +++ b/workflow/engine/methods/tracker/tracker_Ajax.php @@ -87,7 +87,7 @@ try { require_once 'classes/model/Users.php'; $oAppDocument = new AppDocument(); $oAppDocument->Fields = $oAppDocument->load($_POST['APP_DOC_UID']); - + $oInputDocument = new InputDocument(); if ($oAppDocument->Fields['DOC_UID'] != -1) { $Fields = $oInputDocument->load($oAppDocument->Fields['DOC_UID']); @@ -124,20 +124,20 @@ try { } $oAppDocument->Fields['VIEW'] = G::LoadTranslation('ID_OPEN'); $oAppDocument->Fields['FILE'] = 'tracker_ShowDocument?a=' . $_POST['APP_DOC_UID'] . '&r=' . rand(); - + //If plugin and trigger are defined for listing - if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) { + if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); - $filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $_SESSION['APPLICATION'] ); + $filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $_SESSION['APPLICATION'] ); //Now search for the file, if exists the change the download URL - foreach($filesPluginArray as $file){ - if($file->filename==$_POST['APP_DOC_UID']){ - $oAppDocument->Fields['FILE'] = $file->downloadScript; + foreach($filesPluginArray as $file){ + if($file->filename==$_POST['APP_DOC_UID']){ + $oAppDocument->Fields['FILE'] = $file->downloadScript; } } } - - + + $G_PUBLISH = new Publisher; $G_PUBLISH->AddContent('xmlform', 'xmlform', $sXmlForm, '', G::array_merges($Fields, $oAppDocument->Fields), ''); G::RenderPage('publish', 'raw'); @@ -150,8 +150,9 @@ try { require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); $aOD = $oOutputDocument->load($aFields['DOC_UID']); - + $oCriteria = new Criteria('workflow'); + $oCriteria->add(AppDelegationPeer::APP_UID, $aFields['APP_UID']); $oCriteria->add(AppDelegationPeer::DEL_INDEX, $aFields['DEL_INDEX']); $oDataset = AppDelegationPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); @@ -167,22 +168,22 @@ try { $aFields['VIEW'] = G::LoadTranslation('ID_OPEN'); $aFields['FILE1'] = 'tracker_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=doc&random=' . rand(); $aFields['FILE2'] = 'tracker_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=pdf&random=' . rand(); - - + + //If plugin and trigger are defined for listing - if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) { + if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); - $filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $aFields['APP_UID'] ); - //Now search for the file, if exists the change the download URL - foreach($filesPluginArray as $file){ - if($file->filename==$_POST['APP_DOC_UID']){ + $filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $aFields['APP_UID'] ); + //Now search for the file, if exists the change the download URL + foreach($filesPluginArray as $file){ + if($file->filename==$_POST['APP_DOC_UID']){ $aFields['FILE2'] = $file->downloadScript;// The PDF is the only one uploaded to KT } } } - - - + + + $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'tracker/tracker_ViewAnyOutputDocument', '', G::array_merges($aOD, $aFields), ''); G::RenderPage('publish', 'raw'); @@ -311,10 +312,10 @@ try { } $oStage = new Stage(); $oNewStage->label = G::LoadTranslation('ID_STAGE') . ' ' . $iStageNumber; - + if($oData->position->x < 0) $oData->position->x *= -1; if($oData->position->y < 0) $oData->position->y *= -1; - + $oNewStage->uid = $oStage->create(array('PRO_UID' => $oData->uid, 'STG_TITLE' => $oNewStage->label, 'STG_POSX' => $oData->position->x, 'STG_POSY' => $oData->position->y, 'STG_INDEX' => $iIndex)); $oJSON = new Services_JSON(); echo $oJSON->encode($oNewStage); @@ -420,7 +421,7 @@ try { $oCriteria2->add(TaskPeer::STG_UID, ''); BasePeer::doUpdate($oCriteria1, $oCriteria2, Propel::getConnection('workflow')); break; - + case "processMapLegend": $arrayField = array(); $arrayField["sLabel1"] = G::LoadTranslation("ID_TASK_IN_PROGRESS"); @@ -428,7 +429,7 @@ try { $arrayField["sLabel3"] = G::LoadTranslation("ID_PENDING_TASK"); $arrayField["sLabel4"] = G::LoadTranslation("ID_PARALLEL_TASK"); $arrayField["tracker"] = 1; - + $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent("smarty", "cases/cases_Leyends", "", "", $arrayField); G::RenderPage("publish", "raw"); diff --git a/workflow/engine/methods/tracker/tracker_ShowOutputDocument.php b/workflow/engine/methods/tracker/tracker_ShowOutputDocument.php index cad352093..a396dcc86 100755 --- a/workflow/engine/methods/tracker/tracker_ShowOutputDocument.php +++ b/workflow/engine/methods/tracker/tracker_ShowOutputDocument.php @@ -1,10 +1,10 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ /* * Created on 13-02-2008 * * @author David Callizaya */ -if (!isset($_SESSION['PROCESS'])) - { - G::header('location: login'); - } - - require_once ( "classes/model/AppDocumentPeer.php" ); +require_once ( "classes/model/AppDocumentPeer.php" ); - $oAppDocument = new AppDocument(); - $oAppDocument->Fields = $oAppDocument->load($_GET['a']); +$oAppDocument = new AppDocument(); +$oAppDocument->Fields = $oAppDocument->load($_GET['a'],(isset($_GET['v']) )? $_GET['v'] : NULL ); - $sAppDocUid = $oAppDocument->getAppDocUid(); - $info = pathinfo( $oAppDocument->getAppDocFilename() ); - if (!isset($_GET['ext'])) { +$sAppDocUid = $oAppDocument->getAppDocUid(); +$info = pathinfo( $oAppDocument->getAppDocFilename() ); +if (!isset($_GET['ext'])) { $ext = $info['extension']; - } - else { - if ($_GET['ext'] != '') { - $ext = $_GET['ext']; - } - else { - $ext = $info['extension']; - } - } +} +else { + if ($_GET['ext'] != '') { + $ext = $_GET['ext']; + } + else { + $ext = $info['extension']; + } +} +$ver= (isset($_GET['v']) && $_GET['v']!='') ? '_'.$_GET['v'] : ''; - $realPath = PATH_DOCUMENT . $_SESSION['APPLICATION'] . '/outdocs/' . $info['basename'] . '.' . $ext ; - G::streamFile ( $realPath, true ); +if(!$ver) //This code is in the case the outputdocument won't be versioned + $ver='_1'; -?> \ No newline at end of file +$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid .$ver. '.' . $ext ; +$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] .$ver. '.' . $ext ; +$realPath2 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename']. '.' . $ext ; +$sw_file_exists=false; +if(file_exists($realPath)){ + $sw_file_exists=true; +}elseif(file_exists($realPath1)){ + $sw_file_exists=true; + $realPath=$realPath1; +}elseif(file_exists($realPath2)){ + $sw_file_exists=true; + $realPath=$realPath2; +} +if(!$sw_file_exists){ + $error_message="'".$info['basename'] .$ver. '.' . $ext."' ".G::LoadTranslation('ID_ERROR_STREAMING_FILE'); + if((isset($_POST['request']))&&($_POST['request']==true)){ + $res ['success'] = 'failure'; + $res ['message'] = $error_message; + print G::json_encode ( $res ); + }else{ + G::SendMessageText($error_message, "ERROR"); + $backUrlObj=explode("sys".SYS_SYS,$_SERVER['HTTP_REFERER']); + G::header("location: "."/sys".SYS_SYS.$backUrlObj[1]); + die; + } + +}else{ + if((isset($_POST['request']))&&($_POST['request']==true)){ + $res ['success'] = 'success'; + $res ['message'] = $info['basename'] .$ver. '.' . $ext; + print G::json_encode ( $res ); + }else{ + G::streamFile ( $realPath, true ,$info['basename'] .$ver. '.' . $ext ); + } +} +//G::streamFile ( $realPath, true); +?> diff --git a/workflow/engine/xmlform/tracker/tracker_ViewAnyOutputDocument.xml b/workflow/engine/xmlform/tracker/tracker_ViewAnyOutputDocument.xml index 58084712f..7f94414b7 100755 --- a/workflow/engine/xmlform/tracker/tracker_ViewAnyOutputDocument.xml +++ b/workflow/engine/xmlform/tracker/tracker_ViewAnyOutputDocument.xml @@ -5,7 +5,7 @@ Output document - + Create Date