Files
luos/workflow/engine/methods/cases/cases_Step.php

986 lines
49 KiB
PHP
Raw Normal View History

2010-12-02 23:34:41 +00:00
<?php
/**
* cases_Step.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
/* Permissions */
switch ($RBAC->userCanAccess('PM_CASES'))
{
case -2:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
G::header('location: ../login/login');
die;
break;
case -1:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die;
break;
}
if ( (int)$_SESSION['INDEX'] < 1 )
{
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ' . $_SERVER['HTTP_REFERER']);
die;
}
global $_DBArray;
if (!isset($_DBArray)) {
$_DBArray = array();
}
/* Includes */
G::LoadClass('case');
G::LoadClass('derivation');
2010-12-02 23:34:41 +00:00
/* GET , POST & $_SESSION Vars */
if(isset($_GET['POSITION'])) {
$_SESSION['STEP_POSITION'] = (int)$_GET['POSITION'];
}
if(isset($_SESSION['CASES_REFRESH'])){
unset($_SESSION['CASES_REFRESH']);
echo "<script language='javascript'>if(parent.refreshCountFolders) parent.refreshCountFolders();</script>";
}
/* Menues */
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'CASES';
$G_SUB_MENU = 'caseOptions';
$G_ID_SUB_MENU_SELECTED = '_';
/* Prepare page before to show */
$oTemplatePower = new TemplatePower(PATH_TPL . 'cases/cases_Step.html');
$oTemplatePower->prepare();
$G_PUBLISH = new Publisher;
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher->addScriptCode('
var Cse = {};
Cse.panels = {};
var leimnud = new maborak();
leimnud.make();
leimnud.Package.Load("rpc,drag,drop,panel,app,validator,fx,dom,abbr",{Instance:leimnud,Type:"module"});
leimnud.exec(leimnud.fix.memoryLeak);
leimnud.event.add(window,"load",function(){
'.(isset($_SESSION['showCasesWindow'])?'try{'.$_SESSION['showCasesWindow'].'}catch(e){}':'').'
});
');
$G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower);
$oCase = new Cases();
2010-12-02 23:34:41 +00:00
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
$sStatus = $Fields['APP_STATUS'];
$APP_NUMBER = $Fields['APP_NUMBER'];
$APP_TITLE = $Fields['TITLE'];
$oProcess = new Process();
$oProcessFieds = $oProcess->Load($_SESSION['PROCESS']);
2010-12-02 23:34:41 +00:00
#trigger debug routines...
if( isset($oProcessFieds['PRO_DEBUG']) && $oProcessFieds['PRO_DEBUG'] ) { #here we must verify if is a debugg session
2010-12-02 23:34:41 +00:00
$_SESSION['TRIGGER_DEBUG']['ISSET'] = 1;
$_SESSION['PMDEBUGGER']= true;
}
else {
$_SESSION['TRIGGER_DEBUG']['ISSET'] = 0;
$_SESSION['PMDEBUGGER']= false;
}
//cleaning debug variables
if( !isset($_GET['breakpoint']) ) {
if( isset($_SESSION['TRIGGER_DEBUG']['info']) ) unset($_SESSION['TRIGGER_DEBUG']['info']);
2010-12-02 23:34:41 +00:00
if (!isset($_SESSION['_NO_EXECUTE_TRIGGERS_'])) {
$_SESSION['TRIGGER_DEBUG']['ERRORS'] = Array();
}
$_SESSION['TRIGGER_DEBUG']['DATA'] = Array();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array();
$triggers = $oCase->loadTriggers( $_SESSION['TASK'], $_GET['TYPE'], $_GET['UID'], 'BEFORE');
$_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] = count($triggers);
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'BEFORE';
if($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) {
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = $oCase->getTriggerNames($triggers);
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = $triggers;
}
if (!isset($_SESSION['_NO_EXECUTE_TRIGGERS_'])) {
//Execute before triggers - Start
$Fields['APP_DATA'] = $oCase->ExecuteTriggers ( $_SESSION['TASK'], $_GET['TYPE'], $_GET['UID'], 'BEFORE', $Fields['APP_DATA'] );
$Fields['DEL_INDEX']= $_SESSION['INDEX'];
$Fields['TAS_UID'] = $_SESSION['TASK'];
//Execute before triggers - End
}
else {
unset($_SESSION['_NO_EXECUTE_TRIGGERS_']);
$Fields['DEL_INDEX']= $_SESSION['INDEX'];
$Fields['TAS_UID'] = $_SESSION['TASK'];
}
}
if( isset($_GET['breakpoint']) ) {
$_POST['NextStep'] = $_SESSION['TRIGGER_DEBUG']['BREAKPAGE'];
}
/**
* Here we throw the debug view
*/
if ( isset($_GET['breakpoint']) ) {
2010-12-02 23:34:41 +00:00
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameLoader');
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameBreaker');
G::RenderPage('publish', 'blank');
exit();
}
#end trigger debug session.......
//$oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List');
2010-12-02 23:34:41 +00:00
//Save data - Start
$oCase->updateCase ( $_SESSION['APPLICATION'], $Fields );
//Save data - End
//Obtain previous and next step - Start
try {
$oCase = new Cases();
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION']);
$aPreviousStep = $oCase->getPreviousStep($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION']);
}
catch ( Exception $e ) {
}
//Obtain previous and next step - End
try {
//Add content content step - Start
$oApp = ApplicationPeer::retrieveByPK( $_SESSION['APPLICATION'] );
2010-12-02 23:34:41 +00:00
$array['APP_NUMBER'] = $APP_NUMBER;
$sTitleCase = $oApp->getAppTitle();
$array['APP_TITLE'] = $sTitleCase;
2010-12-02 23:34:41 +00:00
$array['CASE'] = G::LoadTranslation('ID_CASE');
$array['TITLE'] = G::LoadTranslation('ID_TITLE');
$G_PUBLISH->AddContent('smarty', 'cases/cases_title', '', '', $array);
switch ($_GET['TYPE'])
{
case 'DYNAFORM':
if (!$aPreviousStep) {
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = '';
}
else {
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
}
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = $aNextStep['PAGE'];
$oStep = new Step();
$oStep = $oStep->loadByProcessTaskPosition($_SESSION['PROCESS'], $_SESSION['TASK'], $_GET['POSITION']);
/** Added By erik 16-05-08
* Description: this was added for the additional database connections */
G::LoadClass ('dbConnections');
$oDbConnections = new dbConnections($_SESSION['PROCESS']);
2010-12-02 23:34:41 +00:00
$oDbConnections->loadAdditionalConnections();
$_SESSION['CURRENT_DYN_UID'] = $_GET['UID'];
$G_PUBLISH->AddContent('dynaform', 'xmlform', $_SESSION['PROCESS']. '/' . $_GET['UID'], '', $Fields['APP_DATA'], 'cases_SaveData?UID=' . $_GET['UID'], '', (strtolower($oStep->getStepMode()) != 'edit' ? strtolower($oStep->getStepMode()) : ''));
break;
case 'INPUT_DOCUMENT':
$oInputDocument = new InputDocument();
$Fields = $oInputDocument->load($_GET['UID']);
2010-12-02 23:34:41 +00:00
if (!$aPreviousStep) {
$Fields['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = '';
$Fields['PREVIOUS_STEP_LABEL'] = '';
}
else {
$Fields['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
$Fields['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
2010-12-02 23:34:41 +00:00
$Fields['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
$Fields['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
}
$Fields['NEXT_STEP'] = $aNextStep['PAGE'];
$Fields['NEXT_STEP_LABEL'] = G::loadTranslation("ID_NEXT_STEP");
switch ($_GET['ACTION'])
{
case 'ATTACH':
switch ($Fields['INP_DOC_FORM_NEEDED']) {
case 'REAL':
$Fields['TYPE_LABEL'] = G::LoadTranslation('ID_NEW');
$sXmlForm = 'cases/cases_AttachInputDocument2';
break;
case 'VIRTUAL':
$Fields['TYPE_LABEL'] = G::LoadTranslation('ID_ATTACH');
$sXmlForm = 'cases/cases_AttachInputDocument1';
break;
case 'VREAL':
$Fields['TYPE_LABEL'] = G::LoadTranslation('ID_ATTACH');
$sXmlForm = 'cases/cases_AttachInputDocument3';
break;
}
$Fields['MESSAGE1'] = G::LoadTranslation('ID_PLEASE_ENTER_COMMENTS');
$Fields['MESSAGE2'] = G::LoadTranslation('ID_PLEASE_SELECT_FILE');
//START: If there is a Break Step registered from Plugin Similar as a Trigger debug
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT_BEFORE ) ) {//If a Plugin has registered a Break Page Evaluator
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT_BEFORE , array('USR_UID'=>$_SESSION['USER_LOGGED']) );
}
2010-12-02 23:34:41 +00:00
//END: If there is a Break Step registered from Plugin
2010-12-02 23:34:41 +00:00
$G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocuments', 'cases/cases_InputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['UID']), array_merge(array('DOC_UID'=>$_GET['UID']),$Fields));//$aFields
//call plugin
2010-12-02 23:34:41 +00:00
//if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST ) ) {
// $folderData = new folderData (null, null, $_SESSION['APPLICATION'], null, $_SESSION['USER_LOGGED'] );
// $oPluginRegistry =& PMPluginRegistry::getSingleton();
// $oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST , $folderData );
// //end plugin
//}
//else
// $G_PUBLISH->AddContent('propeltable', 'cases/paged-table-inputDocuments', 'cases/cases_InputdocsList', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_GET['UID']), array_merge(array('DOC_UID'=>$_GET['UID']),$Fields));//$aFields
$oHeadPublisher =& headPublisher::getSingleton();
2010-12-02 23:34:41 +00:00
$titleDocument="<h3>".$Fields['INP_DOC_TITLE']."<br><small>".G::LoadTranslation('ID_INPUT_DOCUMENT')."</small></h3>";
if($Fields['INP_DOC_DESCRIPTION']) $titleDocument.= " ".str_replace("\n","",str_replace("'","\'",nl2br(htmlentities(utf8_decode($Fields['INP_DOC_DESCRIPTION'])))))."";
2010-12-02 23:34:41 +00:00
$oHeadPublisher->addScriptCode("documentName='{$titleDocument}';");
break;
case 'VIEW':
2010-12-02 23:34:41 +00:00
require_once 'classes/model/AppDocument.php';
require_once 'classes/model/Users.php';
$oAppDocument = new AppDocument();
$oAppDocument->Fields = $oAppDocument->load($_GET['DOC'],$_GET['VERSION']);
$Fields['POSITION'] = $_SESSION['STEP_POSITION'];
$oUser = new Users();
$aUser = $oUser->load($oAppDocument->Fields['USR_UID']);
$Fields['CREATOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'];
switch ($Fields['INP_DOC_FORM_NEEDED'])
{
case 'REAL':
$sXmlForm = 'cases/cases_ViewInputDocument2';
break;
case 'VIRTUAL':
$sXmlForm = 'cases/cases_ViewInputDocument1';
break;
case 'VREAL':
$sXmlForm = 'cases/cases_ViewInputDocument3';
break;
}
$oAppDocument->Fields['VIEW'] = G::LoadTranslation('ID_OPEN');
$oAppDocument->Fields['FILE'] = 'cases_ShowDocument?a=' . $_GET['DOC'] . '&r=' . rand();
$G_PUBLISH->AddContent('xmlform', 'xmlform', $sXmlForm, '', G::array_merges($Fields, $oAppDocument->Fields), '');
break;
}
break;
case 'OUTPUT_DOCUMENT':
require_once 'classes/model/OutputDocument.php';
$oOutputDocument = new OutputDocument();
$aOD = $oOutputDocument->load( $_GET['UID'] );
if (!$aPreviousStep) {
$aOD['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = '';
}
else {
$aOD['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
$aOD['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
}
$aOD['__DYNAFORM_OPTIONS']['NEXT_STEP'] = $aNextStep['PAGE'];
switch ($_GET['ACTION'])
{
case 'GENERATE':
//START: If there is a Break Step registered from Plugin Similar as a Trigger debug
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT_BEFORE ) ) {//If a Plugin has registered a Break Page Evaluator
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT_BEFORE , array('USR_UID'=>$_SESSION['USER_LOGGED']) );
}
2010-12-02 23:34:41 +00:00
//END: If there is a Break Step registered from Plugin
$sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
2010-12-02 23:34:41 +00:00
require_once 'classes/model/AppFolder.php';
require_once 'classes/model/AppDocument.php';
//Get the Custom Folder ID (create if necessary)
2010-12-02 23:34:41 +00:00
$oFolder=new AppFolder();
$folderId=$oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH']);
2010-12-02 23:34:41 +00:00
//Tags
$fileTags=$oFolder->parseTags($aOD['OUT_DOC_TAGS']);
2010-12-02 23:34:41 +00:00
//Get last Document Version and apply versioning if is enabled
$oAppDocument= new AppDocument();
2010-12-02 23:34:41 +00:00
$lastDocVersion=$oAppDocument->getLastDocVersion($_GET['UID'],$_SESSION['APPLICATION']);
2010-12-02 23:34:41 +00:00
//if(($aOD['OUT_DOC_VERSIONING'])||($lastDocVersion==0)){
// $lastDocVersion++;
//}
2010-12-02 23:34:41 +00:00
$oCriteria = new Criteria('workflow');
$oCriteria->add(AppDocumentPeer::APP_UID, $_SESSION['APPLICATION']);
//$oCriteria->add(AppDocumentPeer::DEL_INDEX, $_SESSION['INDEX']);
$oCriteria->add(AppDocumentPeer::DOC_UID, $_GET['UID']);
$oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion);
$oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
$oDataset = AppDocumentPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
if(($aOD['OUT_DOC_VERSIONING'])&&($lastDocVersion!=0)){//Create new Version of current output
$lastDocVersion++;
if ($aRow = $oDataset->getRow()) {
2010-12-02 23:34:41 +00:00
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'],
'DOC_UID' => $_GET['UID'],
'DOC_VERSION' => $lastDocVersion+1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'APP_DOC_TYPE' => 'OUTPUT',
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_FILENAME' => $sFilename,
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument = new AppDocument();
$oAppDocument->create($aFields);
2010-12-02 23:34:41 +00:00
$sDocUID = $aRow['APP_DOC_UID'];
}
}else{//No versioning so Update a current Output or Create new if no exist
if ($aRow = $oDataset->getRow()) { //Update
2010-12-02 23:34:41 +00:00
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'],
'DOC_UID' => $_GET['UID'],
'DOC_VERSION' => $lastDocVersion,
'USR_UID' => $_SESSION['USER_LOGGED'],
'APP_DOC_TYPE' => 'OUTPUT',
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_FILENAME' => $sFilename,
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument = new AppDocument();
$oAppDocument->update($aFields);
$sDocUID = $aRow['APP_DOC_UID'];
}else{ //create
2010-12-02 23:34:41 +00:00
if($lastDocVersion==0) $lastDocVersion++;
$aFields = array('APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'],
'DOC_UID' => $_GET['UID'],
'DOC_VERSION' => $lastDocVersion,
'USR_UID' => $_SESSION['USER_LOGGED'],
'APP_DOC_TYPE' => 'OUTPUT',
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_FILENAME' => $sFilename,
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument = new AppDocument();
$aFields['APP_DOC_UID']=$sDocUID = $oAppDocument->create($aFields);
2010-12-02 23:34:41 +00:00
}
}
//$sFilename = ereg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
//if ( $sFilename == '' ) $sFilename='_';
$sFilename = $aFields['APP_DOC_UID']. "_".$lastDocVersion;
$pathOutput = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP ;
G::mk_dir ( $pathOutput );
switch ( $aOD['OUT_DOC_TYPE'] ) {
case 'HTML' :
$aProperties = array(); //maui
if(!isset($aOD['OUT_DOC_MEDIA']))
$aOD['OUT_DOC_MEDIA'] = 'Letter';
if(!isset($aOD['OUT_DOC_LEFT_MARGIN']))
$aOD['OUT_DOC_LEFT_MARGIN'] = '15';
if(!isset($aOD['OUT_DOC_RIGHT_MARGIN']))
$aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
if(!isset($aOD['OUT_DOC_TOP_MARGIN']))
$aOD['OUT_DOC_TOP_MARGIN'] = '15';
if(!isset($aOD['OUT_DOC_BOTTOM_MARGIN']))
$aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
$aProperties['media']=$aOD['OUT_DOC_MEDIA'];
$aProperties['margins']=array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'],);
$oOutputDocument->generate( $_GET['UID'], $Fields['APP_DATA'], $pathOutput,
//$sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'],$aProperties );
$sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'] );
break;
case 'JRXML' :
//creating the xml with the application data;
$xmlData = "<dynaform>\n";
foreach ( $Fields['APP_DATA'] as $key => $val ) {
$xmlData .= " <$key>$val</$key>\n";
}
$xmlData .= "</dynaform>\n";
$iSize = file_put_contents ( $javaOutput . 'addressBook.xml' , $xmlData );
G::LoadClass ('javaBridgePM');
$JBPM = new JavaBridgePM();
$JBPM->checkJavaExtension();
$util = new Java("com.processmaker.util.pmutils");
$util->setInputPath( $javaInput );
$util->setOutputPath( $javaOutput );
//$content = file_get_contents ( PATH_DYNAFORM . $aOD['PRO_UID'] . PATH_SEP . $aOD['OUT_DOC_UID'] . '.jrxml' );
//$iSize = file_put_contents ( $javaInput . $aOD['OUT_DOC_UID'] . '.jrxml', $content );
copy ( PATH_DYNAFORM . $aOD['PRO_UID'] . PATH_SEP . $aOD['OUT_DOC_UID'] . '.jrxml', $javaInput . $aOD['OUT_DOC_UID'] . '.jrxml' );
$outputFile = $javaOutput . $sFilename . '.pdf' ;
print $util->jrxml2pdf( $aOD['OUT_DOC_UID'] . '.jrxml' , basename($outputFile) );
//$content = file_get_contents ( $outputFile );
//$iSize = file_put_contents ( $pathOutput . $sFilename . '.pdf' , $content );
copy ( $outputFile, $pathOutput . $sFilename . '.pdf' );
//die;
break;
case 'ACROFORM' :
//creating the xml with the application data;
$xmlData = "<dynaform>\n";
foreach ( $Fields['APP_DATA'] as $key => $val ) {
$xmlData .= " <$key>$val</$key>\n";
}
$xmlData .= "</dynaform>\n";
//$iSize = file_put_contents ( $javaOutput . 'addressBook.xml' , $xmlData );
G::LoadClass ('javaBridgePM');
$JBPM = new JavaBridgePM();
$JBPM->checkJavaExtension();
$util = new Java("com.processmaker.util.pmutils");
$util->setInputPath( $javaInput );
$util->setOutputPath( $javaOutput );
copy ( PATH_DYNAFORM . $aOD['PRO_UID'] . PATH_SEP . $aOD['OUT_DOC_UID'] . '.pdf', $javaInput . $aOD['OUT_DOC_UID'] . '.pdf' );
$outputFile = $javaOutput . $sFilename . '.pdf' ;
print $util->writeVarsToAcroFields( $aOD['OUT_DOC_UID'] . '.pdf' , $xmlData );
copy ( $javaOutput. $aOD['OUT_DOC_UID'] . '.pdf', $pathOutput . $sFilename . '.pdf' );
break;
default :
throw ( new Exception ('invalid output document' ));
}
2010-12-02 23:34:41 +00:00
//Execute after triggers - Start
$Fields['APP_DATA'] = $oCase->ExecuteTriggers ( $_SESSION['TASK'], 'OUTPUT_DOCUMENT', $_GET['UID'], 'AFTER', $Fields['APP_DATA'] );
$Fields['DEL_INDEX']= $_SESSION['INDEX'];
$Fields['TAS_UID'] = $_SESSION['TASK'];
//Execute after triggers - End
//Save data - Start
$oCase->updateCase ( $_SESSION['APPLICATION'], $Fields );
//Save data - End
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) {
$triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
2010-12-02 23:34:41 +00:00
$sPathName = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP;
$oData['APP_UID'] = $_SESSION['APPLICATION'];
$oData['ATTACHMENT_FOLDER'] = true;
2010-12-02 23:34:41 +00:00
switch($aOD['OUT_DOC_GENERATE']){
case "BOTH":
$documentData = new uploadDocumentData (
$_SESSION['APPLICATION'],
$_SESSION['USER_LOGGED'],
$pathOutput . $sFilename . '.pdf',
$sFilename. '.pdf',
$sDocUID,
$oAppDocument->getDocVersion()
);
$documentData->sFileType = "PDF";
$documentData->bUseOutputFolder = true;
$uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData );
if($uploadReturn){//Only delete if the file was saved correctly
$aFields['APP_DOC_PLUGIN']=$triggerDetail->sNamespace;
$oAppDocument1 = new AppDocument();
$oAppDocument1->update($aFields);
2010-12-02 23:34:41 +00:00
unlink ( $pathOutput . $sFilename. '.pdf' );
}
2010-12-02 23:34:41 +00:00
$documentData = new uploadDocumentData (
$_SESSION['APPLICATION'],
$_SESSION['USER_LOGGED'],
$pathOutput . $sFilename . '.doc',
$sFilename. '.doc',
$sDocUID,
$oAppDocument->getDocVersion()
);
$documentData->sFileType = "DOC";
$documentData->bUseOutputFolder = true;
$uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData );
if($uploadReturn){//Only delete if the file was saved correctly
unlink ( $pathOutput . $sFilename. '.doc' );
}
break;
case "PDF":
$documentData = new uploadDocumentData (
$_SESSION['APPLICATION'],
$_SESSION['USER_LOGGED'],
$pathOutput . $sFilename . '.pdf',
$sFilename. '.pdf',
$sDocUID,
$oAppDocument->getDocVersion()
);
$documentData->sFileType = "PDF";
$documentData->bUseOutputFolder = true;
$uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData );
if($uploadReturn){//Only delete if the file was saved correctly
unlink ( $pathOutput . $sFilename. '.pdf' );
}
break;
case "DOC":
$documentData = new uploadDocumentData (
$_SESSION['APPLICATION'],
$_SESSION['USER_LOGGED'],
$pathOutput . $sFilename . '.doc',
$sFilename. '.doc',
$sDocUID,
$oAppDocument->getDocVersion()
);
$documentData->sFileType = "DOC";
$documentData->bUseOutputFolder = true;
$uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData );
if($uploadReturn){//Only delete if the file was saved correctly
unlink ( $pathOutput . $sFilename. '.doc' );
}
break;
}
}
$outputNextStep = 'cases_Step?TYPE=OUTPUT_DOCUMENT&UID=' . $_GET['UID'] . '&POSITION=' . $_SESSION['STEP_POSITION'] . '&ACTION=VIEW&DOC=' . $sDocUID;
G::header('location: '.$outputNextStep);
die;
break;
case 'VIEW':
2010-12-02 23:34:41 +00:00
require_once 'classes/model/AppDocument.php';
$oAppDocument = new AppDocument();
$lastVersion=$oAppDocument->getLastAppDocVersion($_GET['DOC'],$_SESSION['APPLICATION']);
$aFields = $oAppDocument->load($_GET['DOC'],$lastVersion);
$listing=false;
$oPluginRegistry = & PMPluginRegistry::getSingleton();
if($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) {
$folderData = new folderData(null, null, $_SESSION['APPLICATION'], null, $_SESSION['USER_LOGGED']);
$folderData->PMType = "OUTPUT";
$folderData->returnList = true;
$listing=$oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
2010-12-02 23:34:41 +00:00
}
2010-12-02 23:34:41 +00:00
require_once 'classes/model/OutputDocument.php';
$oOutputDocument = new OutputDocument();
$aGields = $oOutputDocument->load($aFields['DOC_UID']);
if(isset($aGields['OUT_DOC_VERSIONING']) && $aGields['OUT_DOC_VERSIONING']!=0){
$oAppDocument= new AppDocument();
$lastDocVersion=$oAppDocument->getLastDocVersion($_GET['UID'],$_SESSION['APPLICATION']);
}else {
$lastDocVersion='';
}
2010-12-02 23:34:41 +00:00
$aFields['VIEW1'] = G::LoadTranslation('ID_OPEN');
2010-12-02 23:34:41 +00:00
$aFields['VIEW2'] = G::LoadTranslation('ID_OPEN');
$aFields['FILE1'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v='.$lastDocVersion . '&ext=doc&random=' . rand();
$aFields['FILE2'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v='.$lastDocVersion . '&ext=pdf&random=' . rand();
2010-12-02 23:34:41 +00:00
if ( is_array ($listing) ){//If exist in Plugin Document List
foreach($listing as $folderitem) {
if(($folderitem->filename==$aFields['APP_DOC_UID'])&&($folderitem->type=='DOC')){
2010-12-02 23:34:41 +00:00
$aFields['VIEW1'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE');
$aFields['FILE1'] = $folderitem->downloadScript;
continue;
}
if(($folderitem->filename==$aFields['APP_DOC_UID'])&&($folderitem->type=='PDF')){
2010-12-02 23:34:41 +00:00
$aFields['VIEW2'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE');
$aFields['FILE2'] = $folderitem->downloadScript;
continue;
}
}
}
2010-12-02 23:34:41 +00:00
if(($aGields['OUT_DOC_GENERATE']=='BOTH')||($aGields['OUT_DOC_GENERATE']==''))
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument1', '', G::array_merges($aOD, $aFields), '');
if($aGields['OUT_DOC_GENERATE']=='DOC')
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument2', '', G::array_merges($aOD, $aFields), '');
if($aGields['OUT_DOC_GENERATE']=='PDF')
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument3', '', G::array_merges($aOD, $aFields), '');
2010-12-02 23:34:41 +00:00
break;
}
break;
case 'ASSIGN_TASK':
$oDerivation = new Derivation();
$oProcess = new Process();
2010-12-02 23:34:41 +00:00
$aData = $oCase->loadCase($_SESSION['APPLICATION']);
$aFields['PROCESS'] = $oProcess->load($_SESSION['PROCESS']);
2010-12-02 23:34:41 +00:00
$aFields['PREVIOUS_PAGE'] = $aPreviousStep['PAGE'];
$aFields['PREVIOUS_PAGE_LABEL'] = G::LoadTranslation('ID_PREVIOUS_STEP');
$aFields['ASSIGN_TASK'] = G::LoadTranslation('ID_ASSIGN_TASK');
$aFields['END_OF_PROCESS'] = G::LoadTranslation('ID_END_OF_PROCESS');
$aFields['NEXT_TASK_LABEL'] = G::LoadTranslation('ID_NEXT_TASK');
$aFields['EMPLOYEE'] = G::LoadTranslation('ID_EMPLOYEE');
$aFields['LAST_EMPLOYEE'] = G::LoadTranslation('ID_LAST_EMPLOYEE');
$aFields['OPTION_LABEL'] = G::LoadTranslation('ID_OPTION');
$aFields['CONTINUE'] = G::LoadTranslation('ID_CONTINUE');
$aFields['FINISH'] = G::LoadTranslation('ID_FINISH');
2010-12-02 23:34:41 +00:00
$aFields['CONTINUE_WITH_OPTION'] = G::LoadTranslation('ID_CONTINUE_WITH_OPTION');
$aFields['FINISH_WITH_OPTION'] = G::LoadTranslation('ID_FINISH_WITH_OPTION');
$aFields['TAS_TIMING_TITLE'] = 'Timing Control';
$aFields['TAS_DURATION'] = 'Task Duration';
$aFields['TAS_TIMEUNIT'] = 'Task Unit';
$aFields['TAS_TYPE_DAY'] = 'Count Days By';
$aFields['TAS_CALENDAR'] = 'Calendar';
2010-12-02 23:34:41 +00:00
$aFields['TASK'] = $oDerivation->prepareInformation(
array( 'USER_UID' => $_SESSION['USER_LOGGED'],
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'])
);
if ( empty($aFields['TASK']) ) {
throw ( new Exception ( G::LoadTranslation( 'ID_NO_DERIVATION_RULE') ) );
2010-12-02 23:34:41 +00:00
}
//take the first derivation rule as the task derivation rule type.
$aFields['PROCESS']['ROU_TYPE'] = $aFields['TASK'][1]['ROU_TYPE'];
$aFields['PROCESS']['ROU_FINISH_FLAG'] = false;
2010-12-02 23:34:41 +00:00
foreach ( $aFields['TASK'] as $sKey => &$aValues)
{
$sPriority = '';//set priority value
if ($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') {
//TO DO: review this type of assignment
if (isset($aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])]))
{
$sPriority = $aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])];
}
}//set priority value
$sTask = $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_UID'];
//TAS_UID has a hidden field to store the TAS_UID
$hiddenName = "form[TASKS][" . $sKey . "][TAS_UID]";
$hiddenField = '<input type="hidden" name="' . $hiddenName . '" id="' . $hiddenName . '" value="' . $aValues['NEXT_TASK']['TAS_UID'] . '">';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_HIDDEN_FIELD'] = $hiddenField;
//print "<hr>".$aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']."<hr>";
switch ($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']) {
case 'EVALUATE':
case 'REPORT_TO':
case 'BALANCED':
case 'SELF_SERVICE':
$hiddenName = "form[TASKS][" . $sKey . "][USR_UID]";
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_UID'] = $aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME'];
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_HIDDEN_FIELD'] = '<input type="hidden" name="' . $hiddenName . '" id="' . $hiddenName . '" value="' . $aValues['NEXT_TASK']['USER_ASSIGNED']['USR_UID'] . '">';
//var_dump($aFields);
2010-12-02 23:34:41 +00:00
//there is a error with reportsTo, when the USR_UID is empty means there are no manager for this user, so we are disabling buttons
//but this validation is not for SELF_SERVICE
if ( $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'] != 'SELF_SERVICE' )
if ( $aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_UID'] == '' )
$aFields['PROCESS']['ERROR'] = $aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME'];
break;
case 'MANUAL':
$Aux = array();
foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser)
{
$Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME'];
}
asort($Aux);
$sAux = '<select name="form[TASKS][' . $sKey . '][USR_UID]" id="form[TASKS][' . $sKey . '][USR_UID]">';
$sAux .= '<option value="" enabled>'.G::LoadTranslation('ID_SELECT').'</option>';
foreach ($Aux as $key => $value)
{
$sAux .= '<option value="' . $key . '">' . $value . '</option>';
}
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_UID'] = $sAux;
break;
case 'CANCEL_MI':
case 'STATIC_MI':
//count the Users in the group
$cntInstanceUsers = count($aValues['NEXT_TASK']['USER_ASSIGNED']);
//set TAS_MI_INSTANCE_VARIABLE value
$sMIinstanceVar = '';
if ($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'] != '') {
if (isset($aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'])]))
{
$sMIinstanceVar = $aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'])];
if($sMIinstanceVar > $cntInstanceUsers)
throw (new Exception("Total Multiple Instance Task cannot be greater than number of users in the group."));
else if($sMIinstanceVar == 0)
throw (new Exception("Total Multiple Instance Task cannot be zero."));
}
else if(is_int((int)$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE']))
{
$sMIinstanceVar = $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_INSTANCE_VARIABLE'];
if($sMIinstanceVar > $cntInstanceUsers)
throw (new Exception("Total Multiple Instance Task cannot be greater than number of users in the group."));
}
else
throw (new Exception("Total Multiple Instance Task variable doesn't have valid value."));
}
else
throw (new Exception("Total Multiple Instance Task variable doesn't have valid value."));
////set TAS_MI_INSTANCE_VARIABLE value
//set TAS_MI_COMPLETE_VARIABLE value
$sMIcompleteVar = '';
if ($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'] != '') {
if (isset($aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'])]))
{
$sMIcompleteVar = $aData['APP_DATA'][str_replace('@@', '', $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'])];
//
if($sMIcompleteVar > $sMIinstanceVar)
throw (new Exception("Total Multiple Instance Task to complete cannot be greater than Total number of Instances."));
}
else if(is_int((int)$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE']))
{
$sMIcompleteVar = $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_MI_COMPLETE_VARIABLE'];
if($sMIcompleteVar > $sMIinstanceVar)
throw (new Exception("Total Multiple Instance Task to complete cannot be greater than Total number of Instances."));
}
else
throw ( new Exception("Total Multiple Instance Task to complete variable doesn't have valid value.") ) ;
}
else
throw ( new Exception("Total Multiple Instance Task to complete variable doesn't have valid value.") ) ;
//set TAS_MI_COMPLETE_VARIABLE value
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_NEXT'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'];
//If the Users in the group is equal to the MI Instance variable then Show all the users without Dropdown
if($sMIinstanceVar == $cntInstanceUsers)
{
foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $key=>$aUser)
{
$hiddenName = "form[TASKS][" . $sKey . "][NEXT_TASK][USER_ASSIGNED][".$key."][USR_UID]";
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_UID'] = $aUser['USR_FULLNAME'];
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_HIDDEN_FIELD'] = '<input type="hidden" name="' . $hiddenName . '" id="' . $hiddenName . '" value="' . $aUser['USR_UID'] . '">';
}
}
//If the Users in the group is not equal to the MI Instance variable then Show Only count users in dropdown
else
{
$Aux = array();
foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser)
{
$Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME'];
}
asort($Aux);
$aAux = '<option value="" enabled>'.G::LoadTranslation('ID_SELECT').'</option>';
foreach ($Aux as $akey => $value)
{
$aAux .= '<option value="' . $akey . '">' . $value . '</option>';
}
for($key=0; $key < $sMIinstanceVar; $key++)
{
$hiddenName = "form[TASKS][" . $sKey . "][NEXT_TASK][USER_ASSIGNED][".$key."][USR_UID]";
$sAux = "<select name=$hiddenName id=$hiddenName";
$sAux .= $aAux;
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_HIDDEN_FIELD'] = "<input type='hidden' name='hidden' id='hidden' value=''>";
$aFields['TASK'][$sKey]['NEXT_TASK']['USER_ASSIGNED'][$key]['USR_UID'] = $sAux;
}
}
break;
2010-12-02 23:34:41 +00:00
case '': //when this task is the Finish process
$userFields = $oDerivation->getUsersFullNameFromArray ( $aFields['TASK'][$sKey]['USER_UID'] );
$aFields['TASK'][$sKey]['NEXT_TASK']['USR_UID'] = $userFields['USR_FULLNAME'];
$aFields['TASK'][$sKey]['NEXT_TASK']['ROU_FINISH_FLAG'] = true;
$aFields['PROCESS']['ROU_FINISH_FLAG'] = true;
break;
}
$hiddenName = 'form[TASKS][' . $sKey . ']';
/* Allow user defined Timing Control
* Values in the dropdown will be populated from the Table TASK.
*/
if($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'] != '') //Check for End of Process
{
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TRANSFER_FLY'] = strtolower($aValues['NEXT_TASK']['TAS_TRANSFER_FLY']);
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] = "<input type=hidden name='".$hiddenName."[NEXT_TASK][TAS_TRANSFER_HIDDEN_FLY]' id='".$hiddenName."[NEXT_TASK][TAS_TRANSFER_HIDDEN_FLY]' value=".$aValues['NEXT_TASK']['TAS_TRANSFER_FLY'].">";
if($aValues['NEXT_TASK']['TAS_TRANSFER_FLY'] == 'true')
{
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DURATION'] = '<input type="text" size="5" name="' . $hiddenName . '[NEXT_TASK][TAS_DURATION]" id="' . $hiddenName . '[NEXT_TASK][TAS_DURATION]" value="' . $aValues['NEXT_TASK']['TAS_DURATION'] . '">';
$hoursSelected = $daysSelected = '';
if($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TIMEUNIT'] == 'HOURS')
$hoursSelected = "selected = 'selected'";
else
$daysSelected = "selected = 'selected'";
$sAux = '<select name='.$hiddenName.'[NEXT_TASK][TAS_TIMEUNIT] id= '.$hiddenName.'[NEXT_TASK][TAS_TIMEUNIT] ';
$sAux .= "<option ".$hoursSelected." value='HOURS'>Hours</option> ";
$sAux .= "<option ".$daysSelected." value='DAYS'>Days</option> ";
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TIMEUNIT'] = $sAux;
$workSelected = $calendarSelected = '';
if($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TYPE_DAY'] == '1')
$workSelected = "selected = 'selected'";
else
$calendarSelected = "selected = 'selected'";
$sAux = '<select name='.$hiddenName.'[NEXT_TASK][TAS_TYPE_DAY] id= '.$hiddenName.'[NEXT_TASK][TAS_TYPE_DAY] ';
$sAux .= "<option ".$workSelected." value='1'>Work Days</option> ";
$sAux .= "<option ".$calendarSelected." value='2'>Calendar Days</option> ";
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TYPE_DAY'] = $sAux;
//Check for
G::LoadClass ( 'calendar' );
$calendar = new Calendar ( );
$calendarObj = $calendar->getCalendarList ( true, true );
$availableCalendar = $calendarObj ['array'];
$aCalendar['CALENDAR_UID'] = '00000000000000000000000000000001';
$aCalendar['CALENDAR_NAME'] = 'DEFAULT';
$sAux = '<select name='.$hiddenName.'[NEXT_TASK][TAS_CALENDAR] id= '.$hiddenName.'[NEXT_TASK][TAS_CALENDAR] ';
$sAux .= "<option value='none'>-None-</option> ";
foreach($availableCalendar as $aCalendar)
{
if(is_array($aCalendar))
{
$sAux .= "<option value='".$aCalendar['CALENDAR_UID']."'>".$aCalendar['CALENDAR_NAME']."</option> ";
}
}
$sAux .= '</select>';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_CALENDAR'] = $sAux;
}
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_ASSIGN_TYPE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_ASSIGN_TYPE]" id="' . $hiddenName . '[TAS_ASSIGN_TYPE]" value="' . $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'] . '">';
if (isset ($aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'])){
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DEF_PROC_CODE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_DEF_PROC_CODE]" id="' . $hiddenName . '[TAS_DEF_PROC_CODE]" value="' . $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'] . '">';
} else {
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_DEF_PROC_CODE'] = '<input type="hidden" name="' . $hiddenName . '[TAS_DEF_PROC_CODE]" id="' . $hiddenName . '[TAS_DEF_PROC_CODE]" value="">';
}
$aFields['TASK'][$sKey]['NEXT_TASK']['DEL_PRIORITY'] = '<input type="hidden" name="' . $hiddenName . '[DEL_PRIORITY]" id="' . $hiddenName . '[DEL_PRIORITY]" value="' . $sPriority . '">';
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_PARENT'] = '<input type="hidden" name="' . $hiddenName . '[TAS_PARENT]" id="' . $hiddenName . '[TAS_PARENT]" value="' . $aValues['NEXT_TASK']['TAS_PARENT'] . '">';
}
}
2010-12-02 23:34:41 +00:00
$aFields['PROCESSING_MESSAGE'] = G::loadTranslation('ID_PROCESSING');
2010-12-02 23:34:41 +00:00
$G_PUBLISH->AddContent('smarty', 'cases/cases_ScreenDerivation', '', '', $aFields);
/*
if (isset( $aFields['TASK'][1]['NEXT_TASK']['USER_ASSIGNED'])){
if($aFields['TASK'][1]['NEXT_TASK']['USER_ASSIGNED']!="ERROR" && is_array($aFields['TASK'][1]['NEXT_TASK']['USER_ASSIGNED'])){
$G_PUBLISH->AddContent('smarty', 'cases/cases_ScreenDerivation', '', '', $aFields);
}
else {
$sMessageError = "The current user does not have a valid Reports To user. Please contact administrator.";
//$aFields['TASK'][$sKey]['NEXT_TASK']['USR_HIDDEN_FIELD'] = '<input type="hidden" name="' . $hiddenName . '" id="' . $hiddenName . '" value="' . $sMessageError . '">';
G::SendTemporalMessage ('UID_UNDEFINED_USER', "Error");
$aFields['ERROR_REPORTSTO']= "Error";
$aFields['MESSAGE_ERROR_REPORTSTO']=G::loadTranslation("ID_MSJ_REPORSTO");;
$G_PUBLISH->AddContent('smarty', 'cases/cases_ShowE_Reportsto', '', '', $aFields);
}
}else{
$G_PUBLISH->AddContent('smarty', 'cases/cases_ScreenDerivation', '', '', $aFields);
}
*/
2010-12-02 23:34:41 +00:00
break;
case 'EXTERNAL':
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$externalSteps = $oPluginRegistry->getSteps();
$sNamespace = '';
$sStepName = '';
foreach ( $externalSteps as $key=>$val ) {
if ( $val->sStepId == $_GET['UID'] ) {
$sNamespace = $val->sNamespace;
$sStepName = $val->sStepName;
}
}
if (!$aPreviousStep) {
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = '';
}
else {
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
}
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = $aNextStep['PAGE'];
$Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = G::loadTranslation("ID_NEXT_STEP");
/** Added By erik date: 16-05-08
* Description: this was added for the additional database connections */
G::LoadClass ('dbConnections');
$oDbConnections = new dbConnections($_SESSION['PROCESS']);
2010-12-02 23:34:41 +00:00
$oDbConnections->loadAdditionalConnections();
$stepFilename = "$sNamespace/$sStepName";
2011-02-04 15:00:20 +00:00
$G_PUBLISH->AddContent('content', $stepFilename);
2010-12-02 23:34:41 +00:00
break;
}
2011-03-25 09:30:45 -04:00
//Add content content step - End
2010-12-02 23:34:41 +00:00
}
catch ( Exception $e ) {
2010-12-02 23:34:41 +00:00
G::SendTemporalMessage($e->getMessage(), 'error', 'string', 3, 100);
$aMessage = array();
$aMessage['MESSAGE'] = G::LoadTranslation('ID_PROCESS_DEF_PROBLEM').'<br/>'.G::LoadTranslation('ID_CONTACT_ADMIN');
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish', 'blank' );
die;
}
/* Render page */
$oHeadPublisher =& headPublisher::getSingleton();
2011-03-25 09:14:06 -04:00
$oHeadPublisher->addScriptCode("parent.showCaseNavigatorPanel('$sStatus');");
2011-02-04 15:00:20 +00:00
G::RenderPage('publish', 'blank');
2010-12-02 23:34:41 +00:00
if( $_SESSION['TRIGGER_DEBUG']['ISSET'] ){
G::evalJScript('showdebug();');
}