2010-12-02 23:34:41 +00:00
|
|
|
<?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}' );
|
|
|
|
|
|
2012-03-08 17:07:53 -04:00
|
|
|
try {
|
2010-12-02 23:34:41 +00:00
|
|
|
@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
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
$oForm = new Form ( '{processUid}' . '/' . '{dynaformUid}', PATH_DYNAFORM );
|
|
|
|
|
$oForm->validatePost();
|
|
|
|
|
|
2012-03-08 17:07:53 -04:00
|
|
|
ws_open ();
|
2010-12-02 23:34:41 +00:00
|
|
|
$result = ws_newCase ( '{processUid}', '{taskUid}', convertFormToWSObjects($_POST['form']) );
|
|
|
|
|
|
2012-06-06 12:00:14 -04:00
|
|
|
if ($result->status_code == 0) {
|
2010-12-02 23:34:41 +00:00
|
|
|
$caseId = $result->caseId;
|
2012-06-06 12:00:14 -04:00
|
|
|
$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
|
2010-12-02 23:34:41 +00:00
|
|
|
if ( isset($_FILES['form']) ) {
|
|
|
|
|
foreach ($_FILES['form']['name'] as $sFieldName => $vValue) {
|
|
|
|
|
if ( $_FILES['form']['error'][$sFieldName] == 0 ){
|
2012-04-09 18:48:44 -04:00
|
|
|
file_put_contents(G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName], file_get_contents($_FILES['form']['tmp_name'][$sFieldName]));
|
|
|
|
|
$fpath = G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName];
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-03-08 17:07:53 -04:00
|
|
|
if( isset($_POST['INPUTS'][$sFieldName]) && $_POST['INPUTS'][$sFieldName] != '' ){ #input file type
|
2010-12-02 23:34:41 +00:00
|
|
|
ws_sendFile($fpath, $USR_UID, $caseId, 1, $_POST['INPUTS'][$sFieldName]);
|
|
|
|
|
} else { #attached file type
|
|
|
|
|
ws_sendFile($fpath, $USR_UID, $caseId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = ws_routeCase ($caseId, 1);
|
|
|
|
|
$assign = $result->message;
|
|
|
|
|
|
2011-04-19 18:36:35 -04:00
|
|
|
$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 {
|
|
|
|
|
$aMessage['MESSAGE'] = '<font color="red">An error occurred while the application was being processed.<br/>
|
2012-03-08 17:07:53 -04:00
|
|
|
Error code: '.$result->status_code.'<br/>
|
|
|
|
|
Error message: '.$result->message.'</font><br/><br/>
|
|
|
|
|
<b>please contact to your system administrator.</b>';
|
2010-12-02 23:34:41 +00: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' );
|
|
|
|
|
*/
|
2012-03-08 17:07:53 -04:00
|
|
|
$G_PUBLISH = new Publisher;
|
|
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', $aMessage );
|
|
|
|
|
G::RenderPage( 'publish', 'blank' );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
catch ( Exception $e ) {
|
|
|
|
|
$G_PUBLISH = new Publisher;
|
|
|
|
|
$suggest_message = "This web entry should be regenerated, please contact to your system administrator.";
|
2012-03-08 17:07:53 -04:00
|
|
|
$aMessage['MESSAGE'] = '<font color=\'red\'><pre>'.$e->getMessage().'</pre>'.$suggest_message .'</font>';
|
2010-12-02 23:34:41 +00:00
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
|
|
|
|
G::RenderPage( 'publish', 'blank' );
|
2012-03-08 17:07:53 -04:00
|
|
|
}
|