Merged in bugfix/HOR-4009 (pull request #6144)
HOR-4009 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -1,119 +1,110 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* cases_SupervisorSaveDocument.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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$oAppDocument = new AppDocument();
|
$appDocument = new AppDocument();
|
||||||
$aFields = array (
|
$fields = array(
|
||||||
"APP_UID" => $_GET["APP_UID"],
|
"APP_UID" => $_GET["APP_UID"],
|
||||||
"DEL_INDEX" => 100000,
|
"DEL_INDEX" => 100000,
|
||||||
"USR_UID" => $_SESSION["USER_LOGGED"],
|
"USR_UID" => $_SESSION["USER_LOGGED"],
|
||||||
"DOC_UID" => $_GET["UID"],
|
"DOC_UID" => $_GET["UID"],
|
||||||
"APP_DOC_TYPE" => $_POST["form"]["APP_DOC_TYPE"],
|
"APP_DOC_TYPE" => $_POST["form"]["APP_DOC_TYPE"],
|
||||||
"APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),
|
"APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"),
|
||||||
"APP_DOC_COMMENT" => isset( $_POST["form"]["APP_DOC_COMMENT"] ) ? $_POST["form"]["APP_DOC_COMMENT"] : "",
|
"APP_DOC_COMMENT" => isset($_POST["form"]["APP_DOC_COMMENT"]) ? $_POST["form"]["APP_DOC_COMMENT"] : "",
|
||||||
"APP_DOC_TITLE" => "",
|
"APP_DOC_TITLE" => "",
|
||||||
"APP_DOC_FILENAME" => isset( $_FILES["form"]["name"]["APP_DOC_FILENAME"] ) ? $_FILES["form"]["name"]["APP_DOC_FILENAME"] : "",
|
"APP_DOC_FILENAME" => isset($_FILES["form"]["name"]["APP_DOC_FILENAME"]) ? $_FILES["form"]["name"]["APP_DOC_FILENAME"] : ""
|
||||||
"APP_DOC_UID" => $_GET["APP_DOC_UID"],
|
|
||||||
"DOC_VERSION" => $_GET["DOC_VERSION"]
|
|
||||||
);
|
);
|
||||||
|
if (!empty($_GET["APP_DOC_UID"])) {
|
||||||
|
$fields['APP_DOC_UID'] = $_GET["APP_DOC_UID"];
|
||||||
|
}
|
||||||
|
if (!empty($_GET["DOC_VERSION"])) {
|
||||||
|
$fields['DOC_VERSION'] = $_GET["DOC_VERSION"];
|
||||||
|
}
|
||||||
|
|
||||||
$oAppDocument->create( $aFields );
|
$appDocument->create($fields);
|
||||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
$appDocUid = $appDocument->getAppDocUid();
|
||||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
$info = pathinfo($appDocument->getAppDocFilename());
|
||||||
$ext = (isset( $info['extension'] ) ? $info['extension'] : '');
|
$ext = (isset($info['extension']) ? $info['extension'] : '');
|
||||||
//save the file
|
|
||||||
if (! empty( $_FILES['form'] )) {
|
//Save the file
|
||||||
|
if (!empty($_FILES['form'])) {
|
||||||
if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
|
if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
|
||||||
$sPathName = PATH_DOCUMENT . G::getPathFromUID($_GET['APP_UID']) . PATH_SEP;
|
$pathName = PATH_DOCUMENT . G::getPathFromUID($_GET['APP_UID']) . PATH_SEP;
|
||||||
$sFileName = $sAppDocUid . '.' . $ext;
|
$fileName = $appDocUid . '.' . $ext;
|
||||||
$sOriginalName = $_FILES['form']['name']['APP_DOC_FILENAME'];
|
$originalName = $_FILES['form']['name']['APP_DOC_FILENAME'];
|
||||||
G::uploadFile( $_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName );
|
G::uploadFile($_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $pathName, $fileName);
|
||||||
|
|
||||||
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
$pluginRegistry = PluginRegistry::loadSingleton();
|
||||||
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) {
|
if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
|
||||||
$oData['APP_UID'] = $_GET['APP_UID'];
|
$data['APP_UID'] = $_GET['APP_UID'];
|
||||||
$documentData = new uploadDocumentData( $_GET['APP_UID'], $_SESSION['USER_LOGGED'], $sPathName . $sFileName, $aFields['APP_DOC_FILENAME'], $sAppDocUid );
|
$documentData = new uploadDocumentData(
|
||||||
$oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
$_GET['APP_UID'],
|
||||||
unlink( $sPathName . $sFileName );
|
$_SESSION['USER_LOGGED'],
|
||||||
|
$pathName . $fileName,
|
||||||
|
$fields['APP_DOC_FILENAME'],
|
||||||
|
$appDocUid
|
||||||
|
);
|
||||||
|
$pluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||||
|
unlink($pathName . $fileName);
|
||||||
}
|
}
|
||||||
//end plugin
|
//end plugin
|
||||||
|
|
||||||
//update AppData with the current file uploaded
|
//Update AppData with the current file uploaded
|
||||||
$oCase = new Cases();
|
$case = new Cases();
|
||||||
$aAppDataFields = $oCase->loadCase( $_GET['APP_UID'] );
|
$appDataFields = $case->loadCase($_GET['APP_UID']);
|
||||||
|
|
||||||
$oCriteria = new Criteria('workflow');
|
$criteria = new Criteria('workflow');
|
||||||
$oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
|
$criteria->addSelectColumn(AppDelegationPeer::TAS_UID);
|
||||||
$oCriteria->add(AppDelegationPeer::APP_UID, $_GET['APP_UID'], CRITERIA::EQUAL);
|
$criteria->add(AppDelegationPeer::APP_UID, $_GET['APP_UID'], CRITERIA::EQUAL);
|
||||||
$oCriteria->addAscendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
$criteria->addAscendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
||||||
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
$dataset = AppDelegationPeer::doSelectRS($criteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
$oDataset->next();
|
$dataset->next();
|
||||||
$oTask = new Tasks();
|
$task = new Tasks();
|
||||||
|
|
||||||
$aDynaforms = array();
|
$dynaforms = [];
|
||||||
while ($aRow = $oDataset->getRow()) {
|
while ($row = $dataset->getRow()) {
|
||||||
$aSteps = $oTask->getStepsOfTask($aRow['TAS_UID']);
|
$steps = $task->getStepsOfTask($row['TAS_UID']);
|
||||||
if (is_array($aSteps)) {
|
if (is_array($steps)) {
|
||||||
foreach ($aSteps as $key => $value) {
|
foreach ($steps as $key => $value) {
|
||||||
$oCriteriaStep = new Criteria('workflow');
|
$criteriaStep = new Criteria('workflow');
|
||||||
$oCriteriaStep->addSelectColumn(StepPeer::STEP_UID_OBJ);
|
$criteriaStep->addSelectColumn(StepPeer::STEP_UID_OBJ);
|
||||||
$sStepId = (isset($value['STEP_UID'])) ? $value['STEP_UID'] : 0 ;
|
$stepId = (isset($value['STEP_UID'])) ? $value['STEP_UID'] : 0;
|
||||||
$oCriteriaStep->add(StepPeer::STEP_UID, $sStepId, CRITERIA::EQUAL);
|
$criteriaStep->add(StepPeer::STEP_UID, $stepId, CRITERIA::EQUAL);
|
||||||
$oCriteriaStep->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM', CRITERIA::EQUAL);
|
$criteriaStep->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM', CRITERIA::EQUAL);
|
||||||
$oDataSetStep = StepPeer::doSelectRS($oCriteriaStep);
|
$dataSetStep = StepPeer::doSelectRS($criteriaStep);
|
||||||
$oDataSetStep->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$dataSetStep->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$oDataSetStep->next();
|
$dataSetStep->next();
|
||||||
$aRows = $oDataSetStep->getRow();
|
$rowStep = $dataSetStep->getRow();
|
||||||
|
|
||||||
if (is_array($aRows) && !in_array($aRows['STEP_UID_OBJ'], $aDynaforms)) {
|
if (is_array($rowStep) && !in_array($rowStep['STEP_UID_OBJ'], $dynaforms)) {
|
||||||
$aDynaforms[] = $aRows['STEP_UID_OBJ'];
|
$dynaforms[] = $rowStep['STEP_UID_OBJ'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($value);
|
unset($value);
|
||||||
}
|
}
|
||||||
$oDataset->next();
|
$dataset->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (count($aDynaforms) > 0) {
|
if (count($dynaforms) > 0) {
|
||||||
require_once ("classes/model/Dynaform.php");
|
require_once("classes/model/Dynaform.php");
|
||||||
$dynInstance = new Dynaform();
|
$dynInstance = new Dynaform();
|
||||||
foreach ($aDynaforms as $key => $value) {
|
foreach ($dynaforms as $key => $value) {
|
||||||
$aAllFields = $dynInstance->getDynaformFields($value);
|
$allFields = $dynInstance->getDynaformFields($value);
|
||||||
if (is_array($aAllFields)) {
|
if (is_array($allFields)) {
|
||||||
foreach ($aAllFields as $kInput => $input) {
|
foreach ($allFields as $kInput => $input) {
|
||||||
if (!isset($input->input)) continue;
|
if (!isset($input->input)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($input->type == 'file' && $input->input == $_GET['UID'] && !empty($aAppDataFields['APP_DATA'][$kInput])) {
|
if ($input->type == 'file' && $input->input == $_GET['UID'] && !empty($appDataFields['APP_DATA'][$kInput])) {
|
||||||
$aAppDataFields['APP_DATA'][$kInput] = $sOriginalName;
|
$appDataFields['APP_DATA'][$kInput] = $originalName;
|
||||||
$oCase->updateCase( $_GET['APP_UID'], $aAppDataFields );
|
$case->updateCase($_GET['APP_UID'], $appDataFields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($input);
|
unset($input);
|
||||||
@@ -124,22 +115,23 @@ try {
|
|||||||
//End Update AppData with the current file uploaded
|
//End Update AppData with the current file uploaded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//go to the next step
|
|
||||||
if (! isset( $_POST['form']['MORE'] )) {
|
//Go to the next step
|
||||||
$oCase = new Cases();
|
if (!isset($_POST['form']['MORE'])) {
|
||||||
$aFields = $oCase->loadCase( $_GET['APP_UID'] );
|
$case = new Cases();
|
||||||
$aNextStep = $oCase->getNextSupervisorStep( $aFields['PRO_UID'], $_GET['position'], 'INPUT_DOCUMENT' );
|
$fields = $case->loadCase($_GET['APP_UID']);
|
||||||
G::header( 'location: ' . 'cases_StepToReviseInputs?type=INPUT_DOCUMENT&INP_DOC_UID=' . $aNextStep['UID'] . '&position=' . $aNextStep['POSITION'] . '&APP_UID=' . $_GET['APP_UID'] . '&DEL_INDEX=' );
|
$nextStep = $case->getNextSupervisorStep($fields['PRO_UID'], $_GET['position'], 'INPUT_DOCUMENT');
|
||||||
|
G::header('location: ' . 'cases_StepToReviseInputs?type=INPUT_DOCUMENT&INP_DOC_UID=' . $nextStep['UID'] . '&position=' . $nextStep['POSITION'] . '&APP_UID=' . $_GET['APP_UID'] . '&DEL_INDEX=');
|
||||||
die();
|
die();
|
||||||
} else {
|
} else {
|
||||||
G::header( 'location: ' . $_SERVER['HTTP_REFERER'] );
|
G::header('location: ' . $_SERVER['HTTP_REFERER']);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
/* Render Error page */
|
/* Render Error page */
|
||||||
$aMessage['MESSAGE'] = $e->getMessage();
|
$message = [];
|
||||||
|
$message['MESSAGE'] = $e->getMessage();
|
||||||
$G_PUBLISH = new Publisher();
|
$G_PUBLISH = new Publisher();
|
||||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $message);
|
||||||
G::RenderPage( 'publish' );
|
G::RenderPage('publish');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user