PMC-602
This commit is contained in:
@@ -5612,30 +5612,30 @@ class Cases
|
||||
/**
|
||||
* This function send an email for each task in $arrayTask if $to is definded
|
||||
*
|
||||
* @param $dataLastEmail
|
||||
* @param $arrayData
|
||||
* @param $arrayTask
|
||||
* @param array $dataLastEmail
|
||||
* @param array $arrayData
|
||||
* @param array $arrayTask
|
||||
* @return void
|
||||
*
|
||||
* @see \Cases->sendNotifications()
|
||||
*/
|
||||
public function sendMessage($dataLastEmail, $arrayData, $arrayTask)
|
||||
{
|
||||
foreach ($arrayTask as $aTask) {
|
||||
foreach ($arrayTask as $theTask) {
|
||||
//Check and fix if Task Id is complex
|
||||
if (strpos($aTask['TAS_UID'], "/") !== false) {
|
||||
$aux = explode("/", $aTask['TAS_UID']);
|
||||
if (strpos($theTask['TAS_UID'], "/") !== false) {
|
||||
$aux = explode("/", $theTask['TAS_UID']);
|
||||
if (isset($aux[1])) {
|
||||
$aTask['TAS_UID'] = $aux[1];
|
||||
$theTask['TAS_UID'] = $aux[1];
|
||||
}
|
||||
}
|
||||
//if the next is EOP dont send notification and continue with the next
|
||||
if ($aTask['TAS_UID'] === '-1') {
|
||||
if ($theTask['TAS_UID'] === '-1') {
|
||||
continue;
|
||||
}
|
||||
if (isset($aTask['DEL_INDEX'])) {
|
||||
if (isset($theTask['DEL_INDEX'])) {
|
||||
$arrayData2 = $arrayData;
|
||||
$appDelegation = AppDelegationPeer::retrieveByPK($dataLastEmail['applicationUid'], $aTask['DEL_INDEX']);
|
||||
$appDelegation = AppDelegationPeer::retrieveByPK($dataLastEmail['applicationUid'], $theTask['DEL_INDEX']);
|
||||
if (!is_null($appDelegation)) {
|
||||
$oTaskUpd = new Task();
|
||||
$aTaskUpdate = $oTaskUpd->load($appDelegation->getTasUid());
|
||||
@@ -5646,25 +5646,25 @@ class Cases
|
||||
$arrayData2 = $arrayData;
|
||||
}
|
||||
|
||||
if (isset($aTask['USR_UID']) && !empty($aTask['USR_UID'])) {
|
||||
if (isset($theTask['USR_UID']) && !empty($theTask['USR_UID'])) {
|
||||
$user = new \ProcessMaker\BusinessModel\User();
|
||||
$arrayUserData = $user->getUser($aTask['USR_UID'], true);
|
||||
$arrayUserData = $user->getUser($theTask['USR_UID'], true);
|
||||
$arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2,
|
||||
(trim($arrayUserData['USR_TIME_ZONE']) != '') ? trim($arrayUserData['USR_TIME_ZONE']) :
|
||||
\ProcessMaker\Util\System::getTimeZone());
|
||||
} else {
|
||||
$arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2);
|
||||
}
|
||||
$body2 = G::replaceDataGridField($dataLastEmail['body'], $arrayData2, false);
|
||||
$body2 = G::replaceDataGridField($dataLastEmail['body'], $arrayData2, false, true);
|
||||
$to = null;
|
||||
$cc = '';
|
||||
if ($aTask['TAS_UID'] != '-1') {
|
||||
$respTo = $this->getTo($aTask['TAS_UID'], $aTask['USR_UID'], $arrayData);
|
||||
if ($theTask['TAS_UID'] != '-1') {
|
||||
$respTo = $this->getTo($theTask['TAS_UID'], $theTask['USR_UID'], $arrayData);
|
||||
$to = $respTo['to'];
|
||||
$cc = $respTo['cc'];
|
||||
}
|
||||
|
||||
if ($aTask ["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
|
||||
if ($theTask["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
|
||||
if ($dataLastEmail['swtplDefault'] == 1) {
|
||||
G::verifyPath($dataLastEmail['pathEmail'], true); // Create if it does not exist
|
||||
$fileTemplate = $dataLastEmail['pathEmail'] . G::LoadTranslation('ID_UNASSIGNED_MESSAGE');
|
||||
|
||||
@@ -990,7 +990,7 @@ class WsBase
|
||||
$subject,
|
||||
G::buildFrom($setup, $from),
|
||||
$to,
|
||||
G::replaceDataGridField(file_get_contents($fileTemplate), $fieldsCase, false),
|
||||
G::replaceDataGridField(file_get_contents($fileTemplate), $fieldsCase, false, true),
|
||||
$cc,
|
||||
$bcc,
|
||||
'',
|
||||
|
||||
@@ -508,20 +508,29 @@ class OutputDocument extends BaseOutputDocument
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Generate the output document
|
||||
* @param string $sUID
|
||||
* @param array $aFields
|
||||
* @param string $sPath
|
||||
* @return variant
|
||||
*
|
||||
* @param string $outDocUid
|
||||
* @param array $caseFields
|
||||
* @param string $path
|
||||
* @param string $filename
|
||||
* @param string $content
|
||||
* @param bool $landscape
|
||||
* @param string $typeDocsToGen
|
||||
* @param array $properties
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @see workflow/engine/methods/cases/cases_Step.php
|
||||
* @see workflow/engine/classes/class.pmFunctions.php:PMFGenerateOutputDocument()
|
||||
*/
|
||||
|
||||
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array())
|
||||
public function generate($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [])
|
||||
{
|
||||
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
|
||||
$sContent = G::replaceDataGridField($sContent, $aFields);
|
||||
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
|
||||
$content = G::replaceDataGridField($content, $caseFields, true, true);
|
||||
|
||||
if (strpos($sContent, '<!---{') !== false) {
|
||||
if (strpos($content, '<!---{') !== false) {
|
||||
$template = new Smarty();
|
||||
$template->compile_dir = PATH_SMARTY_C;
|
||||
$template->cache_dir = PATH_SMARTY_CACHE;
|
||||
@@ -529,20 +538,20 @@ class OutputDocument extends BaseOutputDocument
|
||||
$template->caching = false;
|
||||
$template->left_delimiter = '<!---{';
|
||||
$template->right_delimiter = '}--->';
|
||||
$oFile = fopen($sPath . $sFilename . '_smarty.html', 'wb');
|
||||
fwrite($oFile, $sContent);
|
||||
fclose($oFile);
|
||||
$template->templateFile = $sPath . $sFilename . '_smarty.html';
|
||||
$fp = fopen($path . $filename . '_smarty.html', 'wb');
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
$template->templateFile = $path . $filename . '_smarty.html';
|
||||
//assign the variables and use the template $template
|
||||
$template->assign($aFields);
|
||||
$sContent = $template->fetch($template->templateFile);
|
||||
$template->assign($caseFields);
|
||||
$content = $template->fetch($template->templateFile);
|
||||
unlink($template->templateFile);
|
||||
}
|
||||
|
||||
G::verifyPath($sPath, true);
|
||||
G::verifyPath($path, true);
|
||||
|
||||
//Start - Create .doc
|
||||
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
|
||||
$fp = fopen($path . $filename . '.doc', 'wb');
|
||||
|
||||
$size = [];
|
||||
$size["Letter"] = "216mm 279mm";
|
||||
@@ -566,6 +575,7 @@ class OutputDocument extends BaseOutputDocument
|
||||
$size["Screenshot800"] = "800mm 600mm";
|
||||
$size["Screenshot1024"] = "1024mm 768mm";
|
||||
|
||||
$sizeLandscape = [];
|
||||
$sizeLandscape["Letter"] = "279mm 216mm";
|
||||
$sizeLandscape["Legal"] = "357mm 216mm";
|
||||
$sizeLandscape["Executive"] = "267mm 184mm";
|
||||
@@ -587,41 +597,41 @@ class OutputDocument extends BaseOutputDocument
|
||||
$sizeLandscape["Screenshot800"] = "600mm 800mm";
|
||||
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
|
||||
|
||||
if (!isset($aProperties['media'])) {
|
||||
$aProperties['media'] = 'Letter';
|
||||
if (!isset($properties['media'])) {
|
||||
$properties['media'] = 'Letter';
|
||||
}
|
||||
|
||||
if ($sLandscape) {
|
||||
$media = $sizeLandscape[$aProperties['media']];
|
||||
if ($landscape) {
|
||||
$media = $sizeLandscape[$properties['media']];
|
||||
} else {
|
||||
$media = $size[$aProperties['media']];
|
||||
$media = $size[$properties['media']];
|
||||
}
|
||||
|
||||
$marginLeft = '15';
|
||||
|
||||
if (isset($aProperties['margins']['left'])) {
|
||||
$marginLeft = $aProperties['margins']['left'];
|
||||
if (isset($properties['margins']['left'])) {
|
||||
$marginLeft = $properties['margins']['left'];
|
||||
}
|
||||
|
||||
$marginRight = '15';
|
||||
|
||||
if (isset($aProperties['margins']['right'])) {
|
||||
$marginRight = $aProperties['margins']['right'];
|
||||
if (isset($properties['margins']['right'])) {
|
||||
$marginRight = $properties['margins']['right'];
|
||||
}
|
||||
|
||||
$marginTop = '15';
|
||||
|
||||
if (isset($aProperties['margins']['top'])) {
|
||||
$marginTop = $aProperties['margins']['top'];
|
||||
if (isset($properties['margins']['top'])) {
|
||||
$marginTop = $properties['margins']['top'];
|
||||
}
|
||||
|
||||
$marginBottom = '15';
|
||||
|
||||
if (isset($aProperties['margins']['bottom'])) {
|
||||
$marginBottom = $aProperties['margins']['bottom'];
|
||||
if (isset($properties['margins']['bottom'])) {
|
||||
$marginBottom = $properties['margins']['bottom'];
|
||||
}
|
||||
|
||||
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
fwrite($fp, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
@@ -667,31 +677,31 @@ class OutputDocument extends BaseOutputDocument
|
||||
<body>
|
||||
<div class=WordSection1>');
|
||||
|
||||
fwrite($oFile, $sContent);
|
||||
fwrite($oFile, "\n</div></body></html>\n\n");
|
||||
fclose($oFile);
|
||||
fwrite($fp, $content);
|
||||
fwrite($fp, "\n</div></body></html>\n\n");
|
||||
fclose($fp);
|
||||
/* End - Create .doc */
|
||||
|
||||
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
|
||||
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
|
||||
fwrite($oFile, $sContent);
|
||||
fclose($oFile);
|
||||
if ($typeDocsToGen == 'BOTH' || $typeDocsToGen == 'PDF') {
|
||||
$fp = fopen($path . $filename . '.html', 'wb');
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
/* Start - Create .pdf */
|
||||
if (isset($aProperties['report_generator'])) {
|
||||
switch ($aProperties['report_generator']) {
|
||||
if (isset($properties['report_generator'])) {
|
||||
switch ($properties['report_generator']) {
|
||||
case 'TCPDF':
|
||||
$this->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
$this->generateTcpdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
break;
|
||||
case 'HTML2PDF':
|
||||
default:
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
}
|
||||
}
|
||||
//end if $sTypeDocToGener
|
||||
//end if $typeDocsToGen
|
||||
/* End - Create .pdf */
|
||||
} else {
|
||||
return PEAR::raiseError(
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use OutputDocument as ClassesOutputDocument;
|
||||
use PEAR;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
@@ -592,21 +595,31 @@ class OutputDocument
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Generate the output document
|
||||
* @param string $sUID
|
||||
* @param array $aFields
|
||||
* @param string $sPath
|
||||
* @return variant
|
||||
*
|
||||
* @param string $outDocUid
|
||||
* @param array $caseFields
|
||||
* @param string $path
|
||||
* @param string $filename
|
||||
* @param string $content
|
||||
* @param bool $landscape
|
||||
* @param string $typeDocsToGen
|
||||
* @param array $properties
|
||||
* @param string $application
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @see this->addCasesOutputDocument()
|
||||
*/
|
||||
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array(), $sApplication)
|
||||
public function generate($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [], $application = '')
|
||||
{
|
||||
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
|
||||
$sContent = \G::replaceDataGridField($sContent, $aFields);
|
||||
\G::verifyPath($sPath, true);
|
||||
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
|
||||
$content = G::replaceDataGridField($content, $caseFields, true, true);
|
||||
G::verifyPath($path, true);
|
||||
//Start - Create .doc
|
||||
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
|
||||
$size = array();
|
||||
$fp = fopen($path . $filename . '.doc', 'wb');
|
||||
$size = [];
|
||||
$size["Letter"] = "216mm 279mm";
|
||||
$size["Legal"] = "216mm 357mm";
|
||||
$size["Executive"] = "184mm 267mm";
|
||||
@@ -627,6 +640,7 @@ class OutputDocument
|
||||
$size["Screenshot640"] = "640mm 480mm";
|
||||
$size["Screenshot800"] = "800mm 600mm";
|
||||
$size["Screenshot1024"] = "1024mm 768mm";
|
||||
$sizeLandscape = [];
|
||||
$sizeLandscape["Letter"] = "279mm 216mm";
|
||||
$sizeLandscape["Legal"] = "357mm 216mm";
|
||||
$sizeLandscape["Executive"] = "267mm 184mm";
|
||||
@@ -647,31 +661,31 @@ class OutputDocument
|
||||
$sizeLandscape["Screenshot640"] = "480mm 640mm";
|
||||
$sizeLandscape["Screenshot800"] = "600mm 800mm";
|
||||
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
|
||||
if (!isset($aProperties['media'])) {
|
||||
$aProperties['media'] = 'Letter';
|
||||
if (!isset($properties['media'])) {
|
||||
$properties['media'] = 'Letter';
|
||||
}
|
||||
if ($sLandscape) {
|
||||
$media = $sizeLandscape[$aProperties['media']];
|
||||
if ($landscape) {
|
||||
$media = $sizeLandscape[$properties['media']];
|
||||
} else {
|
||||
$media = $size[$aProperties['media']];
|
||||
$media = $size[$properties['media']];
|
||||
}
|
||||
$marginLeft = '15';
|
||||
if (isset($aProperties['margins']['left'])) {
|
||||
$marginLeft = $aProperties['margins']['left'];
|
||||
if (isset($properties['margins']['left'])) {
|
||||
$marginLeft = $properties['margins']['left'];
|
||||
}
|
||||
$marginRight = '15';
|
||||
if (isset($aProperties['margins']['right'])) {
|
||||
$marginRight = $aProperties['margins']['right'];
|
||||
if (isset($properties['margins']['right'])) {
|
||||
$marginRight = $properties['margins']['right'];
|
||||
}
|
||||
$marginTop = '15';
|
||||
if (isset($aProperties['margins']['top'])) {
|
||||
$marginTop = $aProperties['margins']['top'];
|
||||
if (isset($properties['margins']['top'])) {
|
||||
$marginTop = $properties['margins']['top'];
|
||||
}
|
||||
$marginBottom = '15';
|
||||
if (isset($aProperties['margins']['bottom'])) {
|
||||
$marginBottom = $aProperties['margins']['bottom'];
|
||||
if (isset($properties['margins']['bottom'])) {
|
||||
$marginBottom = $properties['margins']['bottom'];
|
||||
}
|
||||
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
fwrite($fp, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
@@ -716,40 +730,40 @@ class OutputDocument
|
||||
</head>
|
||||
<body>
|
||||
<div class=WordSection1>');
|
||||
fwrite($oFile, $sContent);
|
||||
fwrite($oFile, "\n</div></body></html>\n\n");
|
||||
fclose($oFile);
|
||||
fwrite($fp, $content);
|
||||
fwrite($fp, "\n</div></body></html>\n\n");
|
||||
fclose($fp);
|
||||
/* End - Create .doc */
|
||||
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
|
||||
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
|
||||
fwrite($oFile, $sContent);
|
||||
fclose($oFile);
|
||||
if ($typeDocsToGen == 'BOTH' || $typeDocsToGen == 'PDF') {
|
||||
$fp = fopen($path . $filename . '.html', 'wb');
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
/* Start - Create .pdf */
|
||||
if (isset($aProperties['report_generator'])) {
|
||||
switch ($aProperties['report_generator']) {
|
||||
if (isset($properties['report_generator'])) {
|
||||
switch ($properties['report_generator']) {
|
||||
case 'TCPDF':
|
||||
$o = new \OutputDocument();
|
||||
if (strlen($sContent) == 0) {
|
||||
$o = new ClassesOutputDocument();
|
||||
if (strlen($content) == 0) {
|
||||
libxml_use_internal_errors(true);
|
||||
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, ' ', $sLandscape, $aProperties);
|
||||
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, ' ', $landscape, $properties);
|
||||
libxml_use_internal_errors(false);
|
||||
} else {
|
||||
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
}
|
||||
break;
|
||||
case 'HTML2PDF':
|
||||
default:
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties, $sApplication);
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties, $application);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
}
|
||||
}
|
||||
//end if $sTypeDocToGener
|
||||
//end if $typeDocsToGen
|
||||
/* End - Create .pdf */
|
||||
} else {
|
||||
return \PEAR::raiseError(
|
||||
return PEAR::raiseError(
|
||||
null,
|
||||
G_ERROR_USER_UID,
|
||||
null,
|
||||
|
||||
@@ -485,6 +485,33 @@ function csrfToken()
|
||||
return isset($_SESSION['USR_CSRF_TOKEN']) ? $_SESSION['USR_CSRF_TOKEN'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid HTML code
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @see G::replaceDataField()
|
||||
*/
|
||||
function stringIsValidHtml($string)
|
||||
{
|
||||
// To validate we use the DOMDocument class
|
||||
$doc = new DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
// Clean previous errors
|
||||
libxml_clear_errors();
|
||||
|
||||
// This line have to be silenced because if the string is not an HTML a Warning is displayed
|
||||
@$doc->loadHTML($string);
|
||||
|
||||
// Get last error parsing the HTML
|
||||
$libXmlError = libxml_get_last_error();
|
||||
|
||||
// If the attribute "textContent" is empty or exists libxml errors, is not a valid HTML
|
||||
return $doc->textContent !== '' && empty($libXmlError);
|
||||
}
|
||||
|
||||
// Methods deleted in PHP 7.x, added in this file in order to keep compatibility with old libraries included/used in ProcessMaker
|
||||
if (!function_exists('set_magic_quotes_runtime')) {
|
||||
function set_magic_quotes_runtime($value) {
|
||||
|
||||
Reference in New Issue
Block a user