TAS_UID)) {
throw new Exception('The parameter $data->TAS_UID is null.');
}
if (!isset($data->APP_UID)) {
throw new Exception('The parameter $data->APP_UID is null.');
}
if (!isset($data->DEL_INDEX)) {
throw new Exception('The parameter $data->DEL_INDEX is null.');
}
if ($data->TAS_UID == '') {
throw new Exception('The parameter $data->TAS_UID is empty.');
}
if ($data->APP_UID == '') {
throw new Exception('The parameter $data->APP_UID is empty.');
}
if ($data->DEL_INDEX == '') {
throw new Exception('The parameter $data->DEL_INDEX is empty.');
}
G::LoadClass('pmFunctions');
$emailSetup = getEmailConfiguration();
if (!empty($emailSetup)) {
require_once 'classes/model/AbeConfiguration.php';
G::LoadClass('case');
$cases = new Cases();
$caseFields = $cases->loadCase($data->APP_UID);
$criteria = new Criteria();
$criteria->add(AbeConfigurationPeer::PRO_UID, $caseFields['PRO_UID']);
$criteria->add(AbeConfigurationPeer::TAS_UID, $data->TAS_UID);
$result = AbeConfigurationPeer::doSelectRS($criteria);
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$result->next();
if ($configuration = $result->getRow()) {
$configuration['ABE_EMAIL_FIELD'] = str_replace('@@', '', $configuration['ABE_EMAIL_FIELD']);
if ($configuration['ABE_EMAIL_FIELD'] != '' && isset($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']])) {
$email = trim($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']]);
} else {
require_once 'classes/model/Users.php';
$userInstance = new Users();
$userInfo = $userInstance->getAllInformation($data->USR_UID);
$email = $userInfo['mail'];
}
if ($email != '') {
$subject = $caseFields['APP_TITLE'];
// Create
require_once 'classes/model/AbeRequests.php';
$abeRequest = array();
$abeRequest['ABE_REQ_UID'] = '';
$abeRequest['ABE_UID'] = $configuration['ABE_UID'];
$abeRequest['APP_UID'] = $data->APP_UID;
$abeRequest['DEL_INDEX'] = $data->DEL_INDEX;
$abeRequest['ABE_REQ_SENT_TO'] = $email;
$abeRequest['ABE_REQ_SUBJECT'] = $subject;
$abeRequest['ABE_REQ_BODY'] = '';
$abeRequest['ABE_REQ_ANSWERED'] = 0;
$abeRequest['ABE_REQ_STATUS'] = 'PENDING';
try {
$abeRequestsInstance = new AbeRequests();
$abeRequest['ABE_REQ_UID'] = $abeRequestsInstance->createOrUpdate($abeRequest);
} catch (Exception $error) {
throw $error;
}
if ($configuration['ABE_TYPE'] != '') {
// Email
$_SESSION['CURRENT_DYN_UID'] = $configuration['DYN_UID'];
$scriptCode = '';
// foreach ($dynaform->fields as $fieldName => $field) {
// if ($field->type == 'submit') {
// unset($dynaform->fields[$fieldName]);
// }
// }
$__ABE__ = '';
$link = (G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/ActionsByEmail';
switch ($configuration['ABE_TYPE']) {
case 'LINK':
// $__ABE__ .= $dynaform->render(PATH_FEATURES . 'actionsByEmail/xmlform.html', $scriptCode) . '
';
$__ABE__ .= 'Please complete this form';
break;
// coment
case 'FIELD':
$variableService = new \ProcessMaker\Services\Api\Project\Variable();
$variables = $variableService->doGetVariables($caseFields['PRO_UID']);
$field = new stdClass();
$field->label = 'Test';
$field->type = 'dropdown';
$field->options = array();
$actionField = str_replace('@@', '', $configuration['ABE_ACTION_FIELD']);
foreach ($variables as $variable) {
if ($variable['var_name'] == $actionField) {
$field->label = $variable['var_name'];
$field->type = 'dropdown';
$values = json_decode($variable['var_accepted_values']);
foreach ($values as $value) {
$field->options[$value->keyValue] = $value->value;
}
}
}
$__ABE__ .= '' . $field->label . '
';
break;
}
$__ABE__ = preg_replace('/\
/', '' , $__ABE__);
$__ABE__ = preg_replace('/\]*\/>/', '' , $__ABE__);
$__ABE__ = preg_replace('/