2012-10-19 16:13:39 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* cases_SaveData.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
2013-05-14 13:53:12 -04:00
|
|
|
* Copyright (C) 2004 - 2008 Colosa Inc.
|
2012-10-19 16:13:39 -04:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
//validate the data post
|
BUG 11969 Web session TimeOut at HOME
Se realizo una correccion de los direccionamientos de los iframes al perder sesion, ya q siempre q se perdia sesion antes, se mostraba dentro del mismo iframe el cuadro para volverse a logear, logrando asi q el usuario se mantenga en el mismo iframe una ves se relogee, sin tener asi q volver a buscar el lugar donde estaba trabajando. A pedido de QA, ahora se muestra el cuadro de logeo en el iframe mayor, totalmente fuera de PM, y siempre al volver a logearse se redirecciona al tab HOME > Index, y ya no asi al frame o lugar exacto donde se perdio sesion.
Por ejemplo: si se pie sesion en el listado Draft, no se volvera a dicho listado, sino en cambio al volverse a logear se redireccionara a HOME > Indexdex.
El cambio se aplico a los lugares donde se podia redireccionar al parent.
2013-08-29 16:37:25 -04:00
|
|
|
if (!isset($_SESSION['USER_LOGGED'])) {
|
|
|
|
|
G::SendTemporalMessage( 'ID_LOGIN_AGAIN', 'warning', 'labels' );
|
|
|
|
|
die( '<script type="text/javascript">
|
2013-11-06 09:20:54 -04:00
|
|
|
try
|
BUG 11969 Web session TimeOut at HOME
Se realizo una correccion de los direccionamientos de los iframes al perder sesion, ya q siempre q se perdia sesion antes, se mostraba dentro del mismo iframe el cuadro para volverse a logear, logrando asi q el usuario se mantenga en el mismo iframe una ves se relogee, sin tener asi q volver a buscar el lugar donde estaba trabajando. A pedido de QA, ahora se muestra el cuadro de logeo en el iframe mayor, totalmente fuera de PM, y siempre al volver a logearse se redirecciona al tab HOME > Index, y ya no asi al frame o lugar exacto donde se perdio sesion.
Por ejemplo: si se pie sesion en el listado Draft, no se volvera a dicho listado, sino en cambio al volverse a logear se redireccionara a HOME > Indexdex.
El cambio se aplico a los lugares donde se podia redireccionar al parent.
Se tomo en cuenta tambien que algunos clientes utilizan el listado de casos dentro de sus propias webs.
2013-09-02 17:45:37 -04:00
|
|
|
{
|
|
|
|
|
prnt = parent.parent;
|
|
|
|
|
top.location = top.location;
|
|
|
|
|
}
|
2013-11-06 09:20:54 -04:00
|
|
|
catch (err)
|
BUG 11969 Web session TimeOut at HOME
Se realizo una correccion de los direccionamientos de los iframes al perder sesion, ya q siempre q se perdia sesion antes, se mostraba dentro del mismo iframe el cuadro para volverse a logear, logrando asi q el usuario se mantenga en el mismo iframe una ves se relogee, sin tener asi q volver a buscar el lugar donde estaba trabajando. A pedido de QA, ahora se muestra el cuadro de logeo en el iframe mayor, totalmente fuera de PM, y siempre al volver a logearse se redirecciona al tab HOME > Index, y ya no asi al frame o lugar exacto donde se perdio sesion.
Por ejemplo: si se pie sesion en el listado Draft, no se volvera a dicho listado, sino en cambio al volverse a logear se redireccionara a HOME > Indexdex.
El cambio se aplico a los lugares donde se podia redireccionar al parent.
Se tomo en cuenta tambien que algunos clientes utilizan el listado de casos dentro de sus propias webs.
2013-09-02 17:45:37 -04:00
|
|
|
{
|
|
|
|
|
parent.location = parent.location;
|
|
|
|
|
}
|
BUG 11969 Web session TimeOut at HOME
Se realizo una correccion de los direccionamientos de los iframes al perder sesion, ya q siempre q se perdia sesion antes, se mostraba dentro del mismo iframe el cuadro para volverse a logear, logrando asi q el usuario se mantenga en el mismo iframe una ves se relogee, sin tener asi q volver a buscar el lugar donde estaba trabajando. A pedido de QA, ahora se muestra el cuadro de logeo en el iframe mayor, totalmente fuera de PM, y siempre al volver a logearse se redirecciona al tab HOME > Index, y ya no asi al frame o lugar exacto donde se perdio sesion.
Por ejemplo: si se pie sesion en el listado Draft, no se volvera a dicho listado, sino en cambio al volverse a logear se redireccionara a HOME > Indexdex.
El cambio se aplico a los lugares donde se podia redireccionar al parent.
2013-08-29 16:37:25 -04:00
|
|
|
</script>');
|
2013-06-03 18:13:38 -04:00
|
|
|
}
|
2012-10-19 16:13:39 -04:00
|
|
|
try {
|
|
|
|
|
if ($_GET['APP_UID'] !== $_SESSION['APPLICATION']) {
|
2013-05-14 13:53:12 -04:00
|
|
|
throw new Exception( G::LoadTranslation( 'ID_INVALID_APPLICATION_ID_MSG', array ('<a href=\'' . $_SERVER['HTTP_REFERER'] . '\'>{1}</a>',G::LoadTranslation( 'ID_REOPEN' ) ) ) );
|
2012-10-19 16:13:39 -04:00
|
|
|
}
|
2014-09-15 12:09:31 -04:00
|
|
|
|
2014-07-28 12:15:47 -04:00
|
|
|
/*
|
|
|
|
|
* PMDynaform
|
2014-09-15 12:09:31 -04:00
|
|
|
* DYN_VERSION is 1: classic Dynaform,
|
2014-07-28 12:15:47 -04:00
|
|
|
* DYN_VERSION is 2: responsive form, Pmdynaform.
|
|
|
|
|
*/
|
|
|
|
|
$a = new Criteria("workflow");
|
|
|
|
|
$a->addSelectColumn(DynaformPeer::DYN_VERSION);
|
|
|
|
|
$a->add(DynaformPeer::DYN_UID, $_GET['UID'], Criteria::EQUAL);
|
|
|
|
|
$a = ProcessPeer::doSelectRS($a);
|
|
|
|
|
$a->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$a->next();
|
|
|
|
|
$row = $a->getRow();
|
|
|
|
|
$swpmdynaform = isset($row) && $row["DYN_VERSION"] == 2;
|
|
|
|
|
if ($swpmdynaform) {
|
|
|
|
|
$pmdynaform = $_POST["form"];
|
|
|
|
|
}
|
2012-10-19 16:13:39 -04:00
|
|
|
|
|
|
|
|
$oForm = new Form( $_SESSION["PROCESS"] . "/" . $_GET["UID"], PATH_DYNAFORM );
|
|
|
|
|
$oForm->validatePost();
|
|
|
|
|
|
|
|
|
|
//Includes
|
|
|
|
|
G::LoadClass( "case" );
|
|
|
|
|
|
|
|
|
|
//Load the variables
|
|
|
|
|
$oCase = new Cases();
|
2012-11-28 15:57:55 -04:00
|
|
|
$oCase->thisIsTheCurrentUser( $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs" );
|
2012-10-19 16:13:39 -04:00
|
|
|
$Fields = $oCase->loadCase( $_SESSION["APPLICATION"] );
|
|
|
|
|
|
2015-02-02 16:10:21 -04:00
|
|
|
if ($swpmdynaform) {
|
|
|
|
|
$Fields["APP_DATA"] = array_merge( $Fields["APP_DATA"], $pmdynaform );
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:13:39 -04:00
|
|
|
$Fields["APP_DATA"] = array_merge( $Fields["APP_DATA"], G::getSystemConstants() );
|
|
|
|
|
$Fields["APP_DATA"] = array_merge( $Fields["APP_DATA"], $_POST["form"] );
|
|
|
|
|
|
|
|
|
|
#here we must verify if is a debug session
|
2013-10-08 08:59:49 -04:00
|
|
|
$trigger_debug_session = isset($_SESSION['TRIGGER_DEBUG']['ISSET']) ? $_SESSION['TRIGGER_DEBUG']['ISSET'] : null; #here we must verify if is a debugg session
|
2012-10-19 16:13:39 -04:00
|
|
|
|
|
|
|
|
#trigger debug routines...
|
|
|
|
|
|
|
|
|
|
//cleaning debug variables
|
|
|
|
|
$_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'], 'DYNAFORM', $_GET['UID'], 'AFTER' );
|
|
|
|
|
|
|
|
|
|
$_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] = count( $triggers );
|
2014-02-12 16:08:10 -04:00
|
|
|
$_SESSION['TRIGGER_DEBUG']['TIME'] = G::toUpper(G::loadTranslation('ID_AFTER'));
|
2012-10-19 16:13:39 -04:00
|
|
|
if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) {
|
|
|
|
|
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers );
|
|
|
|
|
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = $triggers;
|
2014-06-26 14:32:15 -04:00
|
|
|
$oProcess = new Process();
|
|
|
|
|
$oProcessFieds = $oProcess->Load( $_SESSION['PROCESS'] );
|
|
|
|
|
|
2014-06-26 15:43:07 -04:00
|
|
|
//trigger debug routines...
|
2014-06-26 14:32:15 -04:00
|
|
|
if (isset( $oProcessFieds['PRO_DEBUG'] ) && $oProcessFieds['PRO_DEBUG']) {
|
|
|
|
|
$trigger_debug_session = true;
|
|
|
|
|
}
|
2012-10-19 16:13:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) {
|
|
|
|
|
//Execute after triggers - Start
|
|
|
|
|
$Fields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'DYNAFORM', $_GET['UID'], 'AFTER', $Fields['APP_DATA'] );
|
|
|
|
|
//Execute after triggers - End
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//save data in PM Tables if necessary
|
|
|
|
|
$newValues = array ();
|
|
|
|
|
foreach ($_POST['form'] as $sField => $sAux) {
|
|
|
|
|
if (isset( $oForm->fields[$sField]->pmconnection ) && isset( $oForm->fields[$sField]->pmfield )) {
|
|
|
|
|
if (($oForm->fields[$sField]->pmconnection != '') && ($oForm->fields[$sField]->pmfield != '')) {
|
|
|
|
|
if (isset( $oForm->fields[$oForm->fields[$sField]->pmconnection] )) {
|
|
|
|
|
require_once PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'AdditionalTables.php';
|
|
|
|
|
$oAdditionalTables = new AdditionalTables();
|
|
|
|
|
try {
|
|
|
|
|
$aData = $oAdditionalTables->load( $oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, true );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$aData = array ('FIELDS' => array ()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$aKeys = array ();
|
|
|
|
|
$aAux = explode( '|', $oForm->fields[$oForm->fields[$sField]->pmconnection]->keys );
|
|
|
|
|
$i = 0;
|
|
|
|
|
$aValues = array ();
|
2015-02-02 16:10:21 -04:00
|
|
|
if ($aData == "" || count($aData['FIELDS']) < 1) {
|
|
|
|
|
$message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUNDED_SAVED_DATA' );
|
|
|
|
|
G::SendMessageText( $message, "WARNING" );
|
|
|
|
|
$aRow = false;
|
2014-11-12 12:32:15 -04:00
|
|
|
} else {
|
2015-02-02 16:10:21 -04:00
|
|
|
foreach ($aData['FIELDS'] as $aField) {
|
|
|
|
|
if ($aField['FLD_KEY'] == '1') {
|
|
|
|
|
$aKeys[$aField['FLD_NAME']] = (isset( $aAux[$i] ) ? G::replaceDataField( $aAux[$i], $Fields['APP_DATA'] ) : '');
|
|
|
|
|
$i ++;
|
|
|
|
|
}
|
|
|
|
|
if ($aField['FLD_NAME'] == $oForm->fields[$sField]->pmfield) {
|
|
|
|
|
$aValues[$aField['FLD_NAME']] = $Fields['APP_DATA'][$sField];
|
|
|
|
|
} else {
|
|
|
|
|
$aValues[$aField['FLD_NAME']] = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
$aRow = $oAdditionalTables->getDataTable( $oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, $aKeys );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$aRow = false;
|
|
|
|
|
}
|
2012-10-19 16:13:39 -04:00
|
|
|
}
|
2014-11-12 12:32:15 -04:00
|
|
|
|
2012-10-19 16:13:39 -04:00
|
|
|
if ($aRow) {
|
|
|
|
|
foreach ($aValues as $sKey => $sValue) {
|
|
|
|
|
if ($sKey != $oForm->fields[$sField]->pmfield) {
|
|
|
|
|
$aValues[$sKey] = $aRow[$sKey];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
$oAdditionalTables->updateDataInTable( $oForm->fields[$oForm->fields[$sField]->pmconnection]->pmtable, $aValues );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
//Nothing
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
// assembling the field list in order to save the data ina new record of a pm table
|
|
|
|
|
if (empty( $newValues )) {
|
|
|
|
|
$newValues = $aValues;
|
|
|
|
|
} else {
|
|
|
|
|
foreach ($aValues as $aValueKey => $aValueCont) {
|
|
|
|
|
if (trim( $newValues[$aValueKey] ) == '') {
|
|
|
|
|
$newValues[$aValueKey] = $aValueCont;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//$oAdditionalTables->saveDataInTable ( $oForm->fields [$oForm->fields [$sField]->pmconnection]->pmtable, $aValues );
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
//Nothing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//save data
|
|
|
|
|
$aData = array ();
|
|
|
|
|
$aData['APP_NUMBER'] = $Fields['APP_NUMBER'];
|
2013-07-03 09:48:46 -04:00
|
|
|
//$aData['APP_PROC_STATUS'] = $Fields['APP_PROC_STATUS'];
|
2012-10-19 16:13:39 -04:00
|
|
|
$aData['APP_DATA'] = $Fields['APP_DATA'];
|
|
|
|
|
$aData['DEL_INDEX'] = $_SESSION['INDEX'];
|
|
|
|
|
$aData['TAS_UID'] = $_SESSION['TASK'];
|
|
|
|
|
$aData['CURRENT_DYNAFORM'] = $_GET['UID'];
|
|
|
|
|
$aData['USER_UID'] = $_SESSION['USER_LOGGED'];
|
2013-07-03 09:48:46 -04:00
|
|
|
//$aData['APP_STATUS'] = $Fields['APP_STATUS'];
|
2012-10-19 16:13:39 -04:00
|
|
|
$aData['PRO_UID'] = $_SESSION['PROCESS'];
|
2014-09-15 12:09:31 -04:00
|
|
|
|
2014-07-28 12:15:47 -04:00
|
|
|
if ($swpmdynaform) {
|
|
|
|
|
$aData['APP_DATA'] = array_merge($aData['APP_DATA'], $pmdynaform);
|
2014-09-11 11:34:44 -04:00
|
|
|
$_POST["DynaformRequiredFields"] = '[]';
|
2014-07-28 12:15:47 -04:00
|
|
|
}
|
2012-10-19 16:13:39 -04:00
|
|
|
|
|
|
|
|
$oCase->updateCase( $_SESSION['APPLICATION'], $aData );
|
|
|
|
|
|
|
|
|
|
// saving the data ina pm table in case that is a new record
|
|
|
|
|
if (! empty( $newValues )) {
|
2014-05-06 09:55:35 -04:00
|
|
|
|
2012-10-19 16:13:39 -04:00
|
|
|
$id = key( $newValues );
|
2014-05-06 09:50:05 -04:00
|
|
|
$newValues[$id] = $aData['APP_DATA'][$id];
|
|
|
|
|
foreach ($aKeys as $key => $value) {
|
|
|
|
|
if (!isset($newValues[$key]) || $newValues[$key] == '') {
|
|
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
$aMessage = array ();
|
|
|
|
|
$aMessage['MESSAGE'] = G::LoadTranslation('ID_FILL_PRIMARY_KEYS') . ' ('. $key . ') ';
|
|
|
|
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
|
|
|
|
G::RenderPage( 'publish', 'blank' );
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-16 14:08:25 -04:00
|
|
|
$idPmtable = isset($oForm->fields[$id]->pmconnection->pmtable) && $oForm->fields[$id]->pmconnection->pmtable != '' ? $oForm->fields[$id]->pmconnection->pmtable : $oForm->fields[$id]->owner->tree->children[0]->attributes['pmtable'];
|
2013-11-08 16:45:06 -04:00
|
|
|
|
|
|
|
|
if (!($oAdditionalTables->updateDataInTable($idPmtable, $newValues ))) {
|
2012-10-19 16:13:39 -04:00
|
|
|
//<--This is to know if it is a new registry on the PM Table
|
2013-11-08 16:45:06 -04:00
|
|
|
$oAdditionalTables->saveDataInTable($idPmtable, $newValues );
|
2012-10-19 16:13:39 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Save files
|
2012-11-20 16:45:09 -04:00
|
|
|
//require_once ("classes/model/AppDocument.php");
|
2012-10-19 16:13:39 -04:00
|
|
|
|
|
|
|
|
if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
|
|
|
|
|
$arrayField = array ();
|
|
|
|
|
$arrayFileName = array ();
|
|
|
|
|
$arrayFileTmpName = array ();
|
|
|
|
|
$arrayFileError = array ();
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) {
|
|
|
|
|
if (is_array( $fieldValue )) {
|
|
|
|
|
foreach ($fieldValue as $index => $value) {
|
|
|
|
|
if (is_array( $value )) {
|
|
|
|
|
foreach ($value as $grdFieldIndex => $grdFieldValue) {
|
|
|
|
|
$arrayField[$i]["grdName"] = $fieldIndex;
|
|
|
|
|
$arrayField[$i]["grdFieldName"] = $grdFieldIndex;
|
|
|
|
|
$arrayField[$i]["index"] = $index;
|
|
|
|
|
|
|
|
|
|
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
|
|
|
|
|
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
|
|
|
|
|
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
|
|
|
|
|
$i = $i + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$arrayField[$i] = $fieldIndex;
|
|
|
|
|
|
|
|
|
|
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex];
|
|
|
|
|
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex];
|
|
|
|
|
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex];
|
|
|
|
|
$i = $i + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (count( $arrayField ) > 0) {
|
|
|
|
|
for ($i = 0; $i <= count( $arrayField ) - 1; $i ++) {
|
|
|
|
|
if ($arrayFileError[$i] == 0) {
|
|
|
|
|
$indocUid = null;
|
|
|
|
|
$fieldName = null;
|
2014-09-15 12:09:31 -04:00
|
|
|
$fileSizeByField = 0;
|
2012-10-19 16:13:39 -04:00
|
|
|
|
|
|
|
|
if (is_array( $arrayField[$i] )) {
|
|
|
|
|
if (isset( $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]] ) && ! empty( $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]] )) {
|
|
|
|
|
$indocUid = $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$fieldName = $arrayField[$i]["grdName"] . "_" . $arrayField[$i]["index"] . "_" . $arrayField[$i]["grdFieldName"];
|
2014-09-15 12:09:31 -04:00
|
|
|
|
|
|
|
|
if (isset($_FILES["form"]["size"][$arrayField[$i]["grdName"]][$arrayField[$i]["index"]][$arrayField[$i]["grdFieldName"]])) {
|
|
|
|
|
$fileSizeByField = $_FILES["form"]["size"][$arrayField[$i]["grdName"]][$arrayField[$i]["index"]][$arrayField[$i]["grdFieldName"]];
|
|
|
|
|
}
|
2012-10-19 16:13:39 -04:00
|
|
|
} else {
|
|
|
|
|
if (isset( $_POST["INPUTS"][$arrayField[$i]] ) && ! empty( $_POST["INPUTS"][$arrayField[$i]] )) {
|
|
|
|
|
$indocUid = $_POST["INPUTS"][$arrayField[$i]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$fieldName = $arrayField[$i];
|
2014-09-15 12:09:31 -04:00
|
|
|
|
|
|
|
|
if (isset($_FILES["form"]["size"][$fieldName])) {
|
|
|
|
|
$fileSizeByField = $_FILES["form"]["size"][$fieldName];
|
|
|
|
|
}
|
2012-10-19 16:13:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($indocUid != null) {
|
2012-11-20 16:45:09 -04:00
|
|
|
//require_once ("classes/model/AppFolder.php");
|
|
|
|
|
//require_once ("classes/model/InputDocument.php");
|
2012-10-19 16:13:39 -04:00
|
|
|
|
|
|
|
|
$oInputDocument = new InputDocument();
|
|
|
|
|
$aID = $oInputDocument->load( $indocUid );
|
|
|
|
|
|
|
|
|
|
//Get the Custom Folder ID (create if necessary)
|
|
|
|
|
$oFolder = new AppFolder();
|
|
|
|
|
|
2014-09-15 12:31:49 -04:00
|
|
|
//***Validating the file allowed extensions***
|
2014-10-16 14:08:25 -04:00
|
|
|
$res = G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $arrayFileName[$i], $arrayFileTmpName[$i]);
|
|
|
|
|
if($res->status == 0){
|
|
|
|
|
$message = $res->message;
|
|
|
|
|
G::SendMessageText( $message, "ERROR" );
|
|
|
|
|
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
|
|
|
|
|
G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
|
|
|
|
die();
|
2014-09-15 12:31:49 -04:00
|
|
|
}
|
2014-08-29 15:17:43 -04:00
|
|
|
|
2014-09-17 14:48:01 -04:00
|
|
|
//--- Validate Filesize of $_FILE
|
2014-09-15 12:09:31 -04:00
|
|
|
$inpDocMaxFilesize = $aID["INP_DOC_MAX_FILESIZE"];
|
|
|
|
|
$inpDocMaxFilesizeUnit = $aID["INP_DOC_MAX_FILESIZE_UNIT"];
|
|
|
|
|
|
|
|
|
|
$inpDocMaxFilesize = $inpDocMaxFilesize * (($inpDocMaxFilesizeUnit == "MB")? 1024 *1024 : 1024); //Bytes
|
|
|
|
|
|
|
|
|
|
if ($inpDocMaxFilesize > 0 && $fileSizeByField > 0) {
|
|
|
|
|
if ($fileSizeByField > $inpDocMaxFilesize) {
|
|
|
|
|
G::SendMessageText(G::LoadTranslation("ID_SIZE_VERY_LARGE_PERMITTED"), "ERROR");
|
|
|
|
|
$arrayAux1 = explode("sys" . SYS_SYS, $_SERVER["HTTP_REFERER"]);
|
|
|
|
|
G::header("location: /sys" . SYS_SYS . $arrayAux1[1]);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-14 13:53:12 -04:00
|
|
|
$aFields = array ("APP_UID" => $_SESSION["APPLICATION"],"DEL_INDEX" => $_SESSION["INDEX"],"USR_UID" => $_SESSION["USER_LOGGED"],"DOC_UID" => $indocUid,"APP_DOC_TYPE" => "INPUT","APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => "","APP_DOC_TITLE" => "","APP_DOC_FILENAME" => $arrayFileName[$i],"FOLDER_UID" => $oFolder->createFromPath( $aID["INP_DOC_DESTINATION_PATH"] ),"APP_DOC_TAGS" => $oFolder->parseTags( $aID["INP_DOC_TAGS"] ),"APP_DOC_FIELDNAME" => $fieldName);
|
2012-10-19 16:13:39 -04:00
|
|
|
} else {
|
2013-05-14 13:53:12 -04:00
|
|
|
$aFields = array ("APP_UID" => $_SESSION["APPLICATION"],"DEL_INDEX" => $_SESSION["INDEX"],"USR_UID" => $_SESSION["USER_LOGGED"],"DOC_UID" => - 1,"APP_DOC_TYPE" => "ATTACHED","APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => "","APP_DOC_TITLE" => "","APP_DOC_FILENAME" => $arrayFileName[$i],"APP_DOC_FIELDNAME" => $fieldName);
|
2012-10-19 16:13:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$oAppDocument = new AppDocument();
|
|
|
|
|
$oAppDocument->create( $aFields );
|
|
|
|
|
|
|
|
|
|
$iDocVersion = $oAppDocument->getDocVersion();
|
|
|
|
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
|
|
|
|
$aInfo = pathinfo( $oAppDocument->getAppDocFilename() );
|
|
|
|
|
$sExtension = ((isset( $aInfo["extension"] )) ? $aInfo["extension"] : "");
|
2013-04-29 16:48:29 -04:00
|
|
|
$pathUID = G::getPathFromUID($_SESSION["APPLICATION"]);
|
2013-12-12 15:26:40 -04:00
|
|
|
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
2012-10-19 16:13:39 -04:00
|
|
|
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
|
|
|
|
G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
|
|
|
|
|
|
|
|
|
|
//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 );
|
|
|
|
|
$documentData = new uploadDocumentData( $_SESSION["APPLICATION"], $_SESSION["USER_LOGGED"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion );
|
|
|
|
|
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
|
|
|
|
|
|
|
|
|
if ($uploadReturn) {
|
|
|
|
|
$aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace;
|
|
|
|
|
|
|
|
|
|
if (! isset( $aFields["APP_DOC_UID"] )) {
|
|
|
|
|
$aFields["APP_DOC_UID"] = $sAppDocUid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! isset( $aFields["DOC_VERSION"] )) {
|
|
|
|
|
$aFields["DOC_VERSION"] = $iDocVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$oAppDocument->update( $aFields );
|
|
|
|
|
|
|
|
|
|
unlink( $sPathName . $sFileName );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Go to the next step
|
|
|
|
|
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
|
|
|
|
if (isset( $_GET['_REFRESH_'] )) {
|
|
|
|
|
G::header( 'location: ' . $_SERVER['HTTP_REFERER'] );
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
|
|
|
|
|
$_SESSION['BREAKSTEP']['NEXT_STEP'] = $aNextStep['PAGE'];
|
|
|
|
|
$debuggerAvailable = true;
|
|
|
|
|
|
|
|
|
|
if (isset( $_SESSION['current_ux'] ) && $_SESSION['current_ux'] == 'SIMPLIFIED') {
|
|
|
|
|
$debuggerAvailable = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($trigger_debug_session && $debuggerAvailable) {
|
|
|
|
|
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
|
|
|
|
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$oForm->validatePost();
|
2012-11-20 16:45:09 -04:00
|
|
|
//$oJSON = new Services_JSON();
|
2012-10-19 16:13:39 -04:00
|
|
|
$_POST['__notValidateThisFields__'] = (isset( $_POST['__notValidateThisFields__'] ) && $_POST['__notValidateThisFields__'] != '') ? $_POST['__notValidateThisFields__'] : $_POST['DynaformRequiredFields'];
|
2012-11-20 16:45:09 -04:00
|
|
|
if ($missing_req_values = $oForm->validateRequiredFields( $_POST['form'], Bootstrap::json_decode( stripslashes( $_POST['__notValidateThisFields__'] ) ) )) {
|
2014-04-07 16:54:23 -04:00
|
|
|
$fieldsRequired = Bootstrap::json_decode(str_replace(array("%27", "%39"), array("\"", "'"), $_POST["DynaformRequiredFields"]));
|
|
|
|
|
|
|
|
|
|
foreach ($fieldsRequired as $key1 => $value1) {
|
|
|
|
|
foreach ($missing_req_values as $key2 => $value2) {
|
|
|
|
|
if ($value1->name == $value2) {
|
|
|
|
|
$missing_req_values[$key2] = $value1->label;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:13:39 -04:00
|
|
|
$_POST['next_step'] = $aNextStep;
|
|
|
|
|
$_POST['previous_step'] = $oCase->getPreviousStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
|
|
|
|
$_POST['req_val'] = $missing_req_values;
|
2013-11-06 09:20:54 -04:00
|
|
|
global $G_PUBLISH;
|
2012-10-19 16:13:39 -04:00
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
$G_PUBLISH->AddContent( 'view', 'cases/missRequiredFields' );
|
|
|
|
|
G::RenderPage( 'publish', 'blank' );
|
|
|
|
|
exit( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G::header( 'location: ' . $aNextStep['PAGE'] );
|
|
|
|
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
$aMessage = array ();
|
|
|
|
|
$aMessage['MESSAGE'] = $e->getMessage();
|
|
|
|
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
|
|
|
|
G::RenderPage( 'publish', 'blank' );
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|