2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
2012-10-04 17:54:44 -04:00
|
|
|
/***********************************************************************************************
|
|
|
|
|
* --= Processmaker Web Entry Request handler =-- *
|
|
|
|
|
* *
|
|
|
|
|
* This file was autogenerated by Processmaker Open Source Rel-{version} *
|
|
|
|
|
***********************************************************************************************/
|
|
|
|
|
|
|
|
|
|
//@Dynaform : {dynaform}
|
|
|
|
|
//@Workspace : {ws}
|
|
|
|
|
//@Timestamp : {timestamp}
|
|
|
|
|
|
|
|
|
|
define("WS_WSDL_URL", "{wsdlUrl}");
|
|
|
|
|
define("WS_UPLOAD_URL", "{wsUploadUrl}");
|
|
|
|
|
define("WS_USER_ID", "{wsUser}");
|
|
|
|
|
define("WS_USER_PASS", "{wsPass}");
|
|
|
|
|
define("WS_ROUNDROBIN", "{wsRoundRobin}");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@include_once ("wsClient.php");
|
|
|
|
|
|
|
|
|
|
if (!function_exists("ws_open")){
|
|
|
|
|
throw (new Exception("function ws_open() is not defined. File wsClient.php is missing"));
|
2012-03-08 17:07:53 -04:00
|
|
|
}
|
2012-10-04 17:54:44 -04:00
|
|
|
|
2015-04-27 14:36:09 -04:00
|
|
|
/*
|
|
|
|
|
* PMDynaform
|
|
|
|
|
* DYN_VERSION is 1: classic Dynaform,
|
|
|
|
|
* DYN_VERSION is 2: responsive form, Pmdynaform.
|
|
|
|
|
*/
|
|
|
|
|
$a = new Criteria("workflow");
|
|
|
|
|
$a->addSelectColumn(DynaformPeer::DYN_VERSION);
|
|
|
|
|
$a->add(DynaformPeer::DYN_UID, "{dynaformUid}", 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-04 17:54:44 -04:00
|
|
|
$oForm = new Form("{processUid}" . "/" . "{dynaformUid}", PATH_DYNAFORM);
|
2010-12-02 23:34:41 +00:00
|
|
|
$oForm->validatePost();
|
|
|
|
|
|
2012-10-04 17:54:44 -04:00
|
|
|
ws_open();
|
2015-04-27 14:36:09 -04:00
|
|
|
if ($swpmdynaform) {
|
|
|
|
|
$result = ws_newCase("{processUid}", "{taskUid}", convertFormToWSObjects($pmdynaform));
|
|
|
|
|
} else {
|
|
|
|
|
$result = ws_newCase("{processUid}", "{taskUid}", convertFormToWSObjects($_POST["form"]));
|
|
|
|
|
}
|
2012-10-04 17:54:44 -04:00
|
|
|
|
2012-06-06 12:00:14 -04:00
|
|
|
if ($result->status_code == 0) {
|
2012-10-04 17:54:44 -04:00
|
|
|
$caseId = $result->caseId;
|
|
|
|
|
$caseNr = $result->caseNumber;
|
|
|
|
|
|
|
|
|
|
{USR_VAR}
|
|
|
|
|
|
|
|
|
|
if ($USR_UID == -1) {
|
|
|
|
|
G::LoadClass("sessions");
|
|
|
|
|
|
|
|
|
|
global $sessionId;
|
|
|
|
|
|
|
|
|
|
$sessions = new Sessions();
|
|
|
|
|
$session = $sessions->getSessionUser($sessionId);
|
|
|
|
|
|
|
|
|
|
$USR_UID = $session["USR_UID"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Save files
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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"];
|
|
|
|
|
} else {
|
|
|
|
|
if (isset($_POST["INPUTS"][$arrayField[$i]]) &&
|
|
|
|
|
!empty($_POST["INPUTS"][$arrayField[$i]])
|
|
|
|
|
) {
|
|
|
|
|
$indocUid = $_POST["INPUTS"][$arrayField[$i]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$fieldName = $arrayField[$i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$filePath = G::sys_get_temp_dir() . PATH_SEP . $arrayFileName[$i];
|
|
|
|
|
file_put_contents($filePath, file_get_contents($arrayFileTmpName[$i]));
|
|
|
|
|
|
|
|
|
|
if ($indocUid != null) {
|
|
|
|
|
//Input file type
|
|
|
|
|
ws_sendFile($filePath, $USR_UID, $caseId, 1, $indocUid, $fieldName);
|
|
|
|
|
} else {
|
|
|
|
|
//Attached file type
|
|
|
|
|
ws_sendFile($filePath, $USR_UID, $caseId, 1, null, $fieldName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-04 17:54:44 -04:00
|
|
|
|
|
|
|
|
$result = ws_routeCase($caseId, 1);
|
|
|
|
|
$assign = $result->message;
|
|
|
|
|
|
|
|
|
|
$aMessage["MESSAGE"] = "<br />Case created in ProcessMaker<br />Case Number: $caseNr <br />Case Id: $caseId<br />Case derivated to: $assign";
|
2010-12-02 23:34:41 +00:00
|
|
|
} else {
|
2012-10-04 17:54:44 -04:00
|
|
|
$aMessage["MESSAGE"] = "<font color=\"red\">
|
|
|
|
|
An error occurred while the application was being processed.<br />
|
|
|
|
|
Error code: " . $result->status_code . "<br />
|
|
|
|
|
Error message: " . $result->message . "
|
|
|
|
|
</font>
|
|
|
|
|
<br /><br />
|
|
|
|
|
<strong>Please contact to your system administrator.</strong>";
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-04 17:54:44 -04:00
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
/**
|
2012-10-04 17:54:44 -04:00
|
|
|
* By default show the case info, for the recently created case
|
|
|
|
|
* you can change it or redirect to another page
|
|
|
|
|
* i.e. G::header("Location: http://www.processmaker.com");
|
2010-12-02 23:34:41 +00:00
|
|
|
*/
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2014-08-28 16:57:54 -04:00
|
|
|
$_POST['__notValidateThisFields__'] = (isset( $_POST['__notValidateThisFields__'] ) && $_POST['__notValidateThisFields__'] != '') ? $_POST['__notValidateThisFields__'] : $_POST['DynaformRequiredFields'];
|
|
|
|
|
if ($missing_req_values = $oForm->validateRequiredFields( $_POST['form'], Bootstrap::json_decode( stripslashes( $_POST['__notValidateThisFields__'] ) ) )) {
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_POST['next_step']['PAGE'] = "";
|
|
|
|
|
$_POST['previous_step']['PAGE'] = $_SERVER['HTTP_REFERER'];
|
|
|
|
|
$_POST['req_val'] = $missing_req_values;
|
|
|
|
|
|
|
|
|
|
global $G_PUBLISH;
|
|
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
$G_PUBLISH->AddContent( 'view', 'cases/missRequiredFields' );
|
|
|
|
|
G::RenderPage( 'publish', 'blank' );
|
|
|
|
|
exit( 0 );
|
|
|
|
|
}
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-10-04 17:54:44 -04:00
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
$G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
|
|
|
|
|
G::RenderPage("publish", "blank");
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$G_PUBLISH = new Publisher();
|
2010-12-02 23:34:41 +00:00
|
|
|
$suggest_message = "This web entry should be regenerated, please contact to your system administrator.";
|
2012-10-04 17:54:44 -04:00
|
|
|
$aMessage["MESSAGE"] = "<font color=\"red\"><pre>" . $e->getMessage() . "</pre>" . $suggest_message . "</font>";
|
|
|
|
|
$G_PUBLISH->AddContent("xmlform", "xmlform", "login/showMessage", "", $aMessage);
|
|
|
|
|
G::RenderPage("publish", "blank");
|
|
|
|
|
}
|