toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
return $aFields;
} catch (Exception $oError) {
throw ($oError);
}
}
/*
* Load the application document registry
* @param string $sAppDocUid
* @return variant
*/
public function load($sOutDocUid)
{
try {
$oOutputDocument = OutputDocumentPeer::retrieveByPK($sOutDocUid);
if (!is_null($oOutputDocument)) {
$aFields = $oOutputDocument->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
return $aFields;
} else {
throw(new Exception('This row doesn\'t exist!'));
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the application document registry
* @param array $aData
* @return string
* */
public function create($aData)
{
$oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME);
try {
if (isset($aData['OUT_DOC_UID']) && $aData['OUT_DOC_UID'] == '') {
unset($aData['OUT_DOC_UID']);
}
if (!isset($aData['OUT_DOC_UID'])) {
$aData['OUT_DOC_UID'] = G::generateUniqueID();
}
if (!isset($aData['OUT_DOC_GENERATE'])) {
$aData['OUT_DOC_GENERATE'] = 'BOTH';
} else {
if ($aData['OUT_DOC_GENERATE'] == '') {
$aData['OUT_DOC_GENERATE'] = 'BOTH';
}
}
$oOutputDocument = new OutputDocument();
$oOutputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oOutputDocument->validate()) {
$oConnection->begin();
if (isset($aData['OUT_DOC_TITLE'])) {
$oOutputDocument->setOutDocTitleContent($aData['OUT_DOC_TITLE']);
}
if (isset($aData['OUT_DOC_DESCRIPTION'])) {
$oOutputDocument->setOutDocDescriptionContent($aData['OUT_DOC_DESCRIPTION']);
}
$oOutputDocument->setOutDocFilenameContent($aData['OUT_DOC_FILENAME']);
if (isset($aData['OUT_DOC_TEMPLATE'])) {
$oOutputDocument->setOutDocTemplateContent($aData['OUT_DOC_TEMPLATE']);
}
$iResult = $oOutputDocument->save();
$oConnection->commit();
//Add Audit Log
$description = "Output Document Name: " . $aData['OUT_DOC_TITLE'] . ", Output Document Uid: " . $aData['OUT_DOC_UID'] . ", Filename generated: " . $aData['OUT_DOC_FILENAME'];
if (!empty($aData['OUT_DOC_DESCRIPTION'])) {
$description .= ", Description: " . $aData['OUT_DOC_DESCRIPTION'];
}
if (!empty($aData['OUT_DOC_REPORT_GENERATOR'])) {
$description .= ", Report Generator: " . $aData['OUT_DOC_REPORT_GENERATOR'];
}
if (!empty($aData['OUT_DOC_GENERATE'])) {
$description .= ", Output Document to Generate: " . $aData['OUT_DOC_GENERATE'];
}
if ($aData['OUT_DOC_PDF_SECURITY_ENABLED'] == 0) {
$pdfSecurity = 'Disabled';
} else {
$pdfSecurity = 'Enabled';
}
$description .= ", PDF Security: " . $pdfSecurity;
if (!empty($aData['OUT_DOC_VERSIONING'])) {
$description .= ", Enable Versioning: Yes";
}
if (!empty($aData['OUT_DOC_DESTINATION_PATH'])) {
$description .= ", Destination Path: " . $aData['OUT_DOC_DESTINATION_PATH'];
}
if (!empty($aData['OUT_DOC_TAGS'])) {
$description .= ", Tags: " . $aData['OUT_DOC_TAGS'];
}
if (!empty($aData['OUT_DOC_OPEN_TYPE'])) {
if ($aData['OUT_DOC_OPEN_TYPE'] == 0) {
$genLink = 'Open the file';
} else {
$genLink = 'Download the file';
}
$description .= ", By clicking on the generated file link: " . $genLink;
}
G::auditLog("CreateOutputDocument", $description);
return $aData['OUT_DOC_UID'];
} else {
$sMessage = '';
$aValidationFailures = $oOutputDocument->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '
';
}
throw (new Exception('The registry cannot be created!
' . $sMessage));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Update the application document registry
* @param array $aData
* @return string
* */
public function update($aData)
{
$oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME);
try {
$oOutputDocument = OutputDocumentPeer::retrieveByPK($aData['OUT_DOC_UID']);
if (!is_null($oOutputDocument)) {
$oOutputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oOutputDocument->validate()) {
$oConnection->begin();
if (isset($aData['OUT_DOC_TITLE'])) {
$oOutputDocument->setOutDocTitleContent($aData['OUT_DOC_TITLE']);
}
if (isset($aData['OUT_DOC_DESCRIPTION'])) {
$oOutputDocument->setOutDocDescriptionContent($aData['OUT_DOC_DESCRIPTION']);
}
if (isset($aData['OUT_DOC_FILENAME'])) {
$oOutputDocument->setOutDocFilenameContent($aData['OUT_DOC_FILENAME']);
}
if (isset($aData['OUT_DOC_TEMPLATE'])) {
$oOutputDocument->setOutDocTemplateContent($aData['OUT_DOC_TEMPLATE']);
}
$iResult = $oOutputDocument->save();
$oConnection->commit();
//Add Audit Log
$description = 'Output Document Uid: ' . $aData['OUT_DOC_UID'];
if (array_key_exists('OUT_DOC_TITLE', $aData) && (string)($aData['OUT_DOC_TITLE']) != '') {
$description .= ', Output Document Name: ' . $aData['OUT_DOC_TITLE'];
}
if (array_key_exists('OUT_DOC_FILENAME', $aData) && (string)($aData['OUT_DOC_FILENAME']) != '') {
$description .= ', Filename generated: ' . $aData['OUT_DOC_FILENAME'];
}
if (!empty($aData['OUT_DOC_DESCRIPTION'])) {
$description .= ", Description: " . $aData['OUT_DOC_DESCRIPTION'];
}
if (!empty($aData['OUT_DOC_REPORT_GENERATOR'])) {
$description .= ", Report Generator: " . $aData['OUT_DOC_REPORT_GENERATOR'];
}
if (!empty($aData['OUT_DOC_REPORT_GENERATOR'])) {
$description .= ", Output Document to Generate: " . $aData['OUT_DOC_GENERATE'];
}
if (array_key_exists('OUT_DOC_PDF_SECURITY_ENABLED', $aData) && (string)($aData['OUT_DOC_PDF_SECURITY_ENABLED']) != '') {
$description .= ', PDF Security: ' . (((int)($aData['OUT_DOC_PDF_SECURITY_ENABLED']) != 0) ? 'Enabled' : 'Disabled');
}
if (!empty($aData['OUT_DOC_VERSIONING'])) {
$description .= ", Enable Versioning: Yes";
}
if (!empty($aData['OUT_DOC_DESTINATION_PATH'])) {
$description .= ", Destination Path: " . $aData['OUT_DOC_DESTINATION_PATH'];
}
if (!empty($aData['OUT_DOC_TAGS'])) {
$description .= ", Tags: " . $aData['OUT_DOC_TAGS'];
}
if (!empty($aData['OUT_DOC_OPEN_TYPE'])) {
if ($aData['OUT_DOC_OPEN_TYPE'] == 0) {
$genLink = 'Open the file';
} else {
$genLink = 'Download the file';
}
$description .= ", By clicking on the generated file link: " . $genLink;
}
if (isset($aData['OUT_DOC_TEMPLATE'])) {
$description .= ", [EDIT TEMPLATE]";
}
G::auditLog("UpdateOutputDocument", $description);
return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oOutputDocument->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '
';
}
throw (new Exception('The registry cannot be updated!
' . $sMessage));
}
} else {
throw (new Exception('This row doesn\'t exist!'));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Remove the application document registry
* @param array $aData
* @return string
* */
public function remove($sOutDocUid)
{
$oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME);
try {
$oOutputDocument = OutputDocumentPeer::retrieveByPK($sOutDocUid);
if (!is_null($oOutputDocument)) {
$oConnection->begin();
Content::removeContent('OUT_DOC_TITLE', '', $oOutputDocument->getOutDocUid());
Content::removeContent('OUT_DOC_DESCRIPTION', '', $oOutputDocument->getOutDocUid());
Content::removeContent('OUT_DOC_FILENAME', '', $oOutputDocument->getOutDocUid());
Content::removeContent('OUT_DOC_TEMPLATE', '', $oOutputDocument->getOutDocUid());
$iResult = $oOutputDocument->delete();
$oConnection->commit();
//Add Audit Log
G::auditLog("DeleteOutputDocument", "Output Document Name: " . $oOutputDocument->getOutDocTitle() . ", Output Document Uid: " . $sOutDocUid . ", Description: " . $oOutputDocument->getOutDocDescription() . ", Filename generated: " . $oOutputDocument->getOutDocFilename());
//Return
return $iResult;
} else {
throw (new Exception('This row doesn\'t exist!'));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Get the [out_doc_title] column value.
* @return string
*/
public function getOutDocTitleContent()
{
if ($this->out_doc_title == '') {
try {
$this->out_doc_title = Content::load(
'OUT_DOC_TITLE',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en')
);
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->out_doc_title;
}
/**
* Set the [out_doc_title] column value.
*
* @param string $sValue new value
* @return void
*/
public function setOutDocTitleContent($sValue)
{
if ($sValue !== null && !is_string($sValue)) {
$sValue = (string)$sValue;
}
if (in_array(OutputDocumentPeer::OUT_DOC_TITLE, $this->modifiedColumns) || $sValue === '') {
try {
$this->out_doc_title = $sValue;
$iResult = Content::addContent(
'OUT_DOC_TITLE',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en'),
$this->out_doc_title
);
} catch (Exception $oError) {
$this->out_doc_title = '';
throw ($oError);
}
}
}
/**
* Get the [out_doc_comment] column value.
* @return string
*/
public function getOutDocDescriptionContent()
{
if ($this->out_doc_description == '') {
try {
$this->out_doc_description = Content::load(
'OUT_DOC_DESCRIPTION',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en')
);
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->out_doc_description;
}
/**
* Set the [out_doc_comment] column value.
*
* @param string $sValue new value
* @return void
*/
public function setOutDocDescriptionContent($sValue)
{
if ($sValue !== null && !is_string($sValue)) {
$sValue = (string)$sValue;
}
if (in_array(OutputDocumentPeer::OUT_DOC_DESCRIPTION, $this->modifiedColumns) || $sValue === '') {
try {
$this->out_doc_description = $sValue;
$iResult = Content::addContent(
'OUT_DOC_DESCRIPTION',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en'),
$this->out_doc_description
);
} catch (Exception $oError) {
$this->out_doc_description = '';
throw ($oError);
}
}
}
/**
* Get the [out_doc_filename] column value.
* @return string
*/
public function getOutDocFilenameContent()
{
if ($this->out_doc_filename == '') {
try {
$this->out_doc_filename = Content::load(
'OUT_DOC_FILENAME',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en')
);
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->out_doc_filename;
}
/**
* Set the [out_doc_filename] column value.
*
* @param string $sValue new value
* @return void
*/
public function setOutDocFilenameContent($sValue)
{
if ($sValue !== null && !is_string($sValue)) {
$sValue = (string)$sValue;
}
if (in_array(OutputDocumentPeer::OUT_DOC_FILENAME, $this->modifiedColumns) || $sValue === '') {
try {
$this->out_doc_filename = $sValue;
$iResult = Content::addContent(
'OUT_DOC_FILENAME',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en'),
$this->out_doc_filename
);
} catch (Exception $oError) {
$this->out_doc_filename = '';
throw ($oError);
}
}
}
/**
* Get the [out_doc_template] column value.
* @return string
*/
public function getOutDocTemplateContent()
{
if ($this->out_doc_template == '') {
try {
$this->out_doc_template = Content::load(
'OUT_DOC_TEMPLATE',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en')
);
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->out_doc_template;
}
/**
* Set the [out_doc_template] column value.
*
* @param string $sValue new value
* @return void
*/
public function setOutDocTemplateContent($sValue)
{
if ($sValue !== null && !is_string($sValue)) {
$sValue = (string)$sValue;
}
if (in_array(OutputDocumentPeer::OUT_DOC_TEMPLATE, $this->modifiedColumns) || $sValue === '') {
try {
$this->out_doc_template = $sValue;
$iResult = Content::addContent(
'OUT_DOC_TEMPLATE',
'',
$this->getOutDocUid(),
(defined('SYS_LANG') ? SYS_LANG : 'en'),
$this->out_doc_template
);
} catch (Exception $oError) {
$this->out_doc_template = '';
throw ($oError);
}
}
}
/**
* Generate the output document
*
* @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($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [])
{
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
$content = G::replaceDataGridField($content, $caseFields, true, true);
if (strpos($content, '';
$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($caseFields);
$content = $template->fetch($template->templateFile);
unlink($template->templateFile);
}
G::verifyPath($path, true);
//Start - Create .doc
$fp = fopen($path . $filename . '.doc', 'wb');
$size = [];
$size["Letter"] = "216mm 279mm";
$size["Legal"] = "216mm 357mm";
$size["Executive"] = "184mm 267mm";
$size["B5"] = "182mm 257mm";
$size["Folio"] = "216mm 330mm";
$size["A0Oversize"] = "882mm 1247mm";
$size["A0"] = "841mm 1189mm";
$size["A1"] = "594mm 841mm";
$size["A2"] = "420mm 594mm";
$size["A3"] = "297mm 420mm";
$size["A4"] = "210mm 297mm";
$size["A5"] = "148mm 210mm";
$size["A6"] = "105mm 148mm";
$size["A7"] = "74mm 105mm";
$size["A8"] = "52mm 74mm";
$size["A9"] = "37mm 52mm";
$size["A10"] = "26mm 37mm";
$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";
$sizeLandscape["B5"] = "257mm 182mm";
$sizeLandscape["Folio"] = "330mm 216mm";
$sizeLandscape["A0Oversize"] = "1247mm 882mm";
$sizeLandscape["A0"] = "1189mm 841mm";
$sizeLandscape["A1"] = "841mm 594mm";
$sizeLandscape["A2"] = "594mm 420mm";
$sizeLandscape["A3"] = "420mm 297mm";
$sizeLandscape["A4"] = "297mm 210mm";
$sizeLandscape["A5"] = "210mm 148mm";
$sizeLandscape["A6"] = "148mm 105mm";
$sizeLandscape["A7"] = "105mm 74mm";
$sizeLandscape["A8"] = "74mm 52mm";
$sizeLandscape["A9"] = "52mm 37mm";
$sizeLandscape["A10"] = "37mm 26mm";
$sizeLandscape["Screenshot640"] = "480mm 640mm";
$sizeLandscape["Screenshot800"] = "600mm 800mm";
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
if (!isset($properties['media'])) {
$properties['media'] = 'Letter';
}
if ($landscape) {
$media = $sizeLandscape[$properties['media']];
} else {
$media = $size[$properties['media']];
}
$marginLeft = '15';
if (isset($properties['margins']['left'])) {
$marginLeft = $properties['margins']['left'];
}
$marginRight = '15';
if (isset($properties['margins']['right'])) {
$marginRight = $properties['margins']['right'];
}
$marginTop = '15';
if (isset($properties['margins']['top'])) {
$marginTop = $properties['margins']['top'];
}
$marginBottom = '15';
if (isset($properties['margins']['bottom'])) {
$marginBottom = $properties['margins']['bottom'];
}
fwrite($fp, '