When JS is not enabled in the browser, the JS validations dosen`t work, so you can submit the form even if there are empty requiered fields. A validation <noscript> was added in the HTML code, to validate if the browser has or not JS enable. If there is not JS enable, the validation is make in the php code to.
174 lines
7.7 KiB
Smarty
Executable File
174 lines
7.7 KiB
Smarty
Executable File
<?php
|
|
/***********************************************************************************************
|
|
* --= 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"));
|
|
}
|
|
|
|
$oForm = new Form("{processUid}" . "/" . "{dynaformUid}", PATH_DYNAFORM);
|
|
$oForm->validatePost();
|
|
|
|
ws_open();
|
|
$result = ws_newCase("{processUid}", "{taskUid}", convertFormToWSObjects($_POST["form"]));
|
|
|
|
if ($result->status_code == 0) {
|
|
$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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$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";
|
|
} else {
|
|
$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>";
|
|
}
|
|
|
|
/**
|
|
* 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");
|
|
*/
|
|
|
|
$_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 );
|
|
}
|
|
|
|
$G_PUBLISH = new Publisher();
|
|
$G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
|
|
G::RenderPage("publish", "blank");
|
|
} catch (Exception $e) {
|
|
$G_PUBLISH = new Publisher();
|
|
$suggest_message = "This web entry should be regenerated, please contact to your system administrator.";
|
|
$aMessage["MESSAGE"] = "<font color=\"red\"><pre>" . $e->getMessage() . "</pre>" . $suggest_message . "</font>";
|
|
$G_PUBLISH->AddContent("xmlform", "xmlform", "login/showMessage", "", $aMessage);
|
|
G::RenderPage("publish", "blank");
|
|
}
|